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 | 16 | wiki_enabled: default_features.wiki, |
| 17 | 17 | wall_enabled: default_features.wall, |
| 18 | 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 | 23 | @project = Project.new(default_opts.merge(params)) | ... | ... |
app/views/projects/new.html.haml
| ... | ... | @@ -2,8 +2,12 @@ |
| 2 | 2 | .project-edit-errors |
| 3 | 3 | = render 'projects/errors' |
| 4 | 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 | 11 | %hr |
| 8 | 12 | = form_for @project, remote: true do |f| |
| 9 | 13 | .control-group.project-name-holder | ... | ... |
config/gitlab.yml.example
config/initializers/1_settings.rb
| ... | ... | @@ -75,6 +75,7 @@ Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.g |
| 75 | 75 | Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil? |
| 76 | 76 | Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil? |
| 77 | 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 | 81 | # Gravatar | ... | ... |
spec/contexts/projects_create_context_spec.rb
| ... | ... | @@ -30,6 +30,37 @@ describe Projects::CreateContext do |
| 30 | 30 | it { @project.owner.should == @user } |
| 31 | 31 | it { @project.namespace.should == @group } |
| 32 | 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 | 64 | end |
| 34 | 65 | |
| 35 | 66 | def create_project(user, opts) | ... | ... |