BigW Consortium Gitlab

master_manages_access_requests_spec.rb 1.63 KB
Newer Older
1 2 3 4 5
require 'spec_helper'

feature 'Projects > Members > Master manages access requests', feature: true do
  let(:user) { create(:user) }
  let(:master) { create(:user) }
6
  let(:project) { create(:empty_project, :public, :access_requestable) }
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

  background do
    project.request_access(user)
    project.team << [master, :master]
    login_as(master)
  end

  scenario 'master can see access requests' do
    visit namespace_project_project_members_path(project.namespace, project)

    expect_visible_access_request(project, user)
  end

  scenario 'master can grant access' do
    visit namespace_project_project_members_path(project.namespace, project)

    expect_visible_access_request(project, 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 #{project.name_with_namespace} project was granted"
29 30 31 32 33 34 35
  end

  scenario 'master can deny access' do
    visit namespace_project_project_members_path(project.namespace, project)

    expect_visible_access_request(project, 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 #{project.name_with_namespace} project was denied"
40 41 42
  end

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