2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-17 09:22:16 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'admin issues labels' do
|
2021-04-04 14:09:19 -04:00
|
|
|
let!(:bug_label) { Label.create!(title: 'bug', template: true) }
|
|
|
|
let!(:feature_label) { Label.create!(title: 'feature', template: true) }
|
2016-12-17 09:22:16 -05:00
|
|
|
|
|
|
|
before do
|
2020-11-23 10:09:37 -05:00
|
|
|
admin = create(:admin)
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2016-12-17 09:22:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'list' do
|
|
|
|
before do
|
|
|
|
visit admin_labels_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders labels list' do
|
|
|
|
page.within '.manage-labels-list' do
|
|
|
|
expect(page).to have_content('bug')
|
|
|
|
expect(page).to have_content('feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes label' do
|
|
|
|
page.within "#label_#{bug_label.id}" do
|
|
|
|
click_link 'Delete'
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.manage-labels-list' do
|
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'deletes all labels', :js do
|
2016-12-17 09:22:16 -05:00
|
|
|
page.within '.labels' do
|
2021-05-19 02:10:37 -04:00
|
|
|
page.all('.js-remove-label').each do |remove|
|
2017-10-13 17:40:28 -04:00
|
|
|
accept_confirm { remove.click }
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-12-17 09:22:16 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-10 08:44:00 -05:00
|
|
|
|
|
|
|
expect(page).to have_content("There are no labels yet")
|
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
expect(page).not_to have_content('feature_label')
|
2016-12-17 09:22:16 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'create' do
|
|
|
|
before do
|
|
|
|
visit new_admin_label_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates new label' do
|
|
|
|
fill_in 'Title', with: 'support'
|
|
|
|
fill_in 'Background color', with: '#F95610'
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
page.within '.manage-labels-list' do
|
|
|
|
expect(page).to have_content('support')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not creates label with invalid color' do
|
|
|
|
fill_in 'Title', with: 'support'
|
|
|
|
fill_in 'Background color', with: '#12'
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
page.within '.label-form' do
|
|
|
|
expect(page).to have_content('Color must be a valid color code')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not creates label if label already exists' do
|
|
|
|
fill_in 'Title', with: 'bug'
|
|
|
|
fill_in 'Background color', with: '#F95610'
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
page.within '.label-form' do
|
|
|
|
expect(page).to have_content 'Title has already been taken'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'edit' do
|
|
|
|
it 'changes bug label' do
|
|
|
|
visit edit_admin_label_path(bug_label)
|
|
|
|
|
|
|
|
fill_in 'Title', with: 'fix'
|
|
|
|
fill_in 'Background color', with: '#F15610'
|
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
page.within '.manage-labels-list' do
|
|
|
|
expect(page).to have_content('fix')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|