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

8
  step 'I should see "Release 0.4" in issues' do
9 10 11
    page.should have_content "Release 0.4"
  end

12
  step 'I should not see "Release 0.3" in issues' do
13 14 15
    page.should_not have_content "Release 0.3"
  end

16
  step 'I should not see "Tweet control" in issues' do
17
    page.should_not have_content "Tweet control"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
18 19
  end

20
  step 'I click link "Closed"' do
21 22 23
    click_link "Closed"
  end

24
  step 'I should see "Release 0.3" in issues' do
25 26 27
    page.should have_content "Release 0.3"
  end

28
  step 'I should not see "Release 0.4" in issues' do
29 30 31
    page.should_not have_content "Release 0.4"
  end

32
  step 'I click link "All"' do
33 34 35
    click_link "All"
  end

36
  step 'I click link "Release 0.4"' do
37 38 39
    click_link "Release 0.4"
  end

40
  step 'I should see issue "Release 0.4"' do
41 42 43
    page.should have_content "Release 0.4"
  end

44
  step 'I click link "New Issue"' do
45 46 47
    click_link "New Issue"
  end

48
  step 'I submit new issue "500 error on profile"' do
49
    fill_in "issue_title", with: "500 error on profile"
50 51 52
    click_button "Submit new issue"
  end

53 54 55 56 57 58
  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

59
  step 'I click link "500 error on profile"' do
60 61 62
    click_link "500 error on profile"
  end

63 64 65 66 67 68
  step 'I should see label \'bug\' with issue' do
    within '.issue-show-labels' do
      page.should have_content 'bug'
    end
  end

69
  step 'I should see issue "500 error on profile"' do
skv's avatar
skv committed
70
    issue = Issue.find_by(title: "500 error on profile")
71 72 73 74 75
    page.should have_content issue.title
    page.should have_content issue.author_name
    page.should have_content issue.project.name
  end

76
  step 'I fill in issue search with "Re"' do
77
    filter_issue "Re"
78 79
  end

80
  step 'I fill in issue search with "Bu"' do
81
    filter_issue "Bu"
82 83
  end

84
  step 'I fill in issue search with ".3"' do
85
    filter_issue ".3"
86 87
  end

88
  step 'I fill in issue search with "Something"' do
89
    filter_issue "Something"
90 91
  end

92
  step 'I fill in issue search with ""' do
93
    filter_issue ""
94 95
  end

96
  step 'project "Shop" has milestone "v2.2"' do
97

98
    milestone = create(:milestone, title: "v2.2", project: project)
99

100
    3.times { create(:issue, project: project, milestone: milestone) }
101 102
  end

103
  step 'project "Shop" has milestone "v3.0"' do
104

105
    milestone = create(:milestone, title: "v3.0", project: project)
106

107
    3.times { create(:issue, project: project, milestone: milestone) }
108 109 110 111 112 113
  end

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

114
  step 'I should see selected milestone with title "v3.0"' do
115
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
116 117 118 119
    page.find(issues_milestone_selector).should have_content("v3.0")
  end

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

121 122 123 124
    first_assignee = project.users.first
    select first_assignee.name, from: "assignee_id"
  end

125
  step 'I should see first assignee from "Shop" as selected assignee' do
126
    issues_assignee_selector = "#issue_assignee_id_chzn > a"
127

128 129 130 131
    assignee_name = project.users.first.name
    page.find(issues_assignee_selector).should have_content(assignee_name)
  end

132
  step 'project "Shop" have "Release 0.4" open issue' do
133

134
    create(:issue,
135 136
           title: "Release 0.4",
           project: project,
137 138 139
           author: project.users.first,
           description: "# Description header"
          )
140 141
  end

142
  step 'project "Shop" have "Tweet control" open issue' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
143
    create(:issue,
144
           title: "Tweet control",
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
145 146 147 148
           project: project,
           author: project.users.first)
  end

149
  step 'project "Shop" have "Release 0.3" closed issue' do
Andrew8xx8's avatar
Andrew8xx8 committed
150
    create(:closed_issue,
151 152 153
           title: "Release 0.3",
           project: project,
           author: project.users.first)
154
  end
155

156
  step 'empty project "Empty Project"' do
157 158 159 160 161 162 163 164
    create :empty_project, name: 'Empty Project', namespace: @user.namespace
  end

  When 'I visit empty project page' do
    project = Project.find_by(name: 'Empty Project')
    visit project_path(project)
  end

165
  step 'I see empty project details with ssh clone info' do
166 167 168 169 170 171 172 173 174 175
    project = Project.find_by(name: 'Empty Project')
    page.all(:css, '.git-empty .clone').each do |element|
      element.text.should include(project.url_to_repo)
    end
  end

  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
    visit project_issues_path(project)
  end
Marin Jankovski's avatar
Marin Jankovski committed
176 177 178 179 180 181 182 183 184 185 186 187

  step 'I leave a comment with code block' do
    within(".js-main-target-form") do
      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

  step 'The code block should be unchanged' do
    page.should have_content("```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```")
  end
188

189 190
  step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
    issue = create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
191 192
  end

193 194
  step 'project \'Shop\' has issue \'Feature1\' with description: \'Feature submitted for issue1\'' do
    issue = create(:issue, title: 'Feature1', description: 'Feature submitted for issue1', project: project)
195 196
  end

197
  step 'I fill in issue search with \'Description for issue1\'' do
198
    filter_issue 'Description for issue'
199 200
  end

201
  step 'I fill in issue search with \'issue1\'' do
202
    filter_issue 'issue1'
203 204
  end

205
  step 'I fill in issue search with \'Rock and roll\'' do
206
    filter_issue 'Description for issue'
207 208
  end

209 210
  step 'I should see \'Bugfix1\' in issues' do
    page.should have_content 'Bugfix1'
211 212
  end

213 214
  step 'I should see \'Feature1\' in issues' do
    page.should have_content 'Feature1'
215 216
  end

217 218
  step 'I should not see \'Bugfix1\' in issues' do
    page.should_not have_content 'Bugfix1'
219
  end
220

221 222 223 224 225 226 227 228 229 230 231 232
  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
    within ".issues-list" do
      click_link 'bug'
    end
  end

233 234 235 236 237 238 239 240 241 242
  def filter_issue(text)
    fill_in 'issue_search', with: text

    # make sure AJAX request finished
    URI.parse(current_url).request_uri == project_issues_path(project, issue_search: text)
  end

  def project
    @project ||= Project.find_by(name: 'Shop')
  end
243
end