groups.rb 10.2 KB
Newer Older
1
class Spinach::Features::Groups < Spinach::FeatureSteps
2 3
  include SharedAuthentication
  include SharedPaths
4
  include SharedGroup
5
  include SharedUser
6
  include Select2Helper
7

8 9 10 11
  step 'I should see back to dashboard button' do
    expect(page).to have_content 'Back to Dashboard'
  end

12 13 14 15 16 17 18 19 20 21 22
  step 'gitlab user "Mike"' do
    create(:user, name: "Mike")
  end

  step 'I click link "Add members"' do
    find(:css, 'button.btn-new').click
  end

  step 'I select "Mike" as "Reporter"' do
    user = User.find_by(name: "Mike")

23
    page.within ".users-group-form" do
24 25 26 27 28 29 30 31
      select2(user.id, from: "#user_ids", multiple: true)
      select "Reporter", from: "access_level"
    end

    click_button "Add users to group"
  end

  step 'I should see "Mike" in team list as "Reporter"' do
32
    page.within '.well-list' do
33 34
      expect(page).to have_content('Mike')
      expect(page).to have_content('Reporter')
35 36 37
    end
  end

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

    click_button "Add users to group"
  end

  step 'I should see "sjobs@apple.com" in team list as invited "Reporter"' do
48
    page.within '.well-list' do
49 50 51
      expect(page).to have_content('sjobs@apple.com')
      expect(page).to have_content('invited')
      expect(page).to have_content('Reporter')
52 53 54
    end
  end

55
  step 'I should see group "Owned" projects list' do
56
    Group.find_by(name: "Owned").projects.each do |project|
57
      expect(page).to have_link project.name
58 59 60
    end
  end

61
  step 'I should see projects activity feed' do
62
    expect(page).to have_content 'closed issue'
63 64
  end

65
  step 'I should see issues from group "Owned" assigned to me' do
randx's avatar
randx committed
66
    assigned_to_me(:issues).each do |issue|
67
      expect(page).to have_content issue.title
randx's avatar
randx committed
68 69 70
    end
  end

71
  step 'I should see merge requests from group "Owned" assigned to me' do
randx's avatar
randx committed
72
    assigned_to_me(:merge_requests).each do |issue|
73
      expect(page).to have_content issue.title[0..80]
randx's avatar
randx committed
74 75 76
    end
  end

77
  step 'I select user "Mary Jane" from list with role "Reporter"' do
78
    user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
79
    click_button 'Add members'
80
    page.within ".users-group-form" do
81
      select2(user.id, from: "#user_ids", multiple: true)
82
      select "Reporter", from: "access_level"
83
    end
84
    click_button "Add users to group"
85 86
  end

87
  step 'I should see user "John Doe" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
88
    projects_with_access = find(".panel .well-list")
89
    expect(projects_with_access).to have_content("John Doe")
90 91
  end

92
  step 'I should not see user "John Doe" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
93
    projects_with_access = find(".panel .well-list")
94
    expect(projects_with_access).not_to have_content("John Doe")
95 96
  end

97
  step 'I should see user "Mary Jane" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
98
    projects_with_access = find(".panel .well-list")
99
    expect(projects_with_access).to have_content("Mary Jane")
100 101
  end

102
  step 'I should not see user "Mary Jane" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
103
    projects_with_access = find(".panel .well-list")
104
    expect(projects_with_access).not_to have_content("Mary Jane")
105 106
  end

107
  step 'project from group "Owned" has issues assigned to me' do
randx's avatar
randx committed
108 109 110 111 112 113
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

114
  step 'project from group "Owned" has merge requests assigned to me' do
randx's avatar
randx committed
115
    create :merge_request,
116 117
      source_project: project,
      target_project: project,
randx's avatar
randx committed
118 119 120 121
      assignee: current_user,
      author: current_user
  end

122
  step 'I change group "Owned" name to "new-name"' do
123
    fill_in 'group_name', with: 'new-name'
124
    fill_in 'group_path', with: 'new-name'
125 126 127
    click_button "Save group"
  end

128
  step 'I should see new group "Owned" name' do
129
    page.within ".navbar-gitlab" do
130
      expect(page).to have_content "new-name"
131 132 133
    end
  end

134
  step 'I change group "Owned" avatar' do
135
    attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
Steven Thonus's avatar
Steven Thonus committed
136
    click_button "Save group"
137
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
138 139
  end

140
  step 'I should see new group "Owned" avatar' do
141
    expect(Group.find_by(name: "Owned").avatar).to be_instance_of AvatarUploader
142
    expect(Group.find_by(name: "Owned").avatar.url).to eq "/uploads/group/avatar/#{ Group.find_by(name:"Owned").id }/banana_sample.gif"
Steven Thonus's avatar
Steven Thonus committed
143 144 145
  end

  step 'I should see the "Remove avatar" button' do
146
    expect(page).to have_link("Remove avatar")
Steven Thonus's avatar
Steven Thonus committed
147 148
  end

149
  step 'I have group "Owned" avatar' do
150
    attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
Steven Thonus's avatar
Steven Thonus committed
151
    click_button "Save group"
152
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
153 154
  end

155
  step 'I remove group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
156
    click_link "Remove avatar"
157
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
158 159
  end

160
  step 'I should not see group "Owned" avatar' do
Robert Speicher's avatar
Robert Speicher committed
161
    expect(Group.find_by(name: "Owned").avatar?).to eq false
