debian-mirror-gitlab/spec/features/groups/members/request_access_spec.rb

81 lines
2.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Groups > Members > Request access' do
let(:user) { create(:user) }
let(:owner) { create(:user) }
2019-12-21 20:55:43 +05:30
let(:group) { create(:group, :public) }
2016-08-24 12:49:21 +05:30
let!(:project) { create(:project, :private, namespace: group) }
2018-11-08 19:23:39 +05:30
before do
group.add_owner(owner)
2017-09-10 17:25:29 +05:30
sign_in(user)
visit group_path(group)
end
2018-11-08 19:23:39 +05:30
it 'request access feature is disabled' do
2021-04-29 21:17:54 +05:30
group.update!(request_access_enabled: false)
2016-08-24 12:49:21 +05:30
visit group_path(group)
expect(page).not_to have_content 'Request Access'
end
2018-11-08 19:23:39 +05:30
it 'user can request access to a group' do
perform_enqueued_jobs { click_link 'Request Access' }
2021-11-11 11:23:49 +05:30
expect(ActionMailer::Base.deliveries.last.to).to eq [owner.notification_email_or_default]
expect(ActionMailer::Base.deliveries.last.subject).to match "Request to join the #{group.name} group"
2016-08-24 12:49:21 +05:30
expect(group.requesters.exists?(user_id: user)).to be_truthy
expect(page).to have_content 'Your request for access has been queued for review.'
expect(page).to have_content 'Withdraw Access Request'
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content 'Leave group'
2016-08-24 12:49:21 +05:30
end
2018-11-08 19:23:39 +05:30
it 'user does not see private projects' do
2016-08-24 12:49:21 +05:30
perform_enqueued_jobs { click_link 'Request Access' }
expect(page).not_to have_content project.name
end
2018-11-08 19:23:39 +05:30
it 'user does not see group in the Dashboard > Groups page' do
2016-08-24 12:49:21 +05:30
perform_enqueued_jobs { click_link 'Request Access' }
visit dashboard_groups_path
expect(page).not_to have_content group.name
end
2018-11-08 19:23:39 +05:30
it 'user is not listed in the group members page' do
click_link 'Request Access'
2016-08-24 12:49:21 +05:30
expect(group.requesters.exists?(user_id: user)).to be_truthy
2018-03-17 18:26:18 +05:30
first(:link, 'Members').click
page.within('.content') do
expect(page).not_to have_content(user.name)
end
end
2018-11-08 19:23:39 +05:30
it 'user can withdraw its request for access' do
click_link 'Request Access'
2016-08-24 12:49:21 +05:30
expect(group.requesters.exists?(user_id: user)).to be_truthy
click_link 'Withdraw Access Request'
2016-08-24 12:49:21 +05:30
expect(group.requesters.exists?(user_id: user)).to be_falsey
expect(page).to have_content 'Your access request to the group has been withdrawn.'
end
2017-09-10 17:25:29 +05:30
2018-11-08 19:23:39 +05:30
it 'member does not see the request access button' do
2017-09-10 17:25:29 +05:30
group.add_owner(user)
visit group_path(group)
expect(page).not_to have_content 'Request Access'
end
end