Skip to content
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

Fix deprecation warning for paper_trail_on_destroy(:after) #813

Merged
merged 1 commit into from May 31, 2016
Merged

Fix deprecation warning for paper_trail_on_destroy(:after) #813

merged 1 commit into from May 31, 2016

Conversation

md5
Copy link
Contributor

@md5 md5 commented May 18, 2016

  • Warn for either a "after" or :after
  • Correctly warn on beta versions of ActiveRecord 5

@md5
Copy link
Contributor Author

md5 commented May 18, 2016

I added a spec to ensure that the deprecation warning is happening and it's not passing for some reason. In the process, I discovered that Gem::Version#<=> does not consider beta versions of AR 5 to be >= Gem::Version.new("5") (which makes sense).

allow(::ActiveRecord::Base).to receive(:belongs_to_required_by_default).
and_return(true)
expect(::ActiveSupport::Deprecation).to receive(:warn).
with(/paper_trail_on_destroy(:after) is incompatible with ActiveRecord/)
Copy link
Member

@jaredbeck jaredbeck May 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike, I think your test doesn't pass because your regex doesn't match the actual output.

pattern = /paper_trail_on_destroy(:after) is incompatible with ActiveRecord/
output = "paper_trail_on_destroy(:after) is incompatible with ActiveRecord"
pattern.match(output) # => nil

Parentheses have a special meaning in regular expressions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can run the AR5 tests locally with bundle exec appraisal ar5 rake.

Copy link
Contributor Author

@md5 md5 May 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the parenthesis thing! I should have noticed that previously and I've fixed in an amended commit: 0bf252e

However, that doesn't seem to be the actual issue. If that were the problem, I would have seen the method called 1 time with a mismatched argument, but instead I'm seeing it called 0 times...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the real issue is that paper_trail_on_destroy is a class method that is called as soon as the AfterDestroyModifier class is loaded, so the warning is happening before the example is run in this spec.

@jaredbeck
Copy link
Member

I think the real issue is that paper_trail_on_destroy is a class method that is called as soon as the AfterDestroyModifier class is loaded, so the warning is happening before the example is run in this spec.

Makes sense. We can live without the spec, thanks.

* Accept either a String or a Symbol
* Correctly warn on beta versions of ActiveRecord 5
@md5
Copy link
Contributor Author

md5 commented May 31, 2016

@jaredbeck Dropped the useless spec 👍

@jaredbeck jaredbeck merged commit 7842ae8 into paper-trail-gem:master May 31, 2016
@jaredbeck
Copy link
Member

Thanks Mike!

jaredbeck added a commit that referenced this pull request May 31, 2016
@md5 md5 deleted the fix-belongs_to_required_by_default-warning branch June 1, 2016 00:07
@md5
Copy link
Contributor Author

md5 commented Jun 1, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants