Browse Source

Expired link error page

pull/580/head
baarkerlounger 3 years ago
parent
commit
fe9dfe989e
  1. 2
      app/controllers/auth/confirmations_controller.rb
  2. 11
      app/views/devise/confirmations/expired.html.erb
  3. 6
      spec/requests/auth/confirmations_controller_spec.rb

2
app/controllers/auth/confirmations_controller.rb

@ -11,6 +11,8 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController
else
respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
end
elsif resource.errors.map(&:type).include?(:confirmation_period_expired)
render "devise/confirmations/expired"
else
respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }
end

11
app/views/devise/confirmations/expired.html.erb

@ -0,0 +1,11 @@
<% content_for :title, "Your invitation link has expired" %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
<%= content_for(:title) %>
</h1>
<p class="govuk-body">Contact your coordinator to request a new one.</p>
</div>
</div>

6
spec/requests/auth/confirmations_controller_spec.rb

@ -39,10 +39,8 @@ RSpec.describe Auth::ConfirmationsController, type: :request do
get "/account/confirmation?confirmation_token=#{user.confirmation_token}"
end
it "shows the Resend Invitation page" do
expect(page).to have_selector("#error-summary-title")
expect(page).to have_content(I18n.t("errors.messages.confirmation_period_expired", period:))
expect(page).to have_content("Resend invitation link")
it "shows the error page" do
expect(page).to have_content("Your invitation link has expired")
end
end
end

Loading…
Cancel
Save