debian-mirror-gitlab/spec/controllers/projects/milestones_controller_spec.rb

38 lines
1.2 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
require 'spec_helper'
describe Projects::MilestonesController do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
let(:issue) { create(:issue, project: project, milestone: milestone) }
2015-12-23 02:04:40 +05:30
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
2015-09-11 14:41:01 +05:30
before do
sign_in(user)
project.team << [user, :master]
controller.instance_variable_set(:@project, project)
end
describe "#destroy" do
2016-09-13 17:45:13 +05:30
it "removes milestone" do
2015-09-11 14:41:01 +05:30
expect(issue.milestone_id).to eq(milestone.id)
2015-09-25 12:07:36 +05:30
2015-12-23 02:04:40 +05:30
delete :destroy, namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :js
2015-09-11 14:41:01 +05:30
expect(response).to be_success
2015-09-25 12:07:36 +05:30
expect(Event.first.action).to eq(Event::DESTROYED)
2015-09-11 14:41:01 +05:30
expect { Milestone.find(milestone.id) }.to raise_exception(ActiveRecord::RecordNotFound)
issue.reload
expect(issue.milestone_id).to eq(nil)
2015-09-25 12:07:36 +05:30
merge_request.reload
expect(merge_request.milestone_id).to eq(nil)
2015-09-11 14:41:01 +05:30
# Check system note left for milestone removal
last_note = project.issues.find(issue.id).notes[-1].note
expect(last_note).to eq('Milestone removed')
end
end
end