Commit c7cb7599e23a37f3ff97522a43bbd97222d86774
Exists in
master
and in
4 other branches
Merge pull request #5022 from amacarthur/config-public-project
make public/private setting for project creation configurable
Showing
5 changed files
with
41 additions
and
3 deletions
Show diff stats
app/contexts/projects/create_context.rb
@@ -16,7 +16,8 @@ module Projects | @@ -16,7 +16,8 @@ module Projects | ||
16 | wiki_enabled: default_features.wiki, | 16 | wiki_enabled: default_features.wiki, |
17 | wall_enabled: default_features.wall, | 17 | wall_enabled: default_features.wall, |
18 | snippets_enabled: default_features.snippets, | 18 | snippets_enabled: default_features.snippets, |
19 | - merge_requests_enabled: default_features.merge_requests | 19 | + merge_requests_enabled: default_features.merge_requests, |
20 | + public: default_features.public | ||
20 | } | 21 | } |
21 | 22 | ||
22 | @project = Project.new(default_opts.merge(params)) | 23 | @project = Project.new(default_opts.merge(params)) |
app/views/projects/new.html.haml
@@ -2,8 +2,12 @@ | @@ -2,8 +2,12 @@ | ||
2 | .project-edit-errors | 2 | .project-edit-errors |
3 | = render 'projects/errors' | 3 | = render 'projects/errors' |
4 | .project-edit-content | 4 | .project-edit-content |
5 | - %p.slead | ||
6 | - New projects are private by default. You choose who can see the project and commit to repository. | 5 | + - if Gitlab.config.gitlab.default_projects_features.public |
6 | + %p.slead | ||
7 | + New projects are public by default. Any signed in user can see your project but cannot commit to it unless granted access. | ||
8 | + - else | ||
9 | + %p.slead | ||
10 | + New projects are private by default. You choose who can see the project and commit to repository. | ||
7 | %hr | 11 | %hr |
8 | = form_for @project, remote: true do |f| | 12 | = form_for @project, remote: true do |f| |
9 | .control-group.project-name-holder | 13 | .control-group.project-name-holder |
config/gitlab.yml.example
@@ -58,6 +58,7 @@ production: &base | @@ -58,6 +58,7 @@ production: &base | ||
58 | wiki: true | 58 | wiki: true |
59 | wall: false | 59 | wall: false |
60 | snippets: false | 60 | snippets: false |
61 | + public: false | ||
61 | 62 | ||
62 | ## External issues trackers | 63 | ## External issues trackers |
63 | issues_tracker: | 64 | issues_tracker: |
config/initializers/1_settings.rb
@@ -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 | ||
75 | Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil? | 75 | Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil? |
76 | Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil? | 76 | Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil? |
77 | Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil? | 77 | Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil? |
78 | +Settings.gitlab.default_projects_features['public'] = false if Settings.gitlab.default_projects_features['public'].nil? | ||
78 | 79 | ||
79 | # | 80 | # |
80 | # Gravatar | 81 | # Gravatar |
spec/contexts/projects_create_context_spec.rb
@@ -30,6 +30,37 @@ describe Projects::CreateContext do | @@ -30,6 +30,37 @@ describe Projects::CreateContext do | ||
30 | it { @project.owner.should == @user } | 30 | it { @project.owner.should == @user } |
31 | it { @project.namespace.should == @group } | 31 | it { @project.namespace.should == @group } |
32 | end | 32 | end |
33 | + | ||
34 | + context 'respect configured public setting' do | ||
35 | + before(:each) do | ||
36 | + @settings = double("settings") | ||
37 | + @settings.stub(:issues) { true } | ||
38 | + @settings.stub(:merge_requests) { true } | ||
39 | + @settings.stub(:wiki) { true } | ||
40 | + @settings.stub(:wall) { true } | ||
41 | + @settings.stub(:snippets) { true } | ||
42 | + stub_const("Settings", Class.new) | ||
43 | + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) | ||
44 | + end | ||
45 | + | ||
46 | + context 'should be public when setting is public' do | ||
47 | + before do | ||
48 | + @settings.stub(:public) { true } | ||
49 | + @project = create_project(@user, @opts) | ||
50 | + end | ||
51 | + | ||
52 | + it { @project.public.should be_true } | ||
53 | + end | ||
54 | + | ||
55 | + context 'should be private when setting is not public' do | ||
56 | + before do | ||
57 | + @settings.stub(:public) { false } | ||
58 | + @project = create_project(@user, @opts) | ||
59 | + end | ||
60 | + | ||
61 | + it { @project.public.should be_false } | ||
62 | + end | ||
63 | + end | ||
33 | end | 64 | end |
34 | 65 | ||
35 | def create_project(user, opts) | 66 | def create_project(user, opts) |