2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
feature 'Users', feature: true do
|
2015-10-24 18:46:33 +05:30
|
|
|
let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') }
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
scenario 'GET /users/sign_in creates a new user account' do
|
|
|
|
visit new_user_session_path
|
2016-06-02 11:05:42 +05:30
|
|
|
fill_in 'new_user_name', with: 'Name Surname'
|
|
|
|
fill_in 'new_user_username', with: 'Great'
|
|
|
|
fill_in 'new_user_email', with: 'name@mail.com'
|
|
|
|
fill_in 'new_user_password', with: 'password1234'
|
2015-04-26 12:48:37 +05:30
|
|
|
expect { click_button 'Sign up' }.to change { User.count }.by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Successful user signin invalidates password reset token' do
|
|
|
|
expect(user.reset_password_token).to be_nil
|
|
|
|
|
|
|
|
visit new_user_password_path
|
|
|
|
fill_in 'user_email', with: user.email
|
|
|
|
click_button 'Reset password'
|
|
|
|
|
|
|
|
user.reload
|
|
|
|
expect(user.reset_password_token).not_to be_nil
|
|
|
|
|
|
|
|
login_with(user)
|
|
|
|
expect(current_path).to eq root_path
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
user.reload
|
|
|
|
expect(user.reset_password_token).to be_nil
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
|
|
|
scenario 'Should show one error if email is already taken' do
|
|
|
|
visit new_user_session_path
|
2016-06-02 11:05:42 +05:30
|
|
|
fill_in 'new_user_name', with: 'Another user name'
|
|
|
|
fill_in 'new_user_username', with: 'anotheruser'
|
|
|
|
fill_in 'new_user_email', with: user.email
|
|
|
|
fill_in 'new_user_password', with: '12341234'
|
2015-09-11 14:41:01 +05:30
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|