diff options
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/milestone_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/oauth_registration_spec.rb | 175 |
2 files changed, 100 insertions, 81 deletions
diff --git a/spec/features/milestone_spec.rb b/spec/features/milestone_spec.rb index 3aaffad314e..98d623902a5 100644 --- a/spec/features/milestone_spec.rb +++ b/spec/features/milestone_spec.rb @@ -28,6 +28,12 @@ RSpec.describe 'Milestone' do expect(find('[data-testid="no-issues-alert"]')).to have_content('Assign some issues to this milestone.') expect(page).to have_content('Nov 16, 2016–Dec 16, 2016') end + + it 'passes redirect_path through to form' do + visit new_project_milestone_path(project, redirect_path: 'new_release') + + expect(find('#redirect_path', visible: :all)[:value]).to eq('new_release') + end end describe 'Open a milestone with closed issues' do diff --git a/spec/features/oauth_registration_spec.rb b/spec/features/oauth_registration_spec.rb index cb8343b8065..0a35b5a7e42 100644 --- a/spec/features/oauth_registration_spec.rb +++ b/spec/features/oauth_registration_spec.rb @@ -3,126 +3,139 @@ require 'spec_helper' RSpec.describe 'OAuth Registration', :js, :allow_forgery_protection do - include DeviseHelpers include LoginHelpers include TermsHelper using RSpec::Parameterized::TableSyntax + let(:uid) { 'my-uid' } + let(:email) { 'user@example.com' } + around do |example| with_omniauth_full_host { example.run } end - context 'when the user registers using single-sign on provider' do - let(:uid) { 'my-uid' } - let(:email) { 'user@example.com' } - - where(:provider, :additional_info) do - :github | {} - :twitter | {} - :bitbucket | {} - :gitlab | {} - :google_oauth2 | {} - :facebook | {} - :cas3 | {} - :auth0 | {} - :authentiq | {} - :salesforce | { extra: { email_verified: true } } - :dingtalk | {} - :alicloud | {} + where(:provider, :additional_info) do + :github | {} + :twitter | {} + :bitbucket | {} + :gitlab | {} + :google_oauth2 | {} + :facebook | {} + :cas3 | {} + :auth0 | {} + :authentiq | {} + :salesforce | { extra: { email_verified: true } } + :dingtalk | {} + :alicloud | {} + end + + with_them do + before do + stub_omniauth_provider(provider) + stub_feature_flags(update_oauth_registration_flow: true) end - with_them do + context 'when block_auto_created_users is true' do before do - stub_omniauth_provider(provider) - stub_feature_flags(update_oauth_registration_flow: true) + stub_omniauth_setting(block_auto_created_users: true) end - context 'when block_auto_created_users is true' do - before do - stub_omniauth_setting(block_auto_created_users: true) - end + it 'redirects back to the sign-in page' do + register_via(provider, uid, email, additional_info: additional_info) - it 'redirects back to the sign-in page' do - register_via(provider, uid, email, additional_info: additional_info) + expect(page).to have_current_path new_user_session_path + expect(page).to have_content('Your account is pending approval') + end + end - expect(page).to have_current_path new_user_session_path - expect(page).to have_content('Your account is pending approval') - end + context 'when block_auto_created_users is false' do + before do + stub_omniauth_setting(block_auto_created_users: false) + end + + it 'redirects to the initial welcome path' do + register_via(provider, uid, email, additional_info: additional_info) + + expect(page).to have_current_path users_sign_up_welcome_path + expect(page).to have_content('Welcome to GitLab, mockuser!') end - context 'when block_auto_created_users is false' do + context 'when terms are enforced' do before do - stub_omniauth_setting(block_auto_created_users: false) + enforce_terms end - it 'redirects to the initial welcome path' do + it 'auto accepts terms and redirects to the initial welcome path' do register_via(provider, uid, email, additional_info: additional_info) expect(page).to have_current_path users_sign_up_welcome_path expect(page).to have_content('Welcome to GitLab, mockuser!') end + end - context 'when terms are enforced' do - before do - enforce_terms - end + context 'when provider does not send a verified email address' do + let(:email) { 'temp-email-for-oauth@email.com' } - it 'auto accepts terms and redirects to the initial welcome path' do - register_via(provider, uid, email, additional_info: additional_info) + it 'redirects to the profile path' do + register_via(provider, uid, email, additional_info: additional_info) - expect(page).to have_current_path users_sign_up_welcome_path - expect(page).to have_content('Welcome to GitLab, mockuser!') - end + expect(page).to have_current_path profile_path + expect(page).to have_content('Please complete your profile with email address') end + end - context 'when provider does not send a verified email address' do - let(:email) { 'temp-email-for-oauth@email.com' } + context 'when registering via an invitation email' do + let_it_be(:owner) { create(:user) } + let_it_be(:group) { create(:group, name: 'Owned') } + let_it_be(:project) { create(:project, :repository, namespace: group) } + + let(:invite_email) { generate(:email) } + let(:extra_params) { { invite_type: Emails::Members::INITIAL_INVITE } } + let(:group_invite) do + create( + :group_member, :invited, + group: group, + invite_email: invite_email, + created_by: owner + ) + end - it 'redirects to the profile path' do - register_via(provider, uid, email, additional_info: additional_info) + before do + project.add_maintainer(owner) + group.add_owner(owner) + group_invite.generate_invite_token! - expect(page).to have_current_path profile_path - expect(page).to have_content('Please complete your profile with email address') - end + mock_auth_hash(provider, uid, invite_email, additional_info: additional_info) end - context 'when registering via an invitation email' do - let_it_be(:owner) { create(:user) } - let_it_be(:group) { create(:group, name: 'Owned') } - let_it_be(:project) { create(:project, :repository, namespace: group) } - - let(:invite_email) { generate(:email) } - let(:extra_params) { { invite_type: Emails::Members::INITIAL_INVITE } } - let(:group_invite) do - create( - :group_member, :invited, - group: group, - invite_email: invite_email, - created_by: owner - ) - end - - before do - project.add_maintainer(owner) - group.add_owner(owner) - group_invite.generate_invite_token! - - mock_auth_hash(provider, uid, invite_email, additional_info: additional_info) - end - - it 'redirects to the activity page with all the projects/groups invitations accepted' do - visit invite_path(group_invite.raw_invite_token, extra_params) - click_link_or_button "oauth-login-#{provider}" - fill_in_welcome_form - - expect(page).to have_content('You have been granted Owner access to group Owned.') - expect(page).to have_current_path(activity_group_path(group), ignore_query: true) - end + it 'redirects to the activity page with all the projects/groups invitations accepted' do + visit invite_path(group_invite.raw_invite_token, extra_params) + click_link_or_button "oauth-login-#{provider}" + fill_in_welcome_form + + expect(page).to have_content('You have been granted Owner access to group Owned.') + expect(page).to have_current_path(activity_group_path(group), ignore_query: true) end end end end + context 'when update_oauth_registration_flow is disabled' do + before do + stub_omniauth_provider(:github) + stub_omniauth_setting(block_auto_created_users: false) + stub_feature_flags(update_oauth_registration_flow: false) + + enforce_terms + end + + it 'presents the terms page' do + register_via(:github, uid, email) + + expect(page).to have_content('These are the terms') + end + end + def fill_in_welcome_form select 'Software Developer', from: 'user_role' click_button 'Get started!' |