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

Rails 5 #5

Merged
merged 10 commits into from
Sep 27, 2016
Merged

Rails 5 #5

merged 10 commits into from
Sep 27, 2016

Conversation

lucaspiller
Copy link
Contributor

Adds support for Rails 5. The only thing needing to be changed is support for the ApplicationRecord base class for models:

http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#active-record-models-now-inherit-from-applicationrecord-by-default

I'm open for suggestions to make the code less nasty :D

@vjt
Copy link
Contributor

vjt commented Sep 19, 2016

This change makes the code Rails5 compatible only, as on earlier versions ApplicationRecord doesn't exist.

I would create a singleton method in the AR::Compatibility module, that both checks if defined?(ApplicationRecord) and then proceeding with the equality checks.

wdyt?

target.superclass
else
target
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we even need this here. At this point we already know we are plugging into ActiveRecord, so why can't we just use ActiveRecord::Base directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Nuke it :-)

Copy link
Contributor

@vjt vjt left a comment

Choose a reason for hiding this comment

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

Thanks for untangling the mess :-)

Under the hood it works the same as passing nil to quote_value in Rails
4+, and is deprecated in Rails 5.
if target.respond_to?(:base_class)
target.base_class.superclass # Active Record
if defined?(ActiveRecord::Base) && target.ancestors.include?(ActiveRecord::Base)
ActiveRecord::Base
Copy link
Contributor Author

Choose a reason for hiding this comment

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

V2. Let Ruby do the hard work.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

@lucaspiller lucaspiller left a comment

Choose a reason for hiding this comment

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

Poor wording in the message, quote_value is deprecated in Rails 5.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0002%) to 99.897% when pulling 548eb29 on rails5 into 8d6d985 on master.

@@ -40,7 +40,6 @@ def initialize
run_specs
run_cucumber
report_coverage
generate_documentation
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per the commit message, for some reason this task fails on Travis. Works fine locally, so
¯\_(ツ)_/¯

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I have added #6 asking for a revert, with some details that'll aid investigation.

@@ -25,7 +25,7 @@ module PostgresJSONb
def accessible_by(actor)
return scoped if actor.is_admin?

designators = actor.designators.map {|d| quote_value(d, nil) }
designators = actor.designators.map {|d| sanitize(d) }
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as it works on older Rails it's OK with me.

@lucaspiller
Copy link
Contributor Author

When Travis gets around to testing, it should all be green now. Note that there is a deprecation warning:

DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from authorize at eaco/lib/eaco/controller.rb:57)

I'd suggest in the next version we drop support for Rails 3.2 (and maybe Ruby 2.1?) and switch everything to before_action.

@vjt
Copy link
Contributor

vjt commented Sep 20, 2016

Thanks @lucaspiller. Noted the deprecation warning, and mildly agree on dropping Rails 3.2. I would support it the longest we can.

@coveralls
Copy link

coveralls commented Sep 20, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling fe1e344 on rails5 into 8d6d985 on master.

@coveralls
Copy link

coveralls commented Sep 20, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling fe1e344 on rails5 into 8d6d985 on master.

@coveralls
Copy link

coveralls commented Sep 20, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling 8810df8 on rails5 into 8d6d985 on master.

@coveralls
Copy link

coveralls commented Sep 20, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling b64d78a on rails5 into 8d6d985 on master.

@lucaspiller
Copy link
Contributor Author

All green! The coverage decrease is due to the conditional for the API change in a support file, not sure why it's included in the report:

https://coveralls.io/builds/7964080/source?filename=features%2Fstep_definitions%2Fcontroller_steps.rb

@lucaspiller
Copy link
Contributor Author

@vjt Good to merge?

@vjt
Copy link
Contributor

vjt commented Sep 23, 2016

A # :nocov: around the half-covered lines would be nice! :-)

@lucaspiller
Copy link
Contributor Author

Its in a support file for specs, is there a way to exclude it?

On 23 Sep 2016, 09:59 +0200, Marcello Barnaba notifications@github.com, wrote:

A # :nocov: around the half-covered lines would be nice! :-)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (#5 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABH5P625L3GnUaL8iXLTwif5iOyjVzxks5qs4bsgaJpZM4KAd0Y).

@coveralls
Copy link

coveralls commented Sep 26, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling b64d78a on rails5 into 8d6d985 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling b64d78a on rails5 into 8d6d985 on master.

@coveralls
Copy link

coveralls commented Sep 26, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.192% when pulling b64d78a on rails5 into 8d6d985 on master.

@coveralls
Copy link

coveralls commented Sep 27, 2016

Coverage Status

Coverage decreased (-0.7%) to 99.188% when pulling e81ce4f on rails5 into 8d6d985 on master.

@coveralls
Copy link

coveralls commented Sep 27, 2016

Coverage Status

Coverage increased (+0.1%) to 100.0% when pulling da5141a on rails5 into 8d6d985 on master.

@lucaspiller
Copy link
Contributor Author

💯 % coverage! @vjt Good to merge?

@vjt
Copy link
Contributor

vjt commented Sep 27, 2016

Thanks. Please go on.

~Marcello

~ vjt@openssl.it
~ http://sindro.me/

On 27 Sep 2016, at 11:01, Luca Spiller notifications@github.com wrote:

💯 % coverage! @vjt Good to merge?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@lucaspiller lucaspiller merged commit 97e288d into master Sep 27, 2016
@lucaspiller lucaspiller deleted the rails5 branch September 27, 2016 09:56
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.

3 participants