Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into serialize-updated…
Browse files Browse the repository at this point in the history
…_at-without-to-s

* upstream/master:
  Add docs for confirmation endpoint (lynndylanhurley#1365)
  Remove Trackable option from generator (lynndylanhurley#1362)
  Add rails 6.0 config to travis (lynndylanhurley#1366)
  Fix missing polish and portugese translation errors (lynndylanhurley#1377)
  chore(docs): write complete path for authentication_test_spec (lynndylanhurley#1376)
  Add case sensitive option required to prevent deprecation warning in rails 6 (lynndylanhurley#1368)
  • Loading branch information
briandunn committed Jan 31, 2020
2 parents 71da864 + 55fcd11 commit a52a88f
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 58 deletions.
91 changes: 51 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ rvm:
- 2.4.7
- 2.5.6
- 2.6.4
- 2.7.0

gemfile:
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile

env:
global:
Expand All @@ -28,51 +30,60 @@ env:

matrix:
include:
- rvm: 2.3.8
gemfile: gemfiles/rails_4_2_mongoid_5.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.3.8
gemfile: gemfiles/rails_5_1_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.4.7
gemfile: gemfiles/rails_5_1_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.6.4
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- name: Code Climate Test Coverage
rmv: 2.5.6
env:
- CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d
- GEMFILE_AR=gemfiles/rails_5_1.gemfile
- GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile
script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# with ActiveRecord
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json
# with Mongoid
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID
- BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json
# merge test results
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
- rvm: 2.3.8
gemfile: gemfiles/rails_4_2_mongoid_5.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.3.8
gemfile: gemfiles/rails_5_1_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.4.7
gemfile: gemfiles/rails_5_1_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.6.4
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.7.0
gemfile: gemfiles/rails_6_0_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- name: Code Climate Test Coverage
rvm: 2.5.6
env:
- CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d
- GEMFILE_AR=gemfiles/rails_5_1.gemfile
- GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile
script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# with ActiveRecord
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json
# with Mongoid
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID
- BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json
# merge test results
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
./cc-test-reporter sum-coverage coverage/codeclimate.active_record.json coverage/codeclimate.mongoid.json;
./cc-test-reporter upload-coverage;
fi
fi
exclude:
- rvm: 2.6.4
gemfile: gemfiles/rails_4_2.gemfile
- rvm: 2.7.0
gemfile: gemfiles/rails_4_2.gemfile
- rvm: 2.3.8
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.7
gemfile: gemfiles/rails_6_0.gemfile
fast_finish: true

before_install:
Expand Down
3 changes: 2 additions & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ end
{ name: '5-1', ruby: '2.4.5', rails: '5.1', mongoid: '7.0' },
{ name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '6.4' },
{ name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '7.0' },
{ name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' }
{ name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' },
{ name: '6-0', ruby: '2.7.0', rails: '6.0', mongoid: '7.0' }
].each do |set|
appraise "rails-#{set[:name]}-mongoid-#{set[:mongoid][0]}" do
gem 'rails', "~> #{set[:rails]}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
validates_presence_of :uid, unless: :email_provider?

# only validate unique emails among email registration users
validates :email, uniqueness: { scope: :provider }, on: :create, if: :email_provider?
validates :email, uniqueness: { case_sensitive: false, scope: :provider }, on: :create, if: :email_provider?

# keep uid in sync with email
before_save :sync_uid
Expand Down
7 changes: 4 additions & 3 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ pl:
missing_passwords: "Musisz wypełnić wszystkie pola z etykietą 'Hasło' oraz 'Potwierdzenie hasła'."
successfully_updated: "Twoje hasło zostało zaktualizowane."
errors:
validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
not_email: "nie jest prawidłowym adresem e-mail"
messages:
validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
not_email: "nie jest prawidłowym adresem e-mail"
devise:
mailer:
confirmation_instructions:
Expand Down
7 changes: 4 additions & 3 deletions config/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ pt:
missing_passwords: "Preencha a senha e a confirmação de senha."
successfully_updated: "Senha atualizada com sucesso."
errors:
validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
not_email: "não é um e-mail"
messages:
validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
not_email: "não é um e-mail"
devise:
mailer:
confirmation_instructions:
Expand Down
1 change: 1 addition & 0 deletions docs/usage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ The following routes are available for use by your client. These routes live rel
| /password | POST | Use this route to send a password reset confirmation email to users that registered by email. Accepts **`email`** and **`redirect_url`** as params. The user matching the `email` param will be sent instructions on how to reset their password. `redirect_url` is the url to which the user will be redirected after visiting the link contained in the email. |
| /password | PUT | Use this route to change users' passwords. Requires **`password`** and **`password_confirmation`** as params. This route is only valid for users that registered by email (OAuth2 users will receive an error). It also checks **`current_password`** if **`config.check_current_password_before_update`** is not set `false` (disabled by default). |
| /password/edit | GET | Verify user by password reset token. This route is the destination URL for password reset confirmation. This route must contain **`reset_password_token`** and **`redirect_url`** params. These values will be set automatically by the confirmation email that is generated by the password reset request. |
| /confirmation | POST | Re-sends confirmation email. Requires **`email`** and accepts **`redirect_url`** params (this last one can be omitted if you have set `config.default_confirm_success_url` in `config/initializers/devise_token_auth.rb`). |
3 changes: 2 additions & 1 deletion docs/usage/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Check #75 if you have any problem or doubt.
Below are some generic examples which may assist in helping you devise (pun intended) your own tests:

```ruby
# I've called it authentication_test_spec.rb and placed it in the spec/requests folder
# spec/requests/authentication_test_spec.rb

require 'rails_helper'
include ActionController::RespondWith

Expand Down
45 changes: 45 additions & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0"
gem "sqlite3", "~> 1.4.1"
gem "mysql2"
gem "pg"

group :development, :test do
gem "attr_encrypted"
gem "figaro", git: "https://github.com/laserlemon/figaro"
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
gem "factory_bot_rails"
gem "faker"
gem "fuzz_ball"
gem "guard"
gem "guard-minitest"
gem "minitest"
gem "minitest-focus"
gem "minitest-rails"
gem "minitest-reporters"
gem "mocha", ">= 1.5"
gem "pry"
gem "pry-byebug"
gem "pry-remote"
gem "rubocop", require: false
end

group :test do
gem "rails-controller-testing"
gem "simplecov", require: false
end

group :development do
gem "github_changelog_generator"
end

gemspec path: "../"
44 changes: 44 additions & 0 deletions gemfiles/rails_6_0_mongoid_7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0"
gem "mongoid", "~> 7.0"
gem "mongoid-locker", "~> 1.0"

group :development, :test do
gem "attr_encrypted"
gem "figaro", git: "https://github.com/laserlemon/figaro"
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem "omniauth-apple"
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
gem "factory_bot_rails"
gem "faker"
gem "fuzz_ball"
gem "guard"
gem "guard-minitest"
gem "minitest"
gem "minitest-focus"
gem "minitest-rails"
gem "minitest-reporters"
gem "mocha", ">= 1.5"
gem "pry"
gem "pry-byebug"
gem "pry-remote"
gem "rubocop", require: false
end

group :test do
gem "rails-controller-testing"
gem "simplecov", require: false
end

group :development do
gem "github_changelog_generator"
end

gemspec path: "../"
6 changes: 3 additions & 3 deletions lib/generators/devise_token_auth/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ def database_version
ActiveRecord::Base.connection.select_value('SELECT VERSION()')
end

def rails5?
Rails.version.start_with? '5'
def rails_5_or_newer?
Rails::VERSION::MAJOR >= 5
end

def primary_key_type
primary_key_string if rails5?
primary_key_string if rails_5_or_newer?
end

def primary_key_string
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/devise_token_auth/install_mongoid_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def create_user_model
field :tokens, type: Hash, default: {}
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
:recoverable, :rememberable, :validatable
include DeviseTokenAuth::Concerns::User
index({ uid: 1, provider: 1}, { name: 'uid_provider_index', unique: true, background: true })
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/devise_token_auth/templates/user.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class <%= user_class %> < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
:recoverable, :rememberable, :validatable
include DeviseTokenAuth::Concerns::User
end
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class <%= user_class %>
field :tokens, type: Hash, default: {}

# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
:recoverable, :rememberable, :validatable
include DeviseTokenAuth::Concerns::User

index({ email: 1 }, { name: 'email_index', unique: true, background: true })
Expand Down

0 comments on commit a52a88f

Please sign in to comment.