Steven Thonus's avatar
Steven Thonus committed
162 163 164
  end

  step 'I should not see the "Remove avatar" button' do
165
    expect(page).not_to have_link("Remove avatar")
Steven Thonus's avatar
Steven Thonus committed
166 167
  end

168 169 170 171
  step 'I click on the "Remove User From Group" button for "John Doe"' do
    find(:css, 'li', text: "John Doe").find(:css, 'a.btn-remove').click
    # poltergeist always confirms popups.
  end
172

173 174 175
  step 'I click on the "Remove User From Group" button for "Mary Jane"' do
    find(:css, 'li', text: "Mary Jane").find(:css, 'a.btn-remove').click
    # poltergeist always confirms popups.
176
  end
randx's avatar
randx committed
177

178
  step 'I should not see the "Remove User From Group" button for "John Doe"' do
179
    expect(find(:css, 'li', text: "John Doe")).not_to have_selector(:css, 'a.btn-remove')
180
    # poltergeist always confirms popups.
randx's avatar
randx committed
181 182
  end

183
  step 'I should not see the "Remove User From Group" button for "Mary Jane"' do
184
    expect(find(:css, 'li', text: "Mary Jane")).not_to have_selector(:css, 'a.btn-remove')
185 186 187
    # poltergeist always confirms popups.
  end

188
  step 'I search for \'Mary\' member' do
189
    page.within '.member-search-form' do
190 191 192 193 194
      fill_in 'search', with: 'Mary'
      click_button 'Search'
    end
  end

195 196 197 198 199
  step 'I click on group milestones' do
    click_link 'Milestones'
  end

  step 'I should see group milestones index page has no milestones' do
200
    expect(page).to have_content('No milestones to show')
201 202 203 204 205 206 207
  end

  step 'Group has projects with milestones' do
    group_milestone
  end

  step 'I should see group milestones index page with milestones' do
208 209 210 211
    expect(page).to have_content('Version 7.2')
    expect(page).to have_content('GL-113')
    expect(page).to have_link('2 Issues', href: issues_group_path("owned", milestone_title: "Version 7.2"))
    expect(page).to have_link('3 Merge Requests', href: merge_requests_group_path("owned", milestone_title: "GL-113"))
212 213 214 215 216 217
  end

  step 'I click on one group milestone' do
    click_link 'GL-113'
  end

218
  step 'I should see group milestone with descriptions and expiry date' do
219
    expect(page).to have_content('expires at Aug 20, 2114')
220 221
  end

222
  step 'I should see group milestone with all issues and MRs assigned to that milestone' do
223 224 225 226
    expect(page).to have_content('Milestone GL-113')
    expect(page).to have_content('Progress: 0 closed – 4 open')
    expect(page).to have_link(@issue1.title, href: namespace_project_issue_path(@project1.namespace, @project1, @issue1))
    expect(page).to have_link(@mr3.title, href: namespace_project_merge_request_path(@project3.namespace, @project3, @mr3))
227 228
  end

Artem Sidorenko's avatar
Artem Sidorenko committed
229 230 231 232 233 234 235 236 237
  step 'Group "Owned" has archived project' do
    group = Group.find_by(name: 'Owned')
    create(:project, namespace: group, archived: true, path: "archived-project")
  end

  step 'I should see "archived" label' do
    expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
  end

238 239
  protected

240
  def assigned_to_me(key)
randx's avatar
randx committed
241 242
    project.send(key).where(assignee_id: current_user.id)
  end
243 244 245 246

  def project
    Group.find_by(name: "Owned").projects.first
  end
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275

  def group_milestone
    group = Group.find_by(name: "Owned")

    @project1 = create :project,
                 group: group
    project2 = create :project,
                 path: 'gitlab-ci',
                 group: group
    @project3 = create :project,
                 path: 'cookbook-gitlab',
                 group: group
    milestone1_project1 = create :milestone,
                            title: "Version 7.2",
                            project: @project1
    milestone1_project2 = create :milestone,
                            title: "Version 7.2",
                            project: project2
    milestone1_project3 = create :milestone,
                            title: "Version 7.2",
                            project: @project3
    milestone2_project1 = create :milestone,
                            title: "GL-113",
                            project: @project1
    milestone2_project2 = create :milestone,
                            title: "GL-113",
                            project: project2
    milestone2_project3 = create :milestone,
                            title: "GL-113",
276
                            project: @project3,
277
                            due_date: '2114-08-20',
278
                            description: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry'
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
    @issue1 = create :issue,
               project: @project1,
               assignee: current_user,
               author: current_user,
               milestone: milestone2_project1
    issue2 = create :issue,
               project: project2,
               assignee: current_user,
               author: current_user,
               milestone: milestone1_project2
    issue3 = create :issue,
               project: @project3,
               assignee: current_user,
               author: current_user,
               milestone: milestone1_project1
    mr1 = create :merge_request,
            source_project: @project1,
            target_project: @project1,
            assignee: current_user,
            author: current_user,
            milestone: milestone2_project1
    mr2 = create :merge_request,
            source_project: project2,
            target_project: project2,
            assignee: current_user,
            author: current_user,
            milestone: milestone2_project2
    @mr3 = create :merge_request,
            source_project: @project3,
            target_project: @project3,
            assignee: current_user,
            author: current_user,
            milestone: milestone2_project3
  end
313
end