Commit f897db6b authored by Eulyeon Ko's avatar Eulyeon Ko

Generalize scoped_labels_available helper

Make the helper accept parent parameter.
parent 4ac99e12
......@@ -172,7 +172,7 @@ module IssuesHelper
end
# Overridden in EE
def scoped_labels_available?(project)
def scoped_labels_available?(parent)
false
end
end
......
......@@ -31,6 +31,6 @@
'empty-state-meta': { svg_path: image_path('illustrations/issues.svg') },
'sort-key': @sort,
type: 'issues',
'scoped-labels': @group.feature_available?(:scoped_labels).to_json } }
'scoped-labels': scoped_labels_available?(@group).to_json } }
- else
= render 'shared/issues'
......@@ -55,8 +55,9 @@ module EE
issue.incident? && issue.project.feature_available?(:incident_timeline_view)
end
def scoped_labels_available?(project)
project.feature_available?(:scoped_labels)
override :scoped_labels_available?
def scoped_labels_available?(parent)
parent.feature_available?(:scoped_labels)
end
end
end
......@@ -3,7 +3,8 @@
require "spec_helper"
RSpec.describe EE::IssuesHelper do
let(:project) { create(:project) }
let(:group) { create :group }
let(:project) { create :project, group: group }
let(:issue) { create :issue, project: project }
describe '#issue_closed_link' do
......@@ -91,9 +92,7 @@ RSpec.describe EE::IssuesHelper do
end
describe '#scoped_labels_available?' do
subject { helper.scoped_labels_available?(project) }
context 'without license' do
shared_examples 'without license' do
before do
stub_licensed_features(scoped_labels: false)
end
......@@ -101,12 +100,26 @@ RSpec.describe EE::IssuesHelper do
it { is_expected.to be_falsy }
end
context 'with license' do
shared_examples 'with license' do
before do
stub_licensed_features(scoped_labels: true)
end
it { is_expected.to be_truthy }
end
context 'project' do
subject { helper.scoped_labels_available?(project) }
it_behaves_like 'without license'
it_behaves_like 'with license'
end
context 'group' do
subject { helper.scoped_labels_available?(group) }
it_behaves_like 'without license'
it_behaves_like 'with license'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment