issues.rb 10.2 KB
Newer Older
1
class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2
  include SharedAuthentication
3
  include SharedIssuable
Nihad Abbasov's avatar
Nihad Abbasov committed
4 5 6
  include SharedProject
  include SharedNote
  include SharedPaths
7
  include SharedMarkdown
8
  include SharedUser
Nihad Abbasov's avatar
Nihad Abbasov committed
9

10
  step 'I should see "Release 0.4" in issues' do
11
    expect(page).to have_content "Release 0.4"
12 13
  end

14
  step 'I should not see "Release 0.3" in issues' do
15
    expect(page).not_to have_content "Release 0.3"
16 17
  end

18
  step 'I should not see "Tweet control" in issues' do
19
    expect(page).not_to have_content "Tweet control"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
20 21
  end

Valery Sizov's avatar
tests  
Valery Sizov committed
22
  step 'I should see that I am subscribed' do
23
    expect(find('.issuable-subscribe-button span')).to have_content 'Unsubscribe'
Valery Sizov's avatar
tests  
Valery Sizov committed
24 25 26
  end

  step 'I should see that I am unsubscribed' do
27
    expect(find('.issuable-subscribe-button span')).to have_content 'Subscribe'
Valery Sizov's avatar
tests  
Valery Sizov committed
28 29
  end

30
  step 'I click link "Closed"' do
Phil Hughes's avatar
Phil Hughes committed
31
    find('.issues-state-filters a', text: "Closed").click
32 33
  end

Valery Sizov's avatar
tests  
Valery Sizov committed
34 35 36 37
  step 'I click button "Unsubscribe"' do
    click_on "Unsubscribe"
  end

38
  step 'I should see "Release 0.3" in issues' do
39
    expect(page).to have_content "Release 0.3"
40 41
  end

42
  step 'I should not see "Release 0.4" in issues' do
43
    expect(page).not_to have_content "Release 0.4"
44 45
  end

46
  step 'I click link "All"' do
47 48 49
    click_link "All"
  end

50
  step 'I click link "Release 0.4"' do
51 52 53
    click_link "Release 0.4"
  end

54
  step 'I should see issue "Release 0.4"' do
55
    expect(page).to have_content "Release 0.4"
56 57
  end

58 59 60 61
  step 'I should see issue "Tweet control"' do
    expect(page).to have_content "Tweet control"
  end

62
  step 'I click link "New Issue"' do
63 64 65
    click_link "New Issue"
  end

66
  step 'I click "author" dropdown' do
Phil Hughes's avatar
Phil Hughes committed
67 68
    page.find('.js-author-search').click
    sleep 1
69 70 71
  end

  step 'I see current user as the first user' do
Phil Hughes's avatar
Phil Hughes committed
72 73
    expect(page).to have_selector('.dropdown-content', visible: true)
    users = page.all('.dropdown-menu-author .dropdown-content li a')
74
    expect(users[0].text).to eq 'Any Author'
Phil Hughes's avatar
Phil Hughes committed
75
    expect(users[1].text).to eq "#{current_user.name} #{current_user.to_reference}"
76 77
  end

78
  step 'I submit new issue "500 error on profile"' do
79
    fill_in "issue_title", with: "500 error on profile"
80
    click_button "Submit issue"
81 82
  end

83 84
  step 'I submit new issue "500 error on profile" with label \'bug\'' do
    fill_in "issue_title", with: "500 error on profile"
85 86
    click_button "Label"
    click_link "bug"
87
    click_button "Submit issue"
88 89
  end

90
  step 'I click link "500 error on profile"' do
91 92 93
    click_link "500 error on profile"
  end

94
  step 'I should see label \'bug\' with issue' do
Douwe Maan's avatar
Douwe Maan committed
95
    page.within '.issuable-show-labels' do
96
      expect(page).to have_content 'bug'
97 98 99
    end
  end

100
  step 'I should see issue "500 error on profile"' do
skv's avatar
skv committed
101
    issue = Issue.find_by(title: "500 error on profile")
102 103 104
    expect(page).to have_content issue.title
    expect(page).to have_content issue.author_name
    expect(page).to have_content issue.project.name
105 106
  end

107
  step 'I fill in issue search with "Re"' do
108
    filter_issue "Re"
109 110
  end

