diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-31 21:07:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-31 21:07:42 +0300 |
commit | 580622bdb3c762a8e89facd8a3946881ee480442 (patch) | |
tree | 3ac9d759da23f78f95f50684bd238a9f76839538 /spec/controllers | |
parent | b211a4ea14d5e9ed9b0c248a4e8c5c1d85b542cb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
4 files changed, 53 insertions, 58 deletions
diff --git a/spec/controllers/groups/registry/repositories_controller_spec.rb b/spec/controllers/groups/registry/repositories_controller_spec.rb index 3a74aa1dac0..eadc3a7f739 100644 --- a/spec/controllers/groups/registry/repositories_controller_spec.rb +++ b/spec/controllers/groups/registry/repositories_controller_spec.rb @@ -15,7 +15,7 @@ describe Groups::Registry::RepositoriesController do end shared_examples 'renders a list of repositories' do - context 'when container registry is enabled' do + context 'when user has access to registry' do it 'show index page' do expect(Gitlab::Tracking).not_to receive(:event) @@ -63,21 +63,7 @@ describe Groups::Registry::RepositoriesController do end end - context 'container registry is disabled' do - before do - stub_container_registry_config(enabled: false) - end - - it 'renders not found' do - get :index, params: { - group_id: group - } - - expect(response).to have_gitlab_http_status(:not_found) - end - end - - context 'user do not have acces to container registry' do + context 'user does not have access to container registry' do before do sign_out(user) sign_in(guest) @@ -90,22 +76,6 @@ describe Groups::Registry::RepositoriesController do expect(response).to have_gitlab_http_status(:not_found) end end - - context 'with :vue_container_registry_explorer feature flag disabled' do - before do - stub_feature_flags(vue_container_registry_explorer: { enabled: false, thing: group }) - end - - it 'has the correct response schema' do - get :index, params: { - group_id: group, - format: :json - } - - expect(response).to match_response_schema('registry/repositories') - expect(response).not_to include_pagination_headers - end - end end context 'GET #index' do diff --git a/spec/controllers/projects/registry/repositories_controller_spec.rb b/spec/controllers/projects/registry/repositories_controller_spec.rb index a64673a7f87..e68959b6a96 100644 --- a/spec/controllers/projects/registry/repositories_controller_spec.rb +++ b/spec/controllers/projects/registry/repositories_controller_spec.rb @@ -85,22 +85,6 @@ describe Projects::Registry::RepositoriesController do end end end - - context 'with :vue_container_registry_explorer feature flag disabled' do - before do - stub_feature_flags(vue_container_registry_explorer: { enabled: false, thing: project.group }) - stub_container_registry_tags(repository: project.full_path, - tags: %w[rc1 latest]) - end - - it 'json has a list of projects' do - go_to_index(format: :json) - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('registry/repositories') - expect(response).not_to include_pagination_headers - end - end end describe 'GET #index' do diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index 9fa07cbc7a6..284789305e2 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -116,7 +116,7 @@ describe Projects::SnippetsController do end context 'when the snippet is public' do - it 'rejects the shippet' do + it 'rejects the snippet' do expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } .not_to change { Snippet.count } expect(response).to render_template(:new) @@ -164,6 +164,7 @@ describe Projects::SnippetsController do describe 'PUT #update' do let(:project) { create :project, :public } + let(:visibility_level) { Snippet::PUBLIC } let(:snippet) { create :project_snippet, author: user, project: project, visibility_level: visibility_level } def update_snippet(snippet_params = {}, additional_params = {}) @@ -174,13 +175,27 @@ describe Projects::SnippetsController do put :update, params: { namespace_id: project.namespace.to_param, project_id: project, - id: snippet.id, + id: snippet, project_snippet: { title: 'Title', content: 'Content' }.merge(snippet_params) }.merge(additional_params) snippet.reload end + it_behaves_like 'updating snippet checks blob is binary' do + let_it_be(:title) { 'Foo' } + let(:params) do + { + namespace_id: project.namespace.to_param, + project_id: project, + id: snippet.id, + project_snippet: { title: title } + } + end + + subject { put :update, params: params } + end + context 'when the snippet is spam' do before do allow_next_instance_of(Spam::AkismetService) do |instance| @@ -198,9 +213,7 @@ describe Projects::SnippetsController do end context 'when the snippet is public' do - let(:visibility_level) { Snippet::PUBLIC } - - it 'rejects the shippet' do + it 'rejects the snippet' do expect { update_snippet(title: 'Foo') } .not_to change { snippet.reload.title } end @@ -245,7 +258,7 @@ describe Projects::SnippetsController do context 'when the private snippet is made public' do let(:visibility_level) { Snippet::PRIVATE } - it 'rejects the shippet' do + it 'rejects the snippet' do expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } .not_to change { snippet.reload.title } end @@ -581,4 +594,19 @@ describe Projects::SnippetsController do end end end + + describe 'GET #edit' do + it_behaves_like 'editing snippet checks blob is binary' do + let(:snippet) { create(:project_snippet, :private, project: project, author: user) } + let(:params) do + { + namespace_id: project.namespace, + project_id: project, + id: snippet + } + end + + subject { get :edit, params: params } + end + end end diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index 3025521e189..e41deae0e89 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -308,7 +308,7 @@ describe SnippetsController do end context 'when the snippet is public' do - it 'rejects the shippet' do + it 'rejects the snippet' do expect { create_snippet(visibility_level: Snippet::PUBLIC) } .not_to change { Snippet.count } end @@ -354,6 +354,7 @@ describe SnippetsController do describe 'PUT #update' do let(:project) { create :project } + let(:visibility_level) { Snippet::PUBLIC } let(:snippet) { create :personal_snippet, author: user, project: project, visibility_level: visibility_level } def update_snippet(snippet_params = {}, additional_params = {}) @@ -367,6 +368,12 @@ describe SnippetsController do snippet.reload end + it_behaves_like 'updating snippet checks blob is binary' do + let_it_be(:title) { 'Foo' } + + subject { put :update, params: { id: snippet, personal_snippet: { title: title } } } + end + context 'when the snippet is spam' do before do allow_next_instance_of(Spam::AkismetService) do |instance| @@ -429,9 +436,7 @@ describe SnippetsController do end context 'when the snippet is public' do - let(:visibility_level) { Snippet::PUBLIC } - - it 'rejects the shippet' do + it 'rejects the snippet' do expect { update_snippet(title: 'Foo') } .not_to change { snippet.reload.title } end @@ -793,4 +798,12 @@ describe SnippetsController do end end end + + describe 'GET #edit' do + it_behaves_like 'editing snippet checks blob is binary' do + let_it_be(:snippet) { create(:personal_snippet, :public, :repository, author: user) } + + subject { get :edit, params: { id: snippet } } + end + end end |