2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-18 12:53:32 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Groups > Members > Request access' do
|
2016-04-18 12:53:32 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:owner) { create(:user) }
|
2016-11-11 07:51:50 -05:00
|
|
|
let(:group) { create(:group, :public, :access_requestable) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project, :private, namespace: group) }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2016-04-18 12:53:32 -04:00
|
|
|
group.add_owner(owner)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-07-20 06:34:29 -04:00
|
|
|
visit group_path(group)
|
2016-07-15 17:46:29 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'request access feature is disabled' do
|
2018-07-02 06:43:06 -04:00
|
|
|
group.update(request_access_enabled: false)
|
2016-07-15 17:46:29 -04:00
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
expect(page).not_to have_content 'Request Access'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can request access to a group' do
|
2016-06-02 12:05:06 -04:00
|
|
|
perform_enqueued_jobs { click_link 'Request Access' }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to).to eq [owner.notification_email]
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to match "Request to join the #{group.name} group"
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
expect(page).to have_content 'Your request for access has been queued for review.'
|
2016-06-02 12:05:06 -04:00
|
|
|
|
|
|
|
expect(page).to have_content 'Withdraw Access Request'
|
2016-11-19 10:40:41 -05:00
|
|
|
expect(page).not_to have_content 'Leave group'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user does not see private projects' do
|
2016-06-24 06:01:48 -04:00
|
|
|
perform_enqueued_jobs { click_link 'Request Access' }
|
|
|
|
|
|
|
|
expect(page).not_to have_content project.name
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user does not see group in the Dashboard > Groups page' do
|
2016-06-24 06:01:48 -04:00
|
|
|
perform_enqueued_jobs { click_link 'Request Access' }
|
|
|
|
|
|
|
|
visit dashboard_groups_path
|
|
|
|
|
|
|
|
expect(page).not_to have_content group.name
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user is not listed in the group members page' do
|
2016-04-18 12:53:32 -04:00
|
|
|
click_link 'Request Access'
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2017-09-01 03:41:31 -04:00
|
|
|
first(:link, 'Members').click
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
page.within('.content') do
|
|
|
|
expect(page).not_to have_content(user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can withdraw its request for access' do
|
2016-04-18 12:53:32 -04:00
|
|
|
click_link 'Request Access'
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
click_link 'Withdraw Access Request'
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_falsey
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(page).to have_content 'Your access request to the group has been withdrawn.'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
2017-06-26 10:33:49 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'member does not see the request access button' do
|
2017-06-26 10:33:49 -04:00
|
|
|
group.add_owner(user)
|
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
expect(page).not_to have_content 'Request Access'
|
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|