Skip to content

Commit

Permalink
OAuth status fix (#4618)
Browse files Browse the repository at this point in the history
* started with test

* fix status on creation

* Update user.rb

* Update user_test.rb

* Update user.rb
  • Loading branch information
jywarren authored and grvsachdeva committed Jan 15, 2019
1 parent 4fa3343 commit 3e6ce6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def self.create_with_omniauth(auth)
user.username = email_prefix
user.email = auth["info"]["email"]
user.password = s
user.status = 1
user.password_confirmation = s
user.password_checker = hash[auth["provider"]]
user.save!
Expand Down
26 changes: 26 additions & 0 deletions test/unit/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ class UserTest < ActiveSupport::TestCase
assert_equal user.tagnames, user.tagnames
end

test 'user creation with create_with_omniauth' do
auth = {
'info' => {
'email' => '[email protected]' # there should not already be a username like this
},
'provider' => 'github'
}
user = User.create_with_omniauth(auth)
assert_equal 1, user.status
assert_equal 'bobafett', user.username
assert_equal 2, user.password_checker
end

test 'user with duplicate username creation with create_with_omniauth' do
auth = {
'info' => {
'email' => '[email protected]' # there should already be a bob user
},
'provider' => 'facebook'
}
user = User.create_with_omniauth(auth)
assert_equal 1, user.status
assert_not_equal 'bob', user.username
assert_equal 1, user.password_checker
end

test 'user mysql native fulltext search' do
assert User.count > 0
if ActiveRecord::Base.connection.adapter_name == 'Mysql2'
Expand Down

0 comments on commit 3e6ce6b

Please sign in to comment.