Skip to content

Commit

Permalink
Fixing the test for the :on option receiving a symbol as an argument.…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Ben Atkins committed Aug 30, 2013
1 parent 28d4a42 commit 2d1ee54
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 3.0.0 (Unreleased)

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

## 2.7.2
Expand Down
5 changes: 1 addition & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ desc 'Run PaperTrail specs for the RSpec helper.'
RSpec::Core::RakeTask.new(:spec)

desc 'Run all available test suites'
task :run_all_tests do
system('rake test')
system('rake spec')
end
task :run_all_tests => [:test, :spec]

desc 'Default: run unit tests.'
task :default => :run_all_tests
2 changes: 1 addition & 1 deletion lib/paper_trail/has_paper_trail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def has_paper_trail(options = {})
:order => "#{PaperTrail.timestamp_field} ASC"
end

options_on = Array(options[:on])
options_on = Array(options[:on]) # so that a single symbol can be passed in without wrapping it in an `Array`
after_create :record_create, :if => :save_version? if options_on.empty? || options_on.include?(:create)
before_update :record_update, :if => :save_version? if options_on.empty? || options_on.include?(:update)
after_destroy :record_destroy, :if => :save_version? if options_on.empty? || options_on.include?(:destroy)
Expand Down
17 changes: 11 additions & 6 deletions test/unit/model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1177,12 +1177,17 @@ def without(&block)
end
end
context 'allows a symbol to be passed' do
Fluxor.reset_callbacks :create
Fluxor.reset_callbacks :update
Fluxor.reset_callbacks :destroy
Fluxor.instance_evail <<-END
has_paper_trail :on => :create
END
setup do
Fluxor.reset_callbacks :create
Fluxor.reset_callbacks :update
Fluxor.reset_callbacks :destroy
Fluxor.instance_eval <<-END
has_paper_trail :on => :create
END
@fluxor = Fluxor.create
@fluxor.update_attributes :name => 'blah'
@fluxor.destroy
end
should 'only have a version for hte create event' do
assert_equal 1, @fluxor.versions.length
assert_equal 'create', @fluxor.versions.last.event
Expand Down

0 comments on commit 2d1ee54

Please sign in to comment.