owner_manages_access_requests_spec.rb 1.46 KB
Newer Older
1 2 3 4 5
require 'spec_helper'

feature 'Groups > Members > Owner manages access requests', feature: true do
  let(:user) { create(:user) }
  let(:owner) { create(:user) }
6
  let(:group) { create(:group, :public, :access_requestable) }
7 8 9 10

  background do
    group.request_access(user)
    group.add_owner(owner)
11
    gitlab_sign_in(owner)
12 13 14 15 16 17 18 19
  end

  scenario 'owner can see access requests' do
    visit group_group_members_path(group)

    expect_visible_access_request(group, user)
  end

20
  scenario 'owner can grant access' do
21 22 23 24
    visit group_group_members_path(group)

    expect_visible_access_request(group, user)

25
    perform_enqueued_jobs { click_on 'Grant access' }
26 27

    expect(ActionMailer::Base.deliveries.last.to).to eq [user.notification_email]
28
    expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was granted"
29 30
  end

31
  scenario 'owner can deny access' do
32 33 34 35
    visit group_group_members_path(group)

    expect_visible_access_request(group, user)

36
    perform_enqueued_jobs { click_on 'Deny access' }
37 38

    expect(ActionMailer::Base.deliveries.last.to).to eq [user.notification_email]
39
    expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was denied"
40 41 42
  end

  def expect_visible_access_request(group, user)
43
    expect(group.requesters.exists?(user_id: user)).to be_truthy
Phil Hughes's avatar
Phil Hughes committed
44
    expect(page).to have_content "Users requesting access to #{group.name} 1"
45 46 47
    expect(page).to have_content user.name
  end
end