issues.rb 10.1 KB
Newer Older
1
class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
N
Nihad Abbasov 已提交
2
  include SharedAuthentication
V
Vinnie Okada 已提交
3
  include SharedIssuable
N
Nihad Abbasov 已提交
4 5 6
  include SharedProject
  include SharedNote
  include SharedPaths
7
  include SharedMarkdown
N
Nihad Abbasov 已提交
8

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

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

17
  step 'I should not see "Tweet control" in issues' do
18
    expect(page).not_to have_content "Tweet control"
D
Dmitriy Zaporozhets 已提交
19 20
  end

V
tests  
Valery Sizov 已提交
21
  step 'I should see that I am subscribed' do
22
    expect(find('.subscribe-button span')).to have_content 'Unsubscribe'
V
tests  
Valery Sizov 已提交
23 24 25
  end

  step 'I should see that I am unsubscribed' do
26
    expect(find('.subscribe-button span')).to have_content 'Subscribe'
V
tests  
Valery Sizov 已提交
27 28
  end

29
  step 'I click link "Closed"' do
P
Phil Hughes 已提交
30
    find('.issues-state-filters a', text: "Closed").click
31 32
  end

V
tests  
Valery Sizov 已提交
33 34 35 36
  step 'I click button "Unsubscribe"' do
    click_on "Unsubscribe"
  end

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

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

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

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

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

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

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

65
  step 'I click "author" dropdown' do
P
Phil Hughes 已提交
66 67
    page.find('.js-author-search').click
    sleep 1
68 69 70
  end

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

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

82 83 84
  step 'I submit new issue "500 error on profile" with label \'bug\'' do
    fill_in "issue_title", with: "500 error on profile"
    select 'bug', from: "Labels"
85
    click_button "Submit issue"
86 87
  end

88
  step 'I click link "500 error on profile"' do
89 90 91
    click_link "500 error on profile"
  end

92
  step 'I should see label \'bug\' with issue' do
D
Douwe Maan 已提交
93
    page.within '.issuable-show-labels' do
94
      expect(page).to have_content 'bug'
95 96 97
    end
  end

98
  step 'I should see issue "500 error on profile"' do
S
skv 已提交
99
    issue = Issue.find_by(title: "500 error on profile")
100 101 102
    expect(page).to have_content issue.title
    expect(page).to have_content issue.author_name
    expect(page).to have_content issue.project.name
103 104
  end

105
  step 'I fill in issue search with "Re"' do
106
    filter_issue "Re"
107 108
  end

109
  step 'I fill in issue search with "Bu"' do
110
    filter_issue "Bu"
111 112
  end

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

117
  step 'I fill in issue search with "Something"' do
118
    filter_issue "Something"
119 120
  end

121
  step 'I fill in issue search with ""' do
122
    filter_issue ""
123 124
  end

125
  step 'project "Shop" has milestone "v2.2"' do
126

127
    milestone = create(:milestone, title: "v2.2", project: project)
128

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

132
  step 'project "Shop" has milestone "v3.0"' do
133

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
D
Dmitriy Zaporozhets 已提交
144
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
145
    expect(find(issues_milestone_selector)).to have_content("v3.0")
146 147 148
  end

  When 'I select first assignee from "Shop" project' do
149

150 151 152 153
    first_assignee = project.users.first
    select first_assignee.name, from: "assignee_id"
  end

154
  step 'I should see first assignee from "Shop" as selected assignee' do
D
Dmitriy Zaporozhets 已提交
155
    issues_assignee_selector = "#issue_assignee_id_chzn > a"
156

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

161
  step 'project "Shop" have "Release 0.4" open issue' do
162

163
    create(:issue,
164 165
           title: "Release 0.4",
           project: project,
166 167 168
           author: project.users.first,
           description: "# Description header"
          )
169 170
  end

171
  step 'project "Shop" have "Tweet control" open issue' do
D
Dmitriy Zaporozhets 已提交
172
    create(:issue,
173
           title: "Tweet control",
D
Dmitriy Zaporozhets 已提交
174 175 176 177
           project: project,
           author: project.users.first)
  end

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

185
  step 'project "Shop" have "Release 0.3" closed issue' do
A
Andrew8xx8 已提交
186
    create(:closed_issue,
187 188 189
           title: "Release 0.3",
           project: project,
           author: project.users.first)
190
  end
191

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
  step 'issue "Release 0.4" have 2 upvotes and 1 downvote' do
    issue = Issue.find_by(title: 'Release 0.4')
    create_list(:upvote_note, 2, project: project, noteable: issue)
    create(:downvote_note, project: project, noteable: issue)
  end

  step 'issue "Tweet control" have 1 upvote and 2 downvotes' do
    issue = Issue.find_by(title: 'Tweet control')
    create(:upvote_note, project: project, noteable: issue)
    create_list(:downvote_note, 2, project: project, noteable: issue)
  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'
P
Phil Hughes 已提交
218
        expect(page).to_not have_content '0 0'
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
      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'
P
Phil Hughes 已提交
237
        expect(page).to_not have_content '0 0'
238 239 240 241
      end
    end
  end

242
  step 'empty project "Empty Project"' do
243 244 245 246 247
    create :empty_project, name: 'Empty Project', namespace: @user.namespace
  end

  When 'I visit empty project page' do
    project = Project.find_by(name: 'Empty Project')
V
Vinnie Okada 已提交
248
    visit namespace_project_path(project.namespace, project)
249 250
  end

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

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

263 264
  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
V
Vinnie Okada 已提交
265
    visit namespace_project_issues_path(project.namespace, project)
266
  end
M
Marin Jankovski 已提交
267 268

  step 'I leave a comment with code block' do
269
    page.within(".js-main-target-form") do
M
Marin Jankovski 已提交
270 271 272 273 274 275
      fill_in "note[note]", with: "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```"
      click_button "Add Comment"
      sleep 0.05
    end
  end

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

M
Marin Jankovski 已提交
282
  step 'The code block should be unchanged' do
283
    expect(page).to have_content("```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```")
M
Marin Jankovski 已提交
284
  end
285

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

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

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

298
  step 'I fill in issue search with \'issue1\'' do
299
    filter_issue 'issue1'
300 301
  end

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

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

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

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

318 319 320 321 322 323 324
  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
325
    page.within ".issues-list" do
326 327 328 329
      click_link 'bug'
    end
  end

330
  step 'I should not see labels field' do
D
Dmitriy Zaporozhets 已提交
331
    page.within '.issue-form' do
332 333 334 335 336
      expect(page).not_to have_content("Labels")
    end
  end

  step 'I should not see milestone field' do
D
Dmitriy Zaporozhets 已提交
337
    page.within '.issue-form' do
338 339 340 341 342
      expect(page).not_to have_content("Milestone")
    end
  end

  step 'I should not see assignee field' do
D
Dmitriy Zaporozhets 已提交
343
    page.within '.issue-form' do
344 345 346 347
      expect(page).not_to have_content("Assign to")
    end
  end

G
Grzegorz Bizon 已提交
348 349 350 351 352 353 354 355 356 357
  step 'another user adds a comment with text "Yay!" to issue "Release 0.4"' do
    issue = Issue.find_by!(title: 'Release 0.4')
    create(:note_on_issue, noteable: issue,  note: 'Yay!')
  end

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

359 360 361
  def filter_issue(text)
    fill_in 'issue_search', with: text
  end
362

363
end