acts_as_revisionable 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module ActsAsRevisionable
7
7
  before_create :set_revision_number
8
8
  attr_reader :data_encoding
9
9
 
10
- set_table_name :revision_records
10
+ self.table_name = :revision_records
11
11
 
12
12
  class << self
13
13
  # Find a specific revision record.
@@ -204,7 +204,12 @@ module ActsAsRevisionable
204
204
  begin
205
205
  if reflection.macro == :has_many
206
206
  if association_attributes.kind_of?(Array)
207
- record.send("#{association}=", [])
207
+ # Pop all the associated records to remove all records. In Rails 3.2 setting the value of the list
208
+ # will immediately affect the database
209
+ records = record.send(association)
210
+ while records.pop do
211
+ # no-op
212
+ end
208
213
  association_attributes.each do |attrs|
209
214
  restore_association(record, association, attrs)
210
215
  end
@@ -89,7 +89,7 @@ describe ActsAsRevisionable do
89
89
  end
90
90
 
91
91
  class RevisionRecord2 < ActsAsRevisionable::RevisionRecord
92
- set_table_name "revision_records_2"
92
+ self.table_name = "revision_records_2"
93
93
  create_table
94
94
  connection.add_column(table_name, :label, :string)
95
95
  connection.add_column(table_name, :updated_by, :string)
@@ -113,7 +113,7 @@ describe ActsAsRevisionable do
113
113
  t.column :type_name, :string
114
114
  end unless table_exists?
115
115
 
116
- set_inheritance_column :type_name
116
+ self.inheritance_column = :type_name
117
117
  acts_as_revisionable :dependent => :keep, :on_destroy => true, :encoding => :xml
118
118
  self.store_full_sti_class = false
119
119
  end
@@ -491,7 +491,7 @@ describe ActsAsRevisionable do
491
491
  restored.many_other_things.collect{|t| t.name}.sort.should == ['many_other_thing_3', 'new_many_other_thing_1']
492
492
  restored.valid?.should == true
493
493
 
494
- # make the restore to memory didn't affect the database
494
+ # make sure the restore to memory didn't affect the database
495
495
  model.reload
496
496
  model.name.should == 'new_name'
497
497
  model.many_things(true).collect{|t| t.name}.sort.should == ['many_thing_3', 'new_many_thing_1']
@@ -23,6 +23,8 @@ describe ActsAsRevisionable::RevisionRecord do
23
23
  t.column :value, :integer
24
24
  t.column :test_revisionable_record_id, :integer
25
25
  end unless table_exists?
26
+
27
+ self.primary_key = nil if ActiveRecord::VERSION::MAJOR >= 3 && ActiveRecord::VERSION::MINOR > 0
26
28
  end
27
29
 
28
30
  class TestRevisionableAssociationComposite < ActiveRecord::Base
@@ -304,8 +306,7 @@ describe ActsAsRevisionable::RevisionRecord do
304
306
  it "should be able to restore the has_one associations" do
305
307
  revision = ActsAsRevisionable::RevisionRecord.new(TestRevisionableRecord.new)
306
308
  record = TestRevisionableRecord.new
307
- revision.send(:restore_association, record, :one_association, {'id' => 1, 'name' => 'one', 'value' => 1})
308
- record.one_association.id.should == 1
309
+ revision.send(:restore_association, record, :one_association, {'name' => 'one', 'value' => 1})
309
310
  record.one_association.name.should == 'one'
310
311
  record.one_association.value.should == 1
311
312
  end
@@ -18,8 +18,10 @@ composite_primary_key_version = nil
18
18
  if ActiveRecord::VERSION::MAJOR >= 3
19
19
  if ActiveRecord::VERSION::MINOR == 0
20
20
  composite_primary_key_version = "~>3.1.0"
21
+ elsif ActiveRecord::VERSION::MINOR == 1
22
+ composite_primary_key_version = "~>4"
21
23
  else
22
- composite_primary_key_version = ">=4.0.0"
24
+ composite_primary_key_version = ">4"
23
25
  end
24
26
  else
25
27
  composite_primary_key_version = "~>2.3.5"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_revisionable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-22 00:00:00.000000000 Z
12
+ date: 2012-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2161226620 !ruby/object:Gem::Requirement
16
+ requirement: &2164450060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.3.9
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2161226620
24
+ version_requirements: *2164450060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: composite_primary_keys
27
- requirement: &2161226000 !ruby/object:Gem::Requirement
27
+ requirement: &2164449520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2161226000
35
+ version_requirements: *2164449520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &2161225440 !ruby/object:Gem::Requirement
38
+ requirement: &2164448760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2161225440
46
+ version_requirements: *2164448760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &2161224920 !ruby/object:Gem::Requirement
49
+ requirement: &2164447140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2161224920
57
+ version_requirements: *2164447140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &2161224300 !ruby/object:Gem::Requirement
60
+ requirement: &2164446380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2161224300
68
+ version_requirements: *2164446380
69
69
  description: ActiveRecord extension that provides revision support so that history
70
70
  can be tracked and changes can be reverted. Emphasis for this plugin versus similar
71
71
  ones is including associations, saving on storage, and extensibility of the model.