File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def encrypt_all(attribute)
74
74
all . each do |object |
75
75
clear = object . send ( attribute )
76
76
object . send "#{ attribute } =" , clear
77
- raise ( ActiveRecord ::Rollback ) unless object . save ( :validation => false )
77
+ raise ( ActiveRecord ::Rollback ) unless object . save ( validate : false )
78
78
end
79
79
end ? true : false
80
80
end
@@ -84,7 +84,7 @@ def decrypt_all(attribute)
84
84
all . each do |object |
85
85
clear = object . send ( attribute )
86
86
object . send :write_attribute , attribute , clear
87
- raise ( ActiveRecord ::Rollback ) unless object . save ( :validation => false )
87
+ raise ( ActiveRecord ::Rollback ) unless object . save ( validate : false )
88
88
end
89
89
end ? true : false
90
90
end
Original file line number Diff line number Diff line change 20
20
require File . expand_path ( '../../../../test_helper' , __FILE__ )
21
21
22
22
class Redmine ::CipheringTest < ActiveSupport ::TestCase
23
+ fixtures :auth_sources
23
24
24
25
def test_password_should_be_encrypted
25
26
Redmine ::Configuration . with 'database_cipher_key' => 'secret' do
@@ -106,4 +107,12 @@ def test_decrypt_all
106
107
assert_equal 'bar' , r . read_attribute ( :password )
107
108
end
108
109
end
110
+
111
+ def test_encrypt_all_and_decrypt_all_should_skip_validation
112
+ auth_source = auth_sources ( :auth_sources_001 )
113
+ # validator checks if AuthSource#host is present
114
+ auth_source . update_column ( :host , nil )
115
+ assert AuthSource . encrypt_all ( :account_password )
116
+ assert AuthSource . decrypt_all ( :account_password )
117
+ end
109
118
end
You can’t perform that action at this time.
0 commit comments