+ assert_log_result c, known_logs, [:noop, # object_uuid is spectator
+ :admin_changes_specimen, # object_uuid is a specimen owned by spectator
+ :system_adds_baz] # readable via 'all users' group
+ end
+
+ def assert_log_result result, known_logs, expected_logs
+ # All of expected_logs must appear in result. Additional logs can
+ # appear too, but only if they are _not_ listed in known_logs
+ # (i.e., we do not make any assertions about logs not mentioned in
+ # either "known" or "expected".)
+ result_ids = result.collect &:id
+ expected_logs.each do |want|
+ assert_includes result_ids, logs(want).id
+ end
+ (known_logs - expected_logs).each do |notwant|
+ refute_includes result_ids, logs(notwant).id
+ end
+ end
+
+ 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: txt)
+ assert_logged_with_clean_properties(coll, :create, 'manifest_text')
+ coll.name = "testing"
+ coll.save!
+ assert_logged_with_clean_properties(coll, :update, 'manifest_text')
+ coll.destroy
+ 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