diff options
Diffstat (limited to 'spec/features/users_spec.rb')
-rw-r--r-- | spec/features/users_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 93d2b18b5fc..a4c3dfe9205 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -27,4 +27,25 @@ feature 'Users' do user.reload expect(user.reset_password_token).to be_nil end + + let!(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') } + scenario 'Should show one error if email is already taken' do + visit new_user_session_path + fill_in 'user_name', with: 'Another user name' + fill_in 'user_username', with: 'anotheruser' + fill_in 'user_email', with: user.email + fill_in 'user_password_sign_up', with: '12341234' + expect { click_button 'Sign up' }.to change { User.count }.by(0) + expect(page).to have_text('Email has already been taken') + expect(number_of_errors_on_page(page)).to be(1), 'errors on page:\n #{errors_on_page page}' + end + + def errors_on_page(page) + page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n") + end + + def number_of_errors_on_page(page) + page.find('#error_explanation').find('ul').all('li').count + end + end |