9709: Test empty unlogged_attributes config.
authorTom Clegg <tom@curoverse.com>
Thu, 25 Aug 2016 18:41:01 +0000 (14:41 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 25 Aug 2016 19:08:49 +0000 (15:08 -0400)
services/api/test/unit/log_test.rb

index fcd2b8018d10c53c291c55a63c558fd82299991f..fd71576dfeeac3effe9d2e0ec16007ec26e9174b 100644 (file)
@@ -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