issues.rb 8.4 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
30 31 32
    click_link "Closed"
  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
66
    first('#s2id_author_id').click
67 68 69
  end

  step 'I see current user as the first user' do
70
    expect(page).to have_selector('.user-result', visible: true, count: 3)
71
    users = page.all('.user-name')
72 73
    expect(users[0].text).to eq 'Any Author'
    expect(users[1].text).to eq current_user.name
74 75
  end

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

81 82 83
  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"
84
    click_button "Submit issue"
85 86
  end

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

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

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

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

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

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

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

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

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

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

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

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

133
    milestone = create(:milestone, title: "v3.0", project: project)
134

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

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

142
  step 'I should see selected milestone with title "v3.0"' do
D
Dmitriy Zaporozhets 已提交
143
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
144
    expect(find(issues_milestone_selector)).to have_content("v3.0")
145 146 147
  end

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

149 150 151 152
    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
D
Dmitriy Zaporozhets 已提交
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

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

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

177
  step 'project "Shop" have "Release 0.3" closed issue' do
A
Andrew8xx8 已提交
178
    create(:closed_issue,
179 180 181
           title: "Release 0.3",
           project: project,
           author: project.users.first)
182
  end
183

184
  step 'empty project "Empty Project"' do
185 186 187 188 189
    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 已提交
190
    visit namespace_project_path(project.namespace, project)
191 192
  end

193
  step 'I see empty project details with ssh clone info' do
194
    project = Project.find_by(name: 'Empty Project')
195
    page.all(:css, '.git-empty .clone').each do |element|
196
      expect(element.text).to include(project.url_to_repo)
197 198 199
    end
  end

200 201 202 203 204
  When "I visit project \"Community\" issues page" do
    project = Project.find_by(name: 'Community')
    visit namespace_project_issues_path(project.namespace, project)
  end

205 206
  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
V
Vinnie Okada 已提交
207
    visit namespace_project_issues_path(project.namespace, project)
208
  end
M
Marin Jankovski 已提交
209 210

  step 'I leave a comment with code block' do
211
    page.within(".js-main-target-form") do
M
Marin Jankovski 已提交
212 213 214 215 216 217
      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

218
  step 'I should see an error alert section within the comment form' do
219
    page.within(".js-main-target-form") do
220 221 222 223
      find(".error-alert")
    end
  end

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

228
  step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
229
    create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
230 231
  end

232
  step 'project \'Shop\' has issue \'Feature1\' with description: \'Feature submitted for issue1\'' do
233
    create(:issue, title: 'Feature1', description: 'Feature submitted for issue1', project: project)
234 235
  end

236
  step 'I fill in issue search with \'Description for issue1\'' do
237
    filter_issue 'Description for issue'
238 239
  end

240
  step 'I fill in issue search with \'issue1\'' do
241
    filter_issue 'issue1'
242 243
  end

244
  step 'I fill in issue search with \'Rock and roll\'' do
245
    filter_issue 'Description for issue'
246 247
  end

248
  step 'I should see \'Bugfix1\' in issues' do
249
    expect(page).to have_content 'Bugfix1'
250 251
  end

252
  step 'I should see \'Feature1\' in issues' do
253
    expect(page).to have_content 'Feature1'
254 255
  end

256
  step 'I should not see \'Bugfix1\' in issues' do
257
    expect(page).not_to have_content 'Bugfix1'
258
  end
259

260 261 262 263 264 265 266
  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
267
    page.within ".issues-list" do
268 269 270 271
      click_link 'bug'
    end
  end

272
  step 'I should not see labels field' do
D
Dmitriy Zaporozhets 已提交
273
    page.within '.issue-form' do
274 275 276 277 278
      expect(page).not_to have_content("Labels")
    end
  end

  step 'I should not see milestone field' do
D
Dmitriy Zaporozhets 已提交
279
    page.within '.issue-form' do
280 281 282 283 284
      expect(page).not_to have_content("Milestone")
    end
  end

  step 'I should not see assignee field' do
D
Dmitriy Zaporozhets 已提交
285
    page.within '.issue-form' do
286 287 288 289
      expect(page).not_to have_content("Assign to")
    end
  end

G
Grzegorz Bizon 已提交
290 291 292 293 294 295 296 297 298 299
  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
300 301 302 303 304

  step 'I should see "Release 0.4" at the top' do
    expect(page.find('ul.content-list.issues-list li.issue:first-child')).to have_content("Release 0.4")
  end

305 306 307
  def filter_issue(text)
    fill_in 'issue_search', with: text
  end
308

309
end