Skip to content

Commit fa27d9e

Browse files
authored
Merge pull request #246 from AlchemyCMS/dependabot/bundler/devise-gte-4.9-and-lt-6.0
Allow Devise 5.0
2 parents 6790d08 + 87969e6 commit fa27d9e

7 files changed

Lines changed: 38 additions & 8 deletions

File tree

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ group :test do
2020
if ENV["GITHUB_ACTIONS"]
2121
gem "simplecov-cobertura", "~> 3.0"
2222
end
23+
gem "selenium-webdriver", "~> 4.40"
24+
gem "capybara-screenshot", "~> 1.0"
2325
end
2426

2527
gem "github_fast_changelog", require: false

alchemy-devise.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
1616
s.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "CHANGELOG.md", "README.md"]
1717

1818
s.add_dependency "alchemy_cms", [">= 8.0.0.a", "< 9.0"]
19-
s.add_dependency "devise", ["~> 4.9"]
19+
s.add_dependency "devise", ">= 4.9", "< 6.0"
2020
s.add_dependency "flickwerk", ["~> 0.3.6"]
2121

2222
s.add_development_dependency "capybara"

app/views/alchemy/admin/passwords/edit.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
<p><%= Alchemy.t('Please enter a new password') %></p>
1313
<% end %>
1414
<% else %>
15-
<div id="errors" style="display: block">
16-
<%= devise_error_messages! %>
17-
</div>
15+
<%= render "devise/shared/error_messages", resource: resource %>
1816
<% end %>
1917
<%= alchemy_form_for resource, as: resource_name, url: admin_update_password_path, method: 'patch' do |f| %>
2018
<%= f.hidden_field :reset_password_token %>

app/views/alchemy/admin/passwords/new.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
<p><%= Alchemy.t('Please enter your email address') %></p>
1313
<% end %>
1414
<% else %>
15-
<div id="errors" style="display: block">
16-
<%= devise_error_messages! %>
17-
</div>
15+
<%= render "devise/shared/error_messages", resource: resource %>
1816
<% end %>
1917
<%= alchemy_form_for :user, url: admin_reset_password_path, html: {method: 'post'} do |f| %>
2018
<%= f.input :email,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% if resource.errors.any? %>
2+
<alchemy-message data-turbo-temporary type="error">
3+
<h2>
4+
<%= Alchemy.t("default_message", scope: "forms.error_notification") %>
5+
</h2>
6+
<ul>
7+
<% resource.errors.full_messages.each do |message| %>
8+
<li><%= message %></li>
9+
<% end %>
10+
</ul>
11+
</alchemy-message>
12+
<% end %>

spec/features/password_reset_feature_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
.to have_content("You will receive an email with instructions on how to reset your password in a few minutes.")
2121
end
2222

23+
it "Displays error if email not found." do
24+
visit admin_new_password_path
25+
26+
fill_in :user_email, with: "wrong@email.com"
27+
click_button "Send reset instructions"
28+
29+
expect(page).to have_content("Email not found")
30+
end
31+
2332
it "User can visit edit password form." do
2433
visit admin_edit_password_path(id: user.id, reset_password_token: "1234")
2534

@@ -41,4 +50,14 @@
4150
expect(page)
4251
.to have_content("Your password has been changed successfully.")
4352
end
53+
54+
it "Displays error if reset token is wrong." do
55+
visit admin_edit_password_path(id: user.id, reset_password_token: "1234")
56+
57+
fill_in :user_password, with: "secret123"
58+
fill_in :user_password_confirmation, with: "secret123"
59+
click_button "Change password"
60+
61+
expect(page).to have_content("Reset password token is invalid")
62+
end
4463
end

spec/rails_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
require "rails-controller-testing"
1010
require "rspec/rails"
1111
require "rspec/active_model/mocks"
12-
require "capybara/rails"
12+
require "capybara/rspec"
13+
require "capybara-screenshot/rspec"
1314
require "factory_bot_rails"
1415
require "alchemy/test_support/integration_helpers"
1516
require "alchemy/test_support/config_stubbing"

0 commit comments

Comments
 (0)