-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to change applicant name
This adds the ability for an assessor with the right permissions to change the applicant name associated with an application.
- Loading branch information
1 parent
0f5c5df
commit ffcab97
Showing
6 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/views/assessor_interface/application_forms/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<% title = "Change details for ‘#{application_form_full_name(@application_form)}’" %> | ||
|
||
<% content_for :page_title, "#{"Error: " if @form.errors.any?}#{title}" %> | ||
<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %> | ||
|
||
<%= form_with model: @form, url: [:assessor_interface, @application_form], method: :put do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<h1 class="govuk-heading-xl"><%= title %></h1> | ||
|
||
<h2 class="govuk-heading-m">Current name</h2> | ||
|
||
<%= govuk_summary_list(actions: false) do |summary_list| | ||
summary_list.with_row do |row| | ||
row.with_key { "Given names" } | ||
row.with_value { @application_form.given_names } | ||
end | ||
|
||
summary_list.with_row do |row| | ||
row.with_key { "Family name" } | ||
row.with_value { @application_form.family_name } | ||
end | ||
end %> | ||
|
||
<h2 class="govuk-heading-m">Change name</h2> | ||
<p class="govuk-body">Use this form to change one or more of the names.</p> | ||
|
||
<%= f.govuk_text_field :given_names %> | ||
<%= f.govuk_text_field :family_name %> | ||
|
||
<%= f.govuk_submit do %> | ||
<%= govuk_link_to "Cancel", [:assessor_interface, @application_form] %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
spec/support/autoload/page_objects/assessor_interface/edit_application.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module PageObjects | ||
module AssessorInterface | ||
class EditApplication < SitePrism::Page | ||
set_url "/assessor/applications/{application_form_id}/edit" | ||
|
||
section :form, "form" do | ||
element :given_names_field, | ||
"#assessor-interface-application-form-name-form-given-names-field" | ||
element :family_name_field, | ||
"#assessor-interface-application-form-name-form-family-name-field" | ||
element :submit_button, ".govuk-button" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Assessor change application form name", type: :system do | ||
before do | ||
given_the_service_is_open | ||
given_there_is_an_application_form | ||
end | ||
|
||
it "checks manage applications permission" do | ||
given_i_am_authorized_as_a_user(assessor) | ||
|
||
when_i_visit_the(:assessor_edit_application_page, application_form_id:) | ||
then_i_see_the_forbidden_page | ||
end | ||
|
||
it "allows changing application form name" do | ||
given_i_am_authorized_as_a_user(manager) | ||
|
||
when_i_visit_the(:assessor_application_page, application_id:) | ||
then_i_see_the(:assessor_application_page) | ||
|
||
when_i_click_on_change_name | ||
then_i_see_the(:assessor_edit_application_page, application_form_id:) | ||
|
||
when_i_fill_in_the_name | ||
then_i_see_the(:assessor_application_page, application_id:) | ||
end | ||
|
||
def given_there_is_an_application_form | ||
application_form | ||
end | ||
|
||
def when_i_click_on_change_name | ||
assessor_application_page | ||
.summary_list | ||
.find_row(key: "Name") | ||
.actions | ||
.link | ||
.click | ||
end | ||
|
||
def when_i_fill_in_the_name | ||
assessor_edit_application_page.form.given_names_field.fill_in with: | ||
"New given names" | ||
assessor_edit_application_page.form.family_name_field.fill_in with: | ||
"New family name" | ||
assessor_edit_application_page.form.submit_button.click | ||
end | ||
|
||
def application_form | ||
@application_form ||= | ||
create( | ||
:application_form, | ||
:submitted, | ||
:with_personal_information, | ||
:with_assessment, | ||
) | ||
end | ||
|
||
delegate :id, to: :application_form, prefix: true | ||
alias_method :application_id, :application_form_id | ||
|
||
def assessor | ||
create(:staff, :confirmed, :with_award_decline_permission) | ||
end | ||
|
||
def manager | ||
create(:staff, :confirmed, :with_change_name_permission) | ||
end | ||
end |