project_milestone.rb 2.02 KB
Newer Older
Rubén Dávila's avatar
Rubén Dávila committed
1 2 3 4
class Spinach::Features::ProjectMilestone < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedPaths
Phil Hughes's avatar
Phil Hughes committed
5
  include WaitForAjax
Rubén Dávila's avatar
Rubén Dávila committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

  step 'milestone has issue "Bugfix1" with labels: "bug", "feature"' do
    project = Project.find_by(name: "Shop")
    milestone = project.milestones.find_by(title: 'v2.2')
    issue = create(:issue, title: "Bugfix1", project: project, milestone: milestone)
    issue.labels << project.labels.find_by(title: 'bug')
    issue.labels << project.labels.find_by(title: 'feature')
  end

  step 'milestone has issue "Bugfix2" with labels: "bug", "enhancement"' do
    project = Project.find_by(name: "Shop")
    milestone = project.milestones.find_by(title: 'v2.2')
    issue = create(:issue, title: "Bugfix2", project: project, milestone: milestone)
    issue.labels << project.labels.find_by(title: 'bug')
    issue.labels << project.labels.find_by(title: 'enhancement')
  end

  step 'project "Shop" has milestone "v2.2"' do
    project = Project.find_by(name: "Shop")
    milestone = create(:milestone,
                       title: "v2.2",
                       project: project,
                       description: "# Description header"
                      )
    3.times { create(:issue, project: project, milestone: milestone) }
  end

  step 'I should see the list of labels' do
    expect(page).to have_selector('ul.manage-labels-list')
  end

  step 'I should see the labels "bug", "enhancement" and "feature"' do
Phil Hughes's avatar
Phil Hughes committed
38 39
    wait_for_ajax

Rubén Dávila's avatar
Rubén Dávila committed
40 41 42 43 44 45 46
    page.within('#tab-issues') do
      expect(page).to have_content 'bug'
      expect(page).to have_content 'enhancement'
      expect(page).to have_content 'feature'
    end
  end

47 48 49 50 51 52
  step 'I should see the "bug" label listed only once' do
    page.within('#tab-labels') do
      expect(page).to have_content('bug', count: 1)
    end
  end

Rubén Dávila's avatar
Rubén Dávila committed
53 54 55 56 57
  step 'I click link "v2.2"' do
    click_link "v2.2"
  end

  step 'I click link "Labels"' do
58
    page.within('.layout-nav .nav-links') do
Rubén Dávila's avatar
Rubén Dávila committed
59 60 61 62
      page.find(:xpath, "//a[@href='#tab-labels']").click
    end
  end
end