diff -Nru ruby-devise-4.3.0/app/controllers/devise/confirmations_controller.rb ruby-devise-4.4.3/app/controllers/devise/confirmations_controller.rb --- ruby-devise-4.3.0/app/controllers/devise/confirmations_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise/confirmations_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Devise::ConfirmationsController < DeviseController # GET /resource/confirmation/new def new diff -Nru ruby-devise-4.3.0/app/controllers/devise/omniauth_callbacks_controller.rb ruby-devise-4.4.3/app/controllers/devise/omniauth_callbacks_controller.rb --- ruby-devise-4.3.0/app/controllers/devise/omniauth_callbacks_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise/omniauth_callbacks_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Devise::OmniauthCallbacksController < DeviseController prepend_before_action { request.env["devise.skip_timeout"] = true } @@ -6,7 +8,7 @@ end def failure - set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message + set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message redirect_to after_omniauth_failure_path_for(resource_name) end diff -Nru ruby-devise-4.3.0/app/controllers/devise/passwords_controller.rb ruby-devise-4.4.3/app/controllers/devise/passwords_controller.rb --- ruby-devise-4.3.0/app/controllers/devise/passwords_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise/passwords_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Devise::PasswordsController < DeviseController prepend_before_action :require_no_authentication # Render the #edit only if coming from a reset password email link diff -Nru ruby-devise-4.3.0/app/controllers/devise/registrations_controller.rb ruby-devise-4.4.3/app/controllers/devise/registrations_controller.rb --- ruby-devise-4.3.0/app/controllers/devise/registrations_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise/registrations_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Devise::RegistrationsController < DeviseController prepend_before_action :require_no_authentication, only: [:new, :create, :cancel] prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy] @@ -5,7 +7,7 @@ # GET /resource/sign_up def new - build_resource({}) + build_resource yield resource if block_given? respond_with resource end @@ -97,8 +99,8 @@ # Build a devise resource passing in the session. Useful to move # temporary session data to the newly created user. - def build_resource(hash=nil) - self.resource = resource_class.new_with_session(hash || {}, session) + def build_resource(hash = {}) + self.resource = resource_class.new_with_session(hash, session) end # Signs in a user on sign up. You can overwrite this method in your own diff -Nru ruby-devise-4.3.0/app/controllers/devise/sessions_controller.rb ruby-devise-4.4.3/app/controllers/devise/sessions_controller.rb --- ruby-devise-4.3.0/app/controllers/devise/sessions_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise/sessions_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,8 +1,10 @@ +# frozen_string_literal: true + class Devise::SessionsController < DeviseController prepend_before_action :require_no_authentication, only: [:new, :create] prepend_before_action :allow_params_authentication!, only: :create prepend_before_action :verify_signed_out_user, only: :destroy - prepend_before_action only: [:create, :destroy] { request.env["devise.skip_timeout"] = true } + prepend_before_action(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true } # GET /resource/sign_in def new diff -Nru ruby-devise-4.3.0/app/controllers/devise/unlocks_controller.rb ruby-devise-4.4.3/app/controllers/devise/unlocks_controller.rb --- ruby-devise-4.3.0/app/controllers/devise/unlocks_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise/unlocks_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Devise::UnlocksController < DeviseController prepend_before_action :require_no_authentication diff -Nru ruby-devise-4.3.0/app/controllers/devise_controller.rb ruby-devise-4.4.3/app/controllers/devise_controller.rb --- ruby-devise-4.3.0/app/controllers/devise_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/controllers/devise_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # All Devise controllers are inherited from here. class DeviseController < Devise.parent_controller.constantize include Devise::Controllers::ScopedViews diff -Nru ruby-devise-4.3.0/app/helpers/devise_helper.rb ruby-devise-4.4.3/app/helpers/devise_helper.rb --- ruby-devise-4.3.0/app/helpers/devise_helper.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/helpers/devise_helper.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeviseHelper # A simple way to show error messages for the current devise resource. If you need # to customize this method, you can either overwrite it in your application helpers or diff -Nru ruby-devise-4.3.0/app/mailers/devise/mailer.rb ruby-devise-4.4.3/app/mailers/devise/mailer.rb --- ruby-devise-4.3.0/app/mailers/devise/mailer.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/mailers/devise/mailer.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if defined?(ActionMailer) class Devise::Mailer < Devise.parent_mailer.constantize include Devise::Mailers::Helpers diff -Nru ruby-devise-4.3.0/app/views/devise/confirmations/new.html.erb ruby-devise-4.4.3/app/views/devise/confirmations/new.html.erb --- ruby-devise-4.3.0/app/views/devise/confirmations/new.html.erb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/views/devise/confirmations/new.html.erb 2018-03-21 15:11:01.000000000 +0000 @@ -5,7 +5,7 @@
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> + <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
diff -Nru ruby-devise-4.3.0/app/views/devise/passwords/new.html.erb ruby-devise-4.4.3/app/views/devise/passwords/new.html.erb --- ruby-devise-4.3.0/app/views/devise/passwords/new.html.erb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/views/devise/passwords/new.html.erb 2018-03-21 15:11:01.000000000 +0000 @@ -5,7 +5,7 @@
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
diff -Nru ruby-devise-4.3.0/app/views/devise/registrations/edit.html.erb ruby-devise-4.4.3/app/views/devise/registrations/edit.html.erb --- ruby-devise-4.3.0/app/views/devise/registrations/edit.html.erb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/views/devise/registrations/edit.html.erb 2018-03-21 15:11:01.000000000 +0000 @@ -5,7 +5,7 @@
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> diff -Nru ruby-devise-4.3.0/app/views/devise/registrations/new.html.erb ruby-devise-4.4.3/app/views/devise/registrations/new.html.erb --- ruby-devise-4.3.0/app/views/devise/registrations/new.html.erb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/views/devise/registrations/new.html.erb 2018-03-21 15:11:01.000000000 +0000 @@ -5,7 +5,7 @@
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
diff -Nru ruby-devise-4.3.0/app/views/devise/sessions/new.html.erb ruby-devise-4.4.3/app/views/devise/sessions/new.html.erb --- ruby-devise-4.3.0/app/views/devise/sessions/new.html.erb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/views/devise/sessions/new.html.erb 2018-03-21 15:11:01.000000000 +0000 @@ -3,7 +3,7 @@ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
diff -Nru ruby-devise-4.3.0/app/views/devise/unlocks/new.html.erb ruby-devise-4.4.3/app/views/devise/unlocks/new.html.erb --- ruby-devise-4.3.0/app/views/devise/unlocks/new.html.erb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/app/views/devise/unlocks/new.html.erb 2018-03-21 15:11:01.000000000 +0000 @@ -5,7 +5,7 @@
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
diff -Nru ruby-devise-4.3.0/CHANGELOG.md ruby-devise-4.4.3/CHANGELOG.md --- ruby-devise-4.3.0/CHANGELOG.md 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/CHANGELOG.md 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,50 @@ +### Unreleased + +### 4.4.3 - 2018-03-17 + +* bug fixes + * Fix undefined method `rails5?` for Devise::Test:Module (by @tegon) + * Fix: secret key was being required to be set inside credentials on Rails 5.2 (by @tegon) + +### 4.4.2 - 2018-03-15 + +* enhancements + * Support for :credentials on Rails v5.2.x. (by @gencer) + * Improve documentation about the test suite. (by @tegon) + * Test with Rails 5.2.rc1 on Travis. (by @jcoyne) + * Allow test with Rails 6. (by @Fudoshiki) + * Creating a new section for controller configuration on `devise.rb` template (by @Danilo-Araujo-Silva) + +* bug fixes + * Preserve content_type for unauthenticated tests (by @gmcnaughton) + * Check if the resource is persisted in `update_tracked_fields!` instead of performing validations (by @tegon) + * Revert "Replace log_process_action to append_info_to_payload" (by @tegon) + +### 4.4.1 - 2018-01-23 + +* bug fixes + * Ensure Gemspec is loaded as utf-8. (by @segiddins) + * Fix `ActiveRecord` check on `Confirmable`. (by @tegon) + * Fix `signed_in?` docs without running auth hooks. by (@machty) + +### 4.4.0 - 2017-12-29 + +* enhancements + * Add `frozen_string_literal` pragma comment to all Ruby files. (by @pat) + * Use `set_flash_method!` instead of `set_flash_method` in `Devise::OmniauthCallbacksController#failure`. (by @saichander17) + * Clarify how `store_location_for` modifies URIs. (by @olivierlacan) + * Move `failed_attempts` increment into its own function. by (@mobilutz) + * Add `autocomplete="email"` to email fields. by (@MikeRogers0) + * Add the ability to change the default migrations path introduced in Rails 5.0.3. (by @alexhifer) + * Delete unnecessary condition for helper method. (by @davydovanton) + * Support `id: :uuid` option for migrations. (by @filip373) + +* bug fixes + * Fix syntax for MRI 2.5.0. (by @pat) + * Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster) + * Do not modify options for `#serializable_hash`. (by @guigs) + * Email confirmations were being sent on sign in/sign out for application using `mongoid` and `mongoid-paperclip` gems. This is because previously we were checking if a model is from Active Record by checking if the method `after_commit` was defined - since `mongoid` doesn' have one - but `mongoid-paperclip` gem does define one, which cause this issue. (by @fjg) + ### 4.3.0 - 2017-05-14 * Enhancements diff -Nru ruby-devise-4.3.0/debian/changelog ruby-devise-4.4.3/debian/changelog --- ruby-devise-4.3.0/debian/changelog 2017-09-15 17:19:21.000000000 +0000 +++ ruby-devise-4.4.3/debian/changelog 2018-03-21 16:20:28.000000000 +0000 @@ -1,3 +1,12 @@ +ruby-devise (4.4.3-1) unstable; urgency=medium + + * New upstream version 4.4.3 + * Use salsa.debian.org in Vcs-* fields + * Bump Standards-Version to 4.1.3 (no changes needed) + * Bump debhelper compatibility level to 11 + + -- Pirate Praveen Wed, 21 Mar 2018 21:50:28 +0530 + ruby-devise (4.3.0-1) unstable; urgency=medium * Team upload diff -Nru ruby-devise-4.3.0/debian/compat ruby-devise-4.4.3/debian/compat --- ruby-devise-4.3.0/debian/compat 2017-09-15 17:19:21.000000000 +0000 +++ ruby-devise-4.4.3/debian/compat 2018-03-21 16:20:28.000000000 +0000 @@ -1 +1 @@ -9 +11 diff -Nru ruby-devise-4.3.0/debian/control ruby-devise-4.4.3/debian/control --- ruby-devise-4.3.0/debian/control 2017-09-15 17:19:21.000000000 +0000 +++ ruby-devise-4.4.3/debian/control 2018-03-21 16:20:28.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Debian Ruby Extras Maintainers Uploaders: Markus Tornow , Pirate Praveen -Build-Depends: debhelper (>= 9~), +Build-Depends: debhelper (>= 11~), gem2deb, ruby-bcrypt (>= 3.0.1), ruby-bson-ext, @@ -15,9 +15,9 @@ ruby-thor, ruby-thread-safe, ruby-warden (>= 1.2.1) -Standards-Version: 4.1.0 -Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-devise.git -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-devise.git +Standards-Version: 4.1.3 +Vcs-Git: https://salsa.debian.org/ruby-team/ruby-devise.git +Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-devise Homepage: http://github.com/plataformatec/devise XS-Ruby-Versions: all diff -Nru ruby-devise-4.3.0/debian/rules ruby-devise-4.4.3/debian/rules --- ruby-devise-4.3.0/debian/rules 2017-09-15 17:19:21.000000000 +0000 +++ ruby-devise-4.4.3/debian/rules 2018-03-21 16:20:28.000000000 +0000 @@ -9,3 +9,8 @@ override_dh_installchangelogs: dh_installchangelogs CHANGELOG.md + +override_dh_fixperms: + dh_fixperms + chmod -x debian/ruby-devise/usr/share/rubygems-integration/all/gems/devise-*/lib/generators/templates/devise.rb + chmod -x debian/ruby-devise/usr/share/rubygems-integration/all/gems/devise-*/lib/devise.rb diff -Nru ruby-devise-4.3.0/devise.gemspec ruby-devise-4.4.3/devise.gemspec --- ruby-devise-4.3.0/devise.gemspec 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/devise.gemspec 2018-03-21 15:11:01.000000000 +0000 @@ -1,4 +1,6 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: true + $:.push File.expand_path("../lib", __FILE__) require "devise/version" @@ -21,6 +23,6 @@ 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.2") + s.add_dependency("railties", ">= 4.1.0", "< 6.0") s.add_dependency("responders") end diff -Nru ruby-devise-4.3.0/Gemfile ruby-devise-4.4.3/Gemfile --- ruby-devise-4.3.0/Gemfile 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/Gemfile 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec @@ -14,9 +16,6 @@ gem "responders", "~> 2.1" -# TODO: Remove this line when Rails 5.1.1 is released -gem "minitest", "< 5.10.2" - group :test do gem "omniauth-facebook" gem "omniauth-openid" diff -Nru ruby-devise-4.3.0/Gemfile.lock ruby-devise-4.4.3/Gemfile.lock --- ruby-devise-4.3.0/Gemfile.lock 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/Gemfile.lock 2018-03-21 15:11:01.000000000 +0000 @@ -10,10 +10,10 @@ PATH remote: . specs: - devise (4.3.0) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) @@ -176,7 +176,6 @@ activerecord-jdbcsqlite3-adapter devise! jruby-openssl - minitest (< 5.10.2) mocha (~> 1.1) oauth2 omniauth (~> 1.3) @@ -191,4 +190,4 @@ webrat (= 0.7.3) BUNDLED WITH - 1.14.6 + 1.16.1 diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.1-stable ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.1-stable --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.1-stable 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.1-stable 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec path: ".." @@ -5,7 +7,7 @@ gem "rails", github: "rails/rails", branch: "4-1-stable" gem "omniauth" gem "omniauth-oauth2" -gem "rdoc" +gem "rdoc", "~> 5.1" group :test do gem "omniauth-facebook" diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.1-stable.lock ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.1-stable.lock --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.1-stable.lock 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.1-stable.lock 2018-03-21 15:11:01.000000000 +0000 @@ -21,10 +21,10 @@ PATH remote: .. specs: - devise (4.3.0) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) @@ -162,10 +162,10 @@ omniauth-oauth2 omniauth-openid rails! - rdoc + rdoc (~> 5.1) sqlite3 test_after_commit webrat (= 0.7.3) BUNDLED WITH - 1.14.6 + 1.16.1 diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.2-stable ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.2-stable --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.2-stable 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.2-stable 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec path: ".." @@ -5,7 +7,7 @@ gem "rails", github: "rails/rails", branch: "4-2-stable" gem "omniauth" gem "omniauth-oauth2" -gem "rdoc" +gem "rdoc", "~> 5.1" group :test do gem "omniauth-facebook" diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.2-stable.lock ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.2-stable.lock --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-4.2-stable.lock 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-4.2-stable.lock 2018-03-21 15:11:01.000000000 +0000 @@ -57,10 +57,10 @@ PATH remote: .. specs: - devise (4.3.0) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) @@ -183,10 +183,10 @@ omniauth-oauth2 omniauth-openid rails! - rdoc + rdoc (~> 5.1) sqlite3 test_after_commit webrat (= 0.7.3) BUNDLED WITH - 1.14.6 + 1.16.1 diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.0-stable ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.0-stable --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.0-stable 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.0-stable 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec path: ".." @@ -13,9 +15,6 @@ gem "responders", "~> 2.1" -# TODO: Remove this line when Rails 5.0.3 is released -gem "minitest", "< 5.10.2" - group :test do gem "omniauth-facebook" gem "omniauth-openid" diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.0-stable.lock ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.0-stable.lock --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.0-stable.lock 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.0-stable.lock 2018-03-21 15:11:01.000000000 +0000 @@ -10,10 +10,10 @@ PATH remote: .. specs: - devise (4.3.0) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) @@ -175,7 +175,6 @@ DEPENDENCIES activemodel-serializers-xml! devise! - minitest (< 5.10.2) mocha (~> 1.1) omniauth omniauth-facebook @@ -190,4 +189,4 @@ webrat (= 0.7.3) BUNDLED WITH - 1.14.6 + 1.16.1 diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.2-rc1 ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.2-rc1 --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.2-rc1 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.2-rc1 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,26 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rails", '~> 5.2.0.rc1' +gem "omniauth" +gem "omniauth-oauth2" +gem "rdoc" + +gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml" + +gem "rails-controller-testing" + +gem "responders", "~> 2.1" + +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 diff -Nru ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.2-rc1.lock ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.2-rc1.lock --- ruby-devise-4.3.0/gemfiles/Gemfile.rails-5.2-rc1.lock 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/gemfiles/Gemfile.rails-5.2-rc1.lock 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,201 @@ +GIT + remote: git://github.com/rails/activemodel-serializers-xml.git + revision: 356edf4dfc38fb1fbfee90c87856e4fe5b73c5e1 + specs: + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + +PATH + remote: .. + specs: + devise (4.4.3) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0, < 6.0) + responders + warden (~> 1.2.3) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.0.rc1) + actionpack (= 5.2.0.rc1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.0.rc1) + actionpack (= 5.2.0.rc1) + actionview (= 5.2.0.rc1) + activejob (= 5.2.0.rc1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.0.rc1) + actionview (= 5.2.0.rc1) + activesupport (= 5.2.0.rc1) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.0.rc1) + activesupport (= 5.2.0.rc1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.0.rc1) + activesupport (= 5.2.0.rc1) + globalid (>= 0.3.6) + activemodel (5.2.0.rc1) + activesupport (= 5.2.0.rc1) + activerecord (5.2.0.rc1) + activemodel (= 5.2.0.rc1) + activesupport (= 5.2.0.rc1) + arel (>= 9.0) + activestorage (5.2.0.rc1) + actionpack (= 5.2.0.rc1) + activerecord (= 5.2.0.rc1) + marcel (~> 0.3.1) + activesupport (5.2.0.rc1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bcrypt (3.1.11) + builder (3.2.3) + concurrent-ruby (1.0.5) + crass (1.0.3) + erubi (1.7.0) + faraday (0.12.2) + multipart-post (>= 1.2, < 3) + globalid (0.4.1) + activesupport (>= 4.2.0) + hashie (3.5.7) + i18n (0.9.3) + concurrent-ruby (~> 1.0) + jwt (1.5.6) + loofah (2.1.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.0) + mini_mime (>= 0.1.1) + marcel (0.3.1) + mimemagic (~> 0.3.2) + metaclass (0.0.4) + method_source (0.9.0) + mimemagic (0.3.2) + mini_mime (1.0.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + mocha (1.3.0) + metaclass (~> 0.0.1) + multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nio4r (2.2.0) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) + oauth2 (1.4.0) + faraday (>= 0.8, < 0.13) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) + omniauth (1.8.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.5.0) + oauth2 (~> 1.1) + omniauth (~> 1.2) + omniauth-openid (1.0.1) + omniauth (~> 1.0) + rack-openid (~> 1.3.1) + orm_adapter (0.5.0) + rack (2.0.4) + rack-openid (1.3.1) + rack (>= 1.1.0) + ruby-openid (>= 2.1.8) + rack-test (0.8.2) + rack (>= 1.0, < 3) + rails (5.2.0.rc1) + actioncable (= 5.2.0.rc1) + actionmailer (= 5.2.0.rc1) + actionpack (= 5.2.0.rc1) + actionview (= 5.2.0.rc1) + activejob (= 5.2.0.rc1) + activemodel (= 5.2.0.rc1) + activerecord (= 5.2.0.rc1) + activestorage (= 5.2.0.rc1) + activesupport (= 5.2.0.rc1) + bundler (>= 1.3.0) + railties (= 5.2.0.rc1) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.2) + actionpack (~> 5.x, >= 5.0.1) + actionview (~> 5.x, >= 5.0.1) + activesupport (~> 5.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (5.2.0.rc1) + actionpack (= 5.2.0.rc1) + activesupport (= 5.2.0.rc1) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (12.3.0) + rdoc (6.0.1) + responders (2.4.0) + actionpack (>= 4.2.0, < 5.3) + railties (>= 4.2.0, < 5.3) + ruby-openid (2.7.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + 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.20.0) + thread_safe (0.3.6) + tzinfo (1.2.5) + 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.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + +PLATFORMS + ruby + +DEPENDENCIES + activemodel-serializers-xml! + devise! + mocha (~> 1.1) + omniauth + omniauth-facebook + omniauth-oauth2 + omniauth-openid + rails (~> 5.2.0.rc1) + rails-controller-testing + rdoc + responders (~> 2.1) + sqlite3 + test_after_commit + webrat (= 0.7.3) + +BUNDLED WITH + 1.16.1 diff -Nru ruby-devise-4.3.0/guides/bug_report_templates/integration_test.rb ruby-devise-4.4.3/guides/bug_report_templates/integration_test.rb --- ruby-devise-4.3.0/guides/bug_report_templates/integration_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/guides/bug_report_templates/integration_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'bundler/inline' rescue LoadError => e diff -Nru ruby-devise-4.3.0/ISSUE_TEMPLATE.md ruby-devise-4.4.3/ISSUE_TEMPLATE.md --- ruby-devise-4.3.0/ISSUE_TEMPLATE.md 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/ISSUE_TEMPLATE.md 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,19 @@ +## Precheck + +- Do not use the issues tracker for help or support, try Stack Overflow. +- For bugs, do a quick search and make sure the bug has not yet been reported +- Finally, be nice and have fun! + +## Environment + +- Ruby **[version]** +- Rails **[version]** +- Devise **[version]** + +## Current behavior + +Include code samples, errors, steps to reproduce the error and stacktraces if appropriate. + +Will be even more helpful if you provide a sample application or a test case that reproduces the error. + +## Expected behavior diff -Nru ruby-devise-4.3.0/lib/devise/controllers/helpers.rb ruby-devise-4.4.3/lib/devise/controllers/helpers.rb --- ruby-devise-4.3.0/lib/devise/controllers/helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/controllers/helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Controllers # Those helpers are convenience methods added to ApplicationController. diff -Nru ruby-devise-4.3.0/lib/devise/controllers/rememberable.rb ruby-devise-4.4.3/lib/devise/controllers/rememberable.rb --- ruby-devise-4.3.0/lib/devise/controllers/rememberable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/controllers/rememberable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Controllers # A module that may be optionally included in a controller in order diff -Nru ruby-devise-4.3.0/lib/devise/controllers/scoped_views.rb ruby-devise-4.4.3/lib/devise/controllers/scoped_views.rb --- ruby-devise-4.3.0/lib/devise/controllers/scoped_views.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/controllers/scoped_views.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Controllers module ScopedViews diff -Nru ruby-devise-4.3.0/lib/devise/controllers/sign_in_out.rb ruby-devise-4.4.3/lib/devise/controllers/sign_in_out.rb --- ruby-devise-4.3.0/lib/devise/controllers/sign_in_out.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/controllers/sign_in_out.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,10 +1,15 @@ +# frozen_string_literal: true + module Devise module Controllers # Provide sign in and sign out functionality. # Included by default in all controllers. module SignInOut # Return true if the given scope is signed in session. If no scope given, return - # true if any scope is signed in. Does not run authentication hooks. + # true if any scope is signed in. This will run authentication hooks, which may + # cause exceptions to be thrown from this method; if you simply want to check + # if a scope has already previously been authenticated without running + # authentication hooks, you can directly call `warden.authenticated?(scope: scope)` def signed_in?(scope=nil) [scope || Devise.mappings.keys].flatten.any? do |_scope| warden.authenticate?(scope: _scope) diff -Nru ruby-devise-4.3.0/lib/devise/controllers/store_location.rb ruby-devise-4.4.3/lib/devise/controllers/store_location.rb --- ruby-devise-4.3.0/lib/devise/controllers/store_location.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/controllers/store_location.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "uri" module Devise @@ -33,12 +35,9 @@ # def store_location_for(resource_or_scope, location) session_key = stored_location_key_for(resource_or_scope) - uri = parse_uri(location) - if uri - path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?') - path = [path, uri.fragment].compact.join('#') - session[session_key] = path - end + + path = extract_path_from_location(location) + session[session_key] = path if path end private @@ -53,6 +52,25 @@ scope = Devise::Mapping.find_scope!(resource_or_scope) "#{scope}_return_to" end + + def extract_path_from_location(location) + uri = parse_uri(location) + + if uri + path = remove_domain_from_uri(uri) + path = add_fragment_back_to_path(uri, path) + + path + end + end + + def remove_domain_from_uri(uri) + [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?') + end + + def add_fragment_back_to_path(uri, path) + [path, uri.fragment].compact.join('#') + end end end end diff -Nru ruby-devise-4.3.0/lib/devise/controllers/url_helpers.rb ruby-devise-4.4.3/lib/devise/controllers/url_helpers.rb --- ruby-devise-4.3.0/lib/devise/controllers/url_helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/controllers/url_helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Controllers # Create url helpers to be used with resource/scope configuration. Acts as diff -Nru ruby-devise-4.3.0/lib/devise/delegator.rb ruby-devise-4.4.3/lib/devise/delegator.rb --- ruby-devise-4.3.0/lib/devise/delegator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/delegator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise # Checks the scope in the given environment and returns the associated failure app. class Delegator diff -Nru ruby-devise-4.3.0/lib/devise/encryptor.rb ruby-devise-4.4.3/lib/devise/encryptor.rb --- ruby-devise-4.3.0/lib/devise/encryptor.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/encryptor.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bcrypt' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/failure_app.rb ruby-devise-4.4.3/lib/devise/failure_app.rb --- ruby-devise-4.3.0/lib/devise/failure_app.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/failure_app.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "action_controller/metal" module Devise diff -Nru ruby-devise-4.3.0/lib/devise/hooks/activatable.rb ruby-devise-4.4.3/lib/devise/hooks/activatable.rb --- ruby-devise-4.3.0/lib/devise/hooks/activatable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/activatable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Deny user access whenever their account is not active yet. # We need this as hook to validate the user activity on each request # and in case the user is using other strategies beside Devise ones. diff -Nru ruby-devise-4.3.0/lib/devise/hooks/csrf_cleaner.rb ruby-devise-4.4.3/lib/devise/hooks/csrf_cleaner.rb --- ruby-devise-4.3.0/lib/devise/hooks/csrf_cleaner.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/csrf_cleaner.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Warden::Manager.after_authentication do |record, warden, options| clean_up_for_winning_strategy = !warden.winning_strategy.respond_to?(:clean_up_csrf?) || warden.winning_strategy.clean_up_csrf? diff -Nru ruby-devise-4.3.0/lib/devise/hooks/forgetable.rb ruby-devise-4.4.3/lib/devise/hooks/forgetable.rb --- ruby-devise-4.3.0/lib/devise/hooks/forgetable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/forgetable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Before logout hook to forget the user in the given scope, if it responds # to forget_me! Also clear remember token to ensure the user won't be # remembered again. Notice that we forget the user unless the record is not persisted. diff -Nru ruby-devise-4.3.0/lib/devise/hooks/lockable.rb ruby-devise-4.4.3/lib/devise/hooks/lockable.rb --- ruby-devise-4.3.0/lib/devise/hooks/lockable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/lockable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # After each sign in, if resource responds to failed_attempts, sets it to 0 # This is only triggered when the user is explicitly set (with set_user) Warden::Manager.after_set_user except: :fetch do |record, warden, options| diff -Nru ruby-devise-4.3.0/lib/devise/hooks/proxy.rb ruby-devise-4.4.3/lib/devise/hooks/proxy.rb --- ruby-devise-4.3.0/lib/devise/hooks/proxy.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/proxy.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Hooks # A small warden proxy so we can remember, forget and diff -Nru ruby-devise-4.3.0/lib/devise/hooks/rememberable.rb ruby-devise-4.4.3/lib/devise/hooks/rememberable.rb --- ruby-devise-4.3.0/lib/devise/hooks/rememberable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/rememberable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Warden::Manager.after_set_user except: :fetch do |record, warden, options| scope = options[:scope] if record.respond_to?(:remember_me) && options[:store] != false && diff -Nru ruby-devise-4.3.0/lib/devise/hooks/timeoutable.rb ruby-devise-4.4.3/lib/devise/hooks/timeoutable.rb --- ruby-devise-4.3.0/lib/devise/hooks/timeoutable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/timeoutable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Each time a record is set we check whether its session has already timed out # or not, based on last request time. If so, the record is logged out and # redirected to the sign in page. Also, each time the request comes and the diff -Nru ruby-devise-4.3.0/lib/devise/hooks/trackable.rb ruby-devise-4.4.3/lib/devise/hooks/trackable.rb --- ruby-devise-4.3.0/lib/devise/hooks/trackable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/hooks/trackable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # After each sign in, update sign in time, sign in count and sign in IP. # This is only triggered when the user is explicitly set (with set_user) # and on authentication. Retrieving the user from session (:fetch) does diff -Nru ruby-devise-4.3.0/lib/devise/mailers/helpers.rb ruby-devise-4.4.3/lib/devise/mailers/helpers.rb --- ruby-devise-4.3.0/lib/devise/mailers/helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/mailers/helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Mailers module Helpers diff -Nru ruby-devise-4.3.0/lib/devise/mapping.rb ruby-devise-4.4.3/lib/devise/mapping.rb --- ruby-devise-4.3.0/lib/devise/mapping.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/mapping.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise # Responsible for handling devise mappings and routes configuration. Each # resource configured by devise_for in routes is actually creating a mapping diff -Nru ruby-devise-4.3.0/lib/devise/models/authenticatable.rb ruby-devise-4.4.3/lib/devise/models/authenticatable.rb --- ruby-devise-4.3.0/lib/devise/models/authenticatable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/authenticatable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_model/version' require 'devise/hooks/activatable' require 'devise/hooks/csrf_cleaner' @@ -102,7 +104,7 @@ # and passing a new list of attributes you want to exempt. All attributes # given to :except will simply add names to exempt to Devise internal list. def serializable_hash(options = nil) - options ||= {} + options = options.try(:dup) || {} options[:except] = Array(options[:except]) if options[:force_except] @@ -256,7 +258,7 @@ # end # # Finally, notice that Devise also queries for users in other scenarios - # besides authentication, for example when retrieving an user to send + # besides authentication, for example when retrieving a user to send # an e-mail for password reset. In such cases, find_for_authentication # is not called. def find_for_authentication(tainted_conditions) diff -Nru ruby-devise-4.3.0/lib/devise/models/confirmable.rb ruby-devise-4.4.3/lib/devise/models/confirmable.rb --- ruby-devise-4.3.0/lib/devise/models/confirmable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/confirmable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Models # Confirmable is responsible to verify if an account is already confirmed to @@ -46,7 +48,7 @@ included do before_create :generate_confirmation_token, if: :confirmation_required? after_create :skip_reconfirmation_in_callback!, if: :send_confirmation_notification? - if respond_to?(:after_commit) # ActiveRecord + if defined?(ActiveRecord) && self < ActiveRecord::Base # ActiveRecord after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification? after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required? else # Mongoid diff -Nru ruby-devise-4.3.0/lib/devise/models/database_authenticatable.rb ruby-devise-4.4.3/lib/devise/models/database_authenticatable.rb --- ruby-devise-4.3.0/lib/devise/models/database_authenticatable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/database_authenticatable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/strategies/database_authenticatable' module Devise @@ -10,7 +12,7 @@ # DatabaseAuthenticatable adds the following options to devise_for: # # * +pepper+: a random string used to provide a more secure hash. Use - # `rake secret` to generate new keys. + # `rails secret` to generate new keys. # # * +stretches+: the cost given to bcrypt. # diff -Nru ruby-devise-4.3.0/lib/devise/models/lockable.rb ruby-devise-4.4.3/lib/devise/models/lockable.rb --- ruby-devise-4.3.0/lib/devise/models/lockable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/lockable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "devise/hooks/lockable" module Devise @@ -99,8 +101,7 @@ if super && !access_locked? true else - self.failed_attempts ||= 0 - self.failed_attempts += 1 + increment_failed_attempts if attempts_exceeded? lock_access! unless access_locked? else @@ -109,6 +110,11 @@ false end end + + def increment_failed_attempts + self.failed_attempts ||= 0 + self.failed_attempts += 1 + end def unauthenticated_message # If set to paranoid mode, do not show the locked message because it diff -Nru ruby-devise-4.3.0/lib/devise/models/omniauthable.rb ruby-devise-4.4.3/lib/devise/models/omniauthable.rb --- ruby-devise-4.3.0/lib/devise/models/omniauthable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/omniauthable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/omniauth' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/models/recoverable.rb ruby-devise-4.4.3/lib/devise/models/recoverable.rb --- ruby-devise-4.3.0/lib/devise/models/recoverable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/recoverable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Models diff -Nru ruby-devise-4.3.0/lib/devise/models/registerable.rb ruby-devise-4.4.3/lib/devise/models/registerable.rb --- ruby-devise-4.3.0/lib/devise/models/registerable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/registerable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Models # Registerable is responsible for everything related to registering a new diff -Nru ruby-devise-4.3.0/lib/devise/models/rememberable.rb ruby-devise-4.4.3/lib/devise/models/rememberable.rb --- ruby-devise-4.3.0/lib/devise/models/rememberable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/rememberable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require 'devise/strategies/rememberable' require 'devise/hooks/rememberable' require 'devise/hooks/forgetable' module Devise module Models - # Rememberable manages generating and clearing token for remember the user + # Rememberable manages generating and clearing token for remembering the user # from a saved cookie. Rememberable also has utility methods for dealing # with serializing the user into the cookie and back from the cookie, trying # to lookup the record based on the saved information. diff -Nru ruby-devise-4.3.0/lib/devise/models/timeoutable.rb ruby-devise-4.4.3/lib/devise/models/timeoutable.rb --- ruby-devise-4.3.0/lib/devise/models/timeoutable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/timeoutable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/hooks/timeoutable' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/models/trackable.rb ruby-devise-4.4.3/lib/devise/models/trackable.rb --- ruby-devise-4.3.0/lib/devise/models/trackable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/trackable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/hooks/trackable' module Devise @@ -29,6 +31,11 @@ end def update_tracked_fields!(request) + # We have to check if the user is already persisted before running + # `save` here because invalid users can be saved if we don't. + # See https://github.com/plataformatec/devise/issues/4673 for more details. + return if new_record? + update_tracked_fields(request) save(validate: false) end diff -Nru ruby-devise-4.3.0/lib/devise/models/validatable.rb ruby-devise-4.4.3/lib/devise/models/validatable.rb --- ruby-devise-4.3.0/lib/devise/models/validatable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models/validatable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Models # Validatable creates all needed validations for a user email and password. @@ -10,7 +12,7 @@ # Validatable adds the following options to devise_for: # # * +email_regexp+: the regular expression used to validate e-mails; - # * +password_length+: a range expressing password length. Defaults to 8..72. + # * +password_length+: a range expressing password length. Defaults to 6..128. # module Validatable # All validations used by this module. diff -Nru ruby-devise-4.3.0/lib/devise/models.rb ruby-devise-4.4.3/lib/devise/models.rb --- ruby-devise-4.3.0/lib/devise/models.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/models.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Models class MissingAttribute < StandardError diff -Nru ruby-devise-4.3.0/lib/devise/modules.rb ruby-devise-4.4.3/lib/devise/modules.rb --- ruby-devise-4.3.0/lib/devise/modules.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/modules.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_support/core_ext/object/with_options' Devise.with_options model: true do |d| diff -Nru ruby-devise-4.3.0/lib/devise/omniauth/config.rb ruby-devise-4.4.3/lib/devise/omniauth/config.rb --- ruby-devise-4.3.0/lib/devise/omniauth/config.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/omniauth/config.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module OmniAuth class StrategyNotFound < NameError diff -Nru ruby-devise-4.3.0/lib/devise/omniauth/url_helpers.rb ruby-devise-4.4.3/lib/devise/omniauth/url_helpers.rb --- ruby-devise-4.3.0/lib/devise/omniauth/url_helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/omniauth/url_helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module OmniAuth module UrlHelpers diff -Nru ruby-devise-4.3.0/lib/devise/omniauth.rb ruby-devise-4.4.3/lib/devise/omniauth.rb --- ruby-devise-4.3.0/lib/devise/omniauth.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/omniauth.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require "omniauth" require "omniauth/version" diff -Nru ruby-devise-4.3.0/lib/devise/orm/active_record.rb ruby-devise-4.4.3/lib/devise/orm/active_record.rb --- ruby-devise-4.3.0/lib/devise/orm/active_record.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/orm/active_record.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'orm_adapter/adapters/active_record' ActiveSupport.on_load(:active_record) do diff -Nru ruby-devise-4.3.0/lib/devise/orm/mongoid.rb ruby-devise-4.4.3/lib/devise/orm/mongoid.rb --- ruby-devise-4.3.0/lib/devise/orm/mongoid.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/orm/mongoid.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveSupport.on_load(:mongoid) do require 'orm_adapter/adapters/mongoid' diff -Nru ruby-devise-4.3.0/lib/devise/parameter_filter.rb ruby-devise-4.4.3/lib/devise/parameter_filter.rb --- ruby-devise-4.3.0/lib/devise/parameter_filter.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/parameter_filter.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise class ParameterFilter def initialize(case_insensitive_keys, strip_whitespace_keys) diff -Nru ruby-devise-4.3.0/lib/devise/parameter_sanitizer.rb ruby-devise-4.4.3/lib/devise/parameter_sanitizer.rb --- ruby-devise-4.3.0/lib/devise/parameter_sanitizer.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/parameter_sanitizer.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise # The +ParameterSanitizer+ deals with permitting specific parameters values # for each +Devise+ scope in the application. diff -Nru ruby-devise-4.3.0/lib/devise/rails/routes.rb ruby-devise-4.4.3/lib/devise/rails/routes.rb --- ruby-devise-4.3.0/lib/devise/rails/routes.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/rails/routes.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/object/try" require "active_support/core_ext/hash/slice" diff -Nru ruby-devise-4.3.0/lib/devise/rails/warden_compat.rb ruby-devise-4.4.3/lib/devise/rails/warden_compat.rb --- ruby-devise-4.3.0/lib/devise/rails/warden_compat.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/rails/warden_compat.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Warden::Mixins::Common def request @request ||= ActionDispatch::Request.new(env) diff -Nru ruby-devise-4.3.0/lib/devise/rails.rb ruby-devise-4.4.3/lib/devise/rails.rb --- ruby-devise-4.3.0/lib/devise/rails.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/rails.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/rails/routes' require 'devise/rails/warden_compat' @@ -32,11 +34,7 @@ end initializer "devise.secret_key" do |app| - if app.respond_to?(:secrets) - Devise.secret_key ||= app.secrets.secret_key_base - elsif app.config.respond_to?(:secret_key_base) - Devise.secret_key ||= app.config.secret_key_base - end + Devise.secret_key ||= Devise::SecretKeyFinder.new(app).find Devise.token_generator ||= if secret_key = Devise.secret_key diff -Nru ruby-devise-4.3.0/lib/devise/secret_key_finder.rb ruby-devise-4.4.3/lib/devise/secret_key_finder.rb --- ruby-devise-4.3.0/lib/devise/secret_key_finder.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/secret_key_finder.rb 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Devise + class SecretKeyFinder + def initialize(application) + @application = application + end + + def find + if @application.respond_to?(:credentials) && key_exists?(@application.credentials) + @application.credentials.secret_key_base + elsif @application.respond_to?(:secrets) && key_exists?(@application.secrets) + @application.secrets.secret_key_base + elsif @application.config.respond_to?(:secret_key_base) && key_exists?(@application.config) + @application.config.secret_key_base + end + end + + private + + def key_exists?(object) + object.secret_key_base.present? + end + end +end diff -Nru ruby-devise-4.3.0/lib/devise/strategies/authenticatable.rb ruby-devise-4.4.3/lib/devise/strategies/authenticatable.rb --- ruby-devise-4.3.0/lib/devise/strategies/authenticatable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/strategies/authenticatable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/strategies/base' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/strategies/base.rb ruby-devise-4.4.3/lib/devise/strategies/base.rb --- ruby-devise-4.3.0/lib/devise/strategies/base.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/strategies/base.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Strategies # Base strategy for Devise. Responsible for verifying correct scope and mapping. diff -Nru ruby-devise-4.3.0/lib/devise/strategies/database_authenticatable.rb ruby-devise-4.4.3/lib/devise/strategies/database_authenticatable.rb --- ruby-devise-4.3.0/lib/devise/strategies/database_authenticatable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/strategies/database_authenticatable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/strategies/authenticatable' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/strategies/rememberable.rb ruby-devise-4.4.3/lib/devise/strategies/rememberable.rb --- ruby-devise-4.3.0/lib/devise/strategies/rememberable.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/strategies/rememberable.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'devise/strategies/authenticatable' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/test/controller_helpers.rb ruby-devise-4.4.3/lib/devise/test/controller_helpers.rb --- ruby-devise-4.3.0/lib/devise/test/controller_helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/test/controller_helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Test # `Devise::Test::ControllerHelpers` provides a facility to test controllers @@ -137,6 +139,7 @@ status, headers, response = Devise.warden_config[:failure_app].call(env).to_a @controller.response.headers.merge!(headers) + @controller.response.content_type = headers["Content-Type"] unless Rails.version.start_with?('5') @controller.status = status @controller.response.body = response.body nil # causes process return @response diff -Nru ruby-devise-4.3.0/lib/devise/test/integration_helpers.rb ruby-devise-4.4.3/lib/devise/test/integration_helpers.rb --- ruby-devise-4.3.0/lib/devise/test/integration_helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/test/integration_helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise # Devise::Test::IntegrationHelpers is a helper module for facilitating # authentication on Rails integration tests to bypass the required steps for diff -Nru ruby-devise-4.3.0/lib/devise/test_helpers.rb ruby-devise-4.4.3/lib/devise/test_helpers.rb --- ruby-devise-4.3.0/lib/devise/test_helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/test_helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module TestHelpers def self.included(base) diff -Nru ruby-devise-4.3.0/lib/devise/time_inflector.rb ruby-devise-4.4.3/lib/devise/time_inflector.rb --- ruby-devise-4.3.0/lib/devise/time_inflector.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/time_inflector.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/module/delegation" module Devise diff -Nru ruby-devise-4.3.0/lib/devise/token_generator.rb ruby-devise-4.4.3/lib/devise/token_generator.rb --- ruby-devise-4.3.0/lib/devise/token_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/token_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'openssl' module Devise diff -Nru ruby-devise-4.3.0/lib/devise/version.rb ruby-devise-4.4.3/lib/devise/version.rb --- ruby-devise-4.3.0/lib/devise/version.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise/version.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise - VERSION = "4.3.0".freeze + VERSION = "4.4.3".freeze end diff -Nru ruby-devise-4.3.0/lib/devise.rb ruby-devise-4.4.3/lib/devise.rb --- ruby-devise-4.3.0/lib/devise.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/devise.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails' require 'active_support/core_ext/numeric/time' require 'active_support/dependencies' @@ -16,6 +18,7 @@ autoload :TestHelpers, 'devise/test_helpers' autoload :TimeInflector, 'devise/time_inflector' autoload :TokenGenerator, 'devise/token_generator' + autoload :SecretKeyFinder, 'devise/secret_key_finder' module Controllers autoload :Helpers, 'devise/controllers/helpers' @@ -149,7 +152,7 @@ mattr_accessor :timeout_in @@timeout_in = 30.minutes - # Used to hash the password. Please generate one with rake secret. + # Used to hash the password. Please generate one with rails secret. mattr_accessor :pepper @@pepper = nil diff -Nru ruby-devise-4.3.0/lib/generators/active_record/devise_generator.rb ruby-devise-4.4.3/lib/generators/active_record/devise_generator.rb --- ruby-devise-4.3.0/lib/generators/active_record/devise_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/active_record/devise_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators/active_record' require 'generators/devise/orm_helpers' @@ -6,14 +8,16 @@ class DeviseGenerator < ActiveRecord::Generators::Base argument :attributes, type: :array, default: [], banner: "field:type field:type" + class_option :primary_key_type, type: :string, desc: "The type for primary key" + include Devise::Generators::OrmHelpers source_root File.expand_path("../templates", __FILE__) def copy_devise_migration if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name)) - migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb", migration_version: migration_version + migration_template "migration_existing.rb", "#{migration_path}/add_devise_to_#{table_name}.rb", migration_version: migration_version else - migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb", migration_version: migration_version + migration_template "migration.rb", "#{migration_path}/devise_create_#{table_name}.rb", migration_version: migration_version end end @@ -92,6 +96,15 @@ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end + + def primary_key_type + primary_key_string if rails5? + end + + def primary_key_string + key_string = options[:primary_key_type] + ", id: :#{key_string}" if key_string + end end end end diff -Nru ruby-devise-4.3.0/lib/generators/active_record/templates/migration_existing.rb ruby-devise-4.4.3/lib/generators/active_record/templates/migration_existing.rb --- ruby-devise-4.3.0/lib/generators/active_record/templates/migration_existing.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/active_record/templates/migration_existing.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %> def self.up change_table :<%= table_name %> do |t| diff -Nru ruby-devise-4.3.0/lib/generators/active_record/templates/migration.rb ruby-devise-4.4.3/lib/generators/active_record/templates/migration.rb --- ruby-devise-4.3.0/lib/generators/active_record/templates/migration.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/active_record/templates/migration.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,6 +1,8 @@ +# frozen_string_literal: true + class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %> def change - create_table :<%= table_name %> do |t| + create_table :<%= table_name %><%= primary_key_type %> do |t| <%= migration_data -%> <% attributes.each do |attribute| -%> diff -Nru ruby-devise-4.3.0/lib/generators/devise/controllers_generator.rb ruby-devise-4.4.3/lib/generators/devise/controllers_generator.rb --- ruby-devise-4.3.0/lib/generators/devise/controllers_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/devise/controllers_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators/base' module Devise diff -Nru ruby-devise-4.3.0/lib/generators/devise/devise_generator.rb ruby-devise-4.4.3/lib/generators/devise/devise_generator.rb --- ruby-devise-4.3.0/lib/generators/devise/devise_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/devise/devise_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators/named_base' module Devise @@ -8,7 +10,7 @@ namespace "devise" source_root File.expand_path("../templates", __FILE__) - desc "Generates a model with the given NAME (if one does not exist) with devise " << + desc "Generates a model with the given NAME (if one does not exist) with devise " \ "configuration plus a migration file and devise routes." hook_for :orm @@ -16,7 +18,7 @@ class_option :routes, desc: "Generate routes", type: :boolean, default: true def add_devise_routes - devise_route = "devise_for :#{plural_name}" + devise_route = "devise_for :#{plural_name}".dup devise_route << %Q(, class_name: "#{class_name}") if class_name.include?("::") devise_route << %Q(, skip: :all) unless options.routes? route devise_route diff -Nru ruby-devise-4.3.0/lib/generators/devise/install_generator.rb ruby-devise-4.4.3/lib/generators/devise/install_generator.rb --- ruby-devise-4.3.0/lib/generators/devise/install_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/devise/install_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators/base' require 'securerandom' diff -Nru ruby-devise-4.3.0/lib/generators/devise/orm_helpers.rb ruby-devise-4.4.3/lib/generators/devise/orm_helpers.rb --- ruby-devise-4.3.0/lib/generators/devise/orm_helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/devise/orm_helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise module Generators module OrmHelpers @@ -23,7 +25,11 @@ end def migration_path - @migration_path ||= File.join("db", "migrate") + if Rails.version >= '5.0.3' + db_migrate_path + else + @migration_path ||= File.join("db", "migrate") + end end def model_path diff -Nru ruby-devise-4.3.0/lib/generators/devise/views_generator.rb ruby-devise-4.4.3/lib/generators/devise/views_generator.rb --- ruby-devise-4.3.0/lib/generators/devise/views_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/devise/views_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators/base' module Devise @@ -21,13 +23,6 @@ public_task :copy_views end - # TODO: Add this to Rails itself - module ClassMethods - def hide! - Rails::Generators.hide_namespace self.namespace - end - end - def copy_views if options[:views] options[:views].each do |directory| @@ -139,7 +134,11 @@ default: defined?(SimpleForm) ? "simple_form_for" : "form_for" hook_for :markerb, desc: "Generate markerb instead of erb mail views", - default: defined?(Markerb) ? :markerb : :erb, + default: defined?(Markerb), + type: :boolean + + hook_for :erb, desc: "Generate erb mail views", + default: !defined?(Markerb), type: :boolean end end diff -Nru ruby-devise-4.3.0/lib/generators/mongoid/devise_generator.rb ruby-devise-4.4.3/lib/generators/mongoid/devise_generator.rb --- ruby-devise-4.3.0/lib/generators/mongoid/devise_generator.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/mongoid/devise_generator.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators/named_base' require 'generators/devise/orm_helpers' diff -Nru ruby-devise-4.3.0/lib/generators/templates/controllers/confirmations_controller.rb ruby-devise-4.4.3/lib/generators/templates/controllers/confirmations_controller.rb --- ruby-devise-4.3.0/lib/generators/templates/controllers/confirmations_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/controllers/confirmations_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class <%= @scope_prefix %>ConfirmationsController < Devise::ConfirmationsController # GET /resource/confirmation/new # def new diff -Nru ruby-devise-4.3.0/lib/generators/templates/controllers/omniauth_callbacks_controller.rb ruby-devise-4.4.3/lib/generators/templates/controllers/omniauth_callbacks_controller.rb --- ruby-devise-4.3.0/lib/generators/templates/controllers/omniauth_callbacks_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/controllers/omniauth_callbacks_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallbacksController # You should configure your model like this: # devise :omniauthable, omniauth_providers: [:twitter] diff -Nru ruby-devise-4.3.0/lib/generators/templates/controllers/passwords_controller.rb ruby-devise-4.4.3/lib/generators/templates/controllers/passwords_controller.rb --- ruby-devise-4.3.0/lib/generators/templates/controllers/passwords_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/controllers/passwords_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class <%= @scope_prefix %>PasswordsController < Devise::PasswordsController # GET /resource/password/new # def new diff -Nru ruby-devise-4.3.0/lib/generators/templates/controllers/registrations_controller.rb ruby-devise-4.4.3/lib/generators/templates/controllers/registrations_controller.rb --- ruby-devise-4.3.0/lib/generators/templates/controllers/registrations_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/controllers/registrations_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsController # before_action :configure_sign_up_params, only: [:create] # before_action :configure_account_update_params, only: [:update] diff -Nru ruby-devise-4.3.0/lib/generators/templates/controllers/sessions_controller.rb ruby-devise-4.4.3/lib/generators/templates/controllers/sessions_controller.rb --- ruby-devise-4.3.0/lib/generators/templates/controllers/sessions_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/controllers/sessions_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class <%= @scope_prefix %>SessionsController < Devise::SessionsController # before_action :configure_sign_in_params, only: [:create] diff -Nru ruby-devise-4.3.0/lib/generators/templates/controllers/unlocks_controller.rb ruby-devise-4.4.3/lib/generators/templates/controllers/unlocks_controller.rb --- ruby-devise-4.3.0/lib/generators/templates/controllers/unlocks_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/controllers/unlocks_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class <%= @scope_prefix %>UnlocksController < Devise::UnlocksController # GET /resource/unlock/new # def new diff -Nru ruby-devise-4.3.0/lib/generators/templates/devise.rb ruby-devise-4.4.3/lib/generators/templates/devise.rb --- ruby-devise-4.3.0/lib/generators/templates/devise.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/lib/generators/templates/devise.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| @@ -7,6 +9,10 @@ # Devise will use the `secret_key_base` as its `secret_key` # by default. You can change it below and use your own secret key. # config.secret_key = '<%= SecureRandom.hex(64) %>' + + # ==> Controller configuration + # Configure the parent class to the devise controllers. + # config.parent_controller = 'DeviseController' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, diff -Nru ruby-devise-4.3.0/Rakefile ruby-devise-4.4.3/Rakefile --- ruby-devise-4.3.0/Rakefile 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/Rakefile 2018-03-21 15:11:01.000000000 +0000 @@ -1,4 +1,5 @@ # encoding: UTF-8 +# frozen_string_literal: true require 'bundler/gem_tasks' require 'rake/testtask' diff -Nru ruby-devise-4.3.0/README.md ruby-devise-4.4.3/README.md --- ruby-devise-4.3.0/README.md 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/README.md 2018-03-21 15:11:01.000000000 +0000 @@ -27,6 +27,50 @@ * [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations. * [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period. +## Table of Contents + + + +- [Information](#information) + - [The Devise wiki](#the-devise-wiki) + - [Bug reports](#bug-reports) + - [StackOverflow and Mailing List](#stackoverflow-and-mailing-list) + - [RDocs](#rdocs) + - [Example applications](#example-applications) + - [Extensions](#extensions) + - [Contributing](#contributing) +- [Starting with Rails?](#starting-with-rails) +- [Getting started](#getting-started) + - [Controller filters and helpers](#controller-filters-and-helpers) + - [Configuring Models](#configuring-models) + - [Strong Parameters](#strong-parameters) + - [Configuring views](#configuring-views) + - [Configuring controllers](#configuring-controllers) + - [Configuring routes](#configuring-routes) + - [I18n](#i18n) + - [Test helpers](#test-helpers) + - [Controller tests](#controller-tests) + - [Integration tests](#integration-tests) + - [OmniAuth](#omniauth) + - [Configuring multiple models](#configuring-multiple-models) +- [Create a migration with the required fields](#create-a-migration-with-the-required-fields) +- [Inside your Admin model](#inside-your-admin-model) +- [Inside your routes](#inside-your-routes) +- [Inside your protected controller](#inside-your-protected-controller) +- [Inside your controllers and views](#inside-your-controllers-and-views) + - [ActiveJob Integration](#activejob-integration) + - [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs) + - [Other ORMs](#other-orms) +- [Additional information](#additional-information) + - [Heroku](#heroku) + - [Warden](#warden) + - [Contributors](#contributors) +- [License](#license) + + + + + ## Information ### The Devise wiki @@ -79,7 +123,36 @@ https://github.com/plataformatec/devise/wiki/Contributing -You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run "bundle install" and "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system. +You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`. +Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`. + +### DEVISE_ORM +Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM. +The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`: +``` +DEVISE_ORM=mongoid bin/test + +==> Devise.orm = :mongoid +``` +When running the tests for Mongoid, you will need to have a MongoDB server (version 2.0 or newer) running on your system. + +Please note that the command output will show the variable value being used. + +### BUNDLE_GEMFILE +We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory). +Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite brakes on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable. +For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following: +```bash +rbenv shell 2.4.2 # or rvm use 2.4.2 +BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install +BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test +``` + +You can also combine both of them if the tests broke for Mongoid: +```bash +BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install +BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test +``` ## Starting with Rails? @@ -126,7 +199,7 @@ Then run `rails db:migrate` -You should restart your application after changing Devise's configuration options. Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined. +You should restart your application after changing Devise's configuration options (this includes stopping spring). Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined. ### Controller filters and helpers @@ -216,7 +289,21 @@ end ``` -The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types. Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block: +The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types: + +```ruby +class ApplicationController < ActionController::Base + before_action :configure_permitted_parameters, if: :devise_controller? + + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, address_attributes: [:country, :state, :city, :area, :postal_code]]) + end +end +``` + +Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block: To permit simple scalar values for username and email, use this @@ -374,6 +461,12 @@ This way, you tell Devise to use the scope `:user` when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router. +Please note: You will still need to add `devise_for` in your routes in order to use helper methods such as `current_user`. + +```ruby +devise_for :users, skip: :all +``` + ### I18n Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file: @@ -610,6 +703,6 @@ ## License -MIT License. Copyright 2009-2017 Plataformatec. http://plataformatec.com.br +MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo. diff -Nru ruby-devise-4.3.0/test/controllers/custom_registrations_controller_test.rb ruby-devise-4.4.3/test/controllers/custom_registrations_controller_test.rb --- ruby-devise-4.3.0/test/controllers/custom_registrations_controller_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/custom_registrations_controller_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class CustomRegistrationsControllerTest < Devise::ControllerTestCase diff -Nru ruby-devise-4.3.0/test/controllers/custom_strategy_test.rb ruby-devise-4.4.3/test/controllers/custom_strategy_test.rb --- ruby-devise-4.3.0/test/controllers/custom_strategy_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/custom_strategy_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require 'ostruct' require 'warden/strategies/base' diff -Nru ruby-devise-4.3.0/test/controllers/helper_methods_test.rb ruby-devise-4.4.3/test/controllers/helper_methods_test.rb --- ruby-devise-4.3.0/test/controllers/helper_methods_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/helper_methods_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class ApiController < ActionController::Metal diff -Nru ruby-devise-4.3.0/test/controllers/helpers_test.rb ruby-devise-4.4.3/test/controllers/helpers_test.rb --- ruby-devise-4.3.0/test/controllers/helpers_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/helpers_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require 'ostruct' diff -Nru ruby-devise-4.3.0/test/controllers/inherited_controller_i18n_messages_test.rb ruby-devise-4.4.3/test/controllers/inherited_controller_i18n_messages_test.rb --- ruby-devise-4.3.0/test/controllers/inherited_controller_i18n_messages_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/inherited_controller_i18n_messages_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class SessionsInheritedController < Devise::SessionsController diff -Nru ruby-devise-4.3.0/test/controllers/internal_helpers_test.rb ruby-devise-4.4.3/test/controllers/internal_helpers_test.rb --- ruby-devise-4.3.0/test/controllers/internal_helpers_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/internal_helpers_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class MyController < DeviseController diff -Nru ruby-devise-4.3.0/test/controllers/load_hooks_controller_test.rb ruby-devise-4.4.3/test/controllers/load_hooks_controller_test.rb --- ruby-devise-4.3.0/test/controllers/load_hooks_controller_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/load_hooks_controller_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class LoadHooksControllerTest < Devise::ControllerTestCase diff -Nru ruby-devise-4.3.0/test/controllers/passwords_controller_test.rb ruby-devise-4.4.3/test/controllers/passwords_controller_test.rb --- ruby-devise-4.3.0/test/controllers/passwords_controller_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/passwords_controller_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class PasswordsControllerTest < Devise::ControllerTestCase diff -Nru ruby-devise-4.3.0/test/controllers/sessions_controller_test.rb ruby-devise-4.4.3/test/controllers/sessions_controller_test.rb --- ruby-devise-4.3.0/test/controllers/sessions_controller_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/sessions_controller_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class SessionsControllerTest < Devise::ControllerTestCase diff -Nru ruby-devise-4.3.0/test/controllers/url_helpers_test.rb ruby-devise-4.4.3/test/controllers/url_helpers_test.rb --- ruby-devise-4.3.0/test/controllers/url_helpers_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/controllers/url_helpers_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RoutesTest < Devise::ControllerTestCase diff -Nru ruby-devise-4.3.0/test/delegator_test.rb ruby-devise-4.4.3/test/delegator_test.rb --- ruby-devise-4.3.0/test/delegator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/delegator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class DelegatorTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/devise_test.rb ruby-devise-4.4.3/test/devise_test.rb --- ruby-devise-4.3.0/test/devise_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/devise_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' module Devise diff -Nru ruby-devise-4.3.0/test/failure_app_test.rb ruby-devise-4.4.3/test/failure_app_test.rb --- ruby-devise-4.3.0/test/failure_app_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/failure_app_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require 'ostruct' diff -Nru ruby-devise-4.3.0/test/generators/active_record_generator_test.rb ruby-devise-4.4.3/test/generators/active_record_generator_test.rb --- ruby-devise-4.3.0/test/generators/active_record_generator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/generators/active_record_generator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" if DEVISE_ORM == :active_record @@ -13,6 +15,20 @@ assert_migration "db/migrate/devise_create_monsters.rb", /def change/ end + test "all files are properly created with changed db/migrate path in application configuration" do + old_paths = Rails.application.config.paths["db/migrate"] + Rails.application.config.paths.add "db/migrate", with: "db2/migrate" + + run_generator %w(monster) + if Rails.version >= '5.0.3' + assert_migration "db2/migrate/devise_create_monsters.rb", /def change/ + else + assert_migration "db/migrate/devise_create_monsters.rb", /def change/ + end + + Rails.application.config.paths["db/migrate"] = old_paths + end + test "all files for namespaced model are properly created" do run_generator %w(admin/monster) assert_migration "db/migrate/devise_create_admin_monsters.rb", /def change/ @@ -25,6 +41,23 @@ assert_migration "db/migrate/add_devise_to_monsters.rb" end + test "update model migration when model exists with changed db/migrate path in application configuration" do + old_paths = Rails.application.config.paths["db/migrate"] + Rails.application.config.paths.add "db/migrate", with: "db2/migrate" + + run_generator %w(monster) + assert_file "app/models/monster.rb" + run_generator %w(monster) + + if Rails.version >= '5.0.3' + assert_migration "db2/migrate/add_devise_to_monsters.rb" + else + assert_migration "db/migrate/add_devise_to_monsters.rb" + end + + Rails.application.config.paths["db/migrate"] = old_paths + end + test "all files are properly deleted" do run_generator %w(monster) run_generator %w(monster) @@ -43,6 +76,20 @@ assert_migration "db/migrate/devise_create_monsters.rb", /t.string :current_sign_in_ip/ assert_migration "db/migrate/devise_create_monsters.rb", /t.string :last_sign_in_ip/ end + + test "do NOT add primary key type when NOT specified in rails generator" do + run_generator %w(monster) + assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters do/ + end + + test "add primary key type with rails 5 when specified in rails generator" do + run_generator ["monster", "--primary_key_type=uuid"] + if Rails.version.start_with? '5' + assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/ + else + assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters do/ + end + end end module RailsEngine diff -Nru ruby-devise-4.3.0/test/generators/controllers_generator_test.rb ruby-devise-4.4.3/test/generators/controllers_generator_test.rb --- ruby-devise-4.3.0/test/generators/controllers_generator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/generators/controllers_generator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ControllersGeneratorTest < Rails::Generators::TestCase diff -Nru ruby-devise-4.3.0/test/generators/devise_generator_test.rb ruby-devise-4.4.3/test/generators/devise_generator_test.rb --- ruby-devise-4.3.0/test/generators/devise_generator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/generators/devise_generator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require "generators/devise/devise_generator" diff -Nru ruby-devise-4.3.0/test/generators/install_generator_test.rb ruby-devise-4.4.3/test/generators/install_generator_test.rb --- ruby-devise-4.3.0/test/generators/install_generator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/generators/install_generator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class InstallGeneratorTest < Rails::Generators::TestCase diff -Nru ruby-devise-4.3.0/test/generators/mongoid_generator_test.rb ruby-devise-4.4.3/test/generators/mongoid_generator_test.rb --- ruby-devise-4.3.0/test/generators/mongoid_generator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/generators/mongoid_generator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" if DEVISE_ORM == :mongoid diff -Nru ruby-devise-4.3.0/test/generators/views_generator_test.rb ruby-devise-4.4.3/test/generators/views_generator_test.rb --- ruby-devise-4.3.0/test/generators/views_generator_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/generators/views_generator_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ViewsGeneratorTest < Rails::Generators::TestCase diff -Nru ruby-devise-4.3.0/test/helpers/devise_helper_test.rb ruby-devise-4.4.3/test/helpers/devise_helper_test.rb --- ruby-devise-4.3.0/test/helpers/devise_helper_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/helpers/devise_helper_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class DeviseHelperTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/integration/authenticatable_test.rb ruby-devise-4.4.3/test/integration/authenticatable_test.rb --- ruby-devise-4.3.0/test/integration/authenticatable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/authenticatable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,6 +1,14 @@ +# frozen_string_literal: true + require 'test_helper' class AuthenticationSanityTest < Devise::IntegrationTest + test 'sign in should not run model validations' do + sign_in_as_user + + refute User.validations_performed + end + test 'home should be accessible without sign in' do visit '/' assert_response :success @@ -369,7 +377,7 @@ end end - test 'renders the scoped view if turned on in an specific controller' do + test 'renders the scoped view if turned on in a specific controller' do begin Devise::SessionsController.scoped_views = true assert_raise Webrat::NotFoundError do diff -Nru ruby-devise-4.3.0/test/integration/confirmable_test.rb ruby-devise-4.4.3/test/integration/confirmable_test.rb --- ruby-devise-4.3.0/test/integration/confirmable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/confirmable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class ConfirmationTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/integration/database_authenticatable_test.rb ruby-devise-4.4.3/test/integration/database_authenticatable_test.rb --- ruby-devise-4.3.0/test/integration/database_authenticatable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/database_authenticatable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class DatabaseAuthenticationTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/integration/http_authenticatable_test.rb ruby-devise-4.4.3/test/integration/http_authenticatable_test.rb --- ruby-devise-4.3.0/test/integration/http_authenticatable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/http_authenticatable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,6 +1,14 @@ +# frozen_string_literal: true + require 'test_helper' class HttpAuthenticationTest < Devise::IntegrationTest + test 'sign in with HTTP should not run model validations' do + sign_in_as_new_user_with_http + + refute User.validations_performed + end + test 'handles unverified requests gets rid of caches but continues signed in' do swap ApplicationController, allow_forgery_protection: true do create_user diff -Nru ruby-devise-4.3.0/test/integration/lockable_test.rb ruby-devise-4.4.3/test/integration/lockable_test.rb --- ruby-devise-4.3.0/test/integration/lockable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/lockable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class LockTest < Devise::IntegrationTest @@ -172,7 +174,7 @@ assert_equal response.body, {}.to_json end - test "in paranoid mode, when trying to unlock an user that exists it should not say that it exists if it is locked" do + test "in paranoid mode, when trying to unlock a user that exists it should not say that it exists if it is locked" do swap Devise, paranoid: true do user = create_user(locked: true) @@ -187,7 +189,7 @@ end end - test "in paranoid mode, when trying to unlock an user that exists it should not say that it exists if it is not locked" do + test "in paranoid mode, when trying to unlock a user that exists it should not say that it exists if it is not locked" do swap Devise, paranoid: true do user = create_user(locked: false) @@ -202,7 +204,7 @@ end end - test "in paranoid mode, when trying to unlock an user that does not exists it should not say that it does not exists" do + test "in paranoid mode, when trying to unlock a user that does not exists it should not say that it does not exists" do swap Devise, paranoid: true do visit new_user_session_path click_link "Didn't receive unlock instructions?" diff -Nru ruby-devise-4.3.0/test/integration/mounted_engine_test.rb ruby-devise-4.4.3/test/integration/mounted_engine_test.rb --- ruby-devise-4.3.0/test/integration/mounted_engine_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/mounted_engine_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class MyMountableEngine diff -Nru ruby-devise-4.3.0/test/integration/omniauthable_test.rb ruby-devise-4.4.3/test/integration/omniauthable_test.rb --- ruby-devise-4.3.0/test/integration/omniauthable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/omniauthable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' @@ -40,6 +42,17 @@ end end + test "omniauth sign in should not run model validations" do + stub_action!(:sign_in_facebook) do + create_user + visit "/users/sign_in" + click_link "Sign in with FaceBook" + assert warden.authenticated?(:user) + + refute User.validations_performed + end + end + test "can access omniauth.auth in the env hash" do visit "/users/sign_in" click_link "Sign in with FaceBook" diff -Nru ruby-devise-4.3.0/test/integration/recoverable_test.rb ruby-devise-4.4.3/test/integration/recoverable_test.rb --- ruby-devise-4.3.0/test/integration/recoverable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/recoverable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class PasswordTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/integration/registerable_test.rb ruby-devise-4.4.3/test/integration/registerable_test.rb --- ruby-devise-4.3.0/test/integration/registerable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/registerable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RegistrationTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/integration/rememberable_test.rb ruby-devise-4.4.3/test/integration/rememberable_test.rb --- ruby-devise-4.3.0/test/integration/rememberable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/rememberable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RememberMeTest < Devise::IntegrationTest @@ -10,7 +12,7 @@ end def generate_signed_cookie(raw_cookie) - request = if Devise::Test.rails51? + request = if Devise::Test.rails51? || Devise::Test.rails52? ActionController::TestRequest.create(Class.new) # needs a "controller class" elsif Devise::Test.rails5? ActionController::TestRequest.create diff -Nru ruby-devise-4.3.0/test/integration/timeoutable_test.rb ruby-devise-4.4.3/test/integration/timeoutable_test.rb --- ruby-devise-4.3.0/test/integration/timeoutable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/timeoutable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class SessionTimeoutTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/integration/trackable_test.rb ruby-devise-4.4.3/test/integration/trackable_test.rb --- ruby-devise-4.3.0/test/integration/trackable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/integration/trackable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,6 +1,13 @@ +# frozen_string_literal: true + require 'test_helper' class TrackableHooksTest < Devise::IntegrationTest + test "trackable should not run model validations" do + sign_in_as_user + + refute User.validations_performed + end test "current and last sign in timestamps are updated on each sign in" do user = create_user diff -Nru ruby-devise-4.3.0/test/mailers/confirmation_instructions_test.rb ruby-devise-4.4.3/test/mailers/confirmation_instructions_test.rb --- ruby-devise-4.3.0/test/mailers/confirmation_instructions_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/mailers/confirmation_instructions_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class ConfirmationInstructionsTest < ActionMailer::TestCase diff -Nru ruby-devise-4.3.0/test/mailers/email_changed_test.rb ruby-devise-4.4.3/test/mailers/email_changed_test.rb --- ruby-devise-4.3.0/test/mailers/email_changed_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/mailers/email_changed_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class EmailChangedTest < ActionMailer::TestCase diff -Nru ruby-devise-4.3.0/test/mailers/mailer_test.rb ruby-devise-4.4.3/test/mailers/mailer_test.rb --- ruby-devise-4.3.0/test/mailers/mailer_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/mailers/mailer_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class MailerTest < ActionMailer::TestCase diff -Nru ruby-devise-4.3.0/test/mailers/reset_password_instructions_test.rb ruby-devise-4.4.3/test/mailers/reset_password_instructions_test.rb --- ruby-devise-4.3.0/test/mailers/reset_password_instructions_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/mailers/reset_password_instructions_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class ResetPasswordInstructionsTest < ActionMailer::TestCase diff -Nru ruby-devise-4.3.0/test/mailers/unlock_instructions_test.rb ruby-devise-4.4.3/test/mailers/unlock_instructions_test.rb --- ruby-devise-4.3.0/test/mailers/unlock_instructions_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/mailers/unlock_instructions_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class UnlockInstructionsTest < ActionMailer::TestCase diff -Nru ruby-devise-4.3.0/test/mapping_test.rb ruby-devise-4.4.3/test/mapping_test.rb --- ruby-devise-4.3.0/test/mapping_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/mapping_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class FakeRequest < Struct.new(:path_info, :params) diff -Nru ruby-devise-4.3.0/test/models/authenticatable_test.rb ruby-devise-4.4.3/test/models/authenticatable_test.rb --- ruby-devise-4.3.0/test/models/authenticatable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/authenticatable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class AuthenticatableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/confirmable_test.rb ruby-devise-4.4.3/test/models/confirmable_test.rb --- ruby-devise-4.3.0/test/models/confirmable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/confirmable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class ConfirmableTest < ActiveSupport::TestCase @@ -6,6 +8,17 @@ setup_mailer end + test 'should set callbacks to send the mail' do + if DEVISE_ORM == :active_record + defined_callbacks = User._commit_callbacks.map(&:filter) + assert_includes defined_callbacks, :send_on_create_confirmation_instructions + assert_includes defined_callbacks, :send_reconfirmation_instructions + elsif DEVISE_ORM == :mongoid + assert_includes User._create_callbacks.map(&:filter), :send_on_create_confirmation_instructions + assert_includes User._update_callbacks.map(&:filter), :send_reconfirmation_instructions + end + end + test 'should generate confirmation token after creating a record' do assert_nil new_user.confirmation_token assert_not_nil create_user.confirmation_token diff -Nru ruby-devise-4.3.0/test/models/database_authenticatable_test.rb ruby-devise-4.4.3/test/models/database_authenticatable_test.rb --- ruby-devise-4.3.0/test/models/database_authenticatable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/database_authenticatable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require 'test_models' require 'digest/sha1' diff -Nru ruby-devise-4.3.0/test/models/lockable_test.rb ruby-devise-4.4.3/test/models/lockable_test.rb --- ruby-devise-4.3.0/test/models/lockable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/lockable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class LockableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/omniauthable_test.rb ruby-devise-4.4.3/test/models/omniauthable_test.rb --- ruby-devise-4.3.0/test/models/omniauthable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/omniauthable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class OmniauthableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/recoverable_test.rb ruby-devise-4.4.3/test/models/recoverable_test.rb --- ruby-devise-4.3.0/test/models/recoverable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/recoverable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RecoverableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/registerable_test.rb ruby-devise-4.4.3/test/models/registerable_test.rb --- ruby-devise-4.3.0/test/models/registerable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/registerable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RegisterableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/rememberable_test.rb ruby-devise-4.4.3/test/models/rememberable_test.rb --- ruby-devise-4.3.0/test/models/rememberable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/rememberable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RememberableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/serializable_test.rb ruby-devise-4.4.3/test/models/serializable_test.rb --- ruby-devise-4.3.0/test/models/serializable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/serializable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class SerializableTest < ActiveSupport::TestCase @@ -40,6 +42,10 @@ assert_no_match(/confirmation_token/, @user.inspect) end + test 'should accept frozen options' do + assert_key "username", @user.as_json({only: :username}.freeze)["user"] + end + def assert_key(key, subject) assert subject.key?(key), "Expected #{subject.inspect} to have key #{key.inspect}" end diff -Nru ruby-devise-4.3.0/test/models/timeoutable_test.rb ruby-devise-4.4.3/test/models/timeoutable_test.rb --- ruby-devise-4.3.0/test/models/timeoutable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/timeoutable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class TimeoutableTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/models/trackable_test.rb ruby-devise-4.4.3/test/models/trackable_test.rb --- ruby-devise-4.3.0/test/models/trackable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/trackable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class TrackableTest < ActiveSupport::TestCase @@ -38,4 +40,23 @@ assert_nil user.last_sign_in_at assert_equal 0, user.sign_in_count end + + test "update_tracked_fields! should not persist invalid records" do + user = UserWithValidations.new + request = mock + request.stubs(:remote_ip).returns("127.0.0.1") + + assert_not user.update_tracked_fields!(request) + assert_not user.persisted? + end + + test "update_tracked_fields! should not run model validations" do + user = User.new + request = mock + request.stubs(:remote_ip).returns("127.0.0.1") + + user.expects(:after_validation_callback).never + + assert_not user.update_tracked_fields!(request) + end end diff -Nru ruby-devise-4.3.0/test/models/validatable_test.rb ruby-devise-4.4.3/test/models/validatable_test.rb --- ruby-devise-4.3.0/test/models/validatable_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models/validatable_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,4 +1,6 @@ # encoding: UTF-8 +# frozen_string_literal: true + require 'test_helper' class ValidatableTest < ActiveSupport::TestCase @@ -31,7 +33,7 @@ %w{invalid_email_format 123 $$$ () ☃}.each do |email| user.email = email - assert user.invalid?, 'should be invalid with email ' << email + assert user.invalid?, "should be invalid with email #{email}" assert_equal 'is invalid', user.errors[:email].join end @@ -42,7 +44,7 @@ test 'should accept valid emails' do %w(a.b.c@example.com test_mail@gmail.com any@any.net email@test.br 123@mail.test 1☃3@mail.test).each do |email| user = new_user(email: email) - assert user.valid?, 'should be valid with email ' << email + assert user.valid?, "should be valid with email #{email}" assert_blank user.errors[:email] end end diff -Nru ruby-devise-4.3.0/test/models_test.rb ruby-devise-4.4.3/test/models_test.rb --- ruby-devise-4.3.0/test/models_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/models_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require 'test_models' diff -Nru ruby-devise-4.3.0/test/omniauth/config_test.rb ruby-devise-4.4.3/test/omniauth/config_test.rb --- ruby-devise-4.3.0/test/omniauth/config_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/omniauth/config_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class OmniAuthConfigTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/omniauth/url_helpers_test.rb ruby-devise-4.4.3/test/omniauth/url_helpers_test.rb --- ruby-devise-4.3.0/test/omniauth/url_helpers_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/omniauth/url_helpers_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class OmniAuthRoutesTest < ActionController::TestCase diff -Nru ruby-devise-4.3.0/test/orm/active_record.rb ruby-devise-4.4.3/test/orm/active_record.rb --- ruby-devise-4.3.0/test/orm/active_record.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/orm/active_record.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,8 +1,15 @@ +# frozen_string_literal: true + ActiveRecord::Migration.verbose = false ActiveRecord::Base.logger = Logger.new(nil) ActiveRecord::Base.include_root_in_json = true -ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__)) +migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__) +if Devise::Test.rails52? + ActiveRecord::MigrationContext.new(migrate_path).migrate +else + ActiveRecord::Migrator.migrate(migrate_path) +end class ActiveSupport::TestCase if Devise::Test.rails5? diff -Nru ruby-devise-4.3.0/test/orm/mongoid.rb ruby-devise-4.4.3/test/orm/mongoid.rb --- ruby-devise-4.3.0/test/orm/mongoid.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/orm/mongoid.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'mongoid/version' Mongoid.configure do |config| @@ -8,6 +10,6 @@ class ActiveSupport::TestCase setup do - Mongoid.purge! + Mongoid.default_session.drop end end diff -Nru ruby-devise-4.3.0/test/parameter_sanitizer_test.rb ruby-devise-4.4.3/test/parameter_sanitizer_test.rb --- ruby-devise-4.3.0/test/parameter_sanitizer_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/parameter_sanitizer_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' require 'devise/parameter_sanitizer' diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/admin.rb ruby-devise-4.4.3/test/rails_app/app/active_record/admin.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/admin.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/admin.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_admin' class Admin < ActiveRecord::Base diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/shim.rb ruby-devise-4.4.3/test/rails_app/app/active_record/shim.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/shim.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/shim.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module Shim end diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/user_on_engine.rb ruby-devise-4.4.3/test/rails_app/app/active_record/user_on_engine.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/user_on_engine.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/user_on_engine.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_user_without_omniauth' class UserOnEngine < ActiveRecord::Base diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/user_on_main_app.rb ruby-devise-4.4.3/test/rails_app/app/active_record/user_on_main_app.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/user_on_main_app.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/user_on_main_app.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_user_without_omniauth' class UserOnMainApp < ActiveRecord::Base diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/user.rb ruby-devise-4.4.3/test/rails_app/app/active_record/user.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/user.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/user.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,7 +1,20 @@ +# frozen_string_literal: true + require 'shared_user' class User < ActiveRecord::Base include Shim include SharedUser include ActiveModel::Serializers::Xml if Devise::Test.rails5? + + validates :sign_in_count, presence: true + + cattr_accessor :validations_performed + + after_validation :after_validation_callback + + def after_validation_callback + # used to check in our test if the validations were called + @@validations_performed = true + end end diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/user_without_email.rb ruby-devise-4.4.3/test/rails_app/app/active_record/user_without_email.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/user_without_email.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/user_without_email.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "shared_user_without_email" class UserWithoutEmail < ActiveRecord::Base diff -Nru ruby-devise-4.3.0/test/rails_app/app/active_record/user_with_validations.rb ruby-devise-4.4.3/test/rails_app/app/active_record/user_with_validations.rb --- ruby-devise-4.3.0/test/rails_app/app/active_record/user_with_validations.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/active_record/user_with_validations.rb 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'shared_user' + +class UserWithValidations < ActiveRecord::Base + self.table_name = 'users' + include Shim + include SharedUser + + validates :email, presence: true +end + diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/admins/sessions_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/admins/sessions_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/admins/sessions_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/admins/sessions_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Admins::SessionsController < Devise::SessionsController def new flash[:special] = "Welcome to #{controller_path.inspect} controller!" diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/admins_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/admins_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/admins_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/admins_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AdminsController < ApplicationController before_action :authenticate_admin! diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/application_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/application_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/application_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/application_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/application_with_fake_engine.rb ruby-devise-4.4.3/test/rails_app/app/controllers/application_with_fake_engine.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/application_with_fake_engine.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/application_with_fake_engine.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationWithFakeEngine < ApplicationController private diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/custom/registrations_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/custom/registrations_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/custom/registrations_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/custom/registrations_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Custom::RegistrationsController < Devise::RegistrationsController def new super do |resource| diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/home_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/home_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/home_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/home_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class HomeController < ApplicationController def index end diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/publisher/registrations_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/publisher/registrations_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/publisher/registrations_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/publisher/registrations_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class Publisher::RegistrationsController < ApplicationController end diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/publisher/sessions_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/publisher/sessions_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/publisher/sessions_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/publisher/sessions_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class Publisher::SessionsController < ApplicationController end diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def facebook data = request.respond_to?(:get_header) ? request.get_header("omniauth.auth") : request.env["omniauth.auth"] diff -Nru ruby-devise-4.3.0/test/rails_app/app/controllers/users_controller.rb ruby-devise-4.4.3/test/rails_app/app/controllers/users_controller.rb --- ruby-devise-4.3.0/test/rails_app/app/controllers/users_controller.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/controllers/users_controller.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UsersController < ApplicationController prepend_before_action :current_user, only: :exhibit before_action :authenticate_user!, except: [:accept, :exhibit] diff -Nru ruby-devise-4.3.0/test/rails_app/app/helpers/application_helper.rb ruby-devise-4.4.3/test/rails_app/app/helpers/application_helper.rb --- ruby-devise-4.3.0/test/rails_app/app/helpers/application_helper.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/helpers/application_helper.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Methods added to this helper will be available to all templates in the application. module ApplicationHelper end diff -Nru ruby-devise-4.3.0/test/rails_app/app/mailers/users/from_proc_mailer.rb ruby-devise-4.4.3/test/rails_app/app/mailers/users/from_proc_mailer.rb --- ruby-devise-4.3.0/test/rails_app/app/mailers/users/from_proc_mailer.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mailers/users/from_proc_mailer.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Users::FromProcMailer < Devise::Mailer default from: proc { 'custom@example.com' } end diff -Nru ruby-devise-4.3.0/test/rails_app/app/mailers/users/mailer.rb ruby-devise-4.4.3/test/rails_app/app/mailers/users/mailer.rb --- ruby-devise-4.3.0/test/rails_app/app/mailers/users/mailer.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mailers/users/mailer.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Users::Mailer < Devise::Mailer default from: 'custom@example.com' end diff -Nru ruby-devise-4.3.0/test/rails_app/app/mailers/users/reply_to_mailer.rb ruby-devise-4.4.3/test/rails_app/app/mailers/users/reply_to_mailer.rb --- ruby-devise-4.3.0/test/rails_app/app/mailers/users/reply_to_mailer.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mailers/users/reply_to_mailer.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Users::ReplyToMailer < Devise::Mailer default from: 'custom@example.com' default reply_to: 'custom_reply_to@example.com' diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/admin.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/admin.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/admin.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/admin.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_admin' class Admin diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/shim.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/shim.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/shim.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/shim.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Shim extend ::ActiveSupport::Concern diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/user_on_engine.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/user_on_engine.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/user_on_engine.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/user_on_engine.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_user_without_omniauth' class UserOnEngine diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/user_on_main_app.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/user_on_main_app.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/user_on_main_app.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/user_on_main_app.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_user_without_omniauth' class UserOnMainApp diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/user.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/user.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/user.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/user.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_user' class User @@ -36,4 +38,13 @@ field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts field :unlock_token, type: String # Only if unlock strategy is :email or :both field :locked_at, type: Time + + cattr_accessor :validations_performed + + after_validation :after_validation_callback + + def after_validation_callback + # used to check in our test if the validations were called + @@validations_performed = true + end end diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/user_without_email.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/user_without_email.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/user_without_email.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/user_without_email.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "shared_user_without_email" class UserWithoutEmail diff -Nru ruby-devise-4.3.0/test/rails_app/app/mongoid/user_with_validations.rb ruby-devise-4.4.3/test/rails_app/app/mongoid/user_with_validations.rb --- ruby-devise-4.3.0/test/rails_app/app/mongoid/user_with_validations.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/app/mongoid/user_with_validations.rb 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require "shared_user" + +class UserWithValidations + include Mongoid::Document + include Shim + include SharedUser + + field :username, type: String + field :facebook_token, type: String + + ## Database authenticatable + field :email, type: String, default: "" + field :encrypted_password, type: String, default: "" + + ## Recoverable + field :reset_password_token, type: String + field :reset_password_sent_at, type: Time + + ## Rememberable + field :remember_created_at, type: Time + + ## Trackable + field :sign_in_count, type: Integer, default: 0 + field :current_sign_in_at, type: Time + field :last_sign_in_at, type: Time + field :current_sign_in_ip, type: String + field :last_sign_in_ip, type: String + + ## Lockable + field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts + field :unlock_token, type: String # Only if unlock strategy is :email or :both + field :locked_at, type: Time + + validates :email, presence: true +end diff -Nru ruby-devise-4.3.0/test/rails_app/config/application.rb ruby-devise-4.4.3/test/rails_app/config/application.rb --- ruby-devise-4.3.0/test/rails_app/config/application.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/application.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require File.expand_path('../boot', __FILE__) require "action_controller/railtie" @@ -31,8 +33,10 @@ # config.assets.enabled = false config.action_mailer.default_url_options = { host: "localhost", port: 3000 } - - if DEVISE_ORM == :active_record && (Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 2) + rails_version = Gem::Version.new(Rails.version) + if DEVISE_ORM == :active_record && + rails_version >= Gem::Version.new('4.2.0') && + rails_version < Gem::Version.new('5.1.0') config.active_record.raise_in_transactional_callbacks = true end diff -Nru ruby-devise-4.3.0/test/rails_app/config/boot.rb ruby-devise-4.4.3/test/rails_app/config/boot.rb --- ruby-devise-4.3.0/test/rails_app/config/boot.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/boot.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,10 +1,17 @@ +# frozen_string_literal: true + unless defined?(DEVISE_ORM) DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym end module Devise module Test - # Detection for minor differences between Rails 4 and 5, and 5.1 in tests. + # Detection for minor differences between Rails 4 and 5, 5.1, and 5.2 in tests. + + def self.rails52? + Rails.version.start_with? '5.2' + end + def self.rails51? Rails.version.start_with? '5.1' end diff -Nru ruby-devise-4.3.0/test/rails_app/config/environment.rb ruby-devise-4.4.3/test/rails_app/config/environment.rb --- ruby-devise-4.3.0/test/rails_app/config/environment.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/environment.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Load the rails application. require File.expand_path('../application', __FILE__) diff -Nru ruby-devise-4.3.0/test/rails_app/config/environments/development.rb ruby-devise-4.4.3/test/rails_app/config/environments/development.rb --- ruby-devise-4.3.0/test/rails_app/config/environments/development.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/environments/development.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RailsApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb. diff -Nru ruby-devise-4.3.0/test/rails_app/config/environments/production.rb ruby-devise-4.4.3/test/rails_app/config/environments/production.rb --- ruby-devise-4.3.0/test/rails_app/config/environments/production.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/environments/production.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RailsApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb. diff -Nru ruby-devise-4.3.0/test/rails_app/config/environments/test.rb ruby-devise-4.4.3/test/rails_app/config/environments/test.rb --- ruby-devise-4.3.0/test/rails_app/config/environments/test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/environments/test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RailsApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb. diff -Nru ruby-devise-4.3.0/test/rails_app/config/initializers/backtrace_silencers.rb ruby-devise-4.4.3/test/rails_app/config/initializers/backtrace_silencers.rb --- ruby-devise-4.3.0/test/rails_app/config/initializers/backtrace_silencers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/initializers/backtrace_silencers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff -Nru ruby-devise-4.3.0/test/rails_app/config/initializers/devise.rb ruby-devise-4.4.3/test/rails_app/config/initializers/devise.rb --- ruby-devise-4.3.0/test/rails_app/config/initializers/devise.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/initializers/devise.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "omniauth-facebook" require "omniauth-openid" diff -Nru ruby-devise-4.3.0/test/rails_app/config/initializers/inflections.rb ruby-devise-4.4.3/test/rails_app/config/initializers/inflections.rb --- ruby-devise-4.3.0/test/rails_app/config/initializers/inflections.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/initializers/inflections.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,2 +1,4 @@ +# frozen_string_literal: true + ActiveSupport::Inflector.inflections do |inflect| end diff -Nru ruby-devise-4.3.0/test/rails_app/config/initializers/secret_token.rb ruby-devise-4.4.3/test/rails_app/config/initializers/secret_token.rb --- ruby-devise-4.3.0/test/rails_app/config/initializers/secret_token.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/initializers/secret_token.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + config = Rails.application.config config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10' diff -Nru ruby-devise-4.3.0/test/rails_app/config/initializers/session_store.rb ruby-devise-4.4.3/test/rails_app/config/initializers/session_store.rb --- ruby-devise-4.3.0/test/rails_app/config/initializers/session_store.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/initializers/session_store.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1 +1,3 @@ +# frozen_string_literal: true + RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_session' diff -Nru ruby-devise-4.3.0/test/rails_app/config/routes.rb ruby-devise-4.4.3/test/rails_app/config/routes.rb --- ruby-devise-4.3.0/test/rails_app/config/routes.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/config/routes.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.routes.draw do # Resources for testing resources :users, only: [:index] do diff -Nru ruby-devise-4.3.0/test/rails_app/db/migrate/20100401102949_create_tables.rb ruby-devise-4.4.3/test/rails_app/db/migrate/20100401102949_create_tables.rb --- ruby-devise-4.3.0/test/rails_app/db/migrate/20100401102949_create_tables.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/db/migrate/20100401102949_create_tables.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + superclass = ActiveRecord::Migration # TODO: Inherit from the 5.0 Migration class directly when we drop support for Rails 4. superclass = ActiveRecord::Migration[5.0] if superclass.respond_to?(:[]) diff -Nru ruby-devise-4.3.0/test/rails_app/db/schema.rb ruby-devise-4.4.3/test/rails_app/db/schema.rb --- ruby-devise-4.3.0/test/rails_app/db/schema.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/db/schema.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,4 +1,6 @@ # encoding: UTF-8 +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. diff -Nru ruby-devise-4.3.0/test/rails_app/lib/shared_admin.rb ruby-devise-4.4.3/test/rails_app/lib/shared_admin.rb --- ruby-devise-4.3.0/test/rails_app/lib/shared_admin.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/lib/shared_admin.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SharedAdmin extend ActiveSupport::Concern diff -Nru ruby-devise-4.3.0/test/rails_app/lib/shared_user.rb ruby-devise-4.4.3/test/rails_app/lib/shared_user.rb --- ruby-devise-4.3.0/test/rails_app/lib/shared_user.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/lib/shared_user.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SharedUser extend ActiveSupport::Concern diff -Nru ruby-devise-4.3.0/test/rails_app/lib/shared_user_without_email.rb ruby-devise-4.4.3/test/rails_app/lib/shared_user_without_email.rb --- ruby-devise-4.3.0/test/rails_app/lib/shared_user_without_email.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/lib/shared_user_without_email.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SharedUserWithoutEmail extend ActiveSupport::Concern diff -Nru ruby-devise-4.3.0/test/rails_app/lib/shared_user_without_omniauth.rb ruby-devise-4.4.3/test/rails_app/lib/shared_user_without_omniauth.rb --- ruby-devise-4.3.0/test/rails_app/lib/shared_user_without_omniauth.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_app/lib/shared_user_without_omniauth.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SharedUserWithoutOmniauth extend ActiveSupport::Concern diff -Nru ruby-devise-4.3.0/test/rails_test.rb ruby-devise-4.4.3/test/rails_test.rb --- ruby-devise-4.3.0/test/rails_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/rails_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class RailsTest < ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/routes_test.rb ruby-devise-4.4.3/test/routes_test.rb --- ruby-devise-4.3.0/test/routes_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/routes_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' ExpectedRoutingError = MiniTest::Assertion diff -Nru ruby-devise-4.3.0/test/secret_key_finder_test.rb ruby-devise-4.4.3/test/secret_key_finder_test.rb --- ruby-devise-4.3.0/test/secret_key_finder_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-devise-4.4.3/test/secret_key_finder_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +require 'test_helper' + +class Rails52Credentials + def credentials + OpenStruct.new(secret_key_base: 'credentials') + end +end + +class Rails52Secrets + def credentials + OpenStruct.new(secret_key_base: nil) + end + + def secrets + OpenStruct.new(secret_key_base: 'secrets') + end +end + +class Rails52Config + def credentials + OpenStruct.new(secret_key_base: nil) + end + + def secrets + OpenStruct.new(secret_key_base: nil) + end + + def config + OpenStruct.new(secret_key_base: 'config') + end +end + +class Rails41Secrets + def secrets + OpenStruct.new(secret_key_base: 'secrets') + end + + def config + OpenStruct.new(secret_key_base: nil) + end +end + +class Rails41Config + def secrets + OpenStruct.new(secret_key_base: nil) + end + + def config + OpenStruct.new(secret_key_base: 'config') + end +end + +class Rails40Config + def config + OpenStruct.new(secret_key_base: 'config') + end +end + +class SecretKeyFinderTest < ActiveSupport::TestCase + test "rails 5.2 uses credentials when they're available" do + secret_key_finder = Devise::SecretKeyFinder.new(Rails52Credentials.new) + + assert_equal 'credentials', secret_key_finder.find + end + + test "rails 5.2 uses secrets when credentials are empty" do + secret_key_finder = Devise::SecretKeyFinder.new(Rails52Secrets.new) + + assert_equal 'secrets', secret_key_finder.find + end + + test "rails 5.2 uses config when secrets are empty" do + secret_key_finder = Devise::SecretKeyFinder.new(Rails52Config.new) + + assert_equal 'config', secret_key_finder.find + end + + test "rails 4.1 uses secrets" do + secret_key_finder = Devise::SecretKeyFinder.new(Rails41Secrets.new) + + assert_equal 'secrets', secret_key_finder.find + end + + test "rails 4.1 uses config when secrets are empty" do + secret_key_finder = Devise::SecretKeyFinder.new(Rails41Config.new) + + assert_equal 'config', secret_key_finder.find + end + + test "rails 4.0 uses config" do + secret_key_finder = Devise::SecretKeyFinder.new(Rails40Config.new) + + assert_equal 'config', secret_key_finder.find + end +end diff -Nru ruby-devise-4.3.0/test/support/action_controller/record_identifier.rb ruby-devise-4.4.3/test/support/action_controller/record_identifier.rb --- ruby-devise-4.3.0/test/support/action_controller/record_identifier.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/support/action_controller/record_identifier.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Since webrat uses ActionController::RecordIdentifier class that was moved to # ActionView namespace in Rails 4.1+ diff -Nru ruby-devise-4.3.0/test/support/assertions.rb ruby-devise-4.4.3/test/support/assertions.rb --- ruby-devise-4.3.0/test/support/assertions.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/support/assertions.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_support/test_case' class ActiveSupport::TestCase diff -Nru ruby-devise-4.3.0/test/support/helpers.rb ruby-devise-4.4.3/test/support/helpers.rb --- ruby-devise-4.3.0/test/support/helpers.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/support/helpers.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_support/test_case' class ActiveSupport::TestCase @@ -50,6 +52,10 @@ UserWithoutEmail.create!(valid_attributes(attributes)) end + def create_user_with_validations(attributes={}) + UserWithValidations.create!(valid_attributes(attributes)) + end + # Execute the block setting the given values and restoring old values after # the block is executed. def swap(object, new_values) diff -Nru ruby-devise-4.3.0/test/support/http_method_compatibility.rb ruby-devise-4.4.3/test/support/http_method_compatibility.rb --- ruby-devise-4.3.0/test/support/http_method_compatibility.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/support/http_method_compatibility.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Devise class IntegrationTest < ActionDispatch::IntegrationTest # %w( get post patch put head delete xml_http_request diff -Nru ruby-devise-4.3.0/test/support/integration.rb ruby-devise-4.4.3/test/support/integration.rb --- ruby-devise-4.3.0/test/support/integration.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/support/integration.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'action_dispatch/testing/integration' class ActionDispatch::IntegrationTest @@ -17,6 +19,7 @@ user.update_attribute(:confirmation_sent_at, options[:confirmation_sent_at]) if options[:confirmation_sent_at] user.confirm unless options[:confirm] == false user.lock_access! if options[:locked] == true + User.validations_performed = false user end end diff -Nru ruby-devise-4.3.0/test/support/webrat/integrations/rails.rb ruby-devise-4.4.3/test/support/webrat/integrations/rails.rb --- ruby-devise-4.3.0/test/support/webrat/integrations/rails.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/support/webrat/integrations/rails.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'webrat/core/elements/form' require 'action_dispatch/testing/integration' diff -Nru ruby-devise-4.3.0/test/test/controller_helpers_test.rb ruby-devise-4.4.3/test/test/controller_helpers_test.rb --- ruby-devise-4.3.0/test/test/controller_helpers_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/test/controller_helpers_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class TestControllerHelpersTest < Devise::ControllerTestCase @@ -98,6 +100,11 @@ assert_equal response.body, "You are being redirected." end + test "returns the content type of a failure app" do + get :index, params: { format: :xml } + assert response.content_type.include?('application/xml') + end + test "defined Warden after_authentication callback should not be called when sign_in is called" do begin Warden::Manager.after_authentication do |user, auth, opts| @@ -164,7 +171,7 @@ test "creates a new warden proxy if the request object has changed" do old_warden_proxy = warden - @request = if Devise::Test.rails51? + @request = if Devise::Test.rails51? || Devise::Test.rails52? ActionController::TestRequest.create(Class.new) # needs a "controller class" elsif Devise::Test.rails5? ActionController::TestRequest.create diff -Nru ruby-devise-4.3.0/test/test/integration_helpers_test.rb ruby-devise-4.4.3/test/test/integration_helpers_test.rb --- ruby-devise-4.3.0/test/test/integration_helpers_test.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/test/integration_helpers_test.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test_helper' class TestIntegrationsHelpersTest < Devise::IntegrationTest diff -Nru ruby-devise-4.3.0/test/test_helper.rb ruby-devise-4.4.3/test/test_helper.rb --- ruby-devise-4.3.0/test/test_helper.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/test_helper.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV["RAILS_ENV"] = "test" DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym diff -Nru ruby-devise-4.3.0/test/test_models.rb ruby-devise-4.4.3/test/test_models.rb --- ruby-devise-4.3.0/test/test_models.rb 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/test/test_models.rb 2018-03-21 15:11:01.000000000 +0000 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Configurable < User devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable, stretches: 15, pepper: 'abcdef', allow_unconfirmed_access_for: 5.days, diff -Nru ruby-devise-4.3.0/.travis.yml ruby-devise-4.4.3/.travis.yml --- ruby-devise-4.3.0/.travis.yml 2017-05-29 14:33:47.000000000 +0000 +++ ruby-devise-4.4.3/.travis.yml 2018-03-21 15:11:01.000000000 +0000 @@ -2,13 +2,15 @@ rvm: - 2.1.10 - - 2.2.7 - - 2.3.4 - - 2.4.1 + - 2.2.8 + - 2.3.5 + - 2.4.2 + - 2.5.0 - ruby-head gemfile: - Gemfile + - gemfiles/Gemfile.rails-5.2-rc1 - gemfiles/Gemfile.rails-5.0-stable - gemfiles/Gemfile.rails-4.2-stable - gemfiles/Gemfile.rails-4.1-stable @@ -17,7 +19,11 @@ exclude: - rvm: 2.1.10 gemfile: Gemfile - - rvm: 2.4.1 + - rvm: 2.1.10 + gemfile: gemfiles/Gemfile.rails-5.2-rc1 + - rvm: 2.5.0 + gemfile: gemfiles/Gemfile.rails-4.1-stable + - rvm: 2.4.2 gemfile: gemfiles/Gemfile.rails-4.1-stable - rvm: ruby-head gemfile: gemfiles/Gemfile.rails-4.1-stable @@ -29,6 +35,8 @@ gemfile: Gemfile - env: DEVISE_ORM=mongoid gemfile: gemfiles/Gemfile.rails-5.0-stable + - env: DEVISE_ORM=mongoid + gemfile: gemfiles/Gemfile.rails-5.2-rc1 allow_failures: - rvm: ruby-head services: @@ -43,7 +51,9 @@ - DEVISE_ORM=active_record - DEVISE_ORM=mongoid -before_install: "rm ${BUNDLE_GEMFILE}.lock" +before_install: + - "rm ${BUNDLE_GEMFILE}.lock" + - gem update --system before_script: "bundle update"