2015-07-14 18:20:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::MilestonesController do
|
2017-01-25 16:44:33 -05:00
|
|
|
let(:project) { create(:empty_project) }
|
2015-07-14 18:20:38 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
let(:issue) { create(:issue, project: project, milestone: milestone) }
|
2015-12-05 01:56:10 -05:00
|
|
|
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
|
2015-07-14 18:20:38 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
project.team << [user, :master]
|
|
|
|
controller.instance_variable_set(:@project, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#destroy" do
|
2016-07-25 14:16:19 -04:00
|
|
|
it "removes milestone" do
|
2015-07-14 18:20:38 -04:00
|
|
|
expect(issue.milestone_id).to eq(milestone.id)
|
2015-08-31 00:51:34 -04:00
|
|
|
|
2015-12-05 01:56:10 -05:00
|
|
|
delete :destroy, namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :js
|
2015-07-14 18:20:38 -04:00
|
|
|
expect(response).to be_success
|
2015-08-31 00:51:34 -04:00
|
|
|
|
2016-10-27 00:48:26 -04:00
|
|
|
expect(Event.recent.first.action).to eq(Event::DESTROYED)
|
2015-08-31 00:51:34 -04:00
|
|
|
|
2015-07-14 18:20:38 -04:00
|
|
|
expect { Milestone.find(milestone.id) }.to raise_exception(ActiveRecord::RecordNotFound)
|
|
|
|
issue.reload
|
|
|
|
expect(issue.milestone_id).to eq(nil)
|
2015-09-18 11:39:19 -04:00
|
|
|
|
|
|
|
merge_request.reload
|
|
|
|
expect(merge_request.milestone_id).to eq(nil)
|
|
|
|
|
2015-07-14 18:20:38 -04:00
|
|
|
# Check system note left for milestone removal
|
|
|
|
last_note = project.issues.find(issue.id).notes[-1].note
|
2016-11-23 01:55:23 -05:00
|
|
|
expect(last_note).to eq('removed milestone')
|
2015-07-14 18:20:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|