mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 05:43:16 +08:00
Merge pull request #1381 from einarj/test_nickname_hub_registration_failure
Added test case for nickname registration failure
This commit is contained in:
commit
f87ba0d88f
|
@ -167,7 +167,7 @@ class UsersController < ApplicationController
|
|||
if user.save
|
||||
activator = UserActivator.new(user, session, cookies)
|
||||
message = activator.activation_message
|
||||
create_third_party_auth_records(user, auth) if auth.present?
|
||||
create_third_party_auth_records(user, auth)
|
||||
|
||||
# Clear authentication session.
|
||||
session[:authentication] = nil
|
||||
|
@ -408,6 +408,8 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def create_third_party_auth_records(user, auth)
|
||||
return unless auth.present?
|
||||
|
||||
if twitter_auth?(auth)
|
||||
TwitterUserInfo.create(
|
||||
user_id: user.id,
|
||||
|
|
|
@ -490,6 +490,21 @@ describe UsersController do
|
|||
include_examples 'failed signup'
|
||||
end
|
||||
|
||||
context 'when nickname is unavailable in DiscourseHub' do
|
||||
before do
|
||||
SiteSetting.stubs(:call_discourse_hub?).returns(true)
|
||||
DiscourseHub.stubs(:register_nickname).raises(DiscourseHub::NicknameUnavailable)
|
||||
end
|
||||
let(:create_params) {{
|
||||
name: @user.name,
|
||||
username: @user.username,
|
||||
password: 'strongpassword',
|
||||
email: @user.email
|
||||
}}
|
||||
|
||||
include_examples 'failed signup'
|
||||
end
|
||||
|
||||
context 'when an Exception is raised' do
|
||||
|
||||
[ ActiveRecord::StatementInvalid,
|
||||
|
|
Loading…
Reference in New Issue
Block a user