paper_trail 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -603,6 +603,8 @@ Many thanks to:
603
603
  * [Tom Derks](https://github.com/EgoH)
604
604
  * [Jonas Hoglund](https://github.com/jhoglund)
605
605
  * [Stefan Huber](https://github.com/MSNexploder)
606
+ * [thinkcast](https://github.com/thinkcast)
607
+ * [Dominik Sander](https://github.com/dsander)
606
608
 
607
609
 
608
610
  ## Inspirations
@@ -41,7 +41,7 @@ module PaperTrail
41
41
  cattr_accessor :paper_trail_enabled_for_model
42
42
  self.paper_trail_enabled_for_model = true
43
43
 
44
- has_many :versions, :class_name => version_class_name, :as => :item, :order => 'created_at ASC, id ASC'
44
+ has_many :versions, :class_name => version_class_name, :as => :item, :order => "created_at ASC, #{self.primary_key} ASC"
45
45
 
46
46
  after_create :record_create
47
47
  before_update :record_update
@@ -143,7 +143,7 @@ module PaperTrail
143
143
  end
144
144
 
145
145
  def item_before_change
146
- self.clone.tap do |previous|
146
+ self.dup.tap do |previous|
147
147
  previous.id = id
148
148
  changed_attributes.each { |attr, before| previous[attr] = before }
149
149
  end
@@ -7,16 +7,16 @@ class Version < ActiveRecord::Base
7
7
  end
8
8
 
9
9
  scope :subsequent, lambda { |version|
10
- where(["id > ?", version.is_a?(self) ? version.id : version]).order("id ASC")
10
+ where(["#{self.primary_key} > ?", version.is_a?(self) ? version.id : version]).order("#{self.primary_key} ASC")
11
11
  }
12
12
 
13
13
  scope :preceding, lambda { |version|
14
- where(["id < ?", version.is_a?(self) ? version.id : version]).order("id DESC")
14
+ where(["#{self.primary_key} < ?", version.is_a?(self) ? version.id : version]).order("#{self.primary_key} DESC")
15
15
  }
16
16
 
17
17
  scope :after, lambda { |timestamp|
18
18
  # TODO: is this :order necessary, considering its presence on the has_many :versions association?
19
- where(['created_at > ?', timestamp]).order('created_at ASC, id ASC')
19
+ where(['created_at > ?', timestamp]).order("created_at ASC, #{self.primary_key} ASC")
20
20
  }
21
21
 
22
22
  # Restore the item from this version.
@@ -1,3 +1,3 @@
1
1
  module PaperTrail
2
- VERSION = '2.2.2'
2
+ VERSION = '2.2.3'
3
3
  end
@@ -212,11 +212,11 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
212
212
  end
213
213
 
214
214
  should 'handle datetimes' do
215
- assert_equal @date_time.to_time.utc, @previous.a_datetime.to_time.utc
215
+ assert_equal @date_time.to_time.utc.to_i, @previous.a_datetime.to_time.utc.to_i
216
216
  end
217
217
 
218
218
  should 'handle times' do
219
- assert_equal @time, @previous.a_time
219
+ assert_equal @time.utc.to_i, @previous.a_time.utc.to_i
220
220
  end
221
221
 
222
222
  should 'handle dates' do
@@ -241,14 +241,14 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
241
241
  end
242
242
 
243
243
  should 'restore all forward-compatible attributes' do
244
- assert_equal 'Warble', @last.reify.name
245
- assert_equal 'The quick brown fox', @last.reify.a_text
246
- assert_equal 42, @last.reify.an_integer
247
- assert_in_delta 153.01, @last.reify.a_float, 0.001
248
- assert_in_delta 2.71828, @last.reify.a_decimal, 0.00001
249
- assert_equal @date_time.to_time.utc, @last.reify.a_datetime.to_time.utc
250
- assert_equal @time, @last.reify.a_time
251
- assert_equal @date, @last.reify.a_date
244
+ assert_equal 'Warble', @last.reify.name
245
+ assert_equal 'The quick brown fox', @last.reify.a_text
246
+ assert_equal 42, @last.reify.an_integer
247
+ assert_in_delta 153.01, @last.reify.a_float, 0.001
248
+ assert_in_delta 2.71828, @last.reify.a_decimal, 0.00001
249
+ assert_equal @date_time.to_time.utc.to_i, @last.reify.a_datetime.to_time.utc.to_i
250
+ assert_equal @time.utc.to_i, @last.reify.a_time.utc.to_i
251
+ assert_equal @date, @last.reify.a_date
252
252
  assert @last.reify.a_boolean
253
253
  end
254
254
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
- - 2
10
- version: 2.2.2
9
+ - 3
10
+ version: 2.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Stewart
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-07 00:00:00 +01:00
18
+ date: 2011-05-06 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency