Skip to content

Commit

Permalink
Tweak syntax for PR from #394 to improve performance; Update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
batter committed Jul 9, 2014
1 parent 80071ba commit 6c7efd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 3.1.0 (Unreleased)

- [#394](https://github.com/airblade/paper_trail/pull/394) - Add RSpec matcher `have_a_version_with` for easier testing.

## 3.0.3

- [#386](https://github.com/airblade/paper_trail/issues/386) - Fix eager loading of `versions` association with custom class name
Expand Down
10 changes: 2 additions & 8 deletions lib/paper_trail/frameworks/rspec.rb
Expand Up @@ -25,11 +25,5 @@

RSpec::Matchers.define :have_a_version_with do |attributes|
# check if the model has a version with the specified attributes
match do |actual|
mathing_version = actual.versions.select do |version|
object = version.object ? PaperTrail.serializer.load(version.object) : {}
(HashWithIndifferentAccess.new(attributes).to_a - object.to_a).empty?
end
mathing_version.present?
end
end
match { |actual| actual.versions.where_object(attributes).any? }
end

0 comments on commit 6c7efd0

Please sign in to comment.