groups.rb 9.01 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_button '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 93
  end

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

100
  step 'I should see new group "Owned" name' do
101
    within ".navbar-gitlab" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
102
      page.should have_content "new-name"
103 104 105
    end
  end

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

112 113 114
  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
115 116 117 118 119 120
  end

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

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

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

132 133
  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
134 135 136 137 138 139
  end

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

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

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

150 151 152
  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
153 154
  end

155 156 157 158 159
  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

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

167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
  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

190
  step 'I should see group milestone with descriptions and expiry date' do
191
    page.should have_content('expires at Aug 20, 2114')
192 193
  end

194 195 196 197 198 199 200
  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

201 202
  protected

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

  def project
    Group.find_by(name: "Owned").projects.first
  end
210 211 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

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