Skip to content
Snippets Groups Projects
Commit a2bc870b authored by Doug Stull's avatar Doug Stull :two:
Browse files

Merge branch '424709-increase-sign-up-helper-use' into 'master'

Improve use of sign up helper in feature specs

See merge request !132138



Merged-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Approved-by: default avatarJay Montal <jmontal@gitlab.com>
Approved-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Reviewed-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Reviewed-by: default avatarJay Montal <jmontal@gitlab.com>
Co-authored-by: default avatarRoss Byrne <robyrne@gitlab.com>
parents ccbf2911 20f9fe8a
No related branches found
No related tags found
1 merge request!132138Improve use of sign up helper in feature specs
Pipeline #1011645842 passed
......@@ -5,9 +5,8 @@
RSpec.describe 'GitLab.com Google Analytics DataLayer', :js, feature_category: :application_instrumentation do
include JavascriptFormHelper
let!(:google_tag_manager_id) { 'GTM-WWKMTWS' }
let!(:user_attrs) { attributes_for(:user, first_name: 'GitLab', last_name: 'GitLab', company_name: 'GitLab', phone_number: '555-555-5555') }
let(:google_tag_manager_id) { 'GTM-WWKMTWS' }
let(:new_user) { build(:user) }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
......@@ -25,13 +24,7 @@
prevent_submit_for('#new_new_user')
fill_in 'new_user_first_name', with: user_attrs[:first_name]
fill_in 'new_user_last_name', with: user_attrs[:last_name]
fill_in 'new_user_username', with: user_attrs[:username]
fill_in 'new_user_email', with: user_attrs[:email]
fill_in 'new_user_password', with: user_attrs[:password]
click_button 'Continue'
fill_in_sign_up_form(new_user, 'Continue')
data_layer = execute_script('return window.dataLayer')
last_event_in_data_layer = data_layer[-1]
......@@ -48,13 +41,7 @@
prevent_submit_for('#new_new_user')
fill_in 'new_user_first_name', with: user_attrs[:first_name]
fill_in 'new_user_last_name', with: user_attrs[:last_name]
fill_in 'new_user_username', with: user_attrs[:username]
fill_in 'new_user_email', with: user_attrs[:email]
fill_in 'new_user_password', with: user_attrs[:password]
click_button 'Register'
fill_in_sign_up_form(new_user)
data_layer = execute_script('return window.dataLayer')
last_event_in_data_layer = data_layer[-1]
......
......@@ -24,7 +24,8 @@
end
context 'with a user cap set', :js do
let_it_be(:admin) { create(:user, :admin) }
let_it_be(:admin, freeze: true) { create(:user, :admin) }
let(:new_user) { build(:user) }
before do
stub_application_setting(require_admin_approval_after_user_signup: false)
......@@ -32,18 +33,12 @@
stub_application_setting(new_user_signups_cap: 3)
visit new_user_registration_path
fill_in 'new_user_username', with: 'bang'
fill_in 'new_user_email', with: 'bigbang@example.com'
fill_in 'new_user_first_name', with: 'Big'
fill_in 'new_user_last_name', with: 'Bang'
fill_in 'new_user_password', with: User.random_password
end
context 'when the cap has not been reached' do
before do
perform_enqueued_jobs do
click_button 'Register'
fill_in_sign_up_form(new_user)
end
end
......@@ -68,7 +63,7 @@
it 'sends notification email to the admin', :sidekiq_inline do
perform_enqueued_jobs do
click_button 'Register'
fill_in_sign_up_form(new_user)
end
cap_reached_notification_email = ActionMailer::Base.deliveries.find do |m|
......
......@@ -67,16 +67,6 @@
end
shared_examples 'signup process' do
def fill_in_signup_form
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
fill_in 'new_user_first_name', with: new_user.first_name
fill_in 'new_user_last_name', with: new_user.last_name
fill_in 'new_user_password', with: new_user.password
wait_for_all_requests
end
def confirm_email
new_user_token = User.find_by_email(new_user.email).confirmation_token
......@@ -226,9 +216,7 @@ def confirm_email
it 'creates the user account and sends a confirmation email, and pre-fills email address after confirming' do
visit new_user_registration_path
fill_in_signup_form
expect { click_button 'Register' }.to change { User.count }.by(1)
expect { fill_in_sign_up_form(new_user) }.to change { User.count }.by(1)
expect(page).to have_current_path users_almost_there_path, ignore_query: true
expect(page).to have_content("Please check your email (#{new_user.email}) to confirm your account")
......@@ -246,9 +234,7 @@ def confirm_email
it 'creates the user account and sends a confirmation email' do
visit new_user_registration_path
fill_in_signup_form
expect { click_button 'Register' }.to change { User.count }.by(1)
expect { fill_in_sign_up_form(new_user) }.to change { User.count }.by(1)
expect(page).to have_current_path dashboard_projects_path
end
end
......@@ -262,8 +248,7 @@ def confirm_email
it 'creates the user account and goes to dashboard' do
visit new_user_registration_path
fill_in_signup_form
click_button "Register"
fill_in_sign_up_form(new_user)
expect(page).to have_current_path dashboard_projects_path
end
......@@ -277,9 +262,7 @@ def confirm_email
it 'creates the user but does not sign them in' do
visit new_user_registration_path
fill_in_signup_form
expect { click_button 'Register' }.to change { User.count }.by(1)
expect { fill_in_sign_up_form(new_user) }.to change { User.count }.by(1)
expect(page).to have_current_path new_user_session_path, ignore_query: true
expect(page).to have_content(<<~TEXT.squish)
You have signed up successfully. However, we could not sign you in
......@@ -294,8 +277,7 @@ def confirm_email
create(:user, email: new_user.email)
visit new_user_registration_path
fill_in_signup_form
click_button "Register"
fill_in_sign_up_form(new_user)
expect(page).to have_current_path user_registration_path, ignore_query: true
expect(page).to have_content("error prohibited this user from being saved")
......@@ -306,8 +288,7 @@ def confirm_email
create(:user, email: new_user.email)
visit new_user_registration_path
fill_in_signup_form
click_button "Register"
fill_in_sign_up_form(new_user)
expect(page).to have_current_path user_registration_path, ignore_query: true
expect(page.body).not_to match(/#{new_user.password}/)
......@@ -328,8 +309,7 @@ def confirm_email
visit new_user_registration_path
expect(page).to have_content(terms_text)
fill_in_signup_form
click_button 'Register'
fill_in_sign_up_form(new_user)
expect(page).to have_current_path(dashboard_projects_path)
end
......@@ -357,9 +337,7 @@ def confirm_email
it 'prevents from signing up' do
visit new_user_registration_path
fill_in_signup_form
expect { click_button 'Register' }.not_to change { User.count }
expect { fill_in_sign_up_form(new_user) }.not_to change { User.count }
expect(page).to have_content(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
expect(page).to have_content(
"Minimum length is #{Gitlab::CurrentSettings.minimum_password_length} characters")
......@@ -370,9 +348,7 @@ def confirm_email
it 'prevents from signing up' do
visit new_user_registration_path
fill_in_signup_form
expect { click_button 'Register' }.not_to change { User.count }
expect { fill_in_sign_up_form(new_user) }.not_to change { User.count }
expect(page).to have_content('That was a bit too quick! Please resubmit.')
end
end
......@@ -381,9 +357,7 @@ def confirm_email
it 'allows visiting of a page after initial registration' do
visit new_user_registration_path
fill_in_signup_form
click_button 'Register'
fill_in_sign_up_form(new_user)
visit new_project_path
......@@ -394,8 +368,7 @@ def confirm_email
create(:user, email: new_user.email)
visit new_user_registration_path
fill_in_signup_form
click_button "Register"
fill_in_sign_up_form(new_user)
expect(page).to have_current_path user_registration_path, ignore_query: true
expect(page.body).not_to match(/#{new_user.password}/)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment