FIX: Don't suggest invalid username

This commit is contained in:
Gerhard Schlager
2016-02-21 23:11:52 +01:00
parent dedbb59321
commit c4ec1d0fcf
2 changed files with 18 additions and 2 deletions

View File

@@ -93,6 +93,15 @@ describe UserNameSuggester do
it 'should handle typical facebook usernames' do
expect(UserNameSuggester.suggest('roger.nelson.3344913')).to eq('roger.nelson.33')
end
it 'removes underscore at the end of long usernames that get truncated' do
expect(UserNameSuggester.suggest('uuuuuuuuuuuuuu_u')).to_not end_with('_')
end
it "adds number if it's too short after removing trailing underscore" do
User.stubs(:username_length).returns(8..8)
expect(UserNameSuggester.suggest('uuuuuuu_u')).to eq('uuuuuuu1')
end
end
end