From 36613b09d7de74228556a68e497377eed7a28a75 Mon Sep 17 00:00:00 2001 From: Matthew Rudy Jacobs Date: Sun, 26 Feb 2017 17:58:38 +0000 Subject: [PATCH 1/2] Allow Rails 5.1 --- .travis.yml | 5 + Gemfile.lock | 6 +- devise.gemspec | 2 +- gemfiles/Gemfile.rails-5.1-stable | 32 ++++ gemfiles/Gemfile.rails-5.1-stable.lock | 196 +++++++++++++++++++++++++ 5 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 gemfiles/Gemfile.rails-5.1-stable create mode 100644 gemfiles/Gemfile.rails-5.1-stable.lock diff --git a/.travis.yml b/.travis.yml index 5aed0c1f79..f8c170b052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ rvm: gemfile: - Gemfile + - gemfiles/Gemfile.rails-5.1-stable - gemfiles/Gemfile.rails-4.2-stable - gemfiles/Gemfile.rails-4.1-stable @@ -20,8 +21,12 @@ matrix: gemfile: gemfiles/Gemfile.rails-4.1-stable - rvm: ruby-head gemfile: gemfiles/Gemfile.rails-4.1-stable + - rvm: 2.1.10 + gemfile: gemfiles/Gemfile.rails-5.1-stable - env: DEVISE_ORM=mongoid gemfile: Gemfile + - env: DEVISE_ORM=mongoid + gemfile: gemfiles/Gemfile.rails-5.1-stable allow_failures: - rvm: ruby-head services: diff --git a/Gemfile.lock b/Gemfile.lock index 7e6c689ffb..6c1bb99c52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ PATH devise (4.2.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.1) + railties (>= 4.1.0, < 5.2) responders warden (~> 1.2.3) @@ -159,7 +159,7 @@ GEM thread_safe (0.3.6) tzinfo (1.2.2) thread_safe (~> 0.1) - warden (1.2.6) + warden (1.2.7) rack (>= 1.0) webrat (0.7.3) nokogiri (>= 1.2.0) @@ -192,4 +192,4 @@ DEPENDENCIES webrat (= 0.7.3) BUNDLED WITH - 1.12.6 + 1.13.7 diff --git a/devise.gemspec b/devise.gemspec index a66f97a74f..3e67230b12 100644 --- a/devise.gemspec +++ b/devise.gemspec @@ -21,6 +21,6 @@ Gem::Specification.new do |s| s.add_dependency("warden", "~> 1.2.3") s.add_dependency("orm_adapter", "~> 0.1") s.add_dependency("bcrypt", "~> 3.0") - s.add_dependency("railties", ">= 4.1.0", "< 5.1") + s.add_dependency("railties", ">= 4.1.0", "< 5.2") s.add_dependency("responders") end diff --git a/gemfiles/Gemfile.rails-5.1-stable b/gemfiles/Gemfile.rails-5.1-stable new file mode 100644 index 0000000000..6bbeae5b90 --- /dev/null +++ b/gemfiles/Gemfile.rails-5.1-stable @@ -0,0 +1,32 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rails", '~> 5.1.0' +gem "omniauth" +gem "omniauth-oauth2" +gem "rdoc" + +gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml" + +gem "rails-controller-testing" + +# Waiting on https://github.com/plataformatec/responders/issues/179 +gem "responders", github: "plataformatec/responders" + +group :test do + gem "omniauth-facebook" + gem "omniauth-openid" + gem "webrat", "0.7.3", require: false + gem "mocha", "~> 1.1", require: false + gem 'test_after_commit', require: false +end + +platforms :ruby do + gem "sqlite3" +end + +# TODO: +# group :mongoid do +# gem "mongoid", "~> 4.0.0" +# end diff --git a/gemfiles/Gemfile.rails-5.1-stable.lock b/gemfiles/Gemfile.rails-5.1-stable.lock new file mode 100644 index 0000000000..0ef1da1a76 --- /dev/null +++ b/gemfiles/Gemfile.rails-5.1-stable.lock @@ -0,0 +1,196 @@ +GIT + remote: git://github.com/plataformatec/responders.git + revision: 153f2c603fcbd0adb90a15021a7cba53654a78e5 + specs: + responders (2.3.0) + railties (>= 4.2.0, < 5.3) + +GIT + remote: git://github.com/rails/activemodel-serializers-xml.git + revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531 + specs: + activemodel-serializers-xml (1.0.1) + activemodel (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + +PATH + remote: .. + specs: + devise (4.2.0) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0, < 5.2) + responders + warden (~> 1.2.3) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.1.0) + actionpack (= 5.1.0) + nio4r (~> 2.0) + websocket-driver (~> 0.6.1) + actionmailer (5.1.0) + actionpack (= 5.1.0) + actionview (= 5.1.0) + activejob (= 5.1.0) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.1.0) + actionview (= 5.1.0) + activesupport (= 5.1.0) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.1.0) + activesupport (= 5.1.0) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.1.0) + activesupport (= 5.1.0) + globalid (>= 0.3.6) + activemodel (5.1.0) + activesupport (= 5.1.0) + activerecord (5.1.0) + activemodel (= 5.1.0) + activesupport (= 5.1.0) + arel (~> 8.0) + activesupport (5.1.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (8.0.0) + bcrypt (3.1.11) + builder (3.2.3) + concurrent-ruby (1.0.5) + erubi (1.6.0) + faraday (0.11.0) + multipart-post (>= 1.2, < 3) + globalid (0.4.0) + activesupport (>= 4.2.0) + hashie (3.5.5) + i18n (0.8.1) + jwt (1.5.6) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.5) + mime-types (>= 1.16, < 4) + metaclass (0.0.4) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.1.0) + minitest (5.10.1) + mocha (1.2.1) + metaclass (~> 0.0.1) + multi_json (1.12.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nio4r (2.0.0) + nokogiri (1.7.1) + mini_portile2 (~> 2.1.0) + oauth2 (1.3.1) + faraday (>= 0.8, < 0.12) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) + omniauth (1.6.1) + hashie (>= 3.4.6, < 3.6.0) + rack (>= 1.6.2, < 3) + omniauth-facebook (4.0.0) + omniauth-oauth2 (~> 1.2) + omniauth-oauth2 (1.4.0) + oauth2 (~> 1.0) + omniauth (~> 1.2) + omniauth-openid (1.0.1) + omniauth (~> 1.0) + rack-openid (~> 1.3.1) + orm_adapter (0.5.0) + rack (2.0.1) + rack-openid (1.3.1) + rack (>= 1.1.0) + ruby-openid (>= 2.1.8) + rack-test (0.6.3) + rack (>= 1.0) + rails (5.1.0) + actioncable (= 5.1.0) + actionmailer (= 5.1.0) + actionpack (= 5.1.0) + actionview (= 5.1.0) + activejob (= 5.1.0) + activemodel (= 5.1.0) + activerecord (= 5.1.0) + activesupport (= 5.1.0) + bundler (>= 1.3.0, < 2.0) + railties (= 5.1.0) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.1) + actionpack (~> 5.x) + actionview (~> 5.x) + activesupport (~> 5.x) + rails-dom-testing (2.0.2) + activesupport (>= 4.2.0, < 6.0) + nokogiri (~> 1.6) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (5.1.0) + actionpack (= 5.1.0) + activesupport (= 5.1.0) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (12.0.0) + rdoc (5.1.0) + ruby-openid (2.7.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13) + test_after_commit (1.1.0) + activerecord (>= 3.2) + thor (0.19.4) + thread_safe (0.3.6) + tzinfo (1.2.3) + thread_safe (~> 0.1) + warden (1.2.7) + rack (>= 1.0) + webrat (0.7.3) + nokogiri (>= 1.2.0) + rack (>= 1.0) + rack-test (>= 0.5.3) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) + +PLATFORMS + ruby + +DEPENDENCIES + activemodel-serializers-xml! + devise! + mocha (~> 1.1) + omniauth + omniauth-facebook + omniauth-oauth2 + omniauth-openid + rails (~> 5.1.0) + rails-controller-testing + rdoc + responders! + sqlite3 + test_after_commit + webrat (= 0.7.3) + +BUNDLED WITH + 1.14.6 From 7c4e8c8d17047bceea490173af42bfbbc54cf849 Mon Sep 17 00:00:00 2001 From: Matthew Rudy Jacobs Date: Sun, 26 Feb 2017 20:56:19 +0000 Subject: [PATCH 2/2] Rails 5.1 requires ActionController::TestRequest to have a controller class Pass it in as an anonymous class --- test/integration/rememberable_test.rb | 8 +++++++- test/rails_app/config/boot.rb | 6 +++++- test/test/controller_helpers_test.rb | 10 +++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/integration/rememberable_test.rb b/test/integration/rememberable_test.rb index b5a227db48..cb68664995 100644 --- a/test/integration/rememberable_test.rb +++ b/test/integration/rememberable_test.rb @@ -10,7 +10,13 @@ def create_user_and_remember(add_to_token='') end def generate_signed_cookie(raw_cookie) - request = Devise.rails5? ? ActionDispatch::TestRequest.create : ActionDispatch::TestRequest.new + request = if Devise.rails51? + ActionController::TestRequest.create(Class.new) # needs a "controller class" + elsif Devise.rails5? + ActionController::TestRequest.create + else + ActionController::TestRequest.new + end request.cookie_jar.signed['raw_cookie'] = raw_cookie request.cookie_jar['raw_cookie'] end diff --git a/test/rails_app/config/boot.rb b/test/rails_app/config/boot.rb index fef72810d3..5831994adf 100644 --- a/test/rails_app/config/boot.rb +++ b/test/rails_app/config/boot.rb @@ -3,7 +3,11 @@ end module Devise - # Detection for minor differences between Rails 4 and 5 in tests. + # Detection for minor differences between Rails 4 and 5, and 5.1 in tests. + def self.rails51? + Rails.version.start_with? '5.1' + end + def self.rails5? Rails.version.start_with? '5' end diff --git a/test/test/controller_helpers_test.rb b/test/test/controller_helpers_test.rb index dc0c2a2a7c..cfc37bbdf2 100644 --- a/test/test/controller_helpers_test.rb +++ b/test/test/controller_helpers_test.rb @@ -163,7 +163,15 @@ def respond test "creates a new warden proxy if the request object has changed" do old_warden_proxy = warden - @request = Devise.rails5? ? ActionController::TestRequest.create : ActionController::TestRequest.new + + @request = if Devise.rails51? + ActionController::TestRequest.create(Class.new) # needs a "controller class" + elsif Devise.rails5? + ActionController::TestRequest.create + else + ActionController::TestRequest.new + end + new_warden_proxy = warden assert_not_equal old_warden_proxy, new_warden_proxy