Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/invites_spec.rb')
-rw-r--r--spec/features/invites_spec.rb111
1 files changed, 32 insertions, 79 deletions
diff --git a/spec/features/invites_spec.rb b/spec/features/invites_spec.rb
index bc6efb63f6f..04ac94685cf 100644
--- a/spec/features/invites_spec.rb
+++ b/spec/features/invites_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_category: :acquisition do
let_it_be(:owner) { create(:user, name: 'John Doe') }
- # private will ensure we really have access to the group when we land on the activity page
+ # private will ensure we really have access to the group when we land on the group page
let_it_be(:group) { create(:group, :private, name: 'Owned') }
let_it_be(:project) { create(:project, :repository, namespace: group) }
@@ -17,17 +17,6 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
group.add_owner(owner)
end
- def confirm_email(new_user)
- new_user_token = User.find_by_email(new_user.email).confirmation_token
-
- visit user_confirmation_path(confirmation_token: new_user_token)
- end
-
- def fill_in_welcome_form
- select 'Software Developer', from: 'user_role'
- click_button 'Get started!'
- end
-
context 'when inviting a registered user' do
let(:invite_email) { 'user@example.com' }
@@ -53,8 +42,8 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
expect(find_field('Username or primary email').value).to eq(group_invite.invite_email)
end
- it 'pre-fills the Email field on the sign up box with the invite_email from the invite' do
- expect(find_field('Email').value).to eq(group_invite.invite_email)
+ it 'shows the Email to be the invite_email from the invite' do
+ expect(find_by_testid('invite-email').text).to eq(group_invite.invite_email)
end
end
@@ -66,12 +55,12 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
visit invite_path(group_invite.raw_invite_token, invite_type: Emails::Members::INITIAL_INVITE)
end
- it 'sign in, grants access and redirects to group activity page' do
+ it 'sign in, grants access and redirects to group page' do
click_link 'Sign in'
gitlab_sign_in(user, remember: true, visit: false)
- expect_to_be_on_group_activity_page(group)
+ expect_to_be_on_group_page(group)
end
end
@@ -132,8 +121,8 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
end
end
- def expect_to_be_on_group_activity_page(group)
- expect(page).to have_current_path(activity_group_path(group))
+ def expect_to_be_on_group_page(group)
+ expect(page).to have_current_path(group_path(group))
end
end
end
@@ -160,7 +149,7 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
end
it 'does not sign the user in' do
- fill_in_sign_up_form(new_user)
+ fill_in_sign_up_form(new_user, invite: true)
expect(page).to have_current_path(new_user_session_path, ignore_query: true)
sign_up_message = 'You have signed up successfully. However, we could not sign you in because your account ' \
@@ -175,23 +164,13 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
end
context 'when the user signs up for an account with the invitation email address' do
- it 'redirects to the most recent membership activity page with all invitations automatically accepted' do
- fill_in_sign_up_form(new_user)
+ it 'redirects to the most recent membership group page with all invitations automatically accepted' do
+ fill_in_sign_up_form(new_user, invite: true)
- expect(page).to have_current_path(activity_group_path(group), ignore_query: true)
+ expect(page).to have_current_path(group_path(group), ignore_query: true)
expect(page).to have_content('You have been granted Owner access to group Owned.')
end
end
-
- context 'when the user sign-up using a different email address' do
- let(:invite_email) { build_stubbed(:user).email }
-
- it 'signs up and redirects to the projects dashboard' do
- fill_in_sign_up_form(new_user)
-
- expect_to_be_on_projects_dashboard_with_zero_authorized_projects
- end
- end
end
context 'with email confirmation enabled' do
@@ -199,16 +178,16 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
let(:new_user) { build_stubbed(:user, password: '11111111') }
it 'fails sign up and redirects back to sign up', :aggregate_failures do
- expect { fill_in_sign_up_form(new_user) }.not_to change { User.count }
+ expect { fill_in_sign_up_form(new_user, invite: true) }.not_to change { User.count }
expect(page).to have_content('prohibited this user from being saved')
expect(page).to have_current_path(user_registration_path, ignore_query: true)
- expect(find_field('Email').value).to eq(group_invite.invite_email)
+ expect(find_by_testid('invite-email').text).to eq(group_invite.invite_email)
end
end
context 'with invite email acceptance', :snowplow do
it 'tracks the accepted invite' do
- fill_in_sign_up_form(new_user)
+ fill_in_sign_up_form(new_user, invite: true)
expect_snowplow_event(
category: 'RegistrationsController',
@@ -221,51 +200,25 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
end
context 'when the user signs up for an account with the invitation email address' do
- it 'redirects to the most recent membership activity page with all invitations automatically accepted' do
- fill_in_sign_up_form(new_user)
+ it 'redirects to the most recent membership group page with all invitations automatically accepted' do
+ fill_in_sign_up_form(new_user, invite: true)
- expect(page).to have_current_path(activity_group_path(group), ignore_query: true)
+ expect(page).to have_current_path(group_path(group), ignore_query: true)
end
end
+ end
- context 'when the user signs up using a different email address' do
- let(:invite_email) { build_stubbed(:user).email }
-
- context 'when email confirmation is not set to `soft`' do
- before do
- allow(User).to receive(:allow_unconfirmed_access_for).and_return 0
- stub_feature_flags(identity_verification: false)
- end
-
- it 'signs up and redirects to the projects dashboard' do
- fill_in_sign_up_form(new_user)
- confirm_email(new_user)
- gitlab_sign_in(new_user, remember: true, visit: false)
-
- expect_to_be_on_projects_dashboard_with_zero_authorized_projects
- end
- end
-
- context 'when email confirmation setting is set to `soft`' do
- before do
- stub_application_setting_enum('email_confirmation_setting', 'soft')
- allow(User).to receive(:allow_unconfirmed_access_for).and_return 2.days
- end
-
- it 'signs up and redirects to the projects dashboard' do
- fill_in_sign_up_form(new_user)
-
- expect_to_be_on_projects_dashboard_with_zero_authorized_projects
- end
- end
+ context 'when the email is already taken by a registered user' do
+ before do
+ create(:user, email: invite_email)
end
- end
- def expect_to_be_on_projects_dashboard_with_zero_authorized_projects
- expect(page).to have_current_path(dashboard_projects_path)
+ it 'shows error state of email already used' do
+ fill_in_sign_up_form(new_user, invite: true)
- expect(page).to have_content _('Welcome to GitLab')
- expect(page).to have_content _('Faster releases. Better code. Less pain.')
+ expect(page).to have_content('Email has already been taken')
+ expect(find_by_testid('invite-email').text).to eq(group_invite.invite_email)
+ end
end
end
@@ -275,9 +228,9 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
expect(page).to have_current_path(new_user_registration_path, ignore_query: true)
- fill_in_sign_up_form(new_user, 'Register')
+ fill_in_sign_up_form(new_user, 'Register', invite: true)
- expect(page).to have_current_path(activity_group_path(group))
+ expect(page).to have_current_path(group_path(group))
expect(page).to have_content('You have been granted Owner access to group Owned.')
end
end
@@ -301,16 +254,16 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate
gitlab_sign_in(user)
end
- it 'does not accept the pending invitation and does not redirect to the groups activity path' do
- expect(page).not_to have_current_path(activity_group_path(group), ignore_query: true)
+ it 'does not accept the pending invitation and does not redirect to the group path' do
+ expect(page).not_to have_current_path(group_path(group), ignore_query: true)
expect(group.reload.users).not_to include(user)
end
context 'when the secondary email address is confirmed' do
let(:secondary_email) { create(:email, :confirmed, user: user) }
- it 'accepts the pending invitation and redirects to the groups activity path' do
- expect(page).to have_current_path(activity_group_path(group), ignore_query: true)
+ it 'accepts the pending invitation and redirects to the group path' do
+ expect(page).to have_current_path(group_path(group), ignore_query: true)
expect(group.reload.users).to include(user)
end
end