diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-08 14:26:04 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-08 16:06:56 -0400 |
commit | 57afaf9d92eb7d34d51d89ba7af350531f2e0fde (patch) | |
tree | 0e69c9cb977704a499805fea2b736c4d6876e44d /spec | |
parent | e86e1013709735be5bb767e2b228930c543f25ae (diff) | |
download | gitlab-ce-57afaf9d92eb7d34d51d89ba7af350531f2e0fde.tar.gz |
Upon successful login, clear `reset_password_token` field
Closes #1942
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/users_spec.rb | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 21a3a4bf937..4cfaab03caf 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,14 +1,37 @@ require 'spec_helper' -describe 'Users', feature: true do - describe "GET /users/sign_in" do - it "should create a new user account" do - visit new_user_session_path - fill_in "user_name", with: "Name Surname" - fill_in "user_username", with: "Great" - fill_in "user_email", with: "name@mail.com" - fill_in "user_password_sign_up", with: "password1234" - expect { click_button "Sign up" }.to change { User.count }.by(1) - end +feature 'Users' do + around do |ex| + old_url_options = Rails.application.routes.default_url_options + Rails.application.routes.default_url_options = { host: 'example.foo' } + ex.run + Rails.application.routes.default_url_options = old_url_options + end + + scenario 'GET /users/sign_in creates a new user account' do + visit new_user_session_path + fill_in 'user_name', with: 'Name Surname' + fill_in 'user_username', with: 'Great' + fill_in 'user_email', with: 'name@mail.com' + fill_in 'user_password_sign_up', with: 'password1234' + expect { click_button 'Sign up' }.to change { User.count }.by(1) + end + + scenario 'Successful user signin invalidates password reset token' do + user = create(:user) + 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 + + user.reload + expect(user.reset_password_token).to be_nil end end |