From f2c6c618fba3b262d1b5e0f54a1421c9660df9bd Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 25 Aug 2016 14:41:01 -0400 Subject: [PATCH] 9709: Test empty unlogged_attributes config. --- services/api/test/unit/log_test.rb | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/services/api/test/unit/log_test.rb b/services/api/test/unit/log_test.rb index fcd2b8018d..fd71576dfe 100644 --- a/services/api/test/unit/log_test.rb +++ b/services/api/test/unit/log_test.rb @@ -9,7 +9,7 @@ class LogTest < ActiveSupport::TestCase :destroy => [nil, :assert_not_nil, :assert_nil], } - def setup + setup do @start_time = Time.now @log_count = 1 end @@ -271,10 +271,12 @@ class LogTest < ActiveSupport::TestCase end end - test "manifest_text not included in collection logs" do + test "non-empty configuration.unlogged_attributes" do Rails.configuration.unlogged_attributes = ["manifest_text"] + txt = ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n" + act_as_system_user do - coll = Collection.create(manifest_text: ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n") + coll = Collection.create(manifest_text: txt) assert_logged_with_clean_properties(coll, :create, 'manifest_text') coll.name = "testing" coll.save! @@ -283,4 +285,25 @@ class LogTest < ActiveSupport::TestCase assert_logged_with_clean_properties(coll, :destroy, 'manifest_text') end end + + test "empty configuration.unlogged_attributes" do + Rails.configuration.unlogged_attributes = [] + txt = ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n" + + act_as_system_user do + coll = Collection.create(manifest_text: txt) + assert_logged(coll, :create) do |props| + assert_equal(txt, props['new_attributes']['manifest_text']) + end + coll.update_attributes!(name: "testing") + assert_logged(coll, :update) do |props| + assert_equal(txt, props['old_attributes']['manifest_text']) + assert_equal(txt, props['new_attributes']['manifest_text']) + end + coll.destroy + assert_logged(coll, :destroy) do |props| + assert_equal(txt, props['old_attributes']['manifest_text']) + end + end + end end -- 2.30.2