diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /spec/features/invites_spec.rb | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'spec/features/invites_spec.rb')
-rw-r--r-- | spec/features/invites_spec.rb | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/spec/features/invites_spec.rb b/spec/features/invites_spec.rb index 3954de56eea..8a4c4cc1eca 100644 --- a/spec/features/invites_spec.rb +++ b/spec/features/invites_spec.rb @@ -81,10 +81,10 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do end end - context 'when inviting a user using their email address' do + context 'when inviting a user' do let(:new_user) { build_stubbed(:user) } let(:invite_email) { new_user.email } - let(:group_invite) { create(:group_member, :invited, group: group, invite_email: invite_email) } + let(:group_invite) { create(:group_member, :invited, group: group, invite_email: invite_email, created_by: owner) } let!(:project_invite) { create(:project_member, :invited, project: project, invite_email: invite_email) } context 'when user has not signed in yet' do @@ -210,30 +210,43 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do context 'when declining the invitation' do let(:send_email_confirmation) { true } - context 'when signed in' do - before do - sign_in(user) - visit invite_path(group_invite.raw_invite_token) + 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 - it 'declines application and redirects to dashboard' do - page.click_link 'Decline' + context 'when signed out' do + before do + visit decline_invite_path(group_invite.raw_invite_token) + end - 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 + 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 'when signed out' do + context 'as a non-existing user' 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.') + 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 |