paper_trail 3.0.9 → 4.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -2
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +37 -23
  6. data/README.md +170 -63
  7. data/gemfiles/3.0.gemfile +10 -4
  8. data/lib/generators/paper_trail/install_generator.rb +19 -3
  9. data/lib/generators/paper_trail/templates/add_transaction_id_column_to_versions.rb +11 -0
  10. data/lib/generators/paper_trail/templates/create_version_associations.rb +17 -0
  11. data/lib/paper_trail.rb +24 -4
  12. data/lib/paper_trail/cleaner.rb +3 -3
  13. data/lib/paper_trail/config.rb +17 -0
  14. data/lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb +7 -0
  15. data/lib/paper_trail/frameworks/rails.rb +1 -0
  16. data/lib/paper_trail/frameworks/rspec.rb +5 -0
  17. data/lib/paper_trail/has_paper_trail.rb +112 -38
  18. data/lib/paper_trail/version_association_concern.rb +13 -0
  19. data/lib/paper_trail/version_concern.rb +145 -38
  20. data/lib/paper_trail/version_number.rb +3 -3
  21. data/paper_trail.gemspec +11 -4
  22. data/spec/generators/install_generator_spec.rb +4 -4
  23. data/spec/models/fluxor_spec.rb +19 -0
  24. data/spec/models/gadget_spec.rb +10 -10
  25. data/spec/models/joined_version_spec.rb +9 -9
  26. data/spec/models/post_with_status_spec.rb +3 -3
  27. data/spec/models/version_spec.rb +49 -71
  28. data/spec/models/widget_spec.rb +124 -71
  29. data/spec/modules/version_concern_spec.rb +8 -8
  30. data/spec/modules/version_number_spec.rb +16 -16
  31. data/spec/paper_trail_spec.rb +17 -17
  32. data/spec/rails_helper.rb +34 -0
  33. data/spec/requests/articles_spec.rb +11 -11
  34. data/spec/spec_helper.rb +77 -36
  35. data/test/dummy/app/models/animal.rb +0 -2
  36. data/test/dummy/app/models/book.rb +4 -0
  37. data/test/dummy/app/models/customer.rb +4 -0
  38. data/test/dummy/app/models/editor.rb +4 -0
  39. data/test/dummy/app/models/editorship.rb +5 -0
  40. data/test/dummy/app/models/line_item.rb +4 -0
  41. data/test/dummy/app/models/order.rb +5 -0
  42. data/test/dummy/app/models/person.rb +1 -1
  43. data/test/dummy/app/models/post.rb +0 -1
  44. data/test/dummy/app/models/song.rb +0 -20
  45. data/test/dummy/app/models/widget.rb +4 -0
  46. data/test/dummy/config/application.rb +3 -0
  47. data/test/dummy/config/initializers/paper_trail.rb +1 -1
  48. data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +41 -0
  49. data/test/dummy/db/schema.rb +95 -25
  50. data/test/dummy/public/404.html +26 -0
  51. data/test/dummy/public/422.html +26 -0
  52. data/test/dummy/public/500.html +26 -0
  53. data/test/dummy/public/favicon.ico +0 -0
  54. data/test/dummy/public/javascripts/application.js +2 -0
  55. data/test/dummy/public/javascripts/controls.js +965 -0
  56. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  57. data/test/dummy/public/javascripts/effects.js +1123 -0
  58. data/test/dummy/public/javascripts/rails.js +175 -0
  59. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  60. data/test/test_helper.rb +2 -2
  61. data/test/time_travel_helper.rb +15 -0
  62. data/test/unit/model_test.rb +613 -185
  63. data/test/unit/serializer_test.rb +3 -3
  64. metadata +104 -54
  65. data/spec/models/animal_spec.rb +0 -19
  66. data/test/dummy/public/javascripts/prototype.js +0 -6001
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  # This model is in the test suite soley for the purpose of testing ActiveRecord::Enum,
4
4
  # which is available in ActiveRecord4+ only
5
- describe PostWithStatus do
5
+ describe PostWithStatus, :type => :model do
6
6
  if defined?(ActiveRecord::Enum)
7
7
  with_versioning do
8
8
  let(:post) { PostWithStatus.create!(:status => 'draft') }
@@ -10,7 +10,7 @@ describe PostWithStatus do
10
10
  it "should stash the enum value properly in versions" do
11
11
  post.published!
12
12
  post.archived!
