aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-09-12 17:15:46 -0400
committerGitHub <noreply@github.com>2018-09-12 17:15:46 -0400
commita66efa0b92e2b4fd6f79baa485fa3af17be257c4 (patch)
treeeed48bcecd055687714683774b63a17652be3bd8 /activerecord/test
parentce1248a5b8944606e91edf1bc4f1f4962a4f658d (diff)
parent59cae0755eea9aa7be4d746427b007f61f33c4ec (diff)
downloadrails-a66efa0b92e2b4fd6f79baa485fa3af17be257c4.tar.gz
rails-a66efa0b92e2b4fd6f79baa485fa3af17be257c4.tar.bz2
rails-a66efa0b92e2b4fd6f79baa485fa3af17be257c4.zip
Merge pull request #33832 from bogdanvlviv/follow-up-33756
Follow up #33756
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/filter_attributes_test.rb32
1 files changed, 18 insertions, 14 deletions
diff --git a/activerecord/test/cases/filter_attributes_test.rb b/activerecord/test/cases/filter_attributes_test.rb
index f88cecfe2b..af5badd87d 100644
--- a/activerecord/test/cases/filter_attributes_test.rb
+++ b/activerecord/test/cases/filter_attributes_test.rb
@@ -10,11 +10,12 @@ class FilterAttributesTest < ActiveRecord::TestCase
fixtures :"admin/users", :"admin/accounts"
setup do
+ @previous_filter_attributes = ActiveRecord::Base.filter_attributes
ActiveRecord::Base.filter_attributes = [:name]
end
teardown do
- ActiveRecord::Base.filter_attributes = []
+ ActiveRecord::Base.filter_attributes = @previous_filter_attributes
end
test "filter_attributes" do
@@ -35,20 +36,23 @@ class FilterAttributesTest < ActiveRecord::TestCase
assert_equal 1, account.inspect.scan("[FILTERED]").length
end
- Admin::Account.filter_attributes = []
-
- # Above changes should not impact other models
- Admin::User.all.each do |user|
- assert_includes user.inspect, "name: [FILTERED]"
- assert_equal 1, user.inspect.scan("[FILTERED]").length
+ begin
+ previous_account_filter_attributes = Admin::Account.filter_attributes
+ Admin::Account.filter_attributes = []
+
+ # Above changes should not impact other models
+ Admin::User.all.each do |user|
+ assert_includes user.inspect, "name: [FILTERED]"
+ assert_equal 1, user.inspect.scan("[FILTERED]").length
+ end
+
+ Admin::Account.all.each do |account|
+ assert_not_includes account.inspect, "name: [FILTERED]"
+ assert_equal 0, account.inspect.scan("[FILTERED]").length
+ end
+ ensure
+ Admin::Account.filter_attributes = previous_account_filter_attributes
end
-
- Admin::Account.all.each do |account|
- assert_not_includes account.inspect, "name: [FILTERED]"
- assert_equal 0, account.inspect.scan("[FILTERED]").length
- end
-
- Admin::Account.filter_attributes = [:name]
end
test "filter_attributes should not filter nil value" do