111
  step 'I fill in issue search with "Bu"' do
112
    filter_issue "Bu"
113 114
  end

115
  step 'I fill in issue search with ".3"' do
116
    filter_issue ".3"
117 118
  end

119
  step 'I fill in issue search with "Something"' do
120
    filter_issue "Something"
121 122
  end

123
  step 'I fill in issue search with ""' do
124
    filter_issue ""
125 126
  end

127
  step 'project "Shop" has milestone "v2.2"' do
128
    milestone = create(:milestone, title: "v2.2", project: project)
129

130
    3.times { create(:issue, project: project, milestone: milestone) }
131 132
  end

133
  step 'project "Shop" has milestone "v3.0"' do
134
    milestone = create(:milestone, title: "v3.0", project: project)
135

136
    3.times { create(:issue, project: project, milestone: milestone) }
137 138 139 140 141 142
  end

  When 'I select milestone "v3.0"' do
    select "v3.0", from: "milestone_id"
  end

143
  step 'I should see selected milestone with title "v3.0"' do
144
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
145
    expect(find(issues_milestone_selector)).to have_content("v3.0")
146 147 148 149 150 151 152
  end

  When 'I select first assignee from "Shop" project' do
    first_assignee = project.users.first
    select first_assignee.name, from: "assignee_id"
  end

153
  step 'I should see first assignee from "Shop" as selected assignee' do
154
    issues_assignee_selector = "#issue_assignee_id_chzn > a"
155

156
    assignee_name = project.users.first.name
157
    expect(find(issues_assignee_selector)).to have_content(assignee_name)
158 159
  end

160
  step 'project "Shop" have "Release 0.4" open issue' do
161
    create(:issue,
162 163
           title: "Release 0.4",
           project: project,
164 165 166
           author: project.users.first,
           description: "# Description header"
          )
167 168
  end

169
  step 'project "Shop" have "Tweet control" open issue' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
170
    create(:issue,
171
           title: "Tweet control",
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
172 173 174 175
           project: project,
           author: project.users.first)
  end

176 177 178 179 180 181 182
  step 'project "Shop" have "Bugfix" open issue' do
    create(:issue,
           title: "Bugfix",
           project: project,
           author: project.users.first)
  end

183
  step 'project "Shop" have "Release 0.3" closed issue' do
Andrew8xx8's avatar
Andrew8xx8 committed
184
    create(:closed_issue,
185 186 187
           title: "Release 0.3",
           project: project,
           author: project.users.first)
188
  end
189

190
  step 'issue "Release 0.4" have 2 upvotes and 1 downvote' do
191
    awardable = Issue.find_by(title: 'Release 0.4')
192 193
    create_list(:award_emoji, 2, awardable: awardable)
    create(:award_emoji, :downvote, awardable: awardable)
194 195 196
  end

  step 'issue "Tweet control" have 1 upvote and 2 downvotes' do
197 198 199
    awardable = Issue.find_by(title: 'Tweet control')
    create(:award_emoji, :upvote, awardable: awardable)
    create_list(:award_emoji, 2, awardable: awardable, name: 'thumbsdown')
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
  end

  step 'The list should be sorted by "Least popular"' do
    page.within '.issues-list' do
      page.within 'li.issue:nth-child(1)' do
        expect(page).to have_content 'Tweet control'
        expect(page).to have_content '1 2'
      end

      page.within 'li.issue:nth-child(2)' do
        expect(page).to have_content 'Release 0.4'
        expect(page).to have_content '2 1'
      end

      page.within 'li.issue:nth-child(3)' do
        expect(page).to have_content 'Bugfix'
216
        expect(page).not_to have_content '0 0'
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
      end
    end
  end

  step 'The list should be sorted by "Most popular"' do
    page.within '.issues-list' do
      page.within 'li.issue:nth-child(1)' do
        expect(page).to have_content 'Release 0.4'
        expect(page).to have_content '2 1'
      end

      page.within 'li.issue:nth-child(2)' do
        expect(page).to have_content 'Tweet control'
        expect(page).to have_content '1 2'
      end

      page.within 'li.issue:nth-child(3)' do
        expect(page).to have_content 'Bugfix'
235
        expect(page).not_to have_content '0 0'
236 237 238 239
      end
    end
  end

240
  step 'empty project "Empty Project"' do