13
- post.previous_version.published?.should == true
13
+ expect(post.previous_version.published?).to be true
14
14
  end
15
15
  end
16
16
  end
@@ -1,96 +1,72 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe PaperTrail::Version do
3
+ describe PaperTrail::Version, :type => :model do
4
4
  it "should include the `VersionConcern` module to get base functionality" do
5
- PaperTrail::Version.should include(PaperTrail::VersionConcern)
5
+ expect(PaperTrail::Version).to include(PaperTrail::VersionConcern)
6
6
  end
7
7
 
8
8
  describe "Attributes" do
9
- it { should have_db_column(:item_type).of_type(:string) }
10
- it { should have_db_column(:item_id).of_type(:integer) }
11
- it { should have_db_column(:event).of_type(:string) }
12
- it { should have_db_column(:whodunnit).of_type(:string) }
13
- it { should have_db_column(:object).of_type(:text) }
14
- it { should have_db_column(:created_at).of_type(:datetime) }
9
+ it { is_expected.to have_db_column(:item_type).of_type(:string) }
10
+ it { is_expected.to have_db_column(:item_id).of_type(:integer) }
11
+ it { is_expected.to have_db_column(:event).of_type(:string) }
12
+ it { is_expected.to have_db_column(:whodunnit).of_type(:string) }
13
+ it { is_expected.to have_db_column(:object).of_type(:text) }
14
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
15
+
16
+ describe "object_changes column", :versioning => true do
17
+ let(:widget) { Widget.create!(:name => 'Dashboard') }
18
+ let(:value) { widget.versions.last.object_changes }
19
+
20
+ context "serializer is YAML" do
21
+ specify { expect(PaperTrail.serializer).to be PaperTrail::Serializers::YAML }
22
+
23
+ it "should store out as a plain hash" do
24
+ expect(value =~ /HashWithIndifferentAccess/).to be_nil
25
+ end
26
+ end
27
+
28
+ context "serializer is JSON" do
29
+ before(:all) { PaperTrail.serializer = PaperTrail::Serializers::JSON }
30
+
31
+ it "should store out as a plain hash" do
32
+ expect(value =~ /HashWithIndifferentAccess/).to be_nil
33
+ end
34
+
35
+ after(:all) { PaperTrail.serializer = PaperTrail::Serializers::YAML }
36
+ end
37
+ end
15
38
  end
16
39
 
17
40
  describe "Indexes" do
18
- it { should have_db_index([:item_type, :item_id]) }
41
+ it { is_expected.to have_db_index([:item_type, :item_id]) }
19
42
  end
20
43
 
21
44
  describe "Methods" do
22
45
  describe "Instance" do
23
46
  subject { PaperTrail::Version.new(attributes) rescue PaperTrail::Version.new }
24
47
 
25
- describe '#paper_trail_originator' do
26
- it { is_expected.to respond_to(:paper_trail_originator) }
27
-
28
- context "No previous versions" do
29
- specify { expect(subject.previous).to be_nil }
30
-
31
- it "should return nil" do
32
- expect(subject.paper_trail_originator).to be_nil
33
- end
34
- end
35
-
36
- context "Has previous version", :versioning => true do
37
- let(:name) { Faker::Name.name }
38
- let(:widget) { Widget.create!(:name => Faker::Name.name) }
39
- before do
40
- widget.versions.first.update_attributes!(:whodunnit => name)
41
- widget.update_attributes!(:name => Faker::Name.first_name)
42
- end
43
- subject { widget.versions.last }
44
-
45
- specify { expect(subject.previous).to be_instance_of(PaperTrail::Version) }
46
-
47
- it "should return nil" do
48
- expect(subject.paper_trail_originator).to eq(name)
49
- end
50
- end
51
- end
52
-
53
- describe "#originator" do
54
- it { is_expected.to respond_to(:originator) }
55
- let(:warning_msg) do
56
- "DEPRECATED: use `paper_trail_originator` instead of `originator`." +
57
- " Support for `originator` will be removed in PaperTrail 4.0"
58
- end
59
-
60
- it 'should set the invoke `paper_trail_originator`' do
61
- is_expected.to receive(:warn)
62
- is_expected.to receive(:paper_trail_originator)
63
- subject.originator
64
- end
65
-
66
- it 'should display a deprecation warning' do
67
- is_expected.to receive(:warn).with(warning_msg)
68
- subject.originator
69
- end
70
- end
71
-
72
48
  describe '#terminator' do
