mongoid-history 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f7422b15f0027945a65e155ac5776cbbb7f3a38
4
- data.tar.gz: e23db13692cbf5679ad32fecaa2a6bd000379547
3
+ metadata.gz: fc676c3c474a938c28348873980b310b13a23755
4
+ data.tar.gz: cf12dbab2b4462f7697f0c98e6c15004718df721
5
5
  SHA512:
6
- metadata.gz: 2d88df0753a104a5fa4577ad4c8117d2fb46e0e1bcd1d996669d79a9f64bc92e8bd32dfecbcbc549d7801d815817eeef805f451b01bd8ba9485fd6f2abbbc3b6
7
- data.tar.gz: 718ff47501c3b4feac38f5113131fcffca37570954bce7be763a88ae12a3c7f36f0b6ad6dbe063b6a8018256c4f14f5b7e9d6d364423ec61a34631e02bc1ffaf
6
+ metadata.gz: 8f3a8201b62c8a378a6f5707f047c58c6dc161000289fa0a835b05f732ab3e15b64fb10cc7be8d55ff434d680f72df5ed6e9a79ebf8a4f85067027e32666852a
7
+ data.tar.gz: 41e023a44672b5091e791ac365b88e3ea71b46db42ebfeb4b50a647f51a260579492c07b18897713472a494b994c783b7e21028f29fa000507d1425e71050ab8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.4 (7/29/2014)
2
+ -----------------
3
+
4
+ * [#111](https://github.com/aq1018/mongoid-history/pull/111) - Fixed compatibility of `undo!` and `redo!` methods with Rails 3.x - [@mrjlynch](https://github.com/mrjlynch).
5
+
1
6
  0.4.3 (7/10/2014)
2
7
  -----------------
3
8
 
@@ -80,9 +80,13 @@ module Mongoid
80
80
 
81
81
  versions.each do |v|
82
82
  undo_attr = v.undo_attr(modifier)
83
- attributes.merge!(undo_attr)
83
+ if Mongoid::History.mongoid3? # update_attributes! not bypassing rails 3 protected attributes
84
+ assign_attributes(undo_attr, without_protection: true)
85
+ save!
86
+ else # assign_attributes with 'without_protection' option does not work with rails 4/mongoid 4
87
+ update_attributes!(undo_attr)
88
+ end
84
89
  end
85
- save!
86
90
  end
87
91
 
88
92
  def redo!(modifier = nil, options_or_version = nil)
@@ -91,9 +95,13 @@ module Mongoid
91
95
 
92
96
  versions.each do |v|
93
97
  redo_attr = v.redo_attr(modifier)
94
- attributes.merge!(redo_attr)
98
+ if Mongoid::History.mongoid3?
99
+ assign_attributes(redo_attr, without_protection: true)
100
+ save!
101
+ else
102
+ update_attributes!(redo_attr)
103
+ end
95
104
  end
96
- save!
97
105
  end
98
106
 
99
107
  def get_embedded(name)
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module History
3
- VERSION = '0.4.3'
3
+ VERSION = '0.4.4'
4
4
  end
5
5
  end
@@ -621,98 +621,118 @@ describe Mongoid::History do
621
621
 
622
622
  describe "trackables" do
623
623
  before :each do
624
- comment.update_attributes(title: "Test2") # version == 2
625
- comment.update_attributes(title: "Test3") # version == 3
626
- comment.update_attributes(title: "Test4") # version == 4
624
+ comment.update_attributes!(title: "Test2") # version == 2
625
+ comment.update_attributes!(title: "Test3") # version == 3
626
+ comment.update_attributes!(title: "Test4") # version == 4
627
627
  end
628
628
 
629
629
  describe "undo" do
630
- it "should recognize :from, :to options" do
631
- comment.undo! user, from: 4, to: 2
632
- comment.title.should == "test"
633
- end
634
-
635
- it "should recognize parameter as version number" do
636
- comment.undo! user, 3
637
- comment.title.should == "Test2"
638
- end
639
-
640
- it "should undo last version when no parameter is specified" do
641
- comment.undo! user
642
- comment.title.should == "Test3"
643
- end
644
-
645
- it "should recognize :last options" do
646
- comment.undo! user, last: 2
647
- comment.title.should == "Test2"
648
- end
649
-
650
- if Mongoid::History.mongoid3?
651
- context "protected attributes" do
652
- before :each do
653
- Comment.attr_accessible(nil)
630
+ [nil, :reload].each do |method|
631
+ context "#{method || 'instance'}" do
632
+ it "should recognize :from, :to options" do
633
+ comment.undo! user, from: 4, to: 2
634
+ comment.send(method) if method
635
+ comment.title.should == "test"
654
636
  end
655
637
 
656
- after :each do
657
- Comment.attr_protected(nil)
638
+ it "should recognize parameter as version number" do
639
+ comment.undo! user, 3
640
+ comment.send(method) if method
641
+ comment.title.should == "Test2"
658
642
  end
659
643
 
660
- it "should undo last version when no parameter is specified on protected attributes" do
644
+ it "should undo last version when no parameter is specified" do
661
645
  comment.undo! user
646
+ comment.send(method) if method
662
647
  comment.title.should == "Test3"
663
648
  end
664
649
 
665
- it "should recognize :last options on model with protected attributes" do
650
+ it "should recognize :last options" do
666
651
  comment.undo! user, last: 2
652
+ comment.send(method) if method
667
653
  comment.title.should == "Test2"
668
654
  end
655
+
656
+ if Mongoid::History.mongoid3?
657
+ context "protected attributes" do
658
+ before :each do
659
+ Comment.attr_accessible(nil)
660
+ end
661
+
662
+ after :each do
663
+ Comment.attr_protected(nil)
664
+ end
665
+
666
+ it "should undo last version when no parameter is specified on protected attributes" do
667
+ comment.undo! user
668
+ comment.send(method) if method
669
+ comment.title.should == "Test3"
670
+ end
671
+
672
+ it "should recognize :last options on model with protected attributes" do
673
+ comment.undo! user, last: 2
674
+ comment.send(method) if method
675
+ comment.title.should == "Test2"
676
+ end
677
+ end
678
+ end
669
679
  end
670
680
  end
671
681
  end
672
682
 
673
683
  describe "redo" do
674
- before :each do
675
- comment.update_attributes(title: "Test5")
676
- end
677
-
678
- it "should recognize :from, :to options" do
679
- comment.redo! user, from: 2, to: 4
680
- comment.title.should == "Test4"
681
- end
682
-
683
- it "should recognize parameter as version number" do
684
- comment.redo! user, 2
685
- comment.title.should == "Test2"
686
- end
687
-
688
- it "should redo last version when no parameter is specified" do
689
- comment.redo! user
690
- comment.title.should == "Test5"
691
- end
692
-
693
- it "should recognize :last options" do
694
- comment.redo! user, last: 1
695
- comment.title.should == "Test5"
696
- end
697
-
698
- if Mongoid::History.mongoid3?
699
- context "protected attributes" do
684
+ [nil, :reload].each do |method|
685
+ context "#{method || 'instance'}" do
700
686
  before :each do
701
- Comment.attr_accessible(nil)
687
+ comment.update_attributes(title: "Test5")
702
688
  end
703
689
 
704
- after :each do
705
- Comment.attr_protected(nil)
690
+ it "should recognize :from, :to options" do
691
+ comment.redo! user, from: 2, to: 4
692
+ comment.send(method) if method
693
+ comment.title.should == "Test4"
706
694
  end
707
695
 
708
696
  it "should recognize parameter as version number" do
709
697
  comment.redo! user, 2
698
+ comment.send(method) if method
710
699
  comment.title.should == "Test2"
711
700
  end
712
701
 
713
- it "should recognize :from, :to options" do
714
- comment.redo! user, from: 2, to: 4
715
- comment.title.should == "Test4"
702
+ it "should redo last version when no parameter is specified" do
703
+ comment.redo! user
704
+ comment.send(method) if method
705
+ comment.title.should == "Test5"
706
+ end
707
+
708
+ it "should recognize :last options" do
709
+ comment.redo! user, last: 1
710
+ comment.send(method) if method
711
+ comment.title.should == "Test5"
712
+ end
713
+
714
+ if Mongoid::History.mongoid3?
715
+ context "protected attributes" do
716
+ before :each do
717
+ Comment.attr_accessible(nil)
718
+ end
719
+
720
+ after :each do
721
+ Comment.attr_protected(nil)
722
+ end
723
+
724
+ it "should recognize parameter as version number" do
725
+ comment.redo! user, 2
726
+ comment.send(method) if method
727
+ comment.title.should == "Test2"
728
+ end
729
+
730
+ it "should recognize :from, :to options" do
731
+ comment.redo! user, from: 2, to: 4
732
+ comment.send(method) if method
733
+ comment.title.should == "Test4"
734
+ end
735
+ end
716
736
  end
717
737
  end
718
738
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Qian
@@ -10,90 +10,90 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-10 00:00:00.000000000 Z
13
+ date: 2014-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: easy_diff
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: mongoid
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - '>='
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '3.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '3.0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: activesupport
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rake
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rspec
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '3.0'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '3.0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: bundler
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  - !ruby/object:Gem::Dependency
@@ -114,42 +114,42 @@ dependencies:
114
114
  name: yard
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: gem-release
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - '>='
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: coveralls
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - '>='
145
+ - - ">="
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - '>='
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  description: This library tracks historical changes for any document, including embedded
@@ -169,12 +169,12 @@ executables: []
169
169
  extensions: []
170
170
  extra_rdoc_files: []
171
171
  files:
172
- - .coveralls.yml
173
- - .document
174
- - .gitignore
175
- - .rspec
176
- - .rubocop.yml
177
- - .travis.yml
172
+ - ".coveralls.yml"
173
+ - ".document"
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".rubocop.yml"
177
+ - ".travis.yml"
178
178
  - CHANGELOG.md
179
179
  - CONTRIBUTING.md
180
180
  - Gemfile
@@ -208,17 +208,17 @@ require_paths:
208
208
  - lib
209
209
  required_ruby_version: !ruby/object:Gem::Requirement
210
210
  requirements:
211
- - - '>='
211
+ - - ">="
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  requirements:
216
- - - '>='
216
+ - - ">="
217
217
  - !ruby/object:Gem::Version
218
218
  version: '0'
219
219
  requirements: []
220
220
  rubyforge_project:
221
- rubygems_version: 2.1.11
221
+ rubygems_version: 2.2.2
222
222
  signing_key:
223
223
  specification_version: 4
224
224
  summary: Track and audit, undo and redo changes on Mongoid documents.