2016-06-16 23:09:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature 'Groups > Members > Manage access requests' do
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:owner) { create(:user) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:group) { create(:group, :public, :access_requestable) }
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
background do
|
|
|
|
group.request_access(user)
|
|
|
|
group.add_owner(owner)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(owner)
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'owner can see access requests' do
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect_visible_access_request(group, user)
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
scenario 'owner can grant access' do
|
2016-06-16 23:09:34 +05:30
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect_visible_access_request(group, user)
|
|
|
|
|
|
|
|
perform_enqueued_jobs { click_on 'Grant access' }
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to).to eq [user.notification_email]
|
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was granted"
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
scenario 'owner can deny access' do
|
2016-06-16 23:09:34 +05:30
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect_visible_access_request(group, user)
|
|
|
|
|
|
|
|
perform_enqueued_jobs { click_on 'Deny access' }
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to).to eq [user.notification_email]
|
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was denied"
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_visible_access_request(group, user)
|
2016-08-24 12:49:21 +05:30
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_truthy
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_content "Users requesting access to #{group.name} 1"
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
end
|