Skip to content

Commit

Permalink
Changes for devise 4.9.0 (#333)
Browse files Browse the repository at this point in the history
- heartcombo/devise@f08e0ad
- heartcombo/devise@88625d4
- heartcombo/devise@49ed129

Additionally:

- Modify tests so they check devise's _error_messages.html.erb
- Adjust how the resource name is looked up in registrations/edit.html.erb to match devise's lookup

Co-authored-by: Junichi Ito <[email protected]>
  • Loading branch information
JasonBarnabe and JunichiIto authored Feb 19, 2023
1 parent 737cb9e commit ad00d15
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ group :development do
gem 'omniauth-twitter'
end

gem 'devise', '>= 4.8.0'
gem 'devise', '>= 4.9.0'
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GEM
crass (1.0.6)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.8.1)
devise (4.9.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
Expand Down Expand Up @@ -194,7 +194,7 @@ PLATFORMS

DEPENDENCIES
activemodel
devise (>= 4.8.0)
devise (>= 4.9.0)
i18n-spec (~> 0.6.0)
jeweler!
localeapp
Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2><%= t('.title', resource: resource.model_name.human) %></h2>
<h2><%= t('.title', resource: resource_name.to_s.humanize) %></h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
Expand Down Expand Up @@ -38,6 +38,6 @@

<h3><%= t('.cancel_my_account') %></h3>

<p><%= t('.unhappy') %> <%= button_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete %></p>
<div><%= t('.unhappy') %> <%= button_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure'), turbo_confirm: t('.are_you_sure') }, method: :delete %></div>

<%= link_to t('devise.shared.links.back'), :back %>
2 changes: 1 addition & 1 deletion app/views/devise/shared/_error_messages.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if resource.errors.any? %>
<div id="error_explanation">
<div id="error_explanation" data-turbo-cache="false">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/shared/_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to t('.sign_in_with_provider', provider: OmniAuth::Utils.camelize(provider)), omniauth_authorize_path(resource_name, provider), method: :post %><br />
<%= button_to t('.sign_in_with_provider', provider: OmniAuth::Utils.camelize(provider)), omniauth_authorize_path(resource_name, provider), data: { turbo: false } %><br />
<% end %>
<% end %>
8 changes: 4 additions & 4 deletions devise-i18n.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Christopher Dell".freeze, "mcasimir".freeze, "Jason Barnabe".freeze]
s.date = "2023-02-15"
s.date = "2023-02-19"
s.description = "Translations for the devise gem".freeze
s.email = "[email protected]".freeze
s.extra_rdoc_files = [
Expand Down Expand Up @@ -127,7 +127,7 @@ Gem::Specification.new do |s|
s.specification_version = 4

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<devise>.freeze, [">= 4.8.0"])
s.add_runtime_dependency(%q<devise>.freeze, [">= 4.9.0"])
s.add_development_dependency(%q<rspec>.freeze, [">= 2.8.0"])
s.add_development_dependency(%q<rspec-rails>.freeze, [">= 0"])
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
Expand All @@ -137,7 +137,7 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<activemodel>.freeze, [">= 0"])
s.add_development_dependency(%q<omniauth-twitter>.freeze, [">= 0"])
else
s.add_dependency(%q<devise>.freeze, [">= 4.8.0"])
s.add_dependency(%q<devise>.freeze, [">= 4.9.0"])
s.add_dependency(%q<rspec>.freeze, [">= 2.8.0"])
s.add_dependency(%q<rspec-rails>.freeze, [">= 0"])
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
Expand All @@ -148,7 +148,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<omniauth-twitter>.freeze, [">= 0"])
end
else
s.add_dependency(%q<devise>.freeze, [">= 4.8.0"])
s.add_dependency(%q<devise>.freeze, [">= 4.9.0"])
s.add_dependency(%q<rspec>.freeze, [">= 2.8.0"])
s.add_dependency(%q<rspec-rails>.freeze, [">= 0"])
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2><%= t(".title", resource: resource.model_name.human) %></h2>
<h2><%= t(".title", resource: resource_name.to_s.humanize) %></h2>

<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= f.error_notification %>
Expand Down Expand Up @@ -30,6 +30,6 @@

<h3><%= t(".cancel_my_account") %></h3>

<p><%= t(".unhappy") %> <%= link_to t(".cancel_my_account"), registration_path(resource_name), data: { confirm: t(".are_you_sure") }, method: :delete %></p>
<div><%= t(".unhappy") %> <%= button_to t(".cancel_my_account"), registration_path(resource_name), data: { confirm: t(".are_you_sure"), turbo_confirm: t(".are_you_sure") }, method: :delete %></div>

<%= link_to t("devise.shared.links.back"), :back %>
14 changes: 12 additions & 2 deletions spec/support/devise_i18n_views_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ def remember_me
def reset_password_token
end

def model_name
def self.model_name
ActiveModel::Name.new(self.class)
end

def model_name
self.class.model_name
end

def errors
ActiveModel::Errors.new(self)
errors = ActiveModel::Errors.new(self)
errors.add(:base, :invalid)
errors
end

def self.human_attribute_name(attribute, options = {})
attribute
end
end
USER = User.new
Expand Down

0 comments on commit ad00d15

Please sign in to comment.