Skip to content

Commit

Permalink
Update to how objects are created on the system specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassanmir92 committed Oct 28, 2024
1 parent d2bc1b3 commit 563d62e
Showing 1 changed file with 62 additions and 64 deletions.
126 changes: 62 additions & 64 deletions spec/system/assessor_interface/filtering_application_forms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
require "rails_helper"

RSpec.describe "Assessor filtering application forms", type: :system do
let(:assessors) do
[
create(:staff, :with_assess_permission, name: "Fal Staff"),
create(:staff, :with_assess_permission, name: "Wag Staff"),
]
end

before do
given_there_are_application_forms
given_i_am_authorized_as_an_assessor_user
Expand Down Expand Up @@ -54,7 +61,61 @@
private

def given_there_are_application_forms
application_forms
create(
:application_form,
:submitted,
region: create(:region, :in_country, country_code: "US"),
given_names: "Cher",
family_name: "Bert",
assessor: assessors.second,
submitted_at: 2.months.ago,
reference: "CHERBERT",
)

create(
:application_form,
:submitted,
:action_required_by_admin,
region: create(:region, :in_country, country_code: "FR"),
given_names: "Emma",
family_name: "Dubois",
assessor: assessors.second,
submitted_at: 2.months.ago,
teacher: create(:teacher, email: "[email protected]"),
)

create(
:application_form,
:submitted,
:action_required_by_assessor,
region: create(:region, :in_country, country_code: "ES"),
given_names: "Arnold",
family_name: "Drummond",
assessor: assessors.first,
submitted_at: 2.months.ago,
)

create(
:application_form,
:awarded,
awarded_at: 2.days.ago,
region: create(:region, :in_country, country_code: "PT"),
given_names: "John",
family_name: "Smith",
assessor: assessors.second,
submitted_at: 10.days.ago,
)

create(
:application_form,
:awarded,
awarded_at: 6.months.ago,
region: create(:region, :in_country, country_code: "DE"),
given_names: "Nick",
family_name: "Johnson",
assessor: assessors.second,
submitted_at: 7.months.ago,
)
end

def when_i_visit_the_applications_page
Expand Down Expand Up @@ -201,67 +262,4 @@ def and_i_apply_the_show_all_filter
def then_i_see_a_list_of_all_applications
expect(assessor_applications_page.search_results.count).to eq(5)
end

def application_forms
@application_forms ||= [
create(
:application_form,
:submitted,
region: create(:region, :in_country, country_code: "US"),
given_names: "Cher",
family_name: "Bert",
assessor: assessors.second,
submitted_at: 2.months.ago,
reference: "CHERBERT",
),
create(
:application_form,
:submitted,
:action_required_by_admin,
region: create(:region, :in_country, country_code: "FR"),
given_names: "Emma",
family_name: "Dubois",
assessor: assessors.second,
submitted_at: 2.months.ago,
teacher: create(:teacher, email: "[email protected]"),
),
create(
:application_form,
:submitted,
:action_required_by_assessor,
region: create(:region, :in_country, country_code: "ES"),
given_names: "Arnold",
family_name: "Drummond",
assessor: assessors.first,
submitted_at: 2.months.ago,
),
create(
:application_form,
:awarded,
awarded_at: 2.days.ago,
region: create(:region, :in_country, country_code: "PT"),
given_names: "John",
family_name: "Smith",
assessor: assessors.second,
submitted_at: 10.days.ago,
),
create(
:application_form,
:awarded,
awarded_at: 6.months.ago,
region: create(:region, :in_country, country_code: "DE"),
given_names: "Nick",
family_name: "Johnson",
assessor: assessors.second,
submitted_at: 7.months.ago,
),
]
end

def assessors
@assessors ||= [
create(:staff, :with_assess_permission, name: "Fal Staff"),
create(:staff, :with_assess_permission, name: "Wag Staff"),
]
end
end

0 comments on commit 563d62e

Please sign in to comment.