Skip to content

Commit 2d1ee54

Browse files
author
Ben Atkins
committed
Fixing the test for the :on option receiving a symbol as an argument. Also fixing the rake task to run both test suites so that it will exit out to the console with a 1 when either suite fails
1 parent 28d4a42 commit 2d1ee54

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 3.0.0 (Unreleased)
22

3+
- [#264](https://github.com/airblade/paper_trail/pull/264) - Allow unwrapped symbol to be passed in to the `on` option.
34
- [#224](https://github.com/airblade/paper_trail/issues/224)/[#236](https://github.com/airblade/paper_trail/pull/236) -
45
Fixed compatibility with [ActsAsTaggableOn](https://github.com/mbleigh/acts-as-taggable-on).
56
- [#235](https://github.com/airblade/paper_trail/pull/235) - Dropped unnecessary secondary sort on `versions` association.
@@ -9,7 +10,7 @@
910
- [#207](https://github.com/airblade/paper_trail/issues/207) - Versions for `'create'` events are now created with `create!` instead of
1011
`create` so that an exception gets raised if it is appropriate to do so.
1112
- [#199](https://github.com/airblade/paper_trail/pull/199) - Rails 4 compatibility.
12-
- [#165](https://github.com/airblade/paper_trail/pull/165) - Namespaced the version class under the `PaperTrail` module.
13+
- [#165](https://github.com/airblade/paper_trail/pull/165) - Namespaced the `Version` class under the `PaperTrail` module.
1314
- [#119](https://github.com/airblade/paper_trail/issues/119) - Support for [Sinatra](http://www.sinatrarb.com/); decoupled gem from `Rails`.
1415

1516
## 2.7.2

Rakefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ desc 'Run PaperTrail specs for the RSpec helper.'
1515
RSpec::Core::RakeTask.new(:spec)
1616

1717
desc 'Run all available test suites'
18-
task :run_all_tests do
19-
system('rake test')
20-
system('rake spec')
21-
end
18+
task :run_all_tests => [:test, :spec]
2219

2320
desc 'Default: run unit tests.'
2421
task :default => :run_all_tests

lib/paper_trail/has_paper_trail.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def has_paper_trail(options = {})
7070
:order => "#{PaperTrail.timestamp_field} ASC"
7171
end
7272

73-
options_on = Array(options[:on])
73+
options_on = Array(options[:on]) # so that a single symbol can be passed in without wrapping it in an `Array`
7474
after_create :record_create, :if => :save_version? if options_on.empty? || options_on.include?(:create)
7575
before_update :record_update, :if => :save_version? if options_on.empty? || options_on.include?(:update)
7676
after_destroy :record_destroy, :if => :save_version? if options_on.empty? || options_on.include?(:destroy)

test/unit/model_test.rb

+11-6
Original file line numberDiff line numberDiff line change
@@ -1177,12 +1177,17 @@ def without(&block)
11771177
end
11781178
end
11791179
context 'allows a symbol to be passed' do
1180-
Fluxor.reset_callbacks :create
1181-
Fluxor.reset_callbacks :update
1182-
Fluxor.reset_callbacks :destroy
1183-
Fluxor.instance_evail <<-END
1184-
has_paper_trail :on => :create
1185-
END
1180+
setup do
1181+
Fluxor.reset_callbacks :create
1182+
Fluxor.reset_callbacks :update
1183+
Fluxor.reset_callbacks :destroy
1184+
Fluxor.instance_eval <<-END
1185+
has_paper_trail :on => :create
1186+
END
1187+
@fluxor = Fluxor.create
1188+
@fluxor.update_attributes :name => 'blah'
1189+
@fluxor.destroy
1190+
end
11861191
should 'only have a version for hte create event' do
11871192
assert_equal 1, @fluxor.versions.length
11881193
assert_equal 'create', @fluxor.versions.last.event

0 commit comments

Comments
 (0)