Commit f87e2d2801fa4c9c47466e38012210348fac0710
1 parent
9ad5d9a4
Exists in
master
and in
4 other branches
make public/private setting for project creation configurable
Showing
4 changed files
with
32 additions
and
1 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)) |
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,34 @@ describe Projects::CreateContext do | @@ -30,6 +30,34 @@ 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 | + context 'should be public when setting is public' do | ||
46 | + before do | ||
47 | + @settings.stub(:public) { true } | ||
48 | + @project = create_project(@user, @opts) | ||
49 | + end | ||
50 | + it { @project.public.should be_true } | ||
51 | + end | ||
52 | + context 'should be private when setting is not public' do | ||
53 | + before do | ||
54 | + @settings.stub(:public) { false } | ||
55 | + @project = create_project(@user, @opts) | ||
56 | + end | ||
57 | + it { @project.public.should be_false } | ||
58 | + end | ||
59 | + | ||
60 | + end | ||
33 | end | 61 | end |
34 | 62 | ||
35 | def create_project(user, opts) | 63 | def create_project(user, opts) |