Skip to content

Commit

Permalink
Attach multiple work histories and qualifications
Browse files Browse the repository at this point in the history
This updates the factories for work history and qualifications to ensure
there is more than one work history so it's more realistic.
  • Loading branch information
thomasleese committed Jan 11, 2024
1 parent da90e93 commit 39b1eb7
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 32 deletions.
28 changes: 18 additions & 10 deletions lib/tasks/example_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def application_form_traits_for(region)
traits =
%i[
with_personal_information
with_completed_qualification
with_degree_qualification
with_identification_document
with_age_range
with_subjects
Expand Down Expand Up @@ -188,20 +188,28 @@ def create_requestables(application_form, assessment, state)
unless application_form.teaching_authority_provides_written_statement
assessment.verify!
end
elsif (work_history = application_form.work_histories.first) && rand(3).zero?
FactoryBot.create(:reference_request, state, assessment:, work_history:)
elsif (work_histories = application_form.work_histories).present? &&
rand(3).zero?
work_histories.each do |work_history|
FactoryBot.create(:reference_request, state, assessment:, work_history:)
end

application_form.update!(
statuses: ["#{status_prefix}_reference"],
stage: "verification",
)
assessment.verify!
elsif (qualification = application_form.qualifications.first) && rand(2).zero?
FactoryBot.create(
:qualification_request,
state,
assessment:,
qualification:,
)
elsif (qualifications = application_form.qualifications).present? &&
rand(2).zero?
qualifications.each do |qualification|
FactoryBot.create(
:qualification_request,
state,
assessment:,
qualification:,
)
end

application_form.update!(
statuses: ["#{status_prefix}_qualification"],
stage: "verification",
Expand Down
17 changes: 15 additions & 2 deletions spec/factories/application_forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
end
end

trait :with_completed_qualification do
trait :with_teaching_qualification do
after(:create) do |application_form, _evaluator|
create(
:qualification,
Expand All @@ -300,6 +300,13 @@
end
end

trait :with_degree_qualification do
with_teaching_qualification
after(:create) do |application_form, _evaluator|
create(:qualification, :completed, application_form:)
end
end

trait :with_english_language_medium_of_instruction do
english_language_proof_method { "medium_of_instruction" }

Expand Down Expand Up @@ -356,7 +363,13 @@
has_work_history { true }

after(:create) do |application_form, _evaluator|
create(:work_history, :completed, application_form:)
create(:work_history, :completed, :still_employed, application_form:)
create(
:work_history,
:completed,
:not_still_employed,
application_form:,
)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/application_mailer_observer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
create(
:application_form,
:with_personal_information,
:with_completed_qualification,
:with_teaching_qualification,
region:,
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class CheckYourAnswers < SitePrism::Page
end

section :who_you_can_teach, "#app-application-form-who-you-can-teach" do
section :qualification_summary_list,
GovukSummaryList,
".govuk-summary-card" \
":not(#app-check-your-answers-summary-age-range)" \
":not(#app-check-your-answers-summary-subjects)",
match: :first
sections :qualification_summary_lists,
GovukSummaryList,
".govuk-summary-card" \
":not(#app-check-your-answers-summary-age-range)" \
":not(#app-check-your-answers-summary-subjects)",
match: :first
section :age_range_summary_list,
GovukSummaryList,
"#app-check-your-answers-summary-age-range"
Expand All @@ -34,9 +34,9 @@ class CheckYourAnswers < SitePrism::Page
section :add_summary_list,
GovukSummaryList,
"#app-check-your-answers-summary-add-work-history"
section :work_history_summary_list,
GovukSummaryList,
".govuk-summary-card:not(#app-check-your-answers-summary-add-work-history)"
sections :work_history_summary_lists,
GovukSummaryList,
".govuk-summary-card:not(#app-check-your-answers-summary-add-work-history)"
end

section :proof_of_recognition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def application_form
create(
:application_form,
:old_regs,
:with_completed_qualification,
:with_teaching_qualification,
:with_work_history,
:with_registration_number,
:with_personal_information,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def given_there_is_an_awardable_application_form(traits = [])
create(
:application_form,
:with_personal_information,
:with_completed_qualification,
:with_teaching_qualification,
:submitted,
*traits,
)
Expand Down
19 changes: 12 additions & 7 deletions spec/system/teacher_interface/check_answers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,24 @@ def when_i_click_change_links(section, summary_list, &block)
index = 0
while (
row =
teacher_check_your_answers_page
.send(section)
.send("#{summary_list}_summary_list")
.rows[
index
]
find_change_link_summary_list(section, summary_list).rows[index]
)
row.actions.link.click
block.call
index += 1
end
end

def find_change_link_summary_list(section, summary_list)
section_page_object = teacher_check_your_answers_page.send(section)

begin
section_page_object.send("#{summary_list}_summary_list")
rescue NoMethodError
section_page_object.send("#{summary_list}_summary_lists").first
end
end

def and_i_dont_need_to_upload_another_file
teacher_check_document_page.form.false_radio_item.input.click
teacher_check_document_page.form.continue_button.click
Expand All @@ -168,7 +173,7 @@ def application_form
:with_registration_number,
:with_work_history,
:with_written_statement,
:with_completed_qualification,
:with_teaching_qualification,
teacher:,
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/system/teacher_interface/submitting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def application_form
:with_registration_number,
:with_work_history,
:with_written_statement,
:with_completed_qualification,
:with_teaching_qualification,
teacher:,
)
end
Expand Down

0 comments on commit 39b1eb7

Please sign in to comment.