73
- it { should respond_to(:terminator) }
49
+ it { is_expected.to respond_to(:terminator) }
74
50
 
75
51
  let(:attributes) { {:whodunnit => Faker::Name.first_name} }
76
52
 
77
53
  it "is an alias for the `whodunnit` attribute" do
78
- subject.terminator.should == attributes[:whodunnit]
54
+ expect(subject.whodunnit).to eq(attributes[:whodunnit])
79
55
  end
80
56
  end
81
57
 
82
- describe :version_author do
83
- it { should respond_to(:version_author) }
58
+ describe '#version_author' do
59
+ it { is_expected.to respond_to(:version_author) }
84
60
 
85
61
  it "should be an alias for the `terminator` method" do
86
- subject.method(:version_author).should == subject.method(:terminator)
62
+ expect(subject.method(:version_author)).to eq(subject.method(:terminator))
87
63
  end
88
64
  end
89
65
  end
90
66
 
91
67
  describe "Class" do
92
- describe :where_object do
93
- it { PaperTrail::Version.should respond_to(:where_object) }
68
+ describe '#where_object' do
69
+ it { expect(PaperTrail::Version).to respond_to(:where_object) }
94
70
 
95
71
  context "invalid arguments" do
96
72
  it "should raise an error" do
@@ -111,22 +87,24 @@ describe PaperTrail::Version do
111
87
  end
112
88
 
113
89
  context "`serializer == YAML`" do
114
- specify { PaperTrail.serializer == PaperTrail::Serializers::YAML }
90
+ specify { expect(PaperTrail.serializer).to be PaperTrail::Serializers::YAML }
115
91
 
116
92
  it "should be able to locate versions according to their `object` contents" do
117
- PaperTrail::Version.where_object(:name => name).should == [widget.versions[1]]
118
- PaperTrail::Version.where_object(:an_integer => 100).should == [widget.versions[2]]
93
+ expect(PaperTrail::Version.where_object(:name => name)).to eq([widget.versions[1]])
94
+ expect(PaperTrail::Version.where_object(:an_integer => 100)).to eq([widget.versions[2]])
119
95
  end
120
96
  end
121
97
 
122
98
  context "`serializer == JSON`" do
123
- before { PaperTrail.serializer = PaperTrail::Serializers::JSON }
124
- specify { PaperTrail.serializer == PaperTrail::Serializers::JSON }
99
+ before(:all) { PaperTrail.serializer = PaperTrail::Serializers::JSON }
100
+ specify { expect(PaperTrail.serializer).to be PaperTrail::Serializers::JSON }
125
101
 
126
102
  it "should be able to locate versions according to their `object` contents" do
127
- PaperTrail::Version.where_object(:name => name).should == [widget.versions[1]]
128
- PaperTrail::Version.where_object(:an_integer => 100).should == [widget.versions[2]]
103
+ expect(PaperTrail::Version.where_object(:name => name)).to eq([widget.versions[1]])
104
+ expect(PaperTrail::Version.where_object(:an_integer => 100)).to eq([widget.versions[2]])
129
105
  end
106
+
107
+ after(:all) { PaperTrail.serializer = PaperTrail::Serializers::YAML }
130
108
  end
131
109
  end
132
110
  end
@@ -1,22 +1,36 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Widget do
3
+ describe Widget, :type => :model do
4
4
  describe '`be_versioned` matcher' do
5
- it { should be_versioned }
5
+ it { is_expected.to be_versioned }
6
6
  end
7
7
 
8
8
  let(:widget) { Widget.create! :name => 'Bob', :an_integer => 1 }
9
9
 
10
+ describe '`have_a_version_with` matcher', :versioning => true do
11
+ before do
12
+ widget.update_attributes!(:name => 'Leonard', :an_integer => 1 )
13
+ widget.update_attributes!(:name => 'Tom')
14
+ widget.update_attributes!(:name => 'Bob')
15
+ end
16
+
17
+ it "is possible to do assertions on versions" do
18
+ expect(widget).to have_a_version_with :name => 'Leonard', :an_integer => 1
19
+ expect(widget).to have_a_version_with :an_integer => 1
20
+ expect(widget).to have_a_version_with :name => 'Tom'
21
+ end
22
+ end
23
+
10
24
  describe "`versioning` option" do
11
25
  context :enabled, :versioning => true do
12
26
  it 'should enable versioning for models wrapped within a block' do
13
- widget.versions.size.should == 1
27
+ expect(widget.versions.size).to eq(1)
14
28
  end
