2016-04-18 02:49:11 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Signup' do
|
2016-04-18 02:49:11 -04:00
|
|
|
describe 'signup with no errors' do
|
2016-05-06 16:59:45 -04:00
|
|
|
context "when sending confirmation email" do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
stub_application_setting(send_user_confirmation_email: true)
|
|
|
|
end
|
2016-05-06 16:59:45 -04:00
|
|
|
|
|
|
|
it 'creates the user account and sends a confirmation email' do
|
|
|
|
user = build(:user)
|
2016-04-18 02:49:11 -04:00
|
|
|
|
2016-05-06 16:59:45 -04:00
|
|
|
visit root_path
|
2016-04-18 02:49:11 -04:00
|
|
|
|
2016-11-11 19:47:32 -05:00
|
|
|
fill_in 'new_user_name', with: user.name
|
|
|
|
fill_in 'new_user_username', with: user.username
|
|
|
|
fill_in 'new_user_email', with: user.email
|
|
|
|
fill_in 'new_user_email_confirmation', with: user.email
|
|
|
|
fill_in 'new_user_password', with: user.password
|
2016-09-09 08:21:00 -04:00
|
|
|
click_button "Register"
|
2016-04-18 02:49:11 -04:00
|
|
|
|
2016-05-06 16:59:45 -04:00
|
|
|
expect(current_path).to eq users_almost_there_path
|
|
|
|
expect(page).to have_content("Please check your email to confirm your account")
|
|
|
|
end
|
2016-04-18 02:49:11 -04:00
|
|
|
end
|
2016-05-06 16:59:45 -04:00
|
|
|
|
2017-09-30 19:33:12 -04:00
|
|
|
context "when sigining up with different cased emails" do
|
|
|
|
it "creates the user successfully" do
|
|
|
|
user = build(:user)
|
|
|
|
|
|
|
|
visit root_path
|
|
|
|
|
|
|
|
fill_in 'new_user_name', with: user.name
|
|
|
|
fill_in 'new_user_username', with: user.username
|
|
|
|
fill_in 'new_user_email', with: user.email
|
|
|
|
fill_in 'new_user_email_confirmation', with: user.email.capitalize
|
|
|
|
fill_in 'new_user_password', with: user.password
|
|
|
|
click_button "Register"
|
|
|
|
|
|
|
|
expect(current_path).to eq dashboard_projects_path
|
|
|
|
expect(page).to have_content("Welcome! You have signed up successfully.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-06 16:59:45 -04:00
|
|
|
context "when not sending confirmation email" do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
stub_application_setting(send_user_confirmation_email: false)
|
|
|
|
end
|
2016-05-06 16:59:45 -04:00
|
|
|
|
|
|
|
it 'creates the user account and goes to dashboard' do
|
|
|
|
user = build(:user)
|
|
|
|
|
|
|
|
visit root_path
|
|
|
|
|
2016-11-11 19:47:32 -05:00
|
|
|
fill_in 'new_user_name', with: user.name
|
|
|
|
fill_in 'new_user_username', with: user.username
|
|
|
|
fill_in 'new_user_email', with: user.email
|
|
|
|
fill_in 'new_user_email_confirmation', with: user.email
|
|
|
|
fill_in 'new_user_password', with: user.password
|
2016-09-09 08:21:00 -04:00
|
|
|
click_button "Register"
|
2016-05-06 16:59:45 -04:00
|
|
|
|
|
|
|
expect(current_path).to eq dashboard_projects_path
|
|
|
|
expect(page).to have_content("Welcome! You have signed up successfully.")
|
|
|
|
end
|
|
|
|
end
|
2016-04-18 02:49:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'signup with errors' do
|
|
|
|
it "displays the errors" do
|
|
|
|
existing_user = create(:user)
|
|
|
|
user = build(:user)
|
|
|
|
|
|
|
|
visit root_path
|
|
|
|
|
2016-04-19 16:00:45 -04:00
|
|
|
fill_in 'new_user_name', with: user.name
|
|
|
|
fill_in 'new_user_username', with: user.username
|
|
|
|
fill_in 'new_user_email', with: existing_user.email
|
|
|
|
fill_in 'new_user_password', with: user.password
|
2016-09-09 08:21:00 -04:00
|
|
|
click_button "Register"
|
2016-04-18 02:49:11 -04:00
|
|
|
|
|
|
|
expect(current_path).to eq user_registration_path
|
2016-11-11 19:47:32 -05:00
|
|
|
expect(page).to have_content("errors prohibited this user from being saved")
|
2016-04-18 02:49:11 -04:00
|
|
|
expect(page).to have_content("Email has already been taken")
|
2016-11-11 19:47:32 -05:00
|
|
|
expect(page).to have_content("Email confirmation doesn't match")
|
2016-04-18 02:49:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not redisplay the password' do
|
|
|
|
existing_user = create(:user)
|
|
|
|
user = build(:user)
|
|
|
|
|
|
|
|
visit root_path
|
|
|
|
|
2016-04-19 16:00:45 -04:00
|
|
|
fill_in 'new_user_name', with: user.name
|
|
|
|
fill_in 'new_user_username', with: user.username
|
|
|
|
fill_in 'new_user_email', with: existing_user.email
|
|
|
|
fill_in 'new_user_password', with: user.password
|
2016-09-09 08:21:00 -04:00
|
|
|
click_button "Register"
|
2016-04-18 02:49:11 -04:00
|
|
|
|
|
|
|
expect(current_path).to eq user_registration_path
|
|
|
|
expect(page.body).not_to match(/#{user.password}/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|