Commit c7cb7599 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #5022 from amacarthur/config-public-project

make public/private setting for project creation configurable
parents 3811e434 cc1eb965
...@@ -16,7 +16,8 @@ module Projects ...@@ -16,7 +16,8 @@ module Projects
wiki_enabled: default_features.wiki, wiki_enabled: default_features.wiki,
wall_enabled: default_features.wall, wall_enabled: default_features.wall,
snippets_enabled: default_features.snippets, snippets_enabled: default_features.snippets,
merge_requests_enabled: default_features.merge_requests merge_requests_enabled: default_features.merge_requests,
public: default_features.public
} }
@project = Project.new(default_opts.merge(params)) @project = Project.new(default_opts.merge(params))
......
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
.project-edit-errors .project-edit-errors
= render 'projects/errors' = render 'projects/errors'
.project-edit-content .project-edit-content
%p.slead - if Gitlab.config.gitlab.default_projects_features.public
New projects are private by default. You choose who can see the project and commit to repository. %p.slead
New projects are public by default. Any signed in user can see your project but cannot commit to it unless granted access.
- else
%p.slead
New projects are private by default. You choose who can see the project and commit to repository.
%hr %hr
= form_for @project, remote: true do |f| = form_for @project, remote: true do |f|
.control-group.project-name-holder .control-group.project-name-holder
......
...@@ -58,6 +58,7 @@ production: &base ...@@ -58,6 +58,7 @@ production: &base
wiki: true wiki: true
wall: false wall: false
snippets: false snippets: false
public: false
## External issues trackers ## External issues trackers
issues_tracker: issues_tracker:
......
...@@ -75,6 +75,7 @@ Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.g ...@@ -75,6 +75,7 @@ Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.g
Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil? Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil?
Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil? Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil?
Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil? Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil?
Settings.gitlab.default_projects_features['public'] = false if Settings.gitlab.default_projects_features['public'].nil?
# #
# Gravatar # Gravatar
......
...@@ -30,6 +30,37 @@ describe Projects::CreateContext do ...@@ -30,6 +30,37 @@ describe Projects::CreateContext do
it { @project.owner.should == @user } it { @project.owner.should == @user }
it { @project.namespace.should == @group } it { @project.namespace.should == @group }
end end
context 'respect configured public setting' do
before(:each) do
@settings = double("settings")
@settings.stub(:issues) { true }
@settings.stub(:merge_requests) { true }
@settings.stub(:wiki) { true }
@settings.stub(:wall) { true }
@settings.stub(:snippets) { true }
stub_const("Settings", Class.new)
Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings)
end
context 'should be public when setting is public' do
before do
@settings.stub(:public) { true }
@project = create_project(@user, @opts)
end
it { @project.public.should be_true }
end
context 'should be private when setting is not public' do
before do
@settings.stub(:public) { false }
@project = create_project(@user, @opts)
end
it { @project.public.should be_false }
end
end
end end
def create_project(user, opts) def create_project(user, opts)
......
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