-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with_versioning broken in 3.0.0 #312
Comments
Do you have a special Please see this block in the README about the RSpec helper for more details on how it works. |
Actually
I've published a minimal Rails app as an example here: https://github.com/jacobat/papertrail_error |
@jacobat - You are correct, the docs on the You can also use the |
It used to work. Before upgrading to 3.0 we had an around hook like: around(:each) do |example|
with_versioning do
example.run
end
end This no longer works due to the way the RSpec integration is made (because it runs it's own before-each hook, that will disable PaperTrail for all examples). I don't think it's great to hook into the RSpec tagging system with Actually I would prefer to to make the whole RSpec integration optional and disabled by default. I wouldn't mind having |
@jacobat - you had a special |
Yes, exactly. |
@jacobat - Stepped away from this for a while but trying to wrap this up. Can you share what your helper method looked like? |
My helper method used to look like: def with_versioning
was_enabled = PaperTrail.enabled?
PaperTrail.enabled = true
begin
yield
ensure
PaperTrail.enabled = was_enabled
end
end |
So I've considered some options. The # prior: PaperTrail.enabled? == true
with_versioning do # this block call sets `PaperTrail.enabled = true`, doesn't see `before(:all)` block
# before(:all) block gets triggered here, sets `PaperTrail.enabled = false`
it { PaperTrail.should be_enabled } # fails!
end I figured the |
This is working for me: it 'saves each change in record' do
with_versioning do
PaperTrail.should be_enabled
end
end But when I try with an actual record, it does not work: described_class.all.size.should == 0
model = create(:model)
described_class.all.size.should == 1
model.versions.size.should == 0
model.update_attribute :first, 'rty'
model.reload.versions.size.should == 1 # Fails here
model.versions.first.changeset.should == { :first => ['qwe', 'rty'] } |
@juanpastas - this is within an 'it' block? What is the |
Yes, that's in an |
Is working better now, but I am having this issue now: it 'saves each change in record', :versioning => true do
# with_versioning do
PaperTrail.should be_enabled
described_class.all.size.should == 0
model = create(:model)
described_class.all.size.should == 1
model.versions.size.should == 1
model.update_attribute :first, 'rty'
# Not working in test env
# pending 'Check https://github.com/airblade/paper_trail/issues/312'
model.reload.versions.size.should == 2
model.update_attribute :first, 'three'
model.reload.versions.size.should == 3
binding.pry
model.versions.last.changes.should == { :first => ['rty', 'three'] }
# end
end
|
Also, see what I got from versions: reservation.versions.map(&:changes)
=> [{}, {}, {}]
reservation.versions.map(&:changeset)
=> [nil, nil, nil] |
@juanpastas - Do you have an |
That should be it, thanks a lot. On Tue, Mar 4, 2014 at 2:56 PM, Ben Atkins [email protected] wrote:
|
…gration to install in README; re #312 [ci skip]
@jacobat - Just released |
The introduction of the rspec integration in 3.0.0 has broken with_versioning as this spec demonstrates:
The text was updated successfully, but these errors were encountered: