Rename nickname to username in the code. Use new hub routes. (Old routes still exist as aliases for old Discourse instances.)

This commit is contained in:
Neil Lalonde
2014-03-12 12:39:27 -04:00
parent dc1d6decf5
commit 9ca516e58d
11 changed files with 104 additions and 104 deletions

View File

@@ -53,13 +53,13 @@ describe UserDestroyer do
it 'should unregister the nickname as the discourse hub if hub integration is enabled' do
SiteSetting.stubs(:call_discourse_hub?).returns(true)
DiscourseHub.expects(:unregister_nickname).with(@user.username)
DiscourseHub.expects(:unregister_username).with(@user.username)
destroy
end
it 'should not try to unregister the nickname as the discourse hub if hub integration is disabled' do
SiteSetting.stubs(:call_discourse_hub?).returns(false)
DiscourseHub.expects(:unregister_nickname).never
DiscourseHub.expects(:unregister_username).never
destroy
end
end
@@ -108,7 +108,7 @@ describe UserDestroyer do
end
it 'should not unregister the user at the discourse hub' do
DiscourseHub.expects(:unregister_nickname).never
DiscourseHub.expects(:unregister_username).never
destroy rescue nil
end
end
@@ -192,7 +192,7 @@ describe UserDestroyer do
end
it 'should not unregister the user at the discourse hub' do
DiscourseHub.expects(:unregister_nickname).never
DiscourseHub.expects(:unregister_username).never
destroy rescue nil
end
end

View File

@@ -38,30 +38,30 @@ describe UsernameCheckerService do
context 'username and email is given' do
it 'username is available locally but not globally' do
DiscourseHub.expects(:nickname_available?).never
DiscourseHub.expects(:nickname_match?).returns([false, false, 'porkchop'])
DiscourseHub.expects(:username_available?).never
DiscourseHub.expects(:username_match?).returns([false, false, 'porkchop'])
result = @service.check_username('vincent', @email)
expected = { available: false, global_match: false, suggestion: 'porkchop' }
expect(result).to eq(expected)
end
it 'username is available both locally and globally' do
DiscourseHub.expects(:nickname_available?).never
DiscourseHub.stubs(:nickname_match?).returns([true, true, nil])
DiscourseHub.expects(:username_available?).never
DiscourseHub.stubs(:username_match?).returns([true, true, nil])
result = @service.check_username('vincent', @email)
expected = { available: true, global_match: true }
expect(result).to eq(expected)
end
it 'username is available locally but not globally' do
DiscourseHub.stubs(:nickname_match?).returns([false, false, 'suggestion'])
DiscourseHub.stubs(:username_match?).returns([false, false, 'suggestion'])
result = @service.check_username('vincent', @email)
expected = { available: false, global_match: false, suggestion: 'suggestion' }
expect(result).to eq(expected)
end
it 'username is available globally but not locally' do
DiscourseHub.stubs(:nickname_match?).returns([false, true, nil])
DiscourseHub.stubs(:username_match?).returns([false, true, nil])
User.stubs(:username_available?).returns(false)
UserNameSuggester.stubs(:suggest).returns('einar-j')
expected = { available: false, suggestion: 'einar-j' }
@@ -70,7 +70,7 @@ describe UsernameCheckerService do
end
it 'username not available anywhere' do
DiscourseHub.stubs(:nickname_match?).returns([false, false, 'suggestion'])
DiscourseHub.stubs(:username_match?).returns([false, false, 'suggestion'])
expected = { available: false, suggestion: 'suggestion', global_match: false }
@nil_email = nil
result = @service.check_username('vincent', @email)
@@ -80,26 +80,26 @@ describe UsernameCheckerService do
shared_examples "only email is given" do
it "should call the correct api" do
DiscourseHub.expects(:nickname_available?).never
DiscourseHub.expects(:nickname_match?).never
DiscourseHub.stubs(:nickname_for_email).returns(nil)
DiscourseHub.expects(:username_available?).never
DiscourseHub.expects(:username_match?).never
DiscourseHub.stubs(:username_for_email).returns(nil)
result
end
it 'no match on email' do
DiscourseHub.stubs(:nickname_for_email).returns(nil)
DiscourseHub.stubs(:username_for_email).returns(nil)
result.should == {suggestion: nil}
end
it 'match found for email' do
DiscourseHub.stubs(:nickname_for_email).returns('vincent')
DiscourseHub.stubs(:username_for_email).returns('vincent')
result.should == {suggestion: 'vincent'}
end
it 'match found for email, but username is taken' do
# This case can happen when you've already signed up on the site,
# or enforce_global_nicknames used to be disabled.
DiscourseHub.stubs(:nickname_for_email).returns('taken')
DiscourseHub.stubs(:username_for_email).returns('taken')
User.stubs(:username_available?).with('taken').returns(false)
result.should == {suggestion: nil}
end