Add helpers for labels dropdown
This commit is contained in:
parent
afd2d38111
commit
557344539d
2 changed files with 105 additions and 0 deletions
|
@ -174,6 +174,39 @@ module LabelsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def create_label_title(subject)
|
||||
case subject
|
||||
when Group
|
||||
_('Create group label')
|
||||
when Project
|
||||
_('Create project label')
|
||||
else
|
||||
_('Create new label')
|
||||
end
|
||||
end
|
||||
|
||||
def manage_labels_title(subject)
|
||||
case subject
|
||||
when Group
|
||||
_('Manage group labels')
|
||||
when Project
|
||||
_('Manage project labels')
|
||||
else
|
||||
_('Manage labels')
|
||||
end
|
||||
end
|
||||
|
||||
def view_labels_title(subject)
|
||||
case subject
|
||||
when Group
|
||||
_('View group labels')
|
||||
when Project
|
||||
_('View project labels')
|
||||
else
|
||||
_('View labels')
|
||||
end
|
||||
end
|
||||
|
||||
# Required for Banzai::Filter::LabelReferenceFilter
|
||||
module_function :render_colored_label, :text_color_for_bg, :escape_once
|
||||
end
|
||||
|
|
|
@ -139,4 +139,76 @@ describe LabelsHelper do
|
|||
expect(text_color_for_bg('#000')).to eq '#FFFFFF'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'create_label_title' do
|
||||
set(:group) { create(:group) }
|
||||
|
||||
context 'with a group as subject' do
|
||||
it 'returns "Create group label"' do
|
||||
expect(create_label_title(group)).to eq 'Create group label'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a project as subject' do
|
||||
set(:project) { create(:project, namespace: group) }
|
||||
|
||||
it 'returns "Create project label"' do
|
||||
expect(create_label_title(project)).to eq 'Create project label'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no subject' do
|
||||
it 'returns "Create new label"' do
|
||||
expect(create_label_title(nil)).to eq 'Create new label'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'manage_labels_title' do
|
||||
set(:group) { create(:group) }
|
||||
|
||||
context 'with a group as subject' do
|
||||
it 'returns "Manage group labels"' do
|
||||
expect(manage_labels_title(group)).to eq 'Manage group labels'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a project as subject' do
|
||||
set(:project) { create(:project, namespace: group) }
|
||||
|
||||
it 'returns "Manage project labels"' do
|
||||
expect(manage_labels_title(project)).to eq 'Manage project labels'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no subject' do
|
||||
it 'returns "Manage labels"' do
|
||||
expect(manage_labels_title(nil)).to eq 'Manage labels'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'view_labels_title' do
|
||||
set(:group) { create(:group) }
|
||||
|
||||
context 'with a group as subject' do
|
||||
it 'returns "View group labels"' do
|
||||
expect(view_labels_title(group)).to eq 'View group labels'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a project as subject' do
|
||||
set(:project) { create(:project, namespace: group) }
|
||||
|
||||
it 'returns "View project labels"' do
|
||||
expect(view_labels_title(project)).to eq 'View project labels'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no subject' do
|
||||
it 'returns "View labels"' do
|
||||
expect(view_labels_title(nil)).to eq 'View labels'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue