2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe API::ProjectMilestones do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let!(:project) { create(:project, namespace: user.namespace ) }
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_developer(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'group and project milestones', "/projects/:id/milestones" do
|
|
|
|
let(:route) { "/projects/#{project.id}/milestones" }
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'DELETE /projects/:id/milestones/:milestone_id' do
|
|
|
|
let(:guest) { create(:user) }
|
|
|
|
let(:reporter) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_reporter(reporter)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 404 response when the project does not exists' do
|
|
|
|
delete api("/projects/999/milestones/#{milestone.id}", user)
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(404)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 404 response when the milestone does not exists' do
|
|
|
|
delete api("/projects/#{project.id}/milestones/999", user)
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(404)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns 404 from guest user deleting a milestone" do
|
|
|
|
delete api("/projects/#{project.id}/milestones/#{milestone.id}", guest)
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe 'PUT /projects/:id/milestones/:milestone_id to test observer on close' do
|
|
|
|
it 'creates an activity event when an milestone is closed' do
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(Event).to receive(:create!)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
|
2019-02-15 15:39:39 +05:30
|
|
|
params: { state_event: 'close' }
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|