paper_trail 2.5.0 → 2.5.2

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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # PaperTrail [![Build Status](http://travis-ci.org/airblade/paper_trail.png)](http://travis-ci.org/airblade/paper_trail)
1
+ # PaperTrail [![Build Status](https://secure.travis-ci.org/airblade/paper_trail.png)](http://travis-ci.org/airblade/paper_trail) [![Dependency Status](https://gemnasium.com/airblade/paper_trail.png)](https://gemnasium.com/airblade/paper_trail)
2
2
 
3
3
  PaperTrail lets you track changes to your models' data. It's good for auditing or versioning. You can see how a model looked at any stage in its lifecycle, revert it to any version, and even undelete it after it's been destroyed.
4
4
 
@@ -437,20 +437,24 @@ But none of these will:
437
437
  >> @book.author_ids = [@solzhenistyn.id, @dostoyevsky.id]
438
438
  >> @book.authors = []
439
439
 
440
- Having said that, you can apparently get all these working (I haven't tested it myself) with this [monkey patch](http://stackoverflow.com/questions/2381033/how-to-create-a-full-audit-log-in-rails-for-every-table/2381411#2381411):
440
+ Having said that, you can apparently get all these working (I haven't tested it myself) with this patch:
441
441
 
442
- # In config/initializers/core_extensions.rb or lib/core_extensions.rb
443
- ActiveRecord::Associations::HasManyThroughAssociation.class_eval do
444
- def delete_records(records)
445
- klass = @reflection.through_reflection.klass
446
- records.each do |associate|
447
- klass.destroy_all(construct_join_attributes(associate))
442
+ # In config/initializers/active_record_patch.rb
443
+ module ActiveRecord
444
+ # = Active Record Has Many Through Association
445
+ module Associations
446
+ class HasManyThroughAssociation < HasManyAssociation #:nodoc:
447
+ alias_method :original_delete_records, :delete_records
448
+
449
+ def delete_records(records, method)
450
+ method ||= :destroy
451
+ original_delete_records(records, method)
452
+ end
448
453
  end
449
454
  end
450
455
  end
451
456
 
452
- The difference is the call to `destroy_all` instead of `delete_all` in [the original](http://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/has_many_through_association.rb#L76-81).
453
-
457
+ See [issue 113](https://github.com/airblade/paper_trail/issues/113) for a discussion about this.
454
458
 
455
459
  There may be a way to store authorship versions, probably using association callbacks, no matter how the collection is manipulated but I haven't found it yet. Let me know if you do.
456
460
 
@@ -689,6 +693,7 @@ Many thanks to:
689
693
  * [Nicholas Thrower](https://github.com/throwern)
690
694
  * [Benjamin Curtis](https://github.com/stympy)
691
695
  * [Peter Harkins](https://github.com/pushcx)
696
+ * [Mohd Amree](https://github.com/amree)
692
697
 
693
698
 
694
699
  ## Inspirations
@@ -97,7 +97,7 @@ module PaperTrail
97
97
  def version_at(timestamp, reify_options={})
98
98
  # Because a version stores how its object looked *before* the change,
99
99
  # we need to look for the first version created *after* the timestamp.
100
- v = send(self.class.versions_association_name).after(timestamp).first
100
+ v = send(self.class.versions_association_name).following(timestamp).first
101
101
  v ? v.reify(reify_options) : self
102
102
  end
103
103
 
@@ -15,7 +15,7 @@ class Version < ActiveRecord::Base
15
15
  where(["#{self.primary_key} < ?", version.is_a?(self) ? version.id : version]).order("#{self.primary_key} DESC")
16
16
  }
17
17
 
18
- scope :after, lambda { |timestamp|
18
+ scope :following, lambda { |timestamp|
19
19
  # TODO: is this :order necessary, considering its presence on the has_many :versions association?
20
20
  where(['created_at > ?', timestamp]).order("created_at ASC, #{self.primary_key} ASC")
21
21
  }
@@ -1,3 +1,3 @@
1
1
  module PaperTrail
2
- VERSION = '2.5.0'
2
+ VERSION = '2.5.2'
3
3
  end
data/paper_trail.gemspec CHANGED
@@ -21,5 +21,4 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency 'shoulda', '2.10.3'
22
22
  s.add_development_dependency 'sqlite3-ruby', '~> 1.2'
23
23
  s.add_development_dependency 'capybara', '>= 0.4.0'
24
- s.add_development_dependency 'turn'
25
24
  end
data/test/test_helper.rb CHANGED
@@ -4,12 +4,6 @@ ENV["RAILS_ENV"] = "test"
4
4
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
5
  require "rails/test_help"
6
6
 
7
- begin
8
- require 'turn'
9
- rescue LoadError
10
- # noop
11
- end
12
-
13
7
  #ActionMailer::Base.delivery_method = :test
14
8
  #ActionMailer::Base.perform_deliveries = true
15
9
  #ActionMailer::Base.default_url_options[:host] = "test.com"
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: 27
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- - 0
10
- version: 2.5.0
9
+ - 2
10
+ version: 2.5.2
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-11-11 00:00:00 +01:00
18
+ date: 2012-01-16 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -93,20 +93,6 @@ dependencies:
93
93
  version: 0.4.0
94
94
  type: :development
95
95
  version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- name: turn
98
- prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
100
- none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
108
- type: :development
109
- version_requirements: *id006
110
96
  description: Track changes to your models' data. Good for auditing or versioning.
111
97
  email: boss@airbladesoftware.com
112
98
  executables: []