revo-paper_trail 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.2
1
+ 1.4.3
@@ -6,6 +6,7 @@ class CreateVersions < ActiveRecord::Migration
6
6
  t.string :event, :null => false
7
7
  t.string :whodunnit
8
8
  t.text :object
9
+ t.text :diff
9
10
  t.datetime :created_at
10
11
  end
11
12
  add_index :versions, [:item_type, :item_id]
@@ -43,7 +43,7 @@ module PaperTrail
43
43
  module InstanceMethods
44
44
  def record_create
45
45
  if self.class.paper_trail_active
46
- versions.create merge_metadata(:event => 'create', :whodunnit => PaperTrail.whodunnit)
46
+ versions.create merge_metadata(:event => 'create', :whodunnit => PaperTrail.whodunnit, :diff => changes.to_yaml)
47
47
  end
48
48
  end
49
49
 
@@ -51,7 +51,8 @@ module PaperTrail
51
51
  if changed_and_we_care? and self.class.paper_trail_active
52
52
  versions.build merge_metadata(:event => 'update',
53
53
  :object => object_to_string(previous_version),
54
- :whodunnit => PaperTrail.whodunnit)
54
+ :whodunnit => PaperTrail.whodunnit,
55
+ :diff => changes.to_yaml)
55
56
  end
56
57
  end
57
58
 
@@ -59,12 +60,12 @@ module PaperTrail
59
60
  if self.class.paper_trail_active
60
61
  versions.create merge_metadata(:event => 'destroy',
61
62
  :object => object_to_string(previous_version),
62
- :whodunnit => PaperTrail.whodunnit)
63
+ :whodunnit => PaperTrail.whodunnit,
64
+ :diff => changes.to_yaml)
63
65
  end
64
66
  end
65
-
67
+
66
68
  private
67
-
68
69
  def merge_metadata(data)
69
70
  meta.each do |k,v|
70
71
  data[k] = v.respond_to?(:call) ? v.call(self) : v
@@ -40,6 +40,10 @@ class Version < ActiveRecord::Base
40
40
  model
41
41
  end
42
42
  end
43
+
44
+ def differences
45
+ diff ? YAML.load(diff) : {}
46
+ end
43
47
 
44
48
  def next
45
49
  Version.first :conditions => ["id > ? AND item_type = ? AND item_id = ?", id, item_type, item_id],
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{revo-paper_trail}
8
- s.version = "1.4.2"
8
+ s.version = "1.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Stewart", "Revo Developers"]
12
- s.date = %q{2010-03-04}
12
+ s.date = %q{2010-03-05}
13
13
  s.email = %q{boss@airbladesoftware.com, ge_developers@playup.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.md"
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/paper_trail/has_paper_trail.rb",
30
30
  "lib/paper_trail/version.rb",
31
31
  "rails/init.rb",
32
+ "revo-paper_trail-1.4.3.gem",
32
33
  "revo-paper_trail.gemspec",
33
34
  "tasks/paper_trail_tasks.rake",
34
35
  "test/database.yml",
@@ -214,9 +214,7 @@ class HasPaperTrailModelTest < Test::Unit::TestCase
214
214
  end
215
215
 
216
216
  should 'handle datetimes' do
217
- # Is there a better way to test equality of two datetimes?
218
- format = '%a, %d %b %Y %H:%M:%S %z' # :rfc822
219
- assert_equal @date_time.utc.strftime(format), @previous.a_datetime.utc.strftime(format)
217
+ assert_equal @date_time.to_time.utc, @previous.a_datetime.to_time.utc
220
218
  end
221
219
 
222
220
  should 'handle times' do
@@ -245,13 +243,13 @@ class HasPaperTrailModelTest < Test::Unit::TestCase
245
243
  end
246
244
 
247
245
  should 'restore all forward-compatible attributes' do
248
- format = '%a, %d %b %Y %H:%M:%S %z' # :rfc822
246
+ # format = '%a, %d %b %Y %H:%M:%S %z' # :rfc822
249
247
  assert_equal 'Warble', @last.reify.name
250
248
  assert_equal 'The quick brown fox', @last.reify.a_text
251
249
  assert_equal 42, @last.reify.an_integer
252
250
  assert_in_delta 153.01, @last.reify.a_float, 0.001
253
251
  assert_in_delta 2.71828, @last.reify.a_decimal, 0.00001
254
- assert_equal @date_time.utc.strftime(format), @last.reify.a_datetime.utc.strftime(format)
252
+ assert_equal @date_time.to_time.utc, @last.reify.a_datetime.to_time.utc
255
253
  assert_equal @time, @last.reify.a_time
256
254
  assert_equal @date, @last.reify.a_date
257
255
  assert @last.reify.a_boolean
@@ -21,6 +21,7 @@ ActiveRecord::Schema.define(:version => 0) do
21
21
  t.string :event, :null => false
22
22
  t.string :whodunnit
23
23
  t.text :object
24
+ t.text :diff
24
25
  t.datetime :created_at
25
26
 
26
27
  # Metadata columns.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revo-paper_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-03-04 00:00:00 +11:00
13
+ date: 2010-03-05 00:00:00 +11:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -37,6 +37,7 @@ files:
37
37
  - lib/paper_trail/has_paper_trail.rb
38
38
  - lib/paper_trail/version.rb
39
39
  - rails/init.rb
40
+ - revo-paper_trail-1.4.3.gem
40
41
  - revo-paper_trail.gemspec
41
42
  - tasks/paper_trail_tasks.rake
42
43
  - test/database.yml