Browse Source

Test redirect and text

pull/580/head
baarkerlounger 3 years ago
parent
commit
9d1f07727f
  1. 2
      app/views/devise/passwords/reset_password.html.erb
  2. 3
      config/locales/en.yml
  3. 32
      spec/requests/auth/confirmations_controller_spec.rb
  4. 2
      spec/requests/auth/passwords_controller_spec.rb

2
app/views/devise/passwords/reset_password.html.erb

@ -1,4 +1,4 @@
<% content_for :title, @confirmation ? "Set your password" : "Reset your password" %> <% content_for :title, @confirmation ? I18n.t("user.create_password") : I18n.t("user.reset_password") %>
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(

3
config/locales/en.yml

@ -34,6 +34,9 @@ en:
feedback_form: "https://forms.office.com/Pages/ResponsePage.aspx?id=EGg0v32c3kOociSi7zmVqC4YDsCJ3llAvEZelBFBLUBURFVUTzFDTUJPQlM4M0laTE5DTlNFSjJBQi4u" feedback_form: "https://forms.office.com/Pages/ResponsePage.aspx?id=EGg0v32c3kOociSi7zmVqC4YDsCJ3llAvEZelBFBLUBURFVUTzFDTUJPQlM4M0laTE5DTlNFSjJBQi4u"
organisation: organisation:
updated: "Organisation details updated" updated: "Organisation details updated"
user:
create_password: "Create a password to finish setting up your account"
reset_password: "Reset your password"
validations: validations:
other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided" other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided"

32
spec/requests/auth/confirmations_controller_spec.rb

@ -0,0 +1,32 @@
require "rails_helper"
require_relative "../../support/devise"
RSpec.describe Auth::ConfirmationsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
before do
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true)
end
context "when a confirmation link is clicked by a new user" do
let(:user) { FactoryBot.create(:user, :data_provider, sign_in_count: 0, confirmed_at: nil) }
before do
user.send_confirmation_instructions
get "/account/confirmation?confirmation_token=#{user.confirmation_token}"
end
it "marks the user as confirmed" do
expect(user.reload.confirmed_at).to be_a(Time)
end
it "redirects to the set password page" do
follow_redirect!
expect(page).to have_content(I18n.t("user.create_password"))
end
end
end

2
spec/requests/auth/passwords_controller_spec.rb

@ -87,7 +87,7 @@ RSpec.describe Auth::PasswordsController, type: :request do
it "renders the user edit password view" do it "renders the user edit password view" do
_raw, enc = Devise.token_generator.generate(AdminUser, :reset_password_token) _raw, enc = Devise.token_generator.generate(AdminUser, :reset_password_token)
get "/admin/password/edit?reset_password_token=#{enc}" get "/admin/password/edit?reset_password_token=#{enc}"
expect(page).to have_css("h1", text: "Reset your password") expect(page).to have_css("h1", text: I18n.t("user.reset_password"))
end end
context "when passwords entered don't match" do context "when passwords entered don't match" do

Loading…
Cancel
Save