audit 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'audit'
16
- s.version = '0.4.0'
17
- s.date = '2010-11-16'
16
+ s.version = '0.5.0'
17
+ s.date = '2010-11-17'
18
18
  s.rubyforge_project = 'audit'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -3,7 +3,7 @@
3
3
  module Audit
4
4
 
5
5
  # Everything needs a version.
6
- VERSION = '0.4.0'
6
+ VERSION = '0.5.0'
7
7
 
8
8
  autoload :Log, "audit/log"
9
9
  autoload :Changeset, "audit/changeset"
@@ -20,7 +20,7 @@ module Audit::Log
20
20
  # Returns nothing.
21
21
  def self.record(bucket, key, timestamp, changes)
22
22
  json = Yajl::Encoder.encode(changes)
23
- payload = {SimpleUUID::UUID.new(timestamp) => json}
23
+ payload = {timestamp => json}
24
24
  connection.insert(:Audits, "#{bucket}:#{key}", payload)
25
25
  end
26
26
 
@@ -34,7 +34,7 @@ module Audit::Tracking
34
34
  end
35
35
 
36
36
  data = {"changes" => changes, "metadata" => audit_metadata}
37
- Audit::Tracking.log.record(audit_bucket, self.id, Time.now.utc, data)
37
+ Audit::Tracking.log.record(audit_bucket, self.id, Time.now.utc.iso8601, data)
38
38
  @audit_metadata = {}
39
39
  end
40
40
 
@@ -7,6 +7,12 @@ class LogTest < Test::Unit::TestCase
7
7
  Audit::Log.record(:Users, 1, timestamp, simple_change)
8
8
  end
9
9
  end
10
+
11
+ should "save audit records idempotently" do
12
+ t = Time.now.utc.iso8601
13
+ 3.times { Audit::Log.record(:Users, 1, t, simple_change) }
14
+ assert_equal 1, Audit::Log.audits(:Users, 1).length
15
+ end
10
16
 
11
17
  should "load audit records" do
12
18
  Audit::Log.record(:Users, 1, timestamp, simple_change)
@@ -23,8 +29,13 @@ class LogTest < Test::Unit::TestCase
23
29
  end
24
30
  end
25
31
 
32
+ def teardown
33
+ # FIXME: figure out how to properly clear a keyspace or CF
34
+ Audit::Log.connection.remove(:Audits, "Users:1")
35
+ end
36
+
26
37
  def timestamp
27
- Time.now.utc
38
+ Time.now.utc.iso8601
28
39
  end
29
40
 
30
41
  def simple_change
@@ -2,7 +2,7 @@
2
2
  <Keyspaces>
3
3
  <Keyspace Name="Audit">
4
4
  <KeysCachedFraction>0.01</KeysCachedFraction>
5
- <ColumnFamily CompareWith="TimeUUIDType" Name="Audits" />
5
+ <ColumnFamily CompareWith="UTF8Type" Name="Audits" />
6
6
  <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
7
7
  <ReplicationFactor>1</ReplicationFactor>
8
8
  <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
@@ -10,6 +10,10 @@ require 'cassandra/mock'
10
10
  require 'active_record'
11
11
  require 'audit'
12
12
 
13
+ if ENV["CASSANDRA"] == "Y"
14
+ puts "-- RUNNING TESTS AGAINST CASSANDRA --"
15
+ end
16
+
13
17
  class Test::Unit::TestCase
14
18
 
15
19
  alias_method :original_setup, :setup
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
7
+ - 5
8
8
  - 0
9
- version: 0.4.0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Keys
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-16 00:00:00 -06:00
17
+ date: 2010-11-17 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency