BigW Consortium Gitlab

team_management.rb 4.99 KB
Newer Older
1
class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
Nihad Abbasov committed
2 3 4
  include SharedAuthentication
  include SharedProject
  include SharedPaths
5
  include Select2Helper
Nihad Abbasov committed
6

7
  step 'I should be able to see myself in team' do
8 9
    expect(page).to have_content(@user.name)
    expect(page).to have_content(@user.username)
10 11
  end

12 13
  step 'I should see "Dmitriy" in team list' do
    user = User.find_by(name: "Dmitriy")
14 15
    expect(page).to have_content(user.name)
    expect(page).to have_content(user.username)
16 17
  end

18
  step 'I select "Mike" as "Reporter"' do
skv committed
19
    user = User.find_by(name: "Mike")
20

21
    page.within ".users-project-form" do
22
      select2(user.id, from: "#user_ids", multiple: true)
23
      select "Reporter", from: "access_level"
24
    end
25
    click_button "Add users to project"
26 27
  end

28
  step 'I should see "Mike" in team list as "Reporter"' do
29 30 31
    user = User.find_by(name: 'Mike')
    project_member = project.project_members.find_by(user_id: user.id)
    page.within "#project_member_#{project_member.id}" do
32
      expect(page).to have_content('Mike')
33
      expect(page).to have_content('Reporter')
34
    end
35 36
  end

37
  step 'I select "sjobs@apple.com" as "Reporter"' do
38
    page.within ".users-project-form" do
39 40 41 42 43 44 45
      select2("sjobs@apple.com", from: "#user_ids", multiple: true)
      select "Reporter", from: "access_level"
    end
    click_button "Add users to project"
  end

  step 'I should see "sjobs@apple.com" in team list as invited "Reporter"' do
46 47
    project_member = project.project_members.find_by(invite_email: 'sjobs@apple.com')
    page.within "#project_member_#{project_member.id}" do
48
      expect(page).to have_content('sjobs@apple.com')
49
      expect(page).to have_content('Invited')
50
      expect(page).to have_content('Reporter')
51 52 53
    end
  end

54
  step 'I should see "Dmitriy" in team list as "Developer"' do
55 56 57
    user = User.find_by(name: 'Dmitriy')
    project_member = project.project_members.find_by(user_id: user.id)
    page.within "#project_member_#{project_member.id}" do
58
      expect(page).to have_content('Dmitriy')
59
      expect(page).to have_content('Developer')
60
    end
61 62
  end

63
  step 'I change "Dmitriy" role to "Reporter"' do
64
    project = Project.find_by(name: "Shop")
65
    user = User.find_by(name: 'Dmitriy')
66
    project_member = project.project_members.find_by(user_id: user.id)
67
    page.within "#project_member_#{project_member.id}" do
Douwe Maan committed
68
      click_button "Edit access level"
69
      select "Reporter", from: "project_member_access_level"
Douwe Maan committed
70
      click_button "Save"
71 72 73
    end
  end

74
  step 'I should see "Dmitriy" in team list as "Reporter"' do
75 76 77
    user = User.find_by(name: 'Dmitriy')
    project_member = project.project_members.find_by(user_id: user.id)
    page.within "#project_member_#{project_member.id}" do
78
      expect(page).to have_content('Dmitriy')
79
      expect(page).to have_content('Reporter')
80
    end
81 82
  end

83 84
  step 'I should not see "Dmitriy" in team list' do
    user = User.find_by(name: "Dmitriy")
85 86
    expect(page).not_to have_content(user.name)
    expect(page).not_to have_content(user.username)
87 88
  end

89
  step 'gitlab user "Mike"' do
90
    create(:user, name: "Mike")
91 92
  end

93 94
  step 'gitlab user "Dmitriy"' do
    create(:user, name: "Dmitriy")
95 96
  end

97 98
  step '"Dmitriy" is "Shop" developer' do
    user = User.find_by(name: "Dmitriy")
skv committed
99
    project = Project.find_by(name: "Shop")
100
    project.team << [user, :developer]
101
  end
Dmitriy Zaporozhets committed
102

103
  step 'I own project "Website"' do
104
    @project = create(:empty_project, name: "Website", namespace: @user.namespace)
105
    @project.team << [@user, :master]
Dmitriy Zaporozhets committed
106 107
  end

108
  step '"Mike" is "Website" reporter' do
skv committed
109 110
    user = User.find_by(name: "Mike")
    project = Project.find_by(name: "Website")
111
    project.team << [user, :reporter]
Dmitriy Zaporozhets committed
112 113
  end

114
  step 'I click link "Import team from another project"' do
Dmitriy Zaporozhets committed
115
    click_link "Import members from another project"
Dmitriy Zaporozhets committed
116 117 118
  end

  When 'I submit "Website" project for import team' do
skv committed
119
    project = Project.find_by(name: "Website")
Dmitriy Zaporozhets committed
120
    select project.name_with_namespace, from: 'source_project_id'
Dmitriy Zaporozhets committed
121 122
    click_button 'Import'
  end
123

124
  step 'I click cancel link for "Dmitriy"' do
125
    project = Project.find_by(name: "Shop")
126
    user = User.find_by(name: 'Dmitriy')
127
    project_member = project.project_members.find_by(user_id: user.id)
128
    page.within "#project_member_#{project_member.id}" do
129
      click_link('Remove user from project')
130 131
    end
  end
132 133 134

  step 'I share project with group "OpenSource"' do
    project = Project.find_by(name: 'Shop')
135
    os_group = create(:group, name: 'OpenSource')
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    create(:project, group: os_group)
    @os_user1 = create(:user)
    @os_user2 = create(:user)
    os_group.add_owner(@os_user1)
    os_group.add_user(@os_user2, Gitlab::Access::DEVELOPER)
    share_link = project.project_group_links.new(group_access: Gitlab::Access::MASTER)
    share_link.group_id = os_group.id
    share_link.save!
  end

  step 'I should see "Opensource" group user listing' do
    expect(page).to have_content("Shared with OpenSource group, members with Master role (2)")
    expect(page).to have_content(@os_user1.name)
    expect(page).to have_content(@os_user2.name)
  end
151
end