Skip to content

Commit

Permalink
Rails 6 zeitwerk support (#44)
Browse files Browse the repository at this point in the history
* remove require_dependency for Rails 6 compat

* Rails 6 fix specs

* Rails 6 fix Zeitwerk autoload deprecation warning

Co-authored-by: David Heinemeier Hansson <david@loudthinking.com>
  • Loading branch information
szTheory and dhh authored Jun 25, 2020
1 parent 554e723 commit 6251ae8
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 79 deletions.
157 changes: 87 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,139 +9,156 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.1)
actionpack (= 5.2.1)
actioncable (6.0.0)
actionpack (= 6.0.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
actionmailbox (6.0.0)
actionpack (= 6.0.0)
activejob (= 6.0.0)
activerecord (= 6.0.0)
activestorage (= 6.0.0)
activesupport (= 6.0.0)
mail (>= 2.7.1)
actionmailer (6.0.0)
actionpack (= 6.0.0)
actionview (= 6.0.0)
activejob (= 6.0.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.1)
actionview (= 5.2.1)
activesupport (= 5.2.1)
actionpack (6.0.0)
actionview (= 6.0.0)
activesupport (= 6.0.0)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.1)
activesupport (= 5.2.1)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.0)
actionpack (= 6.0.0)
activerecord (= 6.0.0)
activestorage (= 6.0.0)
activesupport (= 6.0.0)
nokogiri (>= 1.8.5)
actionview (6.0.0)
activesupport (= 6.0.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.1)
activesupport (= 5.2.1)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.0)
activesupport (= 6.0.0)
globalid (>= 0.3.6)
activemodel (5.2.1)
activesupport (= 5.2.1)
activerecord (5.2.1)
activemodel (= 5.2.1)
activesupport (= 5.2.1)
arel (>= 9.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
activemodel (6.0.0)
activesupport (= 6.0.0)
activerecord (6.0.0)
activemodel (= 6.0.0)
activesupport (= 6.0.0)
activestorage (6.0.0)
actionpack (= 6.0.0)
activejob (= 6.0.0)
activerecord (= 6.0.0)
marcel (~> 0.3.1)
activesupport (5.2.1)
activesupport (6.0.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
zeitwerk (~> 2.1, >= 2.1.8)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
builder (3.2.3)
byebug (9.1.0)
concurrent-ruby (1.0.5)
byebug (11.0.1)
concurrent-ruby (1.1.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4)
erubi (1.7.1)
faraday (0.15.3)
erubi (1.9.0)
faraday (0.16.2)
multipart-post (>= 1.2, < 3)
globalid (0.4.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
google-id-token (1.4.2)
jwt (>= 1)
hashdiff (0.3.7)
i18n (1.1.1)
hashdiff (1.0.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jwt (1.5.6)
loofah (2.2.2)
jwt (2.2.1)
loofah (2.3.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.0)
mimemagic (0.3.2)
mini_mime (1.0.1)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
minitest (5.12.2)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.3.1)
multipart-post (2.1.1)
nio4r (2.5.2)
nokogiri (1.10.4)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
oauth2 (1.4.2)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
public_suffix (3.0.3)
rack (2.0.5)
public_suffix (4.0.1)
rack (2.0.7)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
actioncable (= 5.2.1)
actionmailer (= 5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
activemodel (= 5.2.1)
activerecord (= 5.2.1)
activestorage (= 5.2.1)
activesupport (= 5.2.1)
rails (6.0.0)
actioncable (= 6.0.0)
actionmailbox (= 6.0.0)
actionmailer (= 6.0.0)
actionpack (= 6.0.0)
actiontext (= 6.0.0)
actionview (= 6.0.0)
activejob (= 6.0.0)
activemodel (= 6.0.0)
activerecord (= 6.0.0)
activestorage (= 6.0.0)
activesupport (= 6.0.0)
bundler (>= 1.3.0)
railties (= 5.2.1)
railties (= 6.0.0)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.1)
actionpack (= 5.2.1)
activesupport (= 5.2.1)
railties (6.0.0)
actionpack (= 6.0.0)
activesupport (= 6.0.0)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (12.3.3)
safe_yaml (1.0.4)
thor (>= 0.20.3, < 2.0)
rake (13.0.0)
safe_yaml (1.0.5)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.0)
thor (0.20.3)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
webmock (3.4.2)
webmock (3.7.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.7.0)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.4)
zeitwerk (2.1.10)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/google_sign_in/callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_dependency 'google_sign_in/redirect_protector'
require 'google_sign_in/redirect_protector'

class GoogleSignIn::CallbacksController < GoogleSignIn::BaseController
def show
Expand Down
6 changes: 2 additions & 4 deletions lib/google_sign_in/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ class Engine < ::Rails::Engine
end
end

initializer 'google_sign_in.helpers' do
ActiveSupport.on_load :action_controller_base do
helper GoogleSignIn::Engine.helpers
end
config.to_prepare do
ActionController::Base.helper GoogleSignIn::Engine.helpers
end

initializer 'google_sign_in.mount' do |app|
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.load_defaults 6.0

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
Expand Down
3 changes: 0 additions & 3 deletions test/helpers/button_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class GoogleSignIn::ButtonHelperTest < ActionView::TestCase
test "generating a login button with text content" do
assert_dom_equal <<-HTML, google_sign_in_button("Log in with Google", proceed_to: "https://www.example.com/login")
<form action="/google_sign_in/authorization" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="&#x2713;" />
<input name="proceed_to" type="hidden" value="https://www.example.com/login" />
<button type="submit">Log in with Google</button>
</form>
Expand All @@ -14,7 +13,6 @@ class GoogleSignIn::ButtonHelperTest < ActionView::TestCase
test "generating a login button with HTML content" do
assert_dom_equal <<-HTML, google_sign_in_button(proceed_to: "https://www.example.com/login") { image_tag("google.png") }
<form action="/google_sign_in/authorization" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="&#x2713;" />
<input name="proceed_to" type="hidden" value="https://www.example.com/login" />
<button type="submit"><img src="/images/google.png"></button>
</form>
Expand All @@ -27,7 +25,6 @@ class GoogleSignIn::ButtonHelperTest < ActionView::TestCase

assert_dom_equal <<-HTML, button
<form action="/google_sign_in/authorization" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="&#x2713;" />
<input name="proceed_to" type="hidden" value="https://www.example.com/login" />
<button type="submit" class="login-button" data-disable-with="Loading Google login…">Log in with Google</button>
</form>
Expand Down

0 comments on commit 6251ae8

Please sign in to comment.