15
29
  end
16
30
 
17
31
  context '`disabled` (default)' do
18
32
  it 'should not enable versioning for models wrapped within a block not marked to used versioning' do
19
- widget.versions.size.should == 0
33
+ expect(widget.versions.size).to eq(0)
20
34
  end
21
35
  end
22
36
  end
@@ -34,16 +48,28 @@ describe Widget do
34
48
  end
35
49
  end
36
50
 
51
+ describe :after_create do
52
+ let(:widget) { Widget.create!(:name => 'Foobar', :created_at => Time.now - 1.week) }
53
+
54
+ it "corresponding version should use the widget's `created_at`" do
55
+ expect(widget.versions.last.created_at.to_i).to eq(widget.created_at.to_i)
56
+ end
57
+ end
58
+
37
59
  describe :after_update do
38
- before { widget.update_attributes!(:name => 'Foobar') }
60
+ before { widget.update_attributes!(:name => 'Foobar', :updated_at => Time.now + 1.week) }
39
61
 
40
62
  subject { widget.versions.last.reify }
41
63
 
42
- it { subject.should_not be_live }
64
+ it { expect(subject).not_to be_live }
43
65
 
44
66
  it "should clear the `versions_association_name` virtual attribute" do
45
67
  subject.save!
46
- subject.should be_live
68
+ expect(subject).to be_live
69
+ end
70
+
71
+ it "corresponding version should use the widget updated_at" do
72
+ expect(widget.versions.last.created_at.to_i).to eq(widget.updated_at.to_i)
47
73
  end
48
74
  end
49
75
 
@@ -53,10 +79,33 @@ describe Widget do
53
79
  end
54
80
 
55
81
  it "should assign the version into the `versions_association_name`" do
56
- widget.version.should be_nil
82
+ expect(widget.version).to be_nil
57
83
  widget.destroy
58
- widget.version.should_not be_nil
59
- widget.version.should == widget.versions.last
84
+ expect(widget.version).not_to be_nil
85
+ expect(widget.version).to eq(widget.versions.last)
86
+ end
87
+ end
88
+
89
+ describe :after_rollback do
90
+ let(:rolled_back_name) { 'Big Moo' }
91
+
92
+ before do
93
+ begin
94
+ widget.transaction do
95
+ widget.update_attributes!(:name => rolled_back_name)
96
+ widget.update_attributes!(:name => Widget::EXCLUDED_NAME)
97
+ end
98
+ rescue ActiveRecord::RecordInvalid
99
+ widget.reload
100
+ widget.name = nil
101
+ widget.save
102
+ end
103
+ end
104
+
105
+ it 'does not create an event for changes that did not happen' do
106
+ widget.versions.map(&:changeset).each do |changeset|
107
+ expect(changeset.fetch('name', [])).to_not include(rolled_back_name)
108
+ end
60
109
  end
61
110
  end
62
111
  end
@@ -64,16 +113,16 @@ describe Widget do
64
113
  describe "Association", :versioning => true do
65
114
  describe "sort order" do
66
115
  it "should sort by the timestamp order from the `VersionConcern`" do
67
- widget.versions.to_sql.should ==
68
- widget.versions.reorder(PaperTrail::Version.timestamp_sort_order).to_sql
116
+ expect(widget.versions.to_sql).to eq(
117
+ widget.versions.reorder(PaperTrail::Version.timestamp_sort_order).to_sql)
69
118
  end
70
119
  end
71
120
  end
72
121
 
73
122
  describe "Methods" do
74
123
  describe "Instance", :versioning => true do
75
- describe '#paper_trail_originator' do
76
- it { should respond_to(:paper_trail_originator) }
124
+ describe '#originator' do
125
+ it { is_expected.to respond_to(:originator) }
77
126
 
78
127
  describe "return value" do
79
128
  let(:orig_name) { Faker::Name.name }
@@ -81,12 +130,12 @@ describe Widget do
81
130
  before { PaperTrail.whodunnit = orig_name }
82
131
 
83
132
  context "accessed from live model instance" do
84
- specify { widget.should be_live }
133
+ specify { expect(widget).to be_live }
85
134
 
86
135
  it "should return the originator for the model at a given state" do
87
- widget.paper_trail_originator.should == orig_name
136
+ expect(widget.originator).to eq(orig_name)
88
137
  widget.whodunnit(new_name) { |w| w.update_attributes(:name => 'Elizabeth') }
89
- widget.paper_trail_originator.should == new_name
138
+ expect(widget.originator).to eq(new_name)
90
139
  end
91
140
  end
92
141
 
@@ -96,38 +145,36 @@ describe Widget do
96
145
  PaperTrail.whodunnit = new_name
97
146
  widget.update_attributes(:name => 'Elizabeth')
98
147
  end
99
- let(:reified_widget) { widget.versions[1].reify }
100
148
 
101
- it "should return the appropriate originator" do
102
- reified_widget.paper_trail_originator.should == orig_name
103
- end
104
- end
105
- end
106
- end
149
+ context "default behavior (no `options[:dup]` option passed in)" do
150
+ let(:reified_widget) { widget.versions[1].reify }
107
151
 
108
- describe "#originator" do
109
- subject { widget }
152
+ it "should return the appropriate originator" do
153
+ expect(reified_widget.originator).to eq(orig_name)
154
+ end
110
155
 
111
- it { is_expected.to respond_to(:originator) }
112
- let(:warning_msg) do
113
- "DEPRECATED: use `paper_trail_originator` instead of `originator`." +
114
- " Support for `originator` will be removed in PaperTrail 4.0"
115
- end
156
+ it "should not create a new model instance" do
157
+ expect(reified_widget).not_to be_new_record
158
+ end
159
+ end
116
160
 
117
- it 'should set the invoke `paper_trail_originator`' do
118
- is_expected.to receive(:warn)
119
- is_expected.to receive(:paper_trail_originator)
120
- subject.originator
121
- end
161
+ context "creating a new instance (`options[:dup] == true`)" do
162
+ let(:reified_widget) { widget.versions[1].reify(:dup => true) }
122
163
 
123
- it 'should display a deprecation warning' do
124
- is_expected.to receive(:warn).with(warning_msg)
125
- subject.originator
164
+ it "should return the appropriate originator" do
165
+ expect(reified_widget.originator).to eq(orig_name)
166
+ end
167
+
168
+ it "should not create a new model instance" do
169
+ expect(reified_widget).to be_new_record
170
+ end
171
+ end
172
+ end
126
173
  end
127
174
  end
128
175
 
129
176
  describe '#version_at' do
130
- it { should respond_to(:version_at) }
177
+ it { is_expected.to respond_to(:version_at) }
131
178
 
132
179
  context "Timestamp argument is AFTER object has been destroyed" do
133
180
  before do
@@ -136,13 +183,13 @@ describe Widget do
136
183
  end
137
184
 
138
185
  it "should return `nil`" do
139
- widget.version_at(Time.now).should be_nil
186
+ expect(widget.version_at(Time.now)).to be_nil
140
187
  end
141
188
  end
142
189
  end
143
190
 
144
- describe :whodunnit do
145
- it { should respond_to(:whodunnit) }
191
+ describe '#whodunnit' do
192
+ it { is_expected.to respond_to(:whodunnit) }
146
193
 
147
194
  context "no block given" do
148
195
  it "should raise an error" do
@@ -156,44 +203,44 @@ describe Widget do
156
203
 
157
204
  before do
158
205
  PaperTrail.whodunnit = orig_name
159
- widget.versions.last.whodunnit.should == orig_name # persist `widget`
206
+ expect(widget.versions.last.whodunnit).to eq(orig_name) # persist `widget`
160
207
  end
161
208
 
162
209
  it "should modify value of `PaperTrail.whodunnit` while executing the block" do
163
210
  widget.whodunnit(new_name) do
164
- PaperTrail.whodunnit.should == new_name
211
+ expect(PaperTrail.whodunnit).to eq(new_name)
165
212
  widget.update_attributes(:name => 'Elizabeth')
166
213
  end
167
- widget.versions.last.whodunnit.should == new_name
214
+ expect(widget.versions.last.whodunnit).to eq(new_name)
168
215
  end
169
216
 
170
217
  it "should revert the value of `PaperTrail.whodunnit` to it's previous value after executing the block" do
171
218
  widget.whodunnit(new_name) { |w| w.update_attributes(:name => 'Elizabeth') }
172
- PaperTrail.whodunnit.should == orig_name
219
+ expect(PaperTrail.whodunnit).to eq(orig_name)
173
220
  end
174
221
 
175
222
  context "error within block" do
176
223
  it "should ensure that the whodunnit value still reverts to it's previous value" do
177
224
  expect { widget.whodunnit(new_name) { raise } }.to raise_error
