Commit 07833d16760bf30e4c9c84653909d4efe2dbcaff
1 parent
ae1a3148
Exists in
spb-stable
and in
3 other branches
Move Project's service specs to the correct location
[ci skip]
Showing
6 changed files
with
307 additions
and
307 deletions
Show diff stats
spec/services/project_transfer_service_spec.rb
@@ -1,33 +0,0 @@ | @@ -1,33 +0,0 @@ | ||
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe ProjectTransferService do | ||
4 | - before(:each) { enable_observers } | ||
5 | - after(:each) {disable_observers} | ||
6 | - | ||
7 | - context 'namespace -> namespace' do | ||
8 | - let(:user) { create(:user) } | ||
9 | - let(:group) { create(:group) } | ||
10 | - let(:project) { create(:project, namespace: user.namespace) } | ||
11 | - | ||
12 | - before do | ||
13 | - @result = service.transfer(project, group) | ||
14 | - end | ||
15 | - | ||
16 | - it { @result.should be_true } | ||
17 | - it { project.namespace.should == group } | ||
18 | - end | ||
19 | - | ||
20 | - context 'namespace -> no namespace' do | ||
21 | - let(:user) { create(:user) } | ||
22 | - let(:project) { create(:project, namespace: user.namespace) } | ||
23 | - | ||
24 | - it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) } | ||
25 | - end | ||
26 | - | ||
27 | - def service | ||
28 | - service = ProjectTransferService.new | ||
29 | - service.gitlab_shell.stub(mv_repository: true) | ||
30 | - service | ||
31 | - end | ||
32 | -end | ||
33 | - |
@@ -0,0 +1,163 @@ | @@ -0,0 +1,163 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe Projects::CreateService do | ||
4 | + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } | ||
5 | + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } | ||
6 | + | ||
7 | + describe :create_by_user do | ||
8 | + before do | ||
9 | + @user = create :user | ||
10 | + @admin = create :user, admin: true | ||
11 | + @opts = { | ||
12 | + name: "GitLab", | ||
13 | + namespace: @user.namespace | ||
14 | + } | ||
15 | + end | ||
16 | + | ||
17 | + context 'user namespace' do | ||
18 | + before do | ||
19 | + @project = create_project(@user, @opts) | ||
20 | + end | ||
21 | + | ||
22 | + it { @project.should be_valid } | ||
23 | + it { @project.owner.should == @user } | ||
24 | + it { @project.namespace.should == @user.namespace } | ||
25 | + end | ||
26 | + | ||
27 | + context 'group namespace' do | ||
28 | + before do | ||
29 | + @group = create :group | ||
30 | + @group.add_owner(@user) | ||
31 | + | ||
32 | + @opts.merge!(namespace_id: @group.id) | ||
33 | + @project = create_project(@user, @opts) | ||
34 | + end | ||
35 | + | ||
36 | + it { @project.should be_valid } | ||
37 | + it { @project.owner.should == @group } | ||
38 | + it { @project.namespace.should == @group } | ||
39 | + end | ||
40 | + | ||
41 | + context 'wiki_enabled creates repository directory' do | ||
42 | + context 'wiki_enabled true creates wiki repository directory' do | ||
43 | + before do | ||
44 | + @project = create_project(@user, @opts) | ||
45 | + @path = GollumWiki.new(@project, @user).send(:path_to_repo) | ||
46 | + end | ||
47 | + | ||
48 | + it { File.exists?(@path).should be_true } | ||
49 | + end | ||
50 | + | ||
51 | + context 'wiki_enabled false does not create wiki repository directory' do | ||
52 | + before do | ||
53 | + @opts.merge!(wiki_enabled: false) | ||
54 | + @project = create_project(@user, @opts) | ||
55 | + @path = GollumWiki.new(@project, @user).send(:path_to_repo) | ||
56 | + end | ||
57 | + | ||
58 | + it { File.exists?(@path).should be_false } | ||
59 | + end | ||
60 | + end | ||
61 | + | ||
62 | + context 'respect configured visibility setting' do | ||
63 | + before(:each) do | ||
64 | + @settings = double("settings") | ||
65 | + @settings.stub(:issues) { true } | ||
66 | + @settings.stub(:merge_requests) { true } | ||
67 | + @settings.stub(:wiki) { true } | ||
68 | + @settings.stub(:wall) { true } | ||
69 | + @settings.stub(:snippets) { true } | ||
70 | + stub_const("Settings", Class.new) | ||
71 | + @restrictions = double("restrictions") | ||
72 | + @restrictions.stub(:restricted_visibility_levels) { [] } | ||
73 | + Settings.stub_chain(:gitlab).and_return(@restrictions) | ||
74 | + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) | ||
75 | + end | ||
76 | + | ||
77 | + context 'should be public when setting is public' do | ||
78 | + before do | ||
79 | + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } | ||
80 | + @project = create_project(@user, @opts) | ||
81 | + end | ||
82 | + | ||
83 | + it { @project.public?.should be_true } | ||
84 | + end | ||
85 | + | ||
86 | + context 'should be private when setting is private' do | ||
87 | + before do | ||
88 | + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } | ||
89 | + @project = create_project(@user, @opts) | ||
90 | + end | ||
91 | + | ||
92 | + it { @project.private?.should be_true } | ||
93 | + end | ||
94 | + | ||
95 | + context 'should be internal when setting is internal' do | ||
96 | + before do | ||
97 | + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::INTERNAL } | ||
98 | + @project = create_project(@user, @opts) | ||
99 | + end | ||
100 | + | ||
101 | + it { @project.internal?.should be_true } | ||
102 | + end | ||
103 | + end | ||
104 | + | ||
105 | + context 'respect configured visibility restrictions setting' do | ||
106 | + before(:each) do | ||
107 | + @settings = double("settings") | ||
108 | + @settings.stub(:issues) { true } | ||
109 | + @settings.stub(:merge_requests) { true } | ||
110 | + @settings.stub(:wiki) { true } | ||
111 | + @settings.stub(:wall) { true } | ||
112 | + @settings.stub(:snippets) { true } | ||
113 | + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } | ||
114 | + stub_const("Settings", Class.new) | ||
115 | + @restrictions = double("restrictions") | ||
116 | + @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } | ||
117 | + Settings.stub_chain(:gitlab).and_return(@restrictions) | ||
118 | + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) | ||
119 | + end | ||
120 | + | ||
121 | + context 'should be private when option is public' do | ||
122 | + before do | ||
123 | + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
124 | + @project = create_project(@user, @opts) | ||
125 | + end | ||
126 | + | ||
127 | + it { @project.private?.should be_true } | ||
128 | + end | ||
129 | + | ||
130 | + context 'should be public when option is public for admin' do | ||
131 | + before do | ||
132 | + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
133 | + @project = create_project(@admin, @opts) | ||
134 | + end | ||
135 | + | ||
136 | + it { @project.public?.should be_true } | ||
137 | + end | ||
138 | + | ||
139 | + context 'should be private when option is private' do | ||
140 | + before do | ||
141 | + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) | ||
142 | + @project = create_project(@user, @opts) | ||
143 | + end | ||
144 | + | ||
145 | + it { @project.private?.should be_true } | ||
146 | + end | ||
147 | + | ||
148 | + context 'should be internal when option is internal' do | ||
149 | + before do | ||
150 | + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) | ||
151 | + @project = create_project(@user, @opts) | ||
152 | + end | ||
153 | + | ||
154 | + it { @project.internal?.should be_true } | ||
155 | + end | ||
156 | + end | ||
157 | + end | ||
158 | + | ||
159 | + def create_project(user, opts) | ||
160 | + Projects::CreateService.new(user, opts).execute | ||
161 | + end | ||
162 | +end | ||
163 | + |
@@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe ProjectTransferService do | ||
4 | + before(:each) { enable_observers } | ||
5 | + after(:each) {disable_observers} | ||
6 | + | ||
7 | + context 'namespace -> namespace' do | ||
8 | + let(:user) { create(:user) } | ||
9 | + let(:group) { create(:group) } | ||
10 | + let(:project) { create(:project, namespace: user.namespace) } | ||
11 | + | ||
12 | + before do | ||
13 | + @result = service.transfer(project, group) | ||
14 | + end | ||
15 | + | ||
16 | + it { @result.should be_true } | ||
17 | + it { project.namespace.should == group } | ||
18 | + end | ||
19 | + | ||
20 | + context 'namespace -> no namespace' do | ||
21 | + let(:user) { create(:user) } | ||
22 | + let(:project) { create(:project, namespace: user.namespace) } | ||
23 | + | ||
24 | + it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) } | ||
25 | + end | ||
26 | + | ||
27 | + def service | ||
28 | + service = ProjectTransferService.new | ||
29 | + service.gitlab_shell.stub(mv_repository: true) | ||
30 | + service | ||
31 | + end | ||
32 | +end | ||
33 | + |
@@ -0,0 +1,111 @@ | @@ -0,0 +1,111 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe Projects::UpdateService do | ||
4 | + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } | ||
5 | + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } | ||
6 | + | ||
7 | + describe :update_by_user do | ||
8 | + before do | ||
9 | + @user = create :user | ||
10 | + @admin = create :user, admin: true | ||
11 | + @project = create :project, creator_id: @user.id, namespace: @user.namespace | ||
12 | + @opts = { project: {} } | ||
13 | + end | ||
14 | + | ||
15 | + context 'should be private when updated to private' do | ||
16 | + before do | ||
17 | + @created_private = @project.private? | ||
18 | + | ||
19 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) | ||
20 | + update_project(@project, @user, @opts) | ||
21 | + end | ||
22 | + | ||
23 | + it { @created_private.should be_true } | ||
24 | + it { @project.private?.should be_true } | ||
25 | + end | ||
26 | + | ||
27 | + context 'should be internal when updated to internal' do | ||
28 | + before do | ||
29 | + @created_private = @project.private? | ||
30 | + | ||
31 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) | ||
32 | + update_project(@project, @user, @opts) | ||
33 | + end | ||
34 | + | ||
35 | + it { @created_private.should be_true } | ||
36 | + it { @project.internal?.should be_true } | ||
37 | + end | ||
38 | + | ||
39 | + context 'should be public when updated to public' do | ||
40 | + before do | ||
41 | + @created_private = @project.private? | ||
42 | + | ||
43 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
44 | + update_project(@project, @user, @opts) | ||
45 | + end | ||
46 | + | ||
47 | + it { @created_private.should be_true } | ||
48 | + it { @project.public?.should be_true } | ||
49 | + end | ||
50 | + | ||
51 | + context 'respect configured visibility restrictions setting' do | ||
52 | + before(:each) do | ||
53 | + @restrictions = double("restrictions") | ||
54 | + @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } | ||
55 | + Settings.stub_chain(:gitlab).and_return(@restrictions) | ||
56 | + end | ||
57 | + | ||
58 | + context 'should be private when updated to private' do | ||
59 | + before do | ||
60 | + @created_private = @project.private? | ||
61 | + | ||
62 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) | ||
63 | + update_project(@project, @user, @opts) | ||
64 | + end | ||
65 | + | ||
66 | + it { @created_private.should be_true } | ||
67 | + it { @project.private?.should be_true } | ||
68 | + end | ||
69 | + | ||
70 | + context 'should be internal when updated to internal' do | ||
71 | + before do | ||
72 | + @created_private = @project.private? | ||
73 | + | ||
74 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) | ||
75 | + update_project(@project, @user, @opts) | ||
76 | + end | ||
77 | + | ||
78 | + it { @created_private.should be_true } | ||
79 | + it { @project.internal?.should be_true } | ||
80 | + end | ||
81 | + | ||
82 | + context 'should be private when updated to public' do | ||
83 | + before do | ||
84 | + @created_private = @project.private? | ||
85 | + | ||
86 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
87 | + update_project(@project, @user, @opts) | ||
88 | + end | ||
89 | + | ||
90 | + it { @created_private.should be_true } | ||
91 | + it { @project.private?.should be_true } | ||
92 | + end | ||
93 | + | ||
94 | + context 'should be public when updated to public by admin' do | ||
95 | + before do | ||
96 | + @created_private = @project.private? | ||
97 | + | ||
98 | + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
99 | + update_project(@project, @admin, @opts) | ||
100 | + end | ||
101 | + | ||
102 | + it { @created_private.should be_true } | ||
103 | + it { @project.public?.should be_true } | ||
104 | + end | ||
105 | + end | ||
106 | + end | ||
107 | + | ||
108 | + def update_project(project, user, opts) | ||
109 | + Projects::UpdateService.new(project, user, opts).execute | ||
110 | + end | ||
111 | +end |
spec/services/projects_create_service_spec.rb
@@ -1,163 +0,0 @@ | @@ -1,163 +0,0 @@ | ||
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Projects::CreateService do | ||
4 | - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } | ||
5 | - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } | ||
6 | - | ||
7 | - describe :create_by_user do | ||
8 | - before do | ||
9 | - @user = create :user | ||
10 | - @admin = create :user, admin: true | ||
11 | - @opts = { | ||
12 | - name: "GitLab", | ||
13 | - namespace: @user.namespace | ||
14 | - } | ||
15 | - end | ||
16 | - | ||
17 | - context 'user namespace' do | ||
18 | - before do | ||
19 | - @project = create_project(@user, @opts) | ||
20 | - end | ||
21 | - | ||
22 | - it { @project.should be_valid } | ||
23 | - it { @project.owner.should == @user } | ||
24 | - it { @project.namespace.should == @user.namespace } | ||
25 | - end | ||
26 | - | ||
27 | - context 'group namespace' do | ||
28 | - before do | ||
29 | - @group = create :group | ||
30 | - @group.add_owner(@user) | ||
31 | - | ||
32 | - @opts.merge!(namespace_id: @group.id) | ||
33 | - @project = create_project(@user, @opts) | ||
34 | - end | ||
35 | - | ||
36 | - it { @project.should be_valid } | ||
37 | - it { @project.owner.should == @group } | ||
38 | - it { @project.namespace.should == @group } | ||
39 | - end | ||
40 | - | ||
41 | - context 'wiki_enabled creates repository directory' do | ||
42 | - context 'wiki_enabled true creates wiki repository directory' do | ||
43 | - before do | ||
44 | - @project = create_project(@user, @opts) | ||
45 | - @path = GollumWiki.new(@project, @user).send(:path_to_repo) | ||
46 | - end | ||
47 | - | ||
48 | - it { File.exists?(@path).should be_true } | ||
49 | - end | ||
50 | - | ||
51 | - context 'wiki_enabled false does not create wiki repository directory' do | ||
52 | - before do | ||
53 | - @opts.merge!(wiki_enabled: false) | ||
54 | - @project = create_project(@user, @opts) | ||
55 | - @path = GollumWiki.new(@project, @user).send(:path_to_repo) | ||
56 | - end | ||
57 | - | ||
58 | - it { File.exists?(@path).should be_false } | ||
59 | - end | ||
60 | - end | ||
61 | - | ||
62 | - context 'respect configured visibility setting' do | ||
63 | - before(:each) do | ||
64 | - @settings = double("settings") | ||
65 | - @settings.stub(:issues) { true } | ||
66 | - @settings.stub(:merge_requests) { true } | ||
67 | - @settings.stub(:wiki) { true } | ||
68 | - @settings.stub(:wall) { true } | ||
69 | - @settings.stub(:snippets) { true } | ||
70 | - stub_const("Settings", Class.new) | ||
71 | - @restrictions = double("restrictions") | ||
72 | - @restrictions.stub(:restricted_visibility_levels) { [] } | ||
73 | - Settings.stub_chain(:gitlab).and_return(@restrictions) | ||
74 | - Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) | ||
75 | - end | ||
76 | - | ||
77 | - context 'should be public when setting is public' do | ||
78 | - before do | ||
79 | - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } | ||
80 | - @project = create_project(@user, @opts) | ||
81 | - end | ||
82 | - | ||
83 | - it { @project.public?.should be_true } | ||
84 | - end | ||
85 | - | ||
86 | - context 'should be private when setting is private' do | ||
87 | - before do | ||
88 | - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } | ||
89 | - @project = create_project(@user, @opts) | ||
90 | - end | ||
91 | - | ||
92 | - it { @project.private?.should be_true } | ||
93 | - end | ||
94 | - | ||
95 | - context 'should be internal when setting is internal' do | ||
96 | - before do | ||
97 | - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::INTERNAL } | ||
98 | - @project = create_project(@user, @opts) | ||
99 | - end | ||
100 | - | ||
101 | - it { @project.internal?.should be_true } | ||
102 | - end | ||
103 | - end | ||
104 | - | ||
105 | - context 'respect configured visibility restrictions setting' do | ||
106 | - before(:each) do | ||
107 | - @settings = double("settings") | ||
108 | - @settings.stub(:issues) { true } | ||
109 | - @settings.stub(:merge_requests) { true } | ||
110 | - @settings.stub(:wiki) { true } | ||
111 | - @settings.stub(:wall) { true } | ||
112 | - @settings.stub(:snippets) { true } | ||
113 | - @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } | ||
114 | - stub_const("Settings", Class.new) | ||
115 | - @restrictions = double("restrictions") | ||
116 | - @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } | ||
117 | - Settings.stub_chain(:gitlab).and_return(@restrictions) | ||
118 | - Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) | ||
119 | - end | ||
120 | - | ||
121 | - context 'should be private when option is public' do | ||
122 | - before do | ||
123 | - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
124 | - @project = create_project(@user, @opts) | ||
125 | - end | ||
126 | - | ||
127 | - it { @project.private?.should be_true } | ||
128 | - end | ||
129 | - | ||
130 | - context 'should be public when option is public for admin' do | ||
131 | - before do | ||
132 | - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
133 | - @project = create_project(@admin, @opts) | ||
134 | - end | ||
135 | - | ||
136 | - it { @project.public?.should be_true } | ||
137 | - end | ||
138 | - | ||
139 | - context 'should be private when option is private' do | ||
140 | - before do | ||
141 | - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) | ||
142 | - @project = create_project(@user, @opts) | ||
143 | - end | ||
144 | - | ||
145 | - it { @project.private?.should be_true } | ||
146 | - end | ||
147 | - | ||
148 | - context 'should be internal when option is internal' do | ||
149 | - before do | ||
150 | - @opts.merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) | ||
151 | - @project = create_project(@user, @opts) | ||
152 | - end | ||
153 | - | ||
154 | - it { @project.internal?.should be_true } | ||
155 | - end | ||
156 | - end | ||
157 | - end | ||
158 | - | ||
159 | - def create_project(user, opts) | ||
160 | - Projects::CreateService.new(user, opts).execute | ||
161 | - end | ||
162 | -end | ||
163 | - |
spec/services/projects_update_service_spec.rb
@@ -1,111 +0,0 @@ | @@ -1,111 +0,0 @@ | ||
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Projects::UpdateService do | ||
4 | - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } | ||
5 | - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } | ||
6 | - | ||
7 | - describe :update_by_user do | ||
8 | - before do | ||
9 | - @user = create :user | ||
10 | - @admin = create :user, admin: true | ||
11 | - @project = create :project, creator_id: @user.id, namespace: @user.namespace | ||
12 | - @opts = { project: {} } | ||
13 | - end | ||
14 | - | ||
15 | - context 'should be private when updated to private' do | ||
16 | - before do | ||
17 | - @created_private = @project.private? | ||
18 | - | ||
19 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) | ||
20 | - update_project(@project, @user, @opts) | ||
21 | - end | ||
22 | - | ||
23 | - it { @created_private.should be_true } | ||
24 | - it { @project.private?.should be_true } | ||
25 | - end | ||
26 | - | ||
27 | - context 'should be internal when updated to internal' do | ||
28 | - before do | ||
29 | - @created_private = @project.private? | ||
30 | - | ||
31 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) | ||
32 | - update_project(@project, @user, @opts) | ||
33 | - end | ||
34 | - | ||
35 | - it { @created_private.should be_true } | ||
36 | - it { @project.internal?.should be_true } | ||
37 | - end | ||
38 | - | ||
39 | - context 'should be public when updated to public' do | ||
40 | - before do | ||
41 | - @created_private = @project.private? | ||
42 | - | ||
43 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
44 | - update_project(@project, @user, @opts) | ||
45 | - end | ||
46 | - | ||
47 | - it { @created_private.should be_true } | ||
48 | - it { @project.public?.should be_true } | ||
49 | - end | ||
50 | - | ||
51 | - context 'respect configured visibility restrictions setting' do | ||
52 | - before(:each) do | ||
53 | - @restrictions = double("restrictions") | ||
54 | - @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } | ||
55 | - Settings.stub_chain(:gitlab).and_return(@restrictions) | ||
56 | - end | ||
57 | - | ||
58 | - context 'should be private when updated to private' do | ||
59 | - before do | ||
60 | - @created_private = @project.private? | ||
61 | - | ||
62 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) | ||
63 | - update_project(@project, @user, @opts) | ||
64 | - end | ||
65 | - | ||
66 | - it { @created_private.should be_true } | ||
67 | - it { @project.private?.should be_true } | ||
68 | - end | ||
69 | - | ||
70 | - context 'should be internal when updated to internal' do | ||
71 | - before do | ||
72 | - @created_private = @project.private? | ||
73 | - | ||
74 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) | ||
75 | - update_project(@project, @user, @opts) | ||
76 | - end | ||
77 | - | ||
78 | - it { @created_private.should be_true } | ||
79 | - it { @project.internal?.should be_true } | ||
80 | - end | ||
81 | - | ||
82 | - context 'should be private when updated to public' do | ||
83 | - before do | ||
84 | - @created_private = @project.private? | ||
85 | - | ||
86 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
87 | - update_project(@project, @user, @opts) | ||
88 | - end | ||
89 | - | ||
90 | - it { @created_private.should be_true } | ||
91 | - it { @project.private?.should be_true } | ||
92 | - end | ||
93 | - | ||
94 | - context 'should be public when updated to public by admin' do | ||
95 | - before do | ||
96 | - @created_private = @project.private? | ||
97 | - | ||
98 | - @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) | ||
99 | - update_project(@project, @admin, @opts) | ||
100 | - end | ||
101 | - | ||
102 | - it { @created_private.should be_true } | ||
103 | - it { @project.public?.should be_true } | ||
104 | - end | ||
105 | - end | ||
106 | - end | ||
107 | - | ||
108 | - def update_project(project, user, opts) | ||
109 | - Projects::UpdateService.new(project, user, opts).execute | ||
110 | - end | ||
111 | -end |