2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-03 09:20:50 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe "User removes labels" do
|
2018-04-03 09:20:50 -04:00
|
|
|
let(:project) { create(:project_empty_repo, :public) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2018-04-03 09:20:50 -04:00
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when one label" do
|
|
|
|
let!(:label) { create(:label, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit(project_labels_path(project))
|
|
|
|
end
|
|
|
|
|
2021-04-12 08:09:15 -04:00
|
|
|
it "removes label", :js do
|
2018-05-29 07:11:14 -04:00
|
|
|
page.within(".other-labels") do
|
2018-04-03 09:20:50 -04:00
|
|
|
page.first(".label-list-item") do
|
2018-05-29 07:11:14 -04:00
|
|
|
first('.js-label-options-dropdown').click
|
2021-04-14 11:09:04 -04:00
|
|
|
first('.js-delete-label-modal-button').click
|
2018-04-03 09:20:50 -04:00
|
|
|
end
|
2021-04-12 08:09:15 -04:00
|
|
|
end
|
2019-05-28 06:05:20 -04:00
|
|
|
|
2021-04-12 08:09:15 -04:00
|
|
|
expect(page).to have_content("#{label.title} will be permanently deleted from #{project.name}. This cannot be undone.")
|
2019-05-28 06:05:20 -04:00
|
|
|
|
2021-04-12 08:09:15 -04:00
|
|
|
first(:link, "Delete label").click
|
2018-04-03 09:20:50 -04:00
|
|
|
|
|
|
|
expect(page).to have_content("Label was removed").and have_no_content(label.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when many labels", :js do
|
|
|
|
before do
|
|
|
|
create_list(:label, 3, project: project)
|
|
|
|
|
|
|
|
visit(project_labels_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "removes all labels" do
|
2018-05-29 07:11:14 -04:00
|
|
|
loop do
|
2019-04-26 11:51:05 -04:00
|
|
|
li = page.first(".label-list-item", minimum: 0)
|
2018-05-29 07:11:14 -04:00
|
|
|
break unless li
|
2018-05-29 07:50:29 -04:00
|
|
|
|
2018-05-29 07:11:14 -04:00
|
|
|
li.find('.js-label-options-dropdown').click
|
|
|
|
li.click_button("Delete")
|
|
|
|
click_link("Delete label")
|
2018-04-03 09:20:50 -04:00
|
|
|
end
|
2018-05-29 07:11:14 -04:00
|
|
|
|
|
|
|
expect(page).to have_content("Generate a default set of labels").and have_content("New label")
|
2018-04-03 09:20:50 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|