diff --git a/app/controllers/frameworks/application_controller.rb b/app/controllers/frameworks/application_controller.rb index 851c92c72..089862853 100644 --- a/app/controllers/frameworks/application_controller.rb +++ b/app/controllers/frameworks/application_controller.rb @@ -1,6 +1,7 @@ class Frameworks::ApplicationController < ApplicationController include SupportAgents before_action { Current.actor = current_agent } + before_action :set_back_url private @@ -8,6 +9,6 @@ def authorize_agent_scope = :access_frameworks_portal? def portal_namespace = :frameworks def set_back_url - @back_url = back_link_param + @back_url = back_link_param if back_link_param.present? end end diff --git a/app/controllers/frameworks/frameworks_controller.rb b/app/controllers/frameworks/frameworks_controller.rb index 9dac9df6b..e41677c05 100644 --- a/app/controllers/frameworks/frameworks_controller.rb +++ b/app/controllers/frameworks/frameworks_controller.rb @@ -1,12 +1,15 @@ class Frameworks::FrameworksController < Frameworks::ApplicationController before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index - before_action :set_back_url, only: %i[new show] - before_action :load_form_options, only: %i[new create] + before_action :load_form_options, only: %i[new edit create update] def new @framework = Frameworks::Framework.new end + def edit + @framework = Frameworks::Framework.find(params[:id]) + end + def index @filtering = Frameworks::Framework.filtering(filter_form_params) @frameworks = @filtering.results.paginate(page: params[:frameworks_page]) @@ -27,6 +30,16 @@ def create end end + def update + @framework = Frameworks::Framework.find(params[:id]) + + if @framework.update(framework_params) + redirect_to frameworks_framework_path(@framework) + else + render :edit + end + end + private def load_form_options diff --git a/app/controllers/frameworks/provider_contacts_controller.rb b/app/controllers/frameworks/provider_contacts_controller.rb index 0d60a9dda..1feeee5b3 100644 --- a/app/controllers/frameworks/provider_contacts_controller.rb +++ b/app/controllers/frameworks/provider_contacts_controller.rb @@ -1,6 +1,6 @@ class Frameworks::ProviderContactsController < Frameworks::ApplicationController before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index - before_action :set_back_url, only: %i[show edit] + before_action :load_form_options, only: %i[new edit update create] def index @filtering = Frameworks::ProviderContact.filtering(filter_form_params) @@ -12,10 +12,24 @@ def show @activity_log_items = @provider_contact.activity_log_items.paginate(page: params[:activities_page]) end + def new + @provider_contact = Frameworks::ProviderContact.new + end + def edit @provider_contact = Frameworks::ProviderContact.find(params[:id]) end + def create + @provider_contact = Frameworks::ProviderContact.new(provider_contact_params) + + if @provider_contact.save + redirect_to frameworks_provider_contact_path(@provider_contact) + else + render :new + end + end + def update @provider_contact = Frameworks::ProviderContact.find(params[:id]) @@ -28,12 +42,16 @@ def update private + def load_form_options + @providers = Frameworks::Provider.all + end + def filter_form_params params.fetch(:provider_contacts_filter, {}).permit(:sort_by, :sort_order, provider: []) end def provider_contact_params - params.require(:frameworks_provider_contact).permit(:name, :email, :phone) + params.require(:frameworks_provider_contact).permit(:name, :email, :phone, :provider_id) end def redirect_to_register_tab diff --git a/app/controllers/frameworks/providers_controller.rb b/app/controllers/frameworks/providers_controller.rb index 546314ebe..a97579c32 100644 --- a/app/controllers/frameworks/providers_controller.rb +++ b/app/controllers/frameworks/providers_controller.rb @@ -1,6 +1,5 @@ class Frameworks::ProvidersController < Frameworks::ApplicationController before_action :redirect_to_register_tab, unless: :turbo_frame_request?, only: :index - before_action :set_back_url, only: %i[new show] def index @filtering = Frameworks::Provider.filtering(filter_form_params) @@ -12,8 +11,40 @@ def show @activity_log_items = @provider.activity_log_items.paginate(page: params[:activities_page]) end + def new + @provider = Frameworks::Provider.new + end + + def edit + @provider = Frameworks::Provider.find(params[:id]) + end + + def create + @provider = Frameworks::Provider.new(provider_params) + + if @provider.save + redirect_to frameworks_provider_path(@provider) + else + render :new + end + end + + def update + @provider = Frameworks::Provider.find(params[:id]) + + if @provider.update(provider_params) + redirect_to frameworks_provider_path(@provider) + else + render :edit + end + end + private + def provider_params + params.require(:frameworks_provider).permit(:name, :short_name) + end + def filter_form_params params.fetch(:providers_filter, {}).permit( :sort_by, :sort_order diff --git a/app/models/frameworks/provider/sortable.rb b/app/models/frameworks/provider/sortable.rb index 2b0e34d0e..02063d890 100644 --- a/app/models/frameworks/provider/sortable.rb +++ b/app/models/frameworks/provider/sortable.rb @@ -14,7 +14,7 @@ def sorted_by(sort_by:, sort_order:) def available_sort_options [ - ["Short Name", "short_name"] + ["Short Name", "short_name"], ] end diff --git a/app/models/frameworks/provider_contact.rb b/app/models/frameworks/provider_contact.rb index 534e3bd37..79470e84a 100644 --- a/app/models/frameworks/provider_contact.rb +++ b/app/models/frameworks/provider_contact.rb @@ -10,4 +10,5 @@ class Frameworks::ProviderContact < ApplicationRecord validates :name, presence: true validates :email, presence: true + validates :provider_id, presence: true end diff --git a/app/views/frameworks/frameworks/_form.html.erb b/app/views/frameworks/frameworks/_form.html.erb new file mode 100644 index 000000000..164044f3e --- /dev/null +++ b/app/views/frameworks/frameworks/_form.html.erb @@ -0,0 +1,53 @@ +<%= f.govuk_fieldset legend: { text: 'Basic Details' } do %> + <%= f.govuk_text_field :name %> + <%= f.govuk_text_field :short_name, width: "one-third", label: { text: "Abbreviated name" } %> + <%= f.govuk_text_field :url, label: { text: "Providers URL" } %> + <%= f.govuk_text_field :reference, width: "one-third", label: { text: "Providers reference" } %> +<% end %> + +
+ <%= f.govuk_select :provider_id, @providers.map {|provider| [provider.short_name, provider.id] }, + "data-select-option-filter-target" => "input", + options: { include_blank: "Select a provider" }, + label: { text: "Provider" } %> + + <%= f.govuk_select :provider_contact_id, @provider_contacts.map {|contact| [contact.display_name, contact.id, { "data-provider-id" => contact.provider_id }] }, + "data-select-option-filter-target" => "output", + options: { include_blank: "Select a contact" }, + label: { text: "Provider contact" } %> +
+ +<%= f.govuk_fieldset legend: { text: 'Availability' } do %> +
+
+ <%= f.govuk_date_field :dfe_start_date, legend: { size: "s", text: "DfE start date", class: "" } %> +
+
+ <%= f.govuk_date_field :dfe_end_date, legend: { size: "s", text: "DfE end date", class: "" } %> +
+
+
+
+ <%= f.govuk_date_field :provider_start_date, legend: { size: "s", text: "Provider start date" } %> +
+
+ <%= f.govuk_date_field :provider_end_date, legend: { size: "s", text: "Provider end date" } %> +
+
+<% end %> + +<%= f.govuk_fieldset legend: { text: 'Other' } do %> + <% dps_options = [[true, 'Yes'], [false, 'No']] %> + <%= f.govuk_collection_radio_buttons :dps, dps_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a DPS (Dynamic purchasing system)?' } %> + + <% lot_options = [['single', 'Single-lot'], ['multi', 'Multi-lot']] %> + <%= f.govuk_collection_radio_buttons :lot, lot_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a single or multi lot?' } %> + + <% status_options = Frameworks::Framework.statuses.map {|status, id| [status, status.humanize] } %> + <%= f.govuk_collection_radio_buttons :status, status_options, :first, :last, legend: { size: 's', text: 'Approval Status' } %> +<% end %> + +
+ <%= f.govuk_submit submit %> + <%= link_to "Cancel", @framework, class: "govuk-link govuk-link--no-visited-state" %> +
diff --git a/app/views/frameworks/frameworks/_index_filters.html.erb b/app/views/frameworks/frameworks/_index_filters.html.erb index 83029c4bf..ed6f04594 100644 --- a/app/views/frameworks/frameworks/_index_filters.html.erb +++ b/app/views/frameworks/frameworks/_index_filters.html.erb @@ -2,6 +2,8 @@

