2018-04-11 07:47:23 -04:00
|
|
|
require "rails_helper"
|
|
|
|
|
|
|
|
describe "User deletes milestone", :js do
|
2018-08-06 15:02:52 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, namespace: group) }
|
2018-04-11 07:47:23 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-08-06 15:02:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when milestone belongs to project" do
|
|
|
|
let!(:milestone) { create(:milestone, parent: project, title: "project milestone") }
|
|
|
|
|
|
|
|
it "deletes milestone" do
|
|
|
|
project.add_developer(user)
|
|
|
|
visit(project_milestones_path(project))
|
|
|
|
click_link(milestone.title)
|
|
|
|
click_button("Delete")
|
|
|
|
click_button("Delete milestone")
|
|
|
|
|
|
|
|
expect(page).to have_content("No milestones to show")
|
|
|
|
|
|
|
|
visit(activity_project_path(project))
|
2018-04-11 07:47:23 -04:00
|
|
|
|
2018-11-06 09:33:42 -05:00
|
|
|
expect(page).to have_content("#{user.name} #{user.to_reference} destroyed milestone")
|
2018-08-06 15:02:52 -04:00
|
|
|
end
|
2018-04-11 07:47:23 -04:00
|
|
|
end
|
|
|
|
|
2018-08-06 15:02:52 -04:00
|
|
|
context "when milestone belongs to group" do
|
|
|
|
let!(:milestone_to_be_deleted) { create(:milestone, parent: group, title: "group milestone 1") }
|
|
|
|
let!(:milestone) { create(:milestone, parent: group, title: "group milestone 2") }
|
2018-04-11 07:47:23 -04:00
|
|
|
|
2018-08-06 15:02:52 -04:00
|
|
|
it "deletes milestone" do
|
|
|
|
group.add_developer(user)
|
|
|
|
visit(group_milestones_path(group))
|
2018-04-11 07:47:23 -04:00
|
|
|
|
2018-08-06 15:02:52 -04:00
|
|
|
click_link(milestone_to_be_deleted.title)
|
|
|
|
click_button("Delete")
|
|
|
|
click_button("Delete milestone")
|
2018-04-11 07:47:23 -04:00
|
|
|
|
2018-08-06 15:02:52 -04:00
|
|
|
expect(page).to have_content(milestone.title)
|
|
|
|
expect(page).not_to have_content(milestone_to_be_deleted)
|
|
|
|
end
|
2018-04-11 07:47:23 -04:00
|
|
|
end
|
|
|
|
end
|