issues.rb 8.17 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
Nihad Abbasov's avatar
Nihad Abbasov committed
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"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
19 20
  end

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

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

29
  step 'I click link "Closed"' do
30 31 32
    click_link "Closed"
  end

Valery Sizov's avatar
tests  
Valery Sizov committed
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
  step 'I click link "New Issue"' do
58 59 60
    click_link "New Issue"
  end

61
  step 'I click "author" dropdown' do
62
    first('#s2id_author_id').click
63 64 65
  end

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

72
  step 'I submit new issue "500 error on profile"' do
73
    fill_in "issue_title", with: "500 error on profile"
74
    click_button "Submit issue"
75 76
  end

77 78 79
  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"
80
    click_button "Submit issue"
81 82
  end

83
  step 'I click link "500 error on profile"' do
84 85 86
    click_link "500 error on profile"
  end

87
  step 'I should see label \'bug\' with issue' do
Douwe Maan's avatar
Douwe Maan committed
88
    page.within '.issuable-show-labels' do
89
      expect(page).to have_content 'bug'
90 91 92
    end
  end

93
  step 'I should see issue "500 error on profile"' do
skv's avatar
skv committed
94
    issue = Issue.find_by(title: "500 error on profile")
95 96 97
    expect(page).to have_content issue.title
    expect(page).to have_content issue.author_name
    expect(page).to have_content issue.project.name
98 99
  end

100
  step 'I fill in issue search with "Re"' do
101
    filter_issue "Re"
102 103
  end

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

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

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

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

120
  step 'project "Shop" has milestone "v2.2"' do
121

122
    milestone = create(:milestone, title: "v2.2", project: project)
123

124
    3.times { create(:issue, project: project, milestone: milestone) }
125 126
  end

127
  step 'project "Shop" has milestone "v3.0"' do
128

129
    milestone = create(:milestone, title: "v3.0", project: project)
130

131
    3.times { create(:issue, project: project, milestone: milestone) }
132 133 134 135 136 137
  end

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

138
  step 'I should see selected milestone with title "v3.0"' do
139
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
140
    expect(find(issues_milestone_selector)).to have_content("v3.0")
141 142 143
  end

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

145 146 147 148
    first_assignee = project.users.first
    select first_assignee.name, from: "assignee_id"
  end

149
  step 'I should see first assignee from "Shop" as selected assignee' do
150
    issues_assignee_selector = "#issue_assignee_id_chzn > a"
151

152
    assignee_name = project.users.first.name
153
    expect(find(issues_assignee_selector)).to have_content(assignee_name)
154 155
  end

156
  step 'project "Shop" have "Release 0.4" open issue' do
157

158
    create(:issue,
159 160
           title: "Release 0.4",
           project: project,
161 162 163
           author: project.users.first,
           description: "# Description header"
          )
164 165
  end

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

173
  step 'project "Shop" have "Release 0.3" closed issue' do
Andrew8xx8's avatar
Andrew8xx8 committed
174
    create(:closed_issue,
175 176 177
           title: "Release 0.3",
           project: project,
           author: project.users.first)
178
  end
179

180
  step 'empty project "Empty Project"' do
181 182 183 184 185
    create :empty_project, name: 'Empty Project', namespace: @user.namespace
  end

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

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

196 197 198 199 200
  When "I visit project \"Community\" issues page" do
    project = Project.find_by(name: 'Community')
    visit namespace_project_issues_path(project.namespace, project)
  end

201 202
  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
Vinnie Okada's avatar
Vinnie Okada committed
203
    visit namespace_project_issues_path(project.namespace, project)
204
  end
Marin Jankovski's avatar
Marin Jankovski committed
205 206

  step 'I leave a comment with code block' do
207
    page.within(".js-main-target-form") do
Marin Jankovski's avatar
Marin Jankovski committed
208 209 210 211 212 213
      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

214
  step 'I should see an error alert section within the comment form' do
215
    page.within(".js-main-target-form") do
216 217 218 219
      find(".error-alert")
    end
  end

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

224
  step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
225
    create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
226 227
  end

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

232
  step 'I fill in issue search with \'Description for issue1\'' do
233
    filter_issue 'Description for issue'
234 235
  end

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

240
  step 'I fill in issue search with \'Rock and roll\'' do
241
    filter_issue 'Description for issue'
242 243
  end

244
  step 'I should see \'Bugfix1\' in issues' do
245
    expect(page).to have_content 'Bugfix1'
246 247
  end

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

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

256 257 258 259 260 261 262
  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
263
    page.within ".issues-list" do
264 265 266 267
      click_link 'bug'
    end
  end

268
  step 'I should not see labels field' do
269
    page.within '.issue-form' do
270 271 272 273 274
      expect(page).not_to have_content("Labels")
    end
  end

  step 'I should not see milestone field' do
275
    page.within '.issue-form' do
276 277 278 279 280
      expect(page).not_to have_content("Milestone")
    end
  end

  step 'I should not see assignee field' do
281
    page.within '.issue-form' do
282 283 284 285
      expect(page).not_to have_content("Assign to")
    end
  end

286 287 288 289 290 291 292 293 294 295
  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
296 297 298
  def filter_issue(text)
    fill_in 'issue_search', with: text
  end
299
end