<%= I18n.t("support.case.label.filters") %>

<%= form_with model: @filtering, scope: :frameworks_filter, method: :get, url: frameworks_frameworks_path, html: { "data-controller" => "case-filters" } do |form| %> + + <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_frameworks_path(viewing_from_entity: params[:viewing_from_entity]), class: "govuk-button govuk-button--secondary", role: "button" %> <%= form.govuk_select :sort_by, diff --git a/app/views/frameworks/frameworks/edit.html.erb b/app/views/frameworks/frameworks/edit.html.erb new file mode 100644 index 000000000..c3f90ef10 --- /dev/null +++ b/app/views/frameworks/frameworks/edit.html.erb @@ -0,0 +1,14 @@ +<%= content_for :title, "GHBS | Frameworks | Edit Framework" %> + +<%= turbo_frame_tag dom_id(@framework) do %> + +Edit Framework +

<%= @framework.name %>

+ +
+ <%= form_for @framework do |f| %> + <%= render "frameworks/frameworks/form", f:, submit: "Save changes" %> + <% end %> +
+ +<% end %> diff --git a/app/views/frameworks/frameworks/new.html.erb b/app/views/frameworks/frameworks/new.html.erb index ad9c73f86..8adc82011 100644 --- a/app/views/frameworks/frameworks/new.html.erb +++ b/app/views/frameworks/frameworks/new.html.erb @@ -3,60 +3,7 @@

