diff --git a/gemfiles/cancan.gemfile b/gemfiles/cancan.gemfile index ba5b304329..969246566c 100644 --- a/gemfiles/cancan.gemfile +++ b/gemfiles/cancan.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 5.1.0" gem "haml" -gem "devise", "~> 4.0", '< 4.6' +gem "devise", "~> 4.0" gem "sass-rails", "~> 5.0" group :active_record do diff --git a/gemfiles/rails_4.1.gemfile b/gemfiles/rails_4.1.gemfile index d05597bbc7..f3a63a6eb0 100644 --- a/gemfiles/rails_4.1.gemfile +++ b/gemfiles/rails_4.1.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 4.1.0" gem "haml" -gem "devise", ">= 3.2", '< 4.6' +gem "devise", ">= 3.2" gem "capybara", ">= 0.8", group: :test group :active_record do diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index cf4aca81be..48d9279068 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 4.2.0" gem "haml" -gem "devise", ">= 3.4", '< 4.6' +gem "devise", ">= 3.4" gem "sass-rails", "~> 5.0" gem "capybara", ">= 0.8", group: :test diff --git a/gemfiles/rails_5.0.gemfile b/gemfiles/rails_5.0.gemfile index 9842dc6a03..8ba7ad953e 100644 --- a/gemfiles/rails_5.0.gemfile +++ b/gemfiles/rails_5.0.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 5.0.0" gem "haml" -gem "devise", "~> 4.0", '< 4.6' +gem "devise", "~> 4.0" gem "sass-rails", "~> 5.0" group :active_record do diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile index fc9f210dc1..bd9a9b15b2 100644 --- a/gemfiles/rails_5.1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 5.1.0" gem "haml" -gem "devise", "~> 4.0", '< 4.6' +gem "devise", "~> 4.0" gem "sass-rails", "~> 5.0" group :active_record do diff --git a/gemfiles/rails_5.2.gemfile b/gemfiles/rails_5.2.gemfile index 79f58cc0b4..f82a23cd6f 100644 --- a/gemfiles/rails_5.2.gemfile +++ b/gemfiles/rails_5.2.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 5.2.0" gem "haml" -gem "devise", "~> 4.4", '< 4.6' +gem "devise", "~> 4.4" gem "sass-rails", "~> 5.0" group :active_record do diff --git a/lib/rails_admin/config/fields/types/password.rb b/lib/rails_admin/config/fields/types/password.rb index 6be512df67..b7cd0c9422 100644 --- a/lib/rails_admin/config/fields/types/password.rb +++ b/lib/rails_admin/config/fields/types/password.rb @@ -13,7 +13,11 @@ class Password < RailsAdmin::Config::Fields::Types::String end def parse_input(params) - params[name] = params[name].presence + if params[name].present? + params[name] = params[name] + else + params.delete(name) + end end register_instance_option :formatted_value do diff --git a/spec/dummy_app/Gemfile b/spec/dummy_app/Gemfile index b964e84251..4ee305557b 100644 --- a/spec/dummy_app/Gemfile +++ b/spec/dummy_app/Gemfile @@ -30,7 +30,7 @@ group :mongoid do end gem 'carrierwave', '>= 0.8' -gem 'devise', '>= 3.2', '< 4.6' +gem 'devise', '>= 3.2' gem 'dragonfly', '~> 1.0' gem 'mini_magick', '>= 3.4' gem 'mlb', '>= 0.7' diff --git a/spec/rails_admin/config/fields/types/password_spec.rb b/spec/rails_admin/config/fields/types/password_spec.rb index da278f3f0c..e0cb961f1d 100644 --- a/spec/rails_admin/config/fields/types/password_spec.rb +++ b/spec/rails_admin/config/fields/types/password_spec.rb @@ -2,4 +2,33 @@ describe RailsAdmin::Config::Fields::Types::Password do it_behaves_like 'a generic field type', :string_field, :password + + describe '#parse_input' do + let(:field) do + RailsAdmin.config(User).fields.detect do |f| + f.name == :password + end + end + + context 'if password is not present' do + let(:nil_params) { {password: nil} } + let(:blank_params) { {password: ''} } + + it 'cleans nil' do + field.parse_input(nil_params) + expect(nil_params).to eq({}) + field.parse_input(blank_params) + expect(blank_params).to eq({}) + end + end + + context 'if password is present' do + let(:params) { {password: 'aaa'} } + + it 'keeps the value' do + field.parse_input(params) + expect(params).to eq({password: 'aaa'}) + end + end + end end