BigW Consortium Gitlab

milestones.rb 3.78 KB
Newer Older
1
class Spinach::Features::GroupMilestones < Spinach::FeatureSteps
2
  include WaitForRequests
3 4 5 6 7 8
  include SharedAuthentication
  include SharedPaths
  include SharedGroup
  include SharedUser

  step 'I click on group milestones' do
9
    visit group_milestones_path('owned')
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  end

  step 'I should see group milestones index page has no milestones' do
    expect(page).to have_content('No milestones to show')
  end

  step 'Group has projects with milestones' do
    group_milestone
  end

  step 'I should see group milestones index page with milestones' do
    expect(page).to have_content('Version 7.2')
    expect(page).to have_content('GL-113')
    expect(page).to have_link('3 Issues', href: issues_group_path("owned", milestone_title: "Version 7.2"))
    expect(page).to have_link('0 Merge Requests', href: merge_requests_group_path("owned", milestone_title: "GL-113"))
  end

  step 'I click on one group milestone' do
28 29 30
    milestones = Milestone.where(title: 'GL-113')
    @global_milestone = GlobalMilestone.new('GL-113', milestones)

31 32 33 34
    click_link 'GL-113'
  end

  step 'I should see group milestone with descriptions and expiry date' do
Robert Speicher committed
35
    expect(page).to have_content('expires on Aug 20, 2114')
36 37 38 39
  end

  step 'I should see group milestone with all issues and MRs assigned to that milestone' do
    expect(page).to have_content('Milestone GL-113')
40
    expect(page).to have_content('Issues 3 Open: 3 Closed: 0')
41
    issue = Milestone.find_by(name: 'GL-113').issues.first
42
    expect(page).to have_link(issue.title, href: project_issue_path(issue.project, issue))
43 44 45 46 47 48 49
  end

  step 'I fill milestone name' do
    fill_in 'milestone_title', with: 'v2.9.0'
  end

  step 'I click new milestone button' do
50
    click_link "New milestone"
51 52 53
  end

  step 'I press create mileston button' do
54
    click_button "Create milestone"
55 56
  end

Felipe Artur committed
57
  step 'group milestone should be created' do
58
    group = Group.find_by(name: 'Owned')
Felipe Artur committed
59
    expect(page).to have_content group.milestones.find_by_title('v2.9.0').title
60 61
  end

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  step 'I should see the "bug" label' do
    page.within('#tab-issues') do
      expect(page).to have_content 'bug'
    end
  end

  step 'I should see the "feature" label' do
    page.within('#tab-issues') do
      expect(page).to have_content 'bug'
    end
  end

  step 'I should see the project name in the Issue row' do
    page.within('#tab-issues') do
      @global_milestone.projects.each do |project|
        expect(page).to have_content project.name
      end
    end
  end

  step 'I click on the "Labels" tab' do
83
    page.within('.content .nav-links') do
84 85 86 87 88
      page.find(:xpath, "//a[@href='#tab-labels']").click
    end
  end

  step 'I should see the list of labels' do
89
    wait_for_requests
Phil Hughes committed
90

91 92 93 94 95 96
    page.within('#tab-labels') do
      expect(page).to have_content 'bug'
      expect(page).to have_content 'feature'
    end
  end

97 98 99 100 101 102
  private

  def group_milestone
    group = owned_group

    %w(gitlabhq gitlab-ci cookbook-gitlab).each do |path|
103
      project = create(:empty_project, path: path, group: group)
104
      milestone = create :milestone, title: "Version 7.2", project: project
105 106 107 108

      create(:label, project: project, title: 'bug')
      create(:label, project: project, title: 'feature')

109 110
      create :issue,
        project: project,
111
        assignees: [current_user],
112 113 114
        author: current_user,
        milestone: milestone

115 116 117 118 119
      milestone = create :milestone,
        title: "GL-113",
        project: project,
        due_date: '2114-08-20',
        description: 'Lorem Ipsum is simply dummy text'
120

121
      issue = create :issue,
122
        project: project,
123
        assignees: [current_user],
124 125
        author: current_user,
        milestone: milestone
126 127 128

      issue.labels << project.labels.find_by(title: 'bug')
      issue.labels << project.labels.find_by(title: 'feature')
129
    end
130 131

    current_user.refresh_authorized_projects
132 133
  end
end