New Framework

-<%= form_for @framework do |f| %> - <%= f.govuk_fieldset legend: { text: 'Basic Details' } do %> - <%= f.govuk_text_field :name %> - <%= f.govuk_text_field :short_name, width: "one-third", label: { text: "Abbreviated name" } %> - <%= f.govuk_text_field :url, label: { text: "Providers URL" } %> - <%= f.govuk_text_field :reference, width: "one-third", label: { text: "Providers reference" } %> + <%= form_for @framework do |f| %> + <%= render "frameworks/frameworks/form", f:, submit: "Create framework" %> <% end %> - -
- <%= f.govuk_select :provider_id, @providers.map {|provider| [provider.short_name, provider.id] }, - "data-select-option-filter-target" => "input", - options: { include_blank: "Select a provider" }, - label: { text: "Provider" } %> - - <%= f.govuk_select :provider_contact_id, @provider_contacts.map {|contact| [contact.display_name, contact.id, { "data-provider-id" => contact.provider_id }] }, - "data-select-option-filter-target" => "output", - options: { include_blank: "Select a contact" }, - label: { text: "Provider contact" } %> -
- - <%= f.govuk_fieldset legend: { text: 'Availability' } do %> -
-
- <%= f.govuk_date_field :dfe_start_date, legend: { size: "s", text: "DfE start date", class: "" } %> -
-
- <%= f.govuk_date_field :dfe_end_date, legend: { size: "s", text: "DfE end date", class: "" } %> -
-
-
-
- <%= f.govuk_date_field :provider_start_date, legend: { size: "s", text: "Provider start date" } %> -
-
- <%= f.govuk_date_field :provider_end_date, legend: { size: "s", text: "Provider end date" } %> -
-
- <% end %> - - <%= f.govuk_fieldset legend: { text: 'Other' } do %> - <% dps_options = [[true, 'Yes'], [false, 'No']] %> - <%= f.govuk_collection_radio_buttons :dps, dps_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a DPS (Dynamic purchasing system)?' } %> - - <% lot_options = [['single', 'Single-lot'], ['multi', 'Multi-lot']] %> - <%= f.govuk_collection_radio_buttons :lot, lot_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a single or multi lot?' } %> - - <% status_options = Frameworks::Framework.statuses.map {|status, id| [status, status.humanize] } %> - <%= f.govuk_collection_radio_buttons :status, status_options, :first, :last, legend: { size: 's', text: 'Approval Status' } %> - <% end %> - -
- <%= f.govuk_submit "Create framework" %> - <%= link_to "Cancel", @back_url, class: "govuk-link govuk-link--no-visited-state" %> -
- -<% end %>
diff --git a/app/views/frameworks/frameworks/show.html.erb b/app/views/frameworks/frameworks/show.html.erb index 5ad3707fe..1a2588fd7 100644 --- a/app/views/frameworks/frameworks/show.html.erb +++ b/app/views/frameworks/frameworks/show.html.erb @@ -1,5 +1,7 @@ <%= content_for :title, "GHBS | Frameworks | #{@framework.name}" %> +<%= turbo_frame_tag dom_id(@framework) do %> + <%= @framework.reference_and_short_name %>

<%= @framework.name %>

@@ -36,3 +38,10 @@ <% end %> + +

Actions

+ + +<% end %> diff --git a/app/views/frameworks/frameworks/show/_framework_provider.html.erb b/app/views/frameworks/frameworks/show/_framework_provider.html.erb index 0cf66357e..24a6a3d0c 100644 --- a/app/views/frameworks/frameworks/show/_framework_provider.html.erb +++ b/app/views/frameworks/frameworks/show/_framework_provider.html.erb @@ -1,7 +1,7 @@
Provider
-
<%= link_to @framework.provider_name, frameworks_provider_path(@framework.provider, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false %>
+
<%= link_to @framework.provider_name, frameworks_provider_path(@framework.provider, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false if @framework.provider.present? %>
@@ -11,7 +11,7 @@
Framework Owner
-
<%= link_to @framework.provider_framework_owner_name, frameworks_provider_contact_path(@framework.provider_contact, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false %>
+
<%= link_to @framework.provider_framework_owner_name, frameworks_provider_contact_path(@framework.provider_contact, back_to: current_url_b64(:framework_provider)), class: "govuk-link", "data-turbo" => false if @framework.provider_contact.present? %>
diff --git a/app/views/frameworks/provider_contacts/_form.html.erb b/app/views/frameworks/provider_contacts/_form.html.erb new file mode 100644 index 000000000..a2ef0d849 --- /dev/null +++ b/app/views/frameworks/provider_contacts/_form.html.erb @@ -0,0 +1,12 @@ +<%= f.govuk_text_field :name %> +<%= f.govuk_text_field :email %> +<%= f.govuk_text_field :phone %> + +<%= f.govuk_select :provider_id, @providers.map {|provider| [provider.short_name, provider.id] }, + options: { include_blank: "Select a provider" }, + label: { text: "Provider" } %> + +
+ <%= f.govuk_submit submit %> + <%= link_to "Cancel", @provider_contact, class: "govuk-link govuk-link--no-visited-state" %> +
diff --git a/app/views/frameworks/provider_contacts/_index_filters.html.erb b/app/views/frameworks/provider_contacts/_index_filters.html.erb index f0a57af14..80f78033f 100644 --- a/app/views/frameworks/provider_contacts/_index_filters.html.erb +++ b/app/views/frameworks/provider_contacts/_index_filters.html.erb @@ -2,7 +2,9 @@

<%= I18n.t("support.case.label.filters") %>

<%= form_with model: @filtering, scope: :provider_contacts_filter, method: :get, url: frameworks_provider_contacts_path, html: { "data-controller" => "case-filters" } do |form| %> - <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_provider_contacts_path, class: "govuk-button govuk-button--secondary", role: "button" %> + + + <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_provider_contacts_path(viewing_from_entity: params[:viewing_from_entity]), class: "govuk-button govuk-button--secondary", role: "button" %> <%= form.govuk_select :sort_by, options_for_select(@filtering.available_sort_options, @filtering.sort_by), diff --git a/app/views/frameworks/provider_contacts/edit.html.erb b/app/views/frameworks/provider_contacts/edit.html.erb index d6af6a289..f9e54409f 100644 --- a/app/views/frameworks/provider_contacts/edit.html.erb +++ b/app/views/frameworks/provider_contacts/edit.html.erb @@ -8,14 +8,7 @@
<%= form_for @provider_contact do |f| %> - <%= f.govuk_text_field :name %> - <%= f.govuk_text_field :email %> - <%= f.govuk_text_field :phone %> - -
- <%= f.govuk_submit "Save changes" %> - <%= link_to "Cancel", @provider_contact, class: "govuk-link govuk-link--no-visited-state" %> -
+ <%= render "frameworks/provider_contacts/form", f:, submit: "Save changes" %> <% end %>
<% end %> diff --git a/app/views/frameworks/provider_contacts/index.html.erb b/app/views/frameworks/provider_contacts/index.html.erb index 9babb80a3..f46eb1cb7 100644 --- a/app/views/frameworks/provider_contacts/index.html.erb +++ b/app/views/frameworks/provider_contacts/index.html.erb @@ -2,6 +2,10 @@
+ <% unless params[:viewing_from_entity] == "true" %> + <%= link_to "Add Contact", new_frameworks_provider_contact_path(back_to: current_url_b64(:provider_contacts)), class: "govuk-button", "data-turbo" => false %> + <% end %> + <%= render "index_filters" %>
diff --git a/app/views/frameworks/provider_contacts/new.html.erb b/app/views/frameworks/provider_contacts/new.html.erb new file mode 100644 index 000000000..639ed680d --- /dev/null +++ b/app/views/frameworks/provider_contacts/new.html.erb @@ -0,0 +1,9 @@ +<%= content_for :title, "GHBS | Provider Contacts | New Contact" %> + +

New Provider Contact

+ +
+ <%= form_for @provider_contact do |f| %> + <%= render "frameworks/provider_contacts/form", f:, submit: "Create contact" %> + <% end %> +
diff --git a/app/views/frameworks/providers/_form.html.erb b/app/views/frameworks/providers/_form.html.erb new file mode 100644 index 000000000..579535b60 --- /dev/null +++ b/app/views/frameworks/providers/_form.html.erb @@ -0,0 +1,7 @@ +<%= f.govuk_text_field :name %> +<%= f.govuk_text_field :short_name, label: { text: "Short name" } %> + +
+ <%= f.govuk_submit submit %> + <%= link_to "Cancel", @provider, class: "govuk-link govuk-link--no-visited-state" %> +
diff --git a/app/views/frameworks/providers/_index_filters.html.erb b/app/views/frameworks/providers/_index_filters.html.erb index 90511483f..171ed4ea8 100644 --- a/app/views/frameworks/providers/_index_filters.html.erb +++ b/app/views/frameworks/providers/_index_filters.html.erb @@ -2,7 +2,9 @@

<%= I18n.t("support.case.label.filters") %>

<%= form_with model: @filtering, scope: :providers_filter, method: :get, url: frameworks_providers_path, html: { "data-controller" => "case-filters" } do |form| %> - <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_providers_path, class: "govuk-button govuk-button--secondary", role: "button" %> + + + <%= link_to I18n.t("support.case.filter.buttons.clear"), frameworks_providers_path(viewing_from_entity: params[:viewing_from_entity]), class: "govuk-button govuk-button--secondary", role: "button" %> <%= form.govuk_select :sort_by, options_for_select(@filtering.available_sort_options, @filtering.sort_by), diff --git a/app/views/frameworks/providers/edit.html.erb b/app/views/frameworks/providers/edit.html.erb new file mode 100644 index 000000000..74f613b3f --- /dev/null +++ b/app/views/frameworks/providers/edit.html.erb @@ -0,0 +1,14 @@ +<%= content_for :title, "GHBS | Providers | Edit #{@provider.display_name}" %> + +<%= turbo_frame_tag dom_id(@provider) do %> + Edit Framework Provider +

<%= @provider.display_name %>

+ +

Details

+ +
+ <%= form_for @provider do |f| %> + <%= render "frameworks/providers/form", f:, submit: "Save changes" %> + <% end %> +
+<% end %> diff --git a/app/views/frameworks/providers/index.html.erb b/app/views/frameworks/providers/index.html.erb index 389fe907c..976a2bfb3 100644 --- a/app/views/frameworks/providers/index.html.erb +++ b/app/views/frameworks/providers/index.html.erb @@ -2,6 +2,10 @@
+ <% unless params[:viewing_from_entity] == "true" %> + <%= link_to "Add Provider", new_frameworks_provider_path(back_to: current_url_b64(:providers)), class: "govuk-button", "data-turbo" => false %> + <% end %> + <%= render "index_filters" %>
diff --git a/app/views/frameworks/providers/new.html.erb b/app/views/frameworks/providers/new.html.erb new file mode 100644 index 000000000..785e52a5b --- /dev/null +++ b/app/views/frameworks/providers/new.html.erb @@ -0,0 +1,9 @@ +<%= content_for :title, "GHBS | Providers | New Provider" %> + +

New Provider

+ +
+ <%= form_for @provider do |f| %> + <%= render "frameworks/providers/form", f:, submit: "Create provider" %> + <% end %> +
diff --git a/app/views/frameworks/providers/show.html.erb b/app/views/frameworks/providers/show.html.erb index b4aaa6aa6..0861969c3 100644 --- a/app/views/frameworks/providers/show.html.erb +++ b/app/views/frameworks/providers/show.html.erb @@ -44,4 +44,9 @@
<% end %>
+ +

Actions

+
    +
  • <%= link_to "Edit Provider", edit_frameworks_provider_path(@provider), class: "govuk-link" %>
  • +
<% end %> diff --git a/config/brakeman.ignore b/config/brakeman.ignore index 6d9dc6a70..1065b1d9b 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -15,7 +15,7 @@ "type": "controller", "class": "Frameworks::FrameworksController", "method": "show", - "line": 15, + "line": 21, "file": "app/controllers/frameworks/frameworks_controller.rb", "rendered": { "name": "frameworks/frameworks/show", @@ -25,7 +25,7 @@ { "type": "template", "name": "frameworks/frameworks/show", - "line": 23, + "line": 25, "file": "app/views/frameworks/frameworks/show.html.erb", "rendered": { "name": "frameworks/frameworks/show/_framework_details", @@ -67,6 +67,40 @@ ], "note": "" }, + { + "warning_type": "Dynamic Render Path", + "warning_code": 15, + "fingerprint": "188c6c6b5b31525ba4c9508067846c8542e28b3f2b6a1850c158f6662c532303", + "check_name": "Render", + "message": "Render path contains parameter value", + "file": "app/views/frameworks/providers/index.html.erb", + "line": 13, + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "code": "render(action => Frameworks::Provider.filtering(filter_form_params).results.paginate(:page => params[:providers_page]), {})", + "render_path": [ + { + "type": "controller", + "class": "Frameworks::ProvidersController", + "method": "index", + "line": 7, + "file": "app/controllers/frameworks/providers_controller.rb", + "rendered": { + "name": "frameworks/providers/index", + "file": "app/views/frameworks/providers/index.html.erb" + } + } + ], + "location": { + "type": "template", + "template": "frameworks/providers/index" + }, + "user_input": "params[:providers_page]", + "confidence": "Weak", + "cwe_id": [ + 22 + ], + "note": "" + }, { "warning_type": "Dynamic Render Path", "warning_code": 15, @@ -74,7 +108,7 @@ "check_name": "Render", "message": "Render path contains parameter value", "file": "app/views/frameworks/frameworks/index.html.erb", - "line": 9, + "line": 13, "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => Frameworks::Framework.filtering(filter_form_params).results.paginate(:page => params[:frameworks_page]), {})", "render_path": [ @@ -82,7 +116,7 @@ "type": "controller", "class": "Frameworks::FrameworksController", "method": "index", - "line": 10, + "line": 16, "file": "app/controllers/frameworks/frameworks_controller.rb", "rendered": { "name": "frameworks/frameworks/index", @@ -108,7 +142,7 @@ "check_name": "Render", "message": "Render path contains parameter value", "file": "app/views/frameworks/provider_contacts/index.html.erb", - "line": 9, + "line": 13, "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => Frameworks::ProviderContact.filtering(filter_form_params).results.paginate(:page => params[:provider_contacts_page]), {})", "render_path": [ @@ -231,7 +265,7 @@ "check_name": "MassAssignment", "message": "Specify exact keys allowed for mass assignment instead of using `permit!` which allows any keys", "file": "app/controllers/support/cases_controller.rb", - "line": 138, + "line": 140, "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", "code": "params.fetch(:tower, {}).fetch(tab, {}).permit!", "render_path": null, @@ -316,6 +350,6 @@ "note": "" } ], - "updated": "2023-09-12 15:08:09 +0100", + "updated": "2023-09-14 15:05:19 +0100", "brakeman_version": "6.0.1" } diff --git a/config/routes.rb b/config/routes.rb index c7e783d9c..b208acd21 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -301,8 +301,8 @@ # Frameworks portal namespace :frameworks do root to: "dashboards#index" - resources :frameworks, only: %i[index show new create] - resources :provider_contacts, only: %i[index show edit update] + resources :frameworks + resources :provider_contacts resources :providers namespace :management do diff --git a/spec/features/frameworks/register/agent_can_create_provider_contact_spec.rb b/spec/features/frameworks/register/agent_can_create_provider_contact_spec.rb new file mode 100644 index 000000000..0ccbb1953 --- /dev/null +++ b/spec/features/frameworks/register/agent_can_create_provider_contact_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" + +describe "Agent can create provider contacts", js: true do + include_context "with a framework evaluation agent" + + before do + create(:frameworks_provider, short_name: "ABC") + end + + it "creates and takes you to the new contact" do + visit frameworks_root_path + click_on "Provider Contacts" + click_on "Add Contact" + fill_in "Name", with: "Jane Doe" + fill_in "Email", with: "jane.doe@educaction.gov.uk" + fill_in "Phone", with: "0114123456" + select "ABC", from: "Provider" + click_on "Create contact" + + expect(page).to have_css(".govuk-heading-l", text: "Jane Doe") + expect(page).to have_summary("Email", "jane.doe@educaction.gov.uk") + expect(page).to have_summary("Phone", "0114123456") + expect(page).to have_summary("Provider", "ABC") + end +end diff --git a/spec/features/frameworks/register/agent_can_create_provider_spec.rb b/spec/features/frameworks/register/agent_can_create_provider_spec.rb new file mode 100644 index 000000000..b1cbd67e4 --- /dev/null +++ b/spec/features/frameworks/register/agent_can_create_provider_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +describe "Agent can create providers", js: true do + include_context "with a framework evaluation agent" + + it "creates and takes you to the new framework provider" do + visit frameworks_root_path + click_on "Providers" + click_on "Add Provider" + fill_in "Name", with: "New Provider 1" + fill_in "Short name", with: "NP1" + click_on "Create provider" + + expect(page).to have_css(".govuk-heading-l", text: "New Provider 1") + expect(page).to have_summary("Short name", "NP1") + end +end diff --git a/spec/support/capybara_driver_helper.rb b/spec/support/capybara_driver_helper.rb index 30349c298..9231d9a02 100644 --- a/spec/support/capybara_driver_helper.rb +++ b/spec/support/capybara_driver_helper.rb @@ -5,7 +5,7 @@ chrome_options.add_argument("no-sandbox") chrome_options.add_argument("headless") chrome_options.add_argument("disable-gpu") - chrome_options.add_argument("window-size=1400,1400") + chrome_options.add_argument("window-size=1920,1080") if ENV["SELENIUM_HUB_URL"] # use remote chrome (docker default)