groups.rb 9.14 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 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  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")

    within ".users-group-form" do
      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
    within '.well-list' do
      page.should have_content('Mike')
      page.should have_content('Reporter')
    end
  end

34
  step 'I should see group "Owned" projects list' do
35
    Group.find_by(name: "Owned").projects.each do |project|
36 37 38 39
      page.should have_link project.name
    end
  end

40
  step 'I should see projects activity feed' do
41 42 43
    page.should have_content 'closed issue'
  end

44
  step 'I should see issues from group "Owned" assigned to me' do
randx's avatar
randx committed
45 46 47 48 49
    assigned_to_me(:issues).each do |issue|
      page.should have_content issue.title
    end
  end

50
  step 'I should see merge requests from group "Owned" assigned to me' do
randx's avatar
randx committed
51
    assigned_to_me(:merge_requests).each do |issue|
Cyril's avatar
Cyril committed
52
      page.should have_content issue.title[0..80]
randx's avatar
randx committed
53 54 55
    end
  end

56
  step 'I select user "Mary Jane" from list with role "Reporter"' do
57
    user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
58
    click_button 'Add members'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
59
    within ".users-group-form" do
60
      select2(user.id, from: "#user_ids", multiple: true)
61
      select "Reporter", from: "access_level"
62
    end
63
    click_button "Add users to group"
64 65
  end

66
  step 'I should see user "John Doe" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
67
    projects_with_access = find(".panel .well-list")
68
    projects_with_access.should have_content("John Doe")
69 70
  end

71
  step 'I should not see user "John Doe" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
72
    projects_with_access = find(".panel .well-list")
73 74 75
    projects_with_access.should_not have_content("John Doe")
  end

76
  step 'I should see user "Mary Jane" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
77
    projects_with_access = find(".panel .well-list")
78 79 80
    projects_with_access.should have_content("Mary Jane")
  end

81
  step 'I should not see user "Mary Jane" in team list' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
82
    projects_with_access = find(".panel .well-list")
83 84 85
    projects_with_access.should_not have_content("Mary Jane")
  end

86
  step 'project from group "Owned" has issues assigned to me' do
randx's avatar
randx committed
87 88 89 90 91 92
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

93
  step 'project from group "Owned" has merge requests assigned to me' do
randx's avatar
randx committed
94
    create :merge_request,
95 96
      source_project: project,
      target_project: project,
randx's avatar
randx committed
97 98 99 100
      assignee: current_user,
      author: current_user
  end

101
  step 'I change group "Owned" name to "new-name"' do
102
    fill_in 'group_name', with: 'new-name'
103
    fill_in 'group_path', with: 'new-name'
104 105 106
    click_button "Save group"
  end

107
  step 'I should see new group "Owned" name' do
108
    within ".navbar-gitlab" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
109
      page.should have_content "new-name"
110 111 112
    end
  end

113
  step 'I change group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
114 115
    attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save group"
116
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
117 118
  end

119
  step 'I should see new group "Owned" avatar' do
Douwe Maan's avatar
Douwe Maan committed
120
    Group.find_by(name: "Owned").avatar.should be_instance_of AvatarUploader
121
    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
122 123 124 125 126 127
  end

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

128
  step 'I have group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
129 130
    attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save group"
131
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
132 133
  end

134
  step 'I remove group "Owned" avatar' do
Steven Thonus's avatar
Steven Thonus committed
135
    click_link "Remove avatar"
136
    Group.find_by(name: "Owned").reload
Steven Thonus's avatar
Steven Thonus committed
137 138
  end

139 140
  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
141 142 143 144 145 146
  end

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

147 148 149 150
  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
151

152 153 154
  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.
155
  end
randx's avatar
randx committed
156

157 158 159
  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
160 161
  end

162 163 164 165 166
  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

167 168 169 170 171 172 173
  step 'I search for \'Mary\' member' do
    within '.member-search-form' do
      fill_in 'search', with: 'Mary'
      click_button 'Search'
    end
  end

174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  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

197
  step 'I should see group milestone with descriptions and expiry date' do
198
    page.should have_content('expires at Aug 20, 2114')
199 200
  end

201 202 203
  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')
Vinnie Okada's avatar
Vinnie Okada committed
204 205
    page.should have_link(@issue1.title, href: namespace_project_issue_path(@project1.namespace, @project1, @issue1))
    page.should have_link(@mr3.title, href: namespace_project_merge_request_path(@project3.namespace, @project3, @mr3))
206 207
  end

208 209
  protected

210
  def assigned_to_me(key)
randx's avatar
randx committed
211 212
    project.send(key).where(assignee_id: current_user.id)
  end
213 214 215 216

  def project
    Group.find_by(name: "Owned").projects.first
  end
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245

  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",
246
                            project: @project3,
247
                            due_date: '2114-08-20',
248
                            description: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry'
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 278 279 280 281 282
    @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
283
end