Commit c9e6caae authored by Nick Thomas's avatar Nick Thomas

Promote visibility level helpers from Group to Namespace

In EE, we make use of `namespace#public?` in projects. When the project is in a
personal namespace, this breaks as the `public?` helper isn't present.
parent 5f32bd77
......@@ -2,7 +2,6 @@ require 'carrierwave/orm/activerecord'
class Group < Namespace
include Gitlab::ConfigHelper
include Gitlab::VisibilityLevel
include AccessRequestable
include Avatarable
include Referable
......@@ -103,10 +102,6 @@ class Group < Namespace
full_name
end
def visibility_level_field
:visibility_level
end
def visibility_level_allowed_by_projects
allowed_by_projects = self.projects.where('visibility_level > ?', self.visibility_level).none?
......
......@@ -5,6 +5,7 @@ class Namespace < ActiveRecord::Base
include Sortable
include Gitlab::ShellAdapter
include Gitlab::CurrentSettings
include Gitlab::VisibilityLevel
include Routable
include AfterCommitQueue
......@@ -105,6 +106,10 @@ class Namespace < ActiveRecord::Base
end
end
def visibility_level_field
:visibility_level
end
def to_param
full_path
end
......
......@@ -63,6 +63,14 @@ describe Namespace, models: true do
it { is_expected.to respond_to(:has_parent?) }
end
describe 'inclusions' do
it { is_expected.to include_module(Gitlab::VisibilityLevel) }
end
describe '#visibility_level_field' do
it { expect(namespace.visibility_level_field).to eq(:visibility_level) }
end
describe '#to_param' do
it { expect(namespace.to_param).to eq(namespace.full_path) }
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