]> source.dussan.org Git - redmine.git/commitdiff
Merged r19999 from trunk to 4.0-stable (#33926).
authorGo MAEDA <maeda@farend.jp>
Wed, 2 Sep 2020 08:48:36 +0000 (08:48 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 2 Sep 2020 08:48:36 +0000 (08:48 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@20004 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/ciphering.rb
test/unit/lib/redmine/ciphering_test.rb

index ad30e035f563a79f78458090777e4236ddbd7d05..6b93642191c07ec20a70117e34e8730d472ab4b9 100644 (file)
@@ -72,7 +72,7 @@ module Redmine
           all.each do |object|
             clear = object.send(attribute)
             object.send "#{attribute}=", clear
-            raise(ActiveRecord::Rollback) unless object.save(:validation => false)
+            raise(ActiveRecord::Rollback) unless object.save(validate: false)
           end
         end ? true : false
       end
@@ -82,7 +82,7 @@ module Redmine
           all.each do |object|
             clear = object.send(attribute)
             object.send :write_attribute, attribute, clear
-            raise(ActiveRecord::Rollback) unless object.save(:validation => false)
+            raise(ActiveRecord::Rollback) unless object.save(validate: false)
           end
         end ? true : false
       end
index 38f87b4197365433d32a786dd6c3cd16f3137126..d6f9d162ce3629879645ace247e2b92b77fadc65 100644 (file)
@@ -18,6 +18,7 @@
 require File.expand_path('../../../../test_helper', __FILE__)
 
 class Redmine::CipheringTest < ActiveSupport::TestCase
+  fixtures :auth_sources
 
   def test_password_should_be_encrypted
     Redmine::Configuration.with 'database_cipher_key' => 'secret' do
@@ -104,4 +105,12 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
       assert_equal 'bar', r.read_attribute(:password)
     end
   end
+
+  def test_encrypt_all_and_decrypt_all_should_skip_validation
+    auth_source = auth_sources(:auth_sources_001)
+    # validator checks if AuthSource#host is present
+    auth_source.update_column(:host, nil)
+    assert AuthSource.encrypt_all(:account_password)
+    assert AuthSource.decrypt_all(:account_password)
+  end
 end