issues.rb 7.9 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
  step 'I click link "New Issue"' do
58 59 60
    click_link "New Issue"
  end

61 62 63 64 65 66 67
  step 'I click "author" dropdown' do
    first('.ajax-users-select').click
  end

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

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

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

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

88
  step 'I should see label \'bug\' with issue' do
89
    page.within '.issue-show-labels' do
90
      expect(page).to have_content 'bug'
91 92 93
    end
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

M
Marin Jankovski 已提交
221
  step 'The code block should be unchanged' do
J
Jason Lee 已提交
222
    expect(page).to have_content("Command [1]: /usr/local/bin/git , see [text](doc/text)")
M
Marin Jankovski 已提交
223
  end
224

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

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

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

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

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

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

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

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

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

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

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

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

287 288 289
  def filter_issue(text)
    fill_in 'issue_search', with: text
  end
290
end