Browse Source

Render gov uk reset view

pull/157/head
baarkerlounger 4 years ago
parent
commit
0ea91adebf
  1. 5
      app/controllers/auth/passwords_controller.rb
  2. 30
      app/views/users/reset_password.html.erb
  3. 8
      spec/requests/user_controller_spec.rb

5
app/controllers/auth/passwords_controller.rb

@ -23,6 +23,11 @@ class Auth::PasswordsController < Devise::PasswordsController
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
end
def edit
super
render "users/reset_password"
end
protected
def after_sending_reset_password_instructions_path_for(_resource)

30
app/views/users/reset_password.html.erb

@ -0,0 +1,30 @@
<% content_for :title, "Reset your password" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: 'Back',
href: :back,
) %>
<% end %>
<%= form_for(@user, as: :user, html: { method: :patch }) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
<%= content_for(:title) %>
</h1>
<%= f.govuk_password_field :new_password,
label: { text: "New password" },
hint: @minimum_password_length ? { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." } : nil,
autocomplete: "new-password"
%>
<%= f.govuk_password_field :password_confirmation,
label: { text: "Confirm new password" }
%>
<%= f.govuk_submit "Update" %>
</div>
</div>
<% end %>

8
spec/requests/user_controller_spec.rb

@ -37,6 +37,14 @@ RSpec.describe UsersController, type: :request do
expect(response).to redirect_to("/users/sign-in")
end
end
describe "reset password" do
it "renders the user edit password view" do
raw, enc = Devise.token_generator.generate(User, :reset_password_token)
get "/users/password/edit?reset_password_token=#{enc}"
expect(page).to have_css("h1", class: "govuk-heading-l", text: "Reset your password")
end
end
end
describe "#show" do

Loading…
Cancel
Save