BigW Consortium Gitlab

project_milestones_spec.rb 911 Bytes
Newer Older
1 2 3 4
require 'spec_helper'

describe API::ProjectMilestones do
  let(:user) { create(:user) }
5
  let!(:project) { create(:project, namespace: user.namespace ) }
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
  let!(:closed_milestone) { create(:closed_milestone, project: project, title: 'version1', description: 'closed milestone') }
  let!(:milestone) { create(:milestone, project: project, title: 'version2', description: 'open milestone') }

  before do
    project.team << [user, :developer]
  end

  it_behaves_like 'group and project milestones', "/projects/:id/milestones"  do
    let(:route) { "/projects/#{project.id}/milestones" }
  end

  describe 'PUT /projects/:id/milestones/:milestone_id to test observer on close' do
    it 'creates an activity event when an milestone is closed' do
      expect(Event).to receive(:create)

      put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
          state_event: 'close'
    end
  end
end