acts_as_revisionable 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -2
- data/lib/acts_as_revisionable.rb +3 -3
- data/lib/acts_as_revisionable/revision_record.rb +3 -1
- data/spec/acts_as_revisionable_spec.rb +1 -1
- data/spec/revision_record_spec.rb +4 -4
- data/spec/spec_helper.rb +5 -2
- metadata +9 -15
- data/RELEASES.txt +0 -7
- data/VERSION +0 -1
- data/acts_as_revisionable.gemspec +0 -62
data/Rakefile
CHANGED
@@ -33,9 +33,11 @@ begin
|
|
33
33
|
gem.email = "brian@embellishedvisions.com"
|
34
34
|
gem.homepage = "http://github.com/bdurand/acts_as_revisionable"
|
35
35
|
gem.authors = ["Brian Durand"]
|
36
|
-
gem.
|
36
|
+
gem.files = FileList["lib/**/*", "spec/**/*", "README.rdoc", "Rakefile", "MIT-LICENSE"].to_a
|
37
|
+
gem.has_rdoc = true
|
38
|
+
gem.extra_rdoc_files = ["README.rdoc", "MIT_LICENSE"]
|
37
39
|
|
38
|
-
gem.add_dependency('activerecord', '>= 2.3.
|
40
|
+
gem.add_dependency('activerecord', '>= 2.3.9')
|
39
41
|
gem.add_development_dependency('composite_primary_keys')
|
40
42
|
gem.add_development_dependency('sqlite3')
|
41
43
|
gem.add_development_dependency('rspec', '>= 2.0.0')
|
data/lib/acts_as_revisionable.rb
CHANGED
@@ -31,9 +31,9 @@ module ActsAsRevisionable
|
|
31
31
|
#
|
32
32
|
# A has_many :revision_records will also be added to the model for accessing the revisions.
|
33
33
|
def acts_as_revisionable(options = {})
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
class_attribute :acts_as_revisionable_options
|
35
|
+
self.acts_as_revisionable_options = options.clone
|
36
|
+
extend ClassMethods
|
37
37
|
include InstanceMethods
|
38
38
|
has_many_options = {:as => :revisionable, :order => 'revision DESC', :class_name => "ActsAsRevisionable::RevisionRecord"}
|
39
39
|
has_many_options[:dependent] = :destroy unless options[:dependent] == :keep
|
@@ -154,6 +154,8 @@ module ActsAsRevisionable
|
|
154
154
|
def serialize_attributes(record, revisionable_associations, already_serialized = {})
|
155
155
|
return if already_serialized["#{record.class}.#{record.id}"]
|
156
156
|
attrs = record.attributes.dup
|
157
|
+
primary_key = record.class.primary_key.to_s if record.class.primary_key
|
158
|
+
attrs.delete(primary_key) unless record.class.columns_hash.include?(primary_key)
|
157
159
|
already_serialized["#{record.class}.#{record.id}"] = true
|
158
160
|
|
159
161
|
if revisionable_associations.kind_of?(Hash)
|
@@ -231,7 +233,7 @@ module ActsAsRevisionable
|
|
231
233
|
# Restore a record and all its associations.
|
232
234
|
def restore_record(record, attributes)
|
233
235
|
primary_key = record.class.primary_key
|
234
|
-
primary_key = [primary_key] unless primary_key.is_a?(Array)
|
236
|
+
primary_key = [primary_key].compact unless primary_key.is_a?(Array)
|
235
237
|
primary_key.each do |key|
|
236
238
|
record.send("#{key.to_s}=", attributes[key.to_s])
|
237
239
|
end
|
@@ -37,7 +37,7 @@ describe ActsAsRevisionable do
|
|
37
37
|
t.column :revisionable_test_model_id, :integer
|
38
38
|
t.column :other_id, :integer
|
39
39
|
end unless table_exists?
|
40
|
-
set_primary_keys
|
40
|
+
set_primary_keys "revisionable_test_model_id", "other_id"
|
41
41
|
belongs_to :revisionable_test_model
|
42
42
|
end
|
43
43
|
|
@@ -14,7 +14,7 @@ describe ActsAsRevisionable::RevisionRecord do
|
|
14
14
|
t.column :value, :integer
|
15
15
|
t.column :test_revisionable_record_id, :integer
|
16
16
|
end unless table_exists?
|
17
|
-
self.primary_key =
|
17
|
+
self.primary_key = "legacy_id"
|
18
18
|
end
|
19
19
|
|
20
20
|
class TestRevisionableOneAssociationRecord < ActiveRecord::Base
|
@@ -32,7 +32,7 @@ describe ActsAsRevisionable::RevisionRecord do
|
|
32
32
|
t.column :name, :string
|
33
33
|
t.column :value, :integer
|
34
34
|
end unless table_exists?
|
35
|
-
set_primary_keys
|
35
|
+
set_primary_keys "first_id", "second_id"
|
36
36
|
end
|
37
37
|
|
38
38
|
class TestRevisionableAssociationRecord < ActiveRecord::Base
|
@@ -172,7 +172,7 @@ describe ActsAsRevisionable::RevisionRecord do
|
|
172
172
|
original.save!
|
173
173
|
revision = ActsAsRevisionable::RevisionRecord.new(original)
|
174
174
|
revision.revision_attributes['one_association'].should == {
|
175
|
-
"
|
175
|
+
"name"=>"one", "value"=>2, "test_revisionable_record_id"=>original.id
|
176
176
|
}
|
177
177
|
end
|
178
178
|
|
@@ -444,7 +444,7 @@ describe ActsAsRevisionable::RevisionRecord do
|
|
444
444
|
|
445
445
|
it "should delete revisions for models in a class that no longer exist if they are older than a specified number of seconds" do
|
446
446
|
record_1 = TestRevisionableRecord.create(:name => 'record_1')
|
447
|
-
record_2 = TestRevisionableAssociationLegacyRecord.
|
447
|
+
record_2 = TestRevisionableAssociationLegacyRecord.create!(:name => 'record_2')
|
448
448
|
record_2.id = record_1.id
|
449
449
|
record_2.save!
|
450
450
|
revision_0 = ActsAsRevisionable::RevisionRecord.create(record_1)
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,6 @@ else
|
|
8
8
|
gem 'activerecord'
|
9
9
|
end
|
10
10
|
require 'active_record'
|
11
|
-
require 'active_record/version'
|
12
11
|
ActiveRecord::ActiveRecordError
|
13
12
|
|
14
13
|
ActiveRecord::Base.logger = Logger.new(StringIO.new)
|
@@ -16,7 +15,11 @@ puts "Testing with ActiveRecord #{ActiveRecord::VERSION::STRING}"
|
|
16
15
|
|
17
16
|
composite_primary_key_version = nil
|
18
17
|
if ActiveRecord::VERSION::MAJOR >= 3
|
19
|
-
|
18
|
+
if ActiveRecord::VERSION::MINOR == 0
|
19
|
+
composite_primary_key_version = "~>3.1.0"
|
20
|
+
else
|
21
|
+
composite_primary_key_version = "~>4.0.0.a"
|
22
|
+
end
|
20
23
|
else
|
21
24
|
composite_primary_key_version = "~>2.3.5"
|
22
25
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_revisionable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Durand
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-05 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 17
|
30
30
|
segments:
|
31
31
|
- 2
|
32
32
|
- 3
|
33
|
-
-
|
34
|
-
version: 2.3.
|
33
|
+
- 9
|
34
|
+
version: 2.3.9
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -103,10 +103,7 @@ extra_rdoc_files:
|
|
103
103
|
files:
|
104
104
|
- MIT-LICENSE
|
105
105
|
- README.rdoc
|
106
|
-
- RELEASES.txt
|
107
106
|
- Rakefile
|
108
|
-
- VERSION
|
109
|
-
- acts_as_revisionable.gemspec
|
110
107
|
- lib/acts_as_revisionable.rb
|
111
108
|
- lib/acts_as_revisionable/revision_record.rb
|
112
109
|
- spec/acts_as_revisionable_spec.rb
|
@@ -118,11 +115,8 @@ homepage: http://github.com/bdurand/acts_as_revisionable
|
|
118
115
|
licenses: []
|
119
116
|
|
120
117
|
post_install_message:
|
121
|
-
rdoc_options:
|
122
|
-
|
123
|
-
- --main
|
124
|
-
- README.rdoc
|
125
|
-
- MIT-LICENSE
|
118
|
+
rdoc_options: []
|
119
|
+
|
126
120
|
require_paths:
|
127
121
|
- lib
|
128
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/RELEASES.txt
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
1.1.0
|
2
|
-
|
3
|
-
- Add support for compound_primary_keys gem
|
4
|
-
- Incorporate acts_as_trashable functionality
|
5
|
-
- More helper functions for finding revisions from the model
|
6
|
-
- Remove support for ActiveRecord < 2.3.5
|
7
|
-
- Users of earlier versions will need to upgrade the table with a migration
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.1.0
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{acts_as_revisionable}
|
8
|
-
s.version = "1.1.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Brian Durand"]
|
12
|
-
s.date = %q{2011-06-23}
|
13
|
-
s.description = %q{ActiveRecord extension that provides revision support so that history can be tracked and changes can be reverted. Emphasis for this plugin versus similar ones is including associations, saving on storage, and extensibility of the model.}
|
14
|
-
s.email = %q{brian@embellishedvisions.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.rdoc"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
"MIT-LICENSE",
|
20
|
-
"README.rdoc",
|
21
|
-
"RELEASES.txt",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION",
|
24
|
-
"acts_as_revisionable.gemspec",
|
25
|
-
"lib/acts_as_revisionable.rb",
|
26
|
-
"lib/acts_as_revisionable/revision_record.rb",
|
27
|
-
"spec/acts_as_revisionable_spec.rb",
|
28
|
-
"spec/revision_record_spec.rb",
|
29
|
-
"spec/spec_helper.rb",
|
30
|
-
"spec/version_1_1_upgrade_spec.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/bdurand/acts_as_revisionable}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8", "--main", "README.rdoc", "MIT-LICENSE"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.5.2}
|
36
|
-
s.summary = %q{ActiveRecord extension that provides revision support so that history can be tracked and changes can be reverted.}
|
37
|
-
|
38
|
-
if s.respond_to? :specification_version then
|
39
|
-
s.specification_version = 3
|
40
|
-
|
41
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
-
s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
|
43
|
-
s.add_development_dependency(%q<composite_primary_keys>, [">= 0"])
|
44
|
-
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
45
|
-
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
46
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
47
|
-
else
|
48
|
-
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
49
|
-
s.add_dependency(%q<composite_primary_keys>, [">= 0"])
|
50
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
51
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
52
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
53
|
-
end
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
56
|
-
s.add_dependency(%q<composite_primary_keys>, [">= 0"])
|
57
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
58
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
59
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|