Skip to content

Commit

Permalink
Add an ineligible persona
Browse files Browse the repository at this point in the history
This allows us to quickly see what the ineligible page looks like by
selecting this persona.
  • Loading branch information
thomasleese committed Nov 24, 2023
1 parent b0cd5f0 commit afc180e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
14 changes: 14 additions & 0 deletions app/controllers/personas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ def eligible_sign_in
redirect_to %i[eligibility_interface result]
end

def ineligible_sign_in
eligibility_check =
EligibilityCheck.create!(
completed_at: Time.zone.now,
country_code: INELIGIBLE_COUNTRY_CODES.sample,
)

session[:eligibility_check_id] = eligibility_check.id

redirect_to %i[eligibility_interface result]
end

def staff_sign_in
staff = Staff.find(params[:id])
sign_in_and_redirect(staff)
Expand Down Expand Up @@ -78,6 +90,8 @@ def ensure_feature_active
}
end

INELIGIBLE_COUNTRY_CODES = Country::CODES - Country.pluck(:code)

def load_eligible_personas
all_regions = Region.includes(:country).order(:id)

Expand Down
7 changes: 7 additions & 0 deletions app/views/personas/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
<% end %>
</section>

<section id="app-personas-ineligibles" class="app-personas">
<h2 class="govuk-heading-l">Ineligible check</h2>
<p class="govuk-body">
<%= govuk_button_to "Sign&nbsp;in".html_safe, ineligible_sign_in_personas_path %>
</p>
</section>

<section id="app-personas-teachers" class="app-personas">
<h2 class="govuk-heading-l">Teachers</h2>

Expand Down
4 changes: 2 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
}

# Show full error reports and enable caching.
config.consider_all_requests_local = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :memory_store

# Render exception templates instead of raising exceptions.
config.action_dispatch.show_exceptions = :all
config.action_dispatch.show_exceptions = :none

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
Expand Down
6 changes: 6 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,12 @@
post "staff", to: "personas#staff_sign_in", as: "staff_sign_in"
post "teacher", to: "personas#teacher_sign_in", as: "teacher_sign_in"
end

collection do
post "ineligible",
to: "personas#ineligible_sign_in",
as: "ineligible_sign_in"
end
end

resources :autocomplete_locations, only: %i[index]
Expand Down
5 changes: 5 additions & 0 deletions spec/support/autoload/page_objects/personas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class Personas < SitePrism::Page
elements :buttons, ".govuk-button"
end

section :ineligibles, "#app-personas-ineligibles" do
element :heading, "h2"
elements :buttons, ".govuk-button"
end

section :teachers, "#app-personas-teachers" do
element :heading, "h2"
elements :buttons, ".govuk-button"
Expand Down
9 changes: 9 additions & 0 deletions spec/system/personas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

when_i_visit_the(:personas_page)

when_i_sign_in_as_an_ineligible_persona
then_i_see_the(:eligibility_ineligible_page)

when_i_visit_the(:personas_page)

when_i_sign_in_as_a_teacher_persona
then_i_see_the(:teacher_application_page)

Expand Down Expand Up @@ -73,6 +78,10 @@ def when_i_sign_in_as_an_eligible_persona
personas_page.eligibles.buttons.first.click
end

def when_i_sign_in_as_an_ineligible_persona
personas_page.ineligibles.buttons.first.click
end

def when_i_sign_in_as_a_teacher_persona
personas_page.teachers.buttons.first.click
end
Expand Down

0 comments on commit afc180e

Please sign in to comment.