milestone_spec.rb 1.78 KB
Newer Older
1 2 3
require 'rails_helper'

feature 'Milestone', feature: true do
4
  let(:project) { create(:empty_project, :public) }
5 6 7 8
  let(:user)   { create(:user) }

  before do
    project.team << [user, :master]
9
    gitlab_sign_in(user)
10 11 12
  end

  feature 'Create a milestone' do
13
    scenario 'shows an informative message for a new milestone' do
14
      visit new_namespace_project_milestone_path(project.namespace, project)
15

16 17
      page.within '.milestone-form' do
        fill_in "milestone_title", with: '8.7'
18 19
        fill_in "milestone_start_date", with: '2016-11-16'
        fill_in "milestone_due_date", with: '2016-12-16'
20
      end
21

22 23 24
      find('input[name="commit"]').click

      expect(find('.alert-success')).to have_content('Assign some issues to this milestone.')
Pedro Moreira da Silva's avatar
Pedro Moreira da Silva committed
25
      expect(page).to have_content('Nov 16, 2016–Dec 16, 2016')
26 27 28 29
    end
  end

  feature 'Open a milestone with closed issues' do
30
    scenario 'shows an informative message' do
31 32
      milestone = create(:milestone, project: project, title: 8.7)

33 34 35 36 37 38
      create(:issue, title: "Bugfix1", project: project, milestone: milestone, state: "closed")
      visit namespace_project_milestone_path(project.namespace, project, milestone)

      expect(find('.alert-success')).to have_content('All issues for this milestone are closed. You may close this milestone now.')
    end
  end
39 40 41 42 43 44 45 46 47 48 49 50 51 52

  feature 'Open a milestone with an existing title' do
    scenario 'displays validation message' do
      milestone = create(:milestone, project: project, title: 8.7)

      visit new_namespace_project_milestone_path(project.namespace, project)
      page.within '.milestone-form' do
        fill_in "milestone_title", with: milestone.title
      end
      find('input[name="commit"]').click

      expect(find('.alert-danger')).to have_content('Title has already been taken')
    end
  end
53
end