group_members_spec.rb 2.91 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Projects members' do
4
  let(:user) { create(:user) }
5 6
  let(:developer) { create(:user) }
  let(:group) { create(:group, :public, :access_requestable) }
7
  let(:project) { create(:project, :public, :access_requestable, creator: user, group: group) }
8 9 10 11
  let(:project_invitee) { create(:project_member, project: project, invite_token: '123', invite_email: 'test1@abc.com', user: nil) }
  let(:group_invitee) { create(:group_member, group: group, invite_token: '123', invite_email: 'test2@abc.com', user: nil) }
  let(:project_requester) { create(:user) }
  let(:group_requester) { create(:user) }
12

13
  before do
14
    project.add_developer(developer)
15
    group.add_owner(user)
16
    sign_in(user)
17 18
  end

19 20 21
  context 'with a group invitee' do
    before do
      group_invitee
22
      visit project_settings_members_path(project)
23 24
    end

25
    it 'does not appear in the project members page' do
26 27 28 29 30 31 32 33 34 35
      page.within first('.content-list') do
        expect(page).not_to have_content('test2@abc.com')
      end
    end
  end

  context 'with a group and a project invitee' do
    before do
      group_invitee
      project_invitee
36
      visit project_settings_members_path(project)
37 38
    end

39
    it 'shows the project invitee, the project developer, and the group owner' do
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
      page.within first('.content-list') do
        expect(page).to have_content('test1@abc.com')
        expect(page).not_to have_content('test2@abc.com')

        # Project developer
        expect(page).to have_content(developer.name)

        # Group owner
        expect(page).to have_content(user.name)
        expect(page).to have_content(group.name)
      end
    end
  end

  context 'with a group requester' do
    before do
      group.request_access(group_requester)
57
      visit project_settings_members_path(project)
58 59
    end

60
    it 'does not appear in the project members page' do
61 62 63 64 65 66 67 68 69 70
      page.within first('.content-list') do
        expect(page).not_to have_content(group_requester.name)
      end
    end
  end

  context 'with a group and a project requesters' do
    before do
      group.request_access(group_requester)
      project.request_access(project_requester)
71
      visit project_settings_members_path(project)
72 73
    end

74
    it 'shows the project requester, the project developer, and the group owner' do
75 76 77 78 79 80 81 82
      page.within first('.content-list') do
        expect(page).to have_content(project_requester.name)
        expect(page).not_to have_content(group_requester.name)
      end

      page.within all('.content-list').last do
        # Project developer
        expect(page).to have_content(developer.name)
83

84 85 86 87
        # Group owner
        expect(page).to have_content(user.name)
        expect(page).to have_content(group.name)
      end
88 89
    end
  end
90 91 92 93 94 95 96 97

  describe 'showing status of members' do
    it_behaves_like 'showing user status' do
      let(:user_with_status) { developer }

      subject { visit project_settings_members_path(project) }
    end
  end
98
end