241
    create :project_empty_repo, name: 'Empty Project', namespace: @user.namespace
242 243 244 245
  end

  When 'I visit empty project page' do
    project = Project.find_by(name: 'Empty Project')
Vinnie Okada's avatar
Vinnie Okada committed
246
    visit namespace_project_path(project.namespace, project)
247 248
  end

249
  step 'I see empty project details with ssh clone info' do
250
    project = Project.find_by(name: 'Empty Project')
251
    page.all(:css, '.git-empty .clone').each do |element|
252
      expect(element.text).to include(project.url_to_repo)
253 254 255
    end
  end

256 257 258 259 260
  When "I visit project \"Community\" issues page" do
    project = Project.find_by(name: 'Community')
    visit namespace_project_issues_path(project.namespace, project)
  end

261 262
  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
Vinnie Okada's avatar
Vinnie Okada committed
263
    visit namespace_project_issues_path(project.namespace, project)
264
  end
Marin Jankovski's avatar
Marin Jankovski committed
265 266

  step 'I leave a comment with code block' do
267
    page.within(".js-main-target-form") do
Marin Jankovski's avatar
Marin Jankovski committed
268
      fill_in "note[note]", with: "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```"
Phil Hughes's avatar
Phil Hughes committed
269
      click_button "Comment"
Marin Jankovski's avatar
Marin Jankovski committed
270 271 272 273
      sleep 0.05
    end
  end

274
  step 'I should see an error alert section within the comment form' do
275
    page.within(".js-main-target-form") do
276 277 278 279
      find(".error-alert")
    end
  end

Marin Jankovski's avatar
Marin Jankovski committed
280
  step 'The code block should be unchanged' do
281
    expect(page).to have_content("```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```")
Marin Jankovski's avatar
Marin Jankovski committed
282
  end
283

284
  step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
285
    create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
286 287
  end

288
  step 'project \'Shop\' has issue \'Feature1\' with description: \'Feature submitted for issue1\'' do
289
    create(:issue, title: 'Feature1', description: 'Feature submitted for issue1', project: project)
290 291
  end

292
  step 'I fill in issue search with \'Description for issue1\'' do
293
    filter_issue 'Description for issue'
294 295
  end

296
  step 'I fill in issue search with \'issue1\'' do
297
    filter_issue 'issue1'
298 299
  end

300
  step 'I fill in issue search with \'Rock and roll\'' do
301
    filter_issue 'Description for issue'
302 303
  end

304
  step 'I should see \'Bugfix1\' in issues' do
305
    expect(page).to have_content 'Bugfix1'
306 307
  end

308
  step 'I should see \'Feature1\' in issues' do
309
    expect(page).to have_content 'Feature1'
310 311
  end

312
  step 'I should not see \'Bugfix1\' in issues' do
313
    expect(page).not_to have_content 'Bugfix1'
314
  end
315

316 317 318 319 320 321 322
  step 'issue \'Release 0.4\' has label \'bug\'' do
    label = project.labels.create!(name: 'bug', color: '#990000')
    issue = Issue.find_by!(title: 'Release 0.4')
    issue.labels << label
  end

  step 'I click label \'bug\'' do
323
    page.within ".issues-list" do
324 325 326 327
      click_link 'bug'
    end
  end

328
  step 'I should not see labels field' do
329
    page.within '.issue-form' do
330 331 332 333 334
      expect(page).not_to have_content("Labels")
    end
  end

  step 'I should not see milestone field' do
335
    page.within '.issue-form' do
336 337 338 339 340
      expect(page).not_to have_content("Milestone")
    end
  end

  step 'I should not see assignee field' do
341
    page.within '.issue-form' do
342 343 344 345
      expect(page).not_to have_content("Assign to")
    end
  end

346 347
  step 'another user adds a comment with text "Yay!" to issue "Release 0.4"' do
    issue = Issue.find_by!(title: 'Release 0.4')
348
    create(:note_on_issue, noteable: issue, project: project, note: 'Yay!')
349 350 351 352 353 354 355
  end

  step 'I should see a new comment with text "Yay!"' do
    page.within '#notes' do
      expect(page).to have_content('Yay!')
    end
  end
356

357 358 359
  def filter_issue(text)
    fill_in 'issue_search', with: text
  end
360
end