groups.rb 9.19 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
  step 'I should see group "Owned" projects list' do
9
    Group.find_by(name: "Owned").projects.each do |project|
10 11 12 13
      page.should have_link project.name
    end
  end

14
  step 'I should see projects activity feed' do
15 16 17
    page.should have_content 'closed issue'
  end

18
  step 'I should see issues from group "Owned" assigned to me' do
randx's avatar
randx committed
19 20 21 22 23
    assigned_to_me(:issues).each do |issue|
      page.should have_content issue.title
    end
  end

24
  step 'I should see merge requests from group "Owned" assigned to me' do
randx's avatar
randx committed
25
    assigned_to_me(:merge_requests).each do |issue|
Cyril's avatar
Cyril committed
26
      page.should have_content issue.title[0..80]
randx's avatar
randx committed
27 28 29
    end
  end

30
  step 'I select user "Mary Jane" from list with role "Reporter"' do
31
    user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
32
    click_link 'Add members'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
33
    within ".users-group-form" do
34
      select2(user.id, from: "#user_ids", multiple: true)
35
      select "Reporter", from: "access_level"
36
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
37
    click_button "Add users into group"
38 39
  end

40
  step 'I should see user "John Doe" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
41
    projects_with_access = find(".panel .well-list")
42
    projects_with_access.should have_content("John Doe")
43 44
  end

45
  step 'I should not see user "John Doe" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
46
    projects_with_access = find(".panel .well-list")
47 48 49
    projects_with_access.should_not have_content("John Doe")
  end

50
  step 'I should see user "Mary Jane" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
51
    projects_with_access = find(".panel .well-list")
52 53 54
    projects_with_access.should have_content("Mary Jane")
  end

55
  step 'I should not see user "Mary Jane" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
56
    projects_with_access = find(".panel .well-list")
57 58 59
    projects_with_access.should_not have_content("Mary Jane")
  end

60
  step 'project from group "Owned" has issues assigned to me' do
randx's avatar
randx committed
61 62 63 64 65 66
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

67
  step 'project from group "Owned" has merge requests assigned to me' do
randx's avatar
randx committed
68
    create :merge_request,
69 70
      source_project: project,
      target_project: project,
randx's avatar
randx committed
71 72 73 74
      assignee: current_user,
      author: current_user
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
75
  When 'I click new group link' do
76
    click_link "New group"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
77 78
  end

79
  step 'submit form with new group "Samurai" info' do
80
    fill_in 'group_path', with: 'Samurai'
Andrew8xx8's avatar
Andrew8xx8 committed
81
    fill_in 'group_description', with: 'Tokugawa Shogunate'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
82 83 84
    click_button "Create group"
  end

85
  step 'I should be redirected to group "Samurai" page' do
86 87 88
    current_path.should == group_path(Group.last)
  end

89
  step 'I should see newly created group "Samurai"' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
90
    page.should have_content "Samurai"
91
    page.should have_content "Tokugawa Shogunate"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
92
    page.should have_content "Currently you are only seeing events from the"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
93 94
  end

95
  step 'I change group "Owned" name to "new-name"' do
96
    fill_in 'group_name', with: 'new-name'
97
    fill_in 'group_path', with: 'new-name'
98 99 100
    click_button "Save group"
  end

101
  step 'I should see new group "Owned" name' do
102 103 104 105 106
    within ".navbar-gitlab" do
      page.should have_content "group: new-name"
    end
  end

107
  step 'I change group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
108 109
    attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save group"
110
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
111 112
  end

113 114 115
  step 'I should see new group "Owned" avatar' do
    Group.find_by(name: "Owned").avatar.should be_instance_of AttachmentUploader
    Group.find_by(name: "Owned").avatar.url.should == "/uploads/group/avatar/#{ Group.find_by(name:"Owned").id }/gitlab_logo.png"
Steven Thonus's avatar
Steven Thonus committed
116 117 118 119 120 121
  end

  step 'I should see the "Remove avatar" button' do
    page.should have_link("Remove avatar")
  end

122
  step 'I have group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
123 124
    attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save group"
125
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
126 127
  end

128
  step 'I remove group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
129
    click_link "Remove avatar"
130
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
131 132
  end

133 134
  step 'I should not see group "Owned" avatar' do
    Group.find_by(name: "Owned").avatar?.should be_false
Steven Thonus's avatar
Steven Thonus committed
135 136 137 138 139 140
  end

  step 'I should not see the "Remove avatar" button' do
    page.should_not have_link("Remove avatar")
  end

141 142 143 144
  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
145

146 147 148
  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.
149
  end
randx's avatar
randx committed
150

151 152 153
  step 'I should not see the "Remove User From Group" button for "John Doe"' do
    find(:css, 'li', text: "John Doe").should_not have_selector(:css, 'a.btn-remove')
    # poltergeist always confirms popups.
randx's avatar
randx committed
154 155
  end

156 157 158 159 160
  step 'I should not see the "Remove User From Group" button for "Mary Jane"' do
    find(:css, 'li', text: "Mary Jane").should_not have_selector(:css, 'a.btn-remove')
    # poltergeist always confirms popups.
  end

161 162 163 164 165 166 167
  step 'I search for \'Mary\' member' do
    within '.member-search-form' do
      fill_in 'search', with: 'Mary'
      click_button 'Search'
    end
  end

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
  step 'I click on group milestones' do
    click_link 'Milestones'
  end

  step 'I should see group milestones index page has no milestones' do
    page.should have_content('No milestones to show')
  end

  step 'Group has projects with milestones' do
    group_milestone
  end

  step 'I should see group milestones index page with milestones' do
    page.should have_content('Version 7.2')
    page.should have_content('GL-113')
    page.should have_link('2 Issues', href: group_milestone_path("owned", "version-7-2", title: "Version 7.2"))
    page.should have_link('3 Merge Requests', href: group_milestone_path("owned", "gl-113", title: "GL-113"))
  end

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

191 192
  step 'I should see group milestone with descriptions and expiry date' do
    page.should have_content('Lorem Ipsum is simply dummy text of the printing and typesetting industry')
193
    page.should have_content('expires at Aug 20, 2114')
194 195
  end

196 197 198 199 200 201 202
  step 'I should see group milestone with all issues and MRs assigned to that milestone' do
    page.should have_content('Milestone GL-113')
    page.should have_content('Progress: 0 closed – 4 open')
    page.should have_link(@issue1.title, href: project_issue_path(@project1, @issue1))
    page.should have_link(@mr3.title, href: project_merge_request_path(@project3, @mr3))
  end

203 204
  protected

205
  def assigned_to_me(key)
randx's avatar
randx committed
206 207
    project.send(key).where(assignee_id: current_user.id)
  end
208 209 210 211

  def project
    Group.find_by(name: "Owned").projects.first
  end
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240

  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",
241
                            project: @project3,
242
                            due_date: '2114-08-20',
243
                            description: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry'
244 245 246 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 276 277
    @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
278
end