diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/controllers/projects_controller_spec.rb | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 85 |
1 files changed, 60 insertions, 25 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 9d070061850..3d966848c5b 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -312,6 +312,17 @@ RSpec.describe ProjectsController do expect { get_show }.not_to change { Gitlab::GitalyClient.get_request_count } end + + it "renders files even with invalid license" do + controller.instance_variable_set(:@project, public_project) + expect(public_project.repository).to receive(:license_key).and_return('woozle wuzzle').at_least(:once) + + get_show + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('_files') + expect(response.body).to have_content('LICENSE') # would be 'MIT license' if stub not works + end end context "when the url contains .atom" do @@ -409,42 +420,66 @@ RSpec.describe ProjectsController do end describe 'POST create' do - let!(:params) do - { - path: 'foo', - description: 'bar', - import_url: project.http_url_to_repo, - namespace_id: user.namespace.id - } - end - subject { post :create, params: { project: params } } before do sign_in(user) end - context 'when import by url is disabled' do - before do - stub_application_setting(import_sources: []) + context 'on import' do + let(:params) do + { + path: 'foo', + description: 'bar', + namespace_id: user.namespace.id, + import_url: project.http_url_to_repo + } + end + + context 'when import by url is disabled' do + before do + stub_application_setting(import_sources: []) + end + + it 'does not create project and reports an error' do + expect { subject }.not_to change { Project.count } + + expect(response).to have_gitlab_http_status(:not_found) + end end - it 'does not create project and reports an error' do - expect { subject }.not_to change { Project.count } + context 'when import by url is enabled' do + before do + stub_application_setting(import_sources: ['git']) + end + + it 'creates project' do + expect { subject }.to change { Project.count } - expect(response).to have_gitlab_http_status(:not_found) + expect(response).to have_gitlab_http_status(:redirect) + end end end - context 'when import by url is enabled' do - before do - stub_application_setting(import_sources: ['git']) + context 'with new_project_sast_enabled', :experiment do + let(:params) do + { + path: 'foo', + description: 'bar', + namespace_id: user.namespace.id, + initialize_with_sast: '1' + } end - it 'creates project' do - expect { subject }.to change { Project.count } + it 'tracks an event on project creation' do + expect(experiment(:new_project_sast_enabled)).to track(:created, + property: 'blank', + checked: true, + project: an_instance_of(Project), + namespace: user.namespace + ).on_next_instance.with_context(user: user) - expect(response).to have_gitlab_http_status(:redirect) + post :create, params: { project: params } end end end @@ -1373,12 +1408,12 @@ RSpec.describe ProjectsController do end end - context 'when the endpoint receives requests above the limit', :clean_gitlab_redis_cache do + context 'when the endpoint receives requests above the limit', :clean_gitlab_redis_rate_limiting do include_examples 'rate limits project export endpoint' end end - describe '#download_export', :clean_gitlab_redis_cache do + describe '#download_export', :clean_gitlab_redis_rate_limiting do let(:action) { :download_export } context 'object storage enabled' do @@ -1413,7 +1448,7 @@ RSpec.describe ProjectsController do end end - context 'when the endpoint receives requests above the limit', :clean_gitlab_redis_cache do + context 'when the endpoint receives requests above the limit', :clean_gitlab_redis_rate_limiting do before do allow(Gitlab::ApplicationRateLimiter) .to receive(:increment) @@ -1485,7 +1520,7 @@ RSpec.describe ProjectsController do end end - context 'when the endpoint receives requests above the limit', :clean_gitlab_redis_cache do + context 'when the endpoint receives requests above the limit', :clean_gitlab_redis_rate_limiting do include_examples 'rate limits project export endpoint' end end |