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 ...@@ -172,7 +172,7 @@ module IssuesHelper
end end
# Overridden in EE # Overridden in EE
def scoped_labels_available?(project) def scoped_labels_available?(parent)
false false
end end
end end
......
...@@ -31,6 +31,6 @@ ...@@ -31,6 +31,6 @@
'empty-state-meta': { svg_path: image_path('illustrations/issues.svg') }, 'empty-state-meta': { svg_path: image_path('illustrations/issues.svg') },
'sort-key': @sort, 'sort-key': @sort,
type: 'issues', type: 'issues',
'scoped-labels': @group.feature_available?(:scoped_labels).to_json } } 'scoped-labels': scoped_labels_available?(@group).to_json } }
- else - else
= render 'shared/issues' = render 'shared/issues'
...@@ -55,8 +55,9 @@ module EE ...@@ -55,8 +55,9 @@ module EE
issue.incident? && issue.project.feature_available?(:incident_timeline_view) issue.incident? && issue.project.feature_available?(:incident_timeline_view)
end end
def scoped_labels_available?(project) override :scoped_labels_available?
project.feature_available?(:scoped_labels) def scoped_labels_available?(parent)
parent.feature_available?(:scoped_labels)
end end
end end
end end
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
require "spec_helper" require "spec_helper"
RSpec.describe EE::IssuesHelper do 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 } let(:issue) { create :issue, project: project }
describe '#issue_closed_link' do describe '#issue_closed_link' do
...@@ -91,9 +92,7 @@ RSpec.describe EE::IssuesHelper do ...@@ -91,9 +92,7 @@ RSpec.describe EE::IssuesHelper do
end end
describe '#scoped_labels_available?' do describe '#scoped_labels_available?' do
subject { helper.scoped_labels_available?(project) } shared_examples 'without license' do
context 'without license' do
before do before do
stub_licensed_features(scoped_labels: false) stub_licensed_features(scoped_labels: false)
end end
...@@ -101,12 +100,26 @@ RSpec.describe EE::IssuesHelper do ...@@ -101,12 +100,26 @@ RSpec.describe EE::IssuesHelper do
it { is_expected.to be_falsy } it { is_expected.to be_falsy }
end end
context 'with license' do shared_examples 'with license' do
before do before do
stub_licensed_features(scoped_labels: true) stub_licensed_features(scoped_labels: true)
end end
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end 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
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