api: Test that we don't make logs about logs.
authorBrett Smith <brett@curoverse.com>
Thu, 10 Apr 2014 14:15:53 +0000 (10:15 -0400)
committerBrett Smith <brett@curoverse.com>
Thu, 10 Apr 2014 14:15:53 +0000 (10:15 -0400)
services/api/test/unit/log_test.rb

index 1554e0afec6515884276ec5ae355209851feba9c..0d55e4333abd7c6a00f7333eced82e6b84c226c3 100644 (file)
@@ -22,8 +22,12 @@ class LogTest < ActiveSupport::TestCase
     end
   end
 
+  def get_logs_about(thing)
+    Log.where(object_uuid: thing.uuid).order("created_at ASC").all
+  end
+
   def assert_logged(thing, event_type)
-    logs = Log.where(object_uuid: thing.uuid).order("created_at ASC").all
+    logs = get_logs_about(thing)
     assert_equal(@log_count, logs.size, "log count mismatch")
     @log_count += 1
     log = logs.last
@@ -136,4 +140,11 @@ class LogTest < ActiveSupport::TestCase
                    "group final name mismatch")
     end
   end
+
+  test "making a log doesn't get logged" do
+    set_user_from_auth :active_trustedclient
+    log = Log.new
+    log.save!
+    assert_equal(0, get_logs_about(log).size, "made a Log about a Log")
+  end
 end