178
- PaperTrail.whodunnit.should == orig_name
225
+ expect(PaperTrail.whodunnit).to eq(orig_name)
179
226
  end
180
227
  end
181
228
  end
182
229
  end
183
230
 
184
- describe :touch_with_version do
185
- it { should respond_to(:touch_with_version) }
231
+ describe '#touch_with_version' do
232
+ it { is_expected.to respond_to(:touch_with_version) }
186
233
 
187
234
  it "should generate a version" do
188
235
  count = widget.versions.size
189
236
  widget.touch_with_version
190
- widget.versions.size.should == count + 1
237
+ expect(widget.versions.size).to eq(count + 1)
191
238
  end
192
239
 
193
240
  it "should increment the `:updated_at` timestamp" do
194
241
  time_was = widget.updated_at
195
242
  widget.touch_with_version
196
- widget.updated_at.should > time_was
243
+ expect(widget.updated_at).to be > time_was
197
244
  end
198
245
  end
199
246
  end
@@ -201,56 +248,62 @@ describe Widget do
201
248
  describe "Class" do
202
249
  subject { Widget }
203
250
 
204
- describe :paper_trail_off! do
205
- it { should respond_to(:paper_trail_off!) }
251
+ describe "#paper_trail_enabled_for_model?" do
252
+ it { is_expected.to respond_to(:paper_trail_enabled_for_model?) }
253
+
254
+ it { expect(subject.paper_trail_enabled_for_model?).to be true }
255
+ end
256
+
257
+ describe '#paper_trail_off!' do
258
+ it { is_expected.to respond_to(:paper_trail_off!) }
206
259
 
207
260
  it 'should set the `paper_trail_enabled_for_model?` to `false`' do
208
- subject.paper_trail_enabled_for_model?.should == true
261
+ expect(subject.paper_trail_enabled_for_model?).to be true
209
262
  subject.paper_trail_off!
210
- subject.paper_trail_enabled_for_model?.should == false
263
+ expect(subject.paper_trail_enabled_for_model?).to be false
211
264
  end
212
265
  end
213
266
 
214
- describe :paper_trail_off do
215
- it { should respond_to(:paper_trail_off) }
267
+ describe '#paper_trail_off' do
268
+ it { is_expected.to respond_to(:paper_trail_off) }
216
269
 
217
270
  it 'should set the invoke `paper_trail_off!`' do
218
- subject.should_receive(:warn)
219
- subject.should_receive(:paper_trail_off!)
271
+ is_expected.to receive(:warn)
272
+ is_expected.to receive(:paper_trail_off!)
220
273
  subject.paper_trail_off
221
274
  end
222
275
 
223
276
  it 'should display a deprecation warning' do
224
- subject.should_receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 4.0")
277
+ is_expected.to receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 4.0")
225
278
  subject.paper_trail_on
226
279
  end
227
280
  end
228
281
 
229
- describe :paper_trail_on! do
282
+ describe '#paper_trail_on!' do
230
283
  before { subject.paper_trail_off! }
231
284
 
232
- it { should respond_to(:paper_trail_on!) }
285
+ it { is_expected.to respond_to(:paper_trail_on!) }
233
286
 
234
287
  it 'should set the `paper_trail_enabled_for_model?` to `true`' do
235
- subject.paper_trail_enabled_for_model?.should == false
288
+ expect(subject.paper_trail_enabled_for_model?).to be false
236
289
  subject.paper_trail_on!
237
- subject.paper_trail_enabled_for_model?.should == true
290
+ expect(subject.paper_trail_enabled_for_model?).to be true
238
291
  end
239
292
  end
240
293
 
241
- describe :paper_trail_on do
294
+ describe '#paper_trail_on' do
242
295
  before { subject.paper_trail_off! }
243
296
 
244
- it { should respond_to(:paper_trail_on) }
297
+ it { is_expected.to respond_to(:paper_trail_on) }
245
298
 
246
299
  it 'should set the invoke `paper_trail_on!`' do
247
- subject.should_receive(:warn)
248
- subject.should_receive(:paper_trail_on!)
300
+ is_expected.to receive(:warn)
301
+ is_expected.to receive(:paper_trail_on!)
249
302
  subject.paper_trail_on
250
303
  end
251
304
 
252
305
  it 'should display a deprecation warning' do
253
- subject.should_receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 4.0")
306
+ is_expected.to receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 4.0")
254
307
  subject.paper_trail_on
255
308
  end
256
309
  end