Commit 852f5097 authored by Mike Greiling's avatar Mike Greiling

rename skip_level? to disallowed_visibitility_level?

parent 37edce19
...@@ -95,7 +95,7 @@ module VisibilityLevelHelper ...@@ -95,7 +95,7 @@ module VisibilityLevelHelper
:default_group_visibility, :default_group_visibility,
to: :current_application_settings to: :current_application_settings
def skip_level?(form_model, level) def disallowed_visibility_level?(form_model, level)
return false unless form_model.respond_to?(:visibility_level_allowed?) return false unless form_model.respond_to?(:visibility_level_allowed?)
!form_model.visibility_level_allowed?(level) !form_model.visibility_level_allowed?(level)
end end
......
- Gitlab::VisibilityLevel.values.each do |level| - Gitlab::VisibilityLevel.values.each do |level|
- next if skip_level?(form_model, level) - next if disallowed_visibility_level?(form_model, level)
.radio .radio
- restricted = restricted_visibility_levels.include?(level) - restricted = restricted_visibility_levels.include?(level)
= form.label "#{model_method}_#{level}" do = form.label "#{model_method}_#{level}" do
......
...@@ -58,35 +58,35 @@ describe VisibilityLevelHelper do ...@@ -58,35 +58,35 @@ describe VisibilityLevelHelper do
end end
end end
describe "skip_level?" do describe "disallowed_visibility_level?" do
describe "forks" do describe "forks" do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, forked_from_project: project) }
it "skips levels" do it "disallows levels" do
expect(skip_level?(fork_project, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy expect(disallowed_visibility_level?(fork_project, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy
expect(skip_level?(fork_project, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey expect(disallowed_visibility_level?(fork_project, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey
expect(skip_level?(fork_project, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey expect(disallowed_visibility_level?(fork_project, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey
end end
end end
describe "non-forked project" do describe "non-forked project" do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal) }
it "skips levels" do it "disallows levels" do
expect(skip_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey expect(disallowed_visibility_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
expect(skip_level?(project, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey expect(disallowed_visibility_level?(project, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey
expect(skip_level?(project, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey expect(disallowed_visibility_level?(project, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey
end end
end end
describe "Snippet" do describe "Snippet" do
let(:snippet) { create(:snippet, :internal) } let(:snippet) { create(:snippet, :internal) }
it "skips levels" do it "disallows levels" do
expect(skip_level?(snippet, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey expect(disallowed_visibility_level?(snippet, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
expect(skip_level?(snippet, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey expect(disallowed_visibility_level?(snippet, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey
expect(skip_level?(snippet, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey expect(disallowed_visibility_level?(snippet, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey
end 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