Added test case for nickname registration failure

* Also made a minor readability change by moving the auth.present? check
* from UsersController#create into #create_third_party_auth_records
* which is the method that relies on the check.
This commit is contained in:
Einar Jonsson
2013-08-25 20:18:07 +00:00
parent b32e87c929
commit 0d22a77c63
2 changed files with 18 additions and 1 deletions

View File

@ -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,