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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-18 21:10:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-18 21:10:54 +0300
commit042cd704b8177e7997af4a2ca90967d3178ccc3f (patch)
tree06fec320acf76fbb87df66810cd75fe4e7f2357c /spec/features/invites_spec.rb
parent346c2ebb5a818524c5d8d95dc6b9fc8c892e3b5c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/invites_spec.rb')
-rw-r--r--spec/features/invites_spec.rb202
1 files changed, 116 insertions, 86 deletions
diff --git a/spec/features/invites_spec.rb b/spec/features/invites_spec.rb
index fd6718ddb9b..a72cf033d61 100644
--- a/spec/features/invites_spec.rb
+++ b/spec/features/invites_spec.rb
@@ -7,15 +7,12 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do
let_it_be(:group) { create(:group, name: 'Owned') }
let_it_be(:project) { create(:project, :repository, namespace: group) }
- let(:user) { create(:user, email: 'user@example.com') }
let(:group_invite) { group.group_members.invite.last }
before do
stub_application_setting(require_admin_approval_after_user_signup: false)
project.add_maintainer(owner)
group.add_owner(owner)
- group.add_developer('user@example.com', owner)
- group_invite.generate_invite_token!
end
def confirm_email(new_user)
@@ -45,45 +42,128 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do
click_button 'Get started!'
end
- context 'when signed out' do
+ context 'when inviting a registered user' do
+ let(:invite_email) { 'user@example.com' }
+
before do
- visit invite_path(group_invite.raw_invite_token)
+ group.add_developer(invite_email, owner)
+ group_invite.generate_invite_token!
end
- it 'renders sign up page with sign up notice' do
- expect(current_path).to eq(new_user_registration_path)
- expect(page).to have_content('To accept this invitation, create an account or sign in')
- end
+ context 'when signed out' do
+ context 'when analyzing the redirects and forms from invite link click' do
+ before do
+ visit invite_path(group_invite.raw_invite_token)
+ end
- it 'pre-fills the "Username or email" field on the sign in box with the invite_email from the invite' do
- click_link 'Sign in'
+ it 'renders sign up page with sign up notice' do
+ expect(current_path).to eq(new_user_registration_path)
+ expect(page).to have_content('To accept this invitation, create an account or sign in')
+ end
- expect(find_field('Username or email').value).to eq(group_invite.invite_email)
- end
+ it 'pre-fills the "Username or email" field on the sign in box with the invite_email from the invite' do
+ click_link 'Sign in'
- 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)
- end
+ expect(find_field('Username or email').value).to eq(group_invite.invite_email)
+ end
- it 'sign in, grants access and redirects to group activity page' do
- click_link 'Sign in'
+ 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)
+ end
+ end
- fill_in_sign_in_form(user)
+ context 'when invite is sent before account is created - ldap or social sign in for manual acceptance edge case' do
+ let(:user) { create(:user, email: 'user@example.com') }
- expect(current_path).to eq(activity_group_path(group))
- end
- end
+ context 'when invite clicked and not signed in' do
+ before do
+ visit invite_path(group_invite.raw_invite_token)
+ end
- context 'when signed in as an existing member' do
- before do
- sign_in(owner)
- end
+ it 'sign in, grants access and redirects to group activity page' do
+ click_link 'Sign in'
- it 'shows message user already a member' do
- visit invite_path(group_invite.raw_invite_token)
+ fill_in_sign_in_form(user)
- expect(page).to have_link(owner.name, href: user_url(owner))
- expect(page).to have_content('However, you are already a member of this group.')
+ expect(current_path).to eq(activity_group_path(group))
+ end
+ end
+
+ context 'when signed in and an invite link is clicked' do
+ context 'when an invite email is a secondary email for the user' do
+ let(:invite_email) { 'user_secondary@example.com' }
+
+ before do
+ sign_in(user)
+ visit invite_path(group_invite.raw_invite_token)
+ end
+
+ it 'sends user to the invite url and allows them to decline' do
+ expect(current_path).to eq(invite_path(group_invite.raw_invite_token))
+ expect(page).to have_content("Note that this invitation was sent to #{invite_email}")
+ expect(page).to have_content("but you are signed in as #{user.to_reference} with email #{user.email}")
+
+ click_link('Decline')
+
+ expect(page).to have_content('You have declined the invitation')
+ expect(current_path).to eq(dashboard_projects_path)
+ expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
+ end
+
+ it 'sends uer to the invite url and allows them to accept' do
+ expect(current_path).to eq(invite_path(group_invite.raw_invite_token))
+ expect(page).to have_content("Note that this invitation was sent to #{invite_email}")
+ expect(page).to have_content("but you are signed in as #{user.to_reference} with email #{user.email}")
+
+ click_link('Accept invitation')
+
+ expect(page).to have_content('You have been granted')
+ expect(current_path).to eq(activity_group_path(group))
+ end
+ end
+
+ context 'when user is an existing member' do
+ before do
+ sign_in(owner)
+ visit invite_path(group_invite.raw_invite_token)
+ end
+
+ it 'shows message user already a member' do
+ expect(current_path).to eq(invite_path(group_invite.raw_invite_token))
+ expect(page).to have_link(owner.name, href: user_url(owner))
+ expect(page).to have_content('However, you are already a member of this group.')
+ end
+ end
+ end
+
+ context 'when declining the invitation from invitation reminder email' do
+ context 'when signed in' do
+ before do
+ sign_in(user)
+ visit decline_invite_path(group_invite.raw_invite_token)
+ end
+
+ it 'declines application and redirects to dashboard' do
+ expect(current_path).to eq(dashboard_projects_path)
+ expect(page).to have_content('You have declined the invitation to join group Owned.')
+ expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
+ end
+ end
+
+ context 'when signed out with signup onboarding' do
+ before do
+ visit decline_invite_path(group_invite.raw_invite_token)
+ end
+
+ it 'declines application and redirects to sign in page' do
+ expect(current_path).to eq(decline_invite_path(group_invite.raw_invite_token))
+ expect(page).not_to have_content('You have declined the invitation to join')
+ expect(page).to have_content('You successfully declined the invitation')
+ expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
+ end
+ end
+ end
+ end
end
end
@@ -243,63 +323,13 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do
end
end
- context 'when declining the invitation' do
- context 'as an existing user' do
- let(:group_invite) { create(:group_member, user: user, group: group, created_by: owner) }
-
- context 'when signed in' do
- before do
- sign_in(user)
- visit decline_invite_path(group_invite.raw_invite_token)
- end
-
- it 'declines application and redirects to dashboard' do
- expect(current_path).to eq(dashboard_projects_path)
- expect(page).to have_content('You have declined the invitation to join group Owned.')
- expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
- end
- end
-
- context 'when signed out' do
- before do
- visit decline_invite_path(group_invite.raw_invite_token)
- end
-
- it 'declines application and redirects to sign in page' do
- expect(current_path).to eq(new_user_session_path)
- expect(page).to have_content('You have declined the invitation to join group Owned.')
- expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
- end
- end
- end
-
- context 'as a non-existing user' do
- before do
- visit decline_invite_path(group_invite.raw_invite_token)
- end
-
- it 'declines application and shows a decline page' do
- expect(current_path).to eq(decline_invite_path(group_invite.raw_invite_token))
- expect(page).to have_content('You successfully declined the invitation')
- expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
- end
- end
- end
-
- context 'when accepting the invitation as an existing user' do
- before do
- sign_in(user)
- visit invite_path(group_invite.raw_invite_token)
- end
-
- it 'grants access and redirects to the group activity page' do
- expect(group.users.include?(user)).to be false
-
- page.click_link 'Accept invitation'
+ context 'when declining the invitation from invitation reminder email' do
+ it 'declines application and shows a decline page' do
+ visit decline_invite_path(group_invite.raw_invite_token)
- expect(current_path).to eq(activity_group_path(group))
- expect(page).to have_content('You have been granted Owner access to group Owned.')
- expect(group.users.include?(user)).to be true
+ expect(current_path).to eq(decline_invite_path(group_invite.raw_invite_token))
+ expect(page).to have_content('You successfully declined the invitation')
+ expect { group_invite.reload }.to raise_error ActiveRecord::RecordNotFound
end
end
end