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

79 lines
2.2 KiB
Ruby
Raw Normal View History

require 'spec_helper'
2018-11-08 19:23:39 +05:30
describe 'Groups > Members > Request access' do
let(:user) { create(:user) }
let(:owner) { create(:user) }
2017-08-17 22:00:37 +05:30
let(:group) { create(:group, :public, :access_requestable) }
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
2016-08-24 12:49:21 +05:30
group.update_attributes(request_access_enabled: false)
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' }
expect(ActionMailer::Base.deliveries.last.to).to eq [owner.notification_email]
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