From ab7cf450ba19cf80b9534f25dc707b33845e3014 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 3 Dec 2019 18:06:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/support/helpers/kubernetes_helpers.rb | 29 ++++++++++++++++++++++ spec/support/helpers/position_tracer_helpers.rb | 2 +- .../controllers/uploads_actions_shared_examples.rb | 14 ++++++++++- .../creatable_merge_request_shared_examples.rb | 10 ++++++-- 4 files changed, 51 insertions(+), 4 deletions(-) (limited to 'spec/support') diff --git a/spec/support/helpers/kubernetes_helpers.rb b/spec/support/helpers/kubernetes_helpers.rb index 677aef57661..cac43e94a92 100644 --- a/spec/support/helpers/kubernetes_helpers.rb +++ b/spec/support/helpers/kubernetes_helpers.rb @@ -194,6 +194,11 @@ module KubernetesHelpers .to_return(kube_response({})) end + def stub_kubeclient_put_cluster_role_binding(api_url, name) + WebMock.stub_request(:put, api_url + "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/#{name}") + .to_return(kube_response({})) + end + def stub_kubeclient_get_role_binding(api_url, name, namespace: 'default') WebMock.stub_request(:get, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/rolebindings/#{name}") .to_return(kube_response({})) @@ -219,11 +224,21 @@ module KubernetesHelpers .to_return(kube_response({})) end + def stub_kubeclient_get_namespaces(api_url) + WebMock.stub_request(:get, api_url + '/api/v1/namespaces') + .to_return(kube_response(kube_v1_namespace_list_body)) + end + def stub_kubeclient_get_namespace(api_url, namespace: 'default') WebMock.stub_request(:get, api_url + "/api/v1/namespaces/#{namespace}") .to_return(kube_response({})) end + def stub_kubeclient_put_cluster_role(api_url, name) + WebMock.stub_request(:put, api_url + "/apis/rbac.authorization.k8s.io/v1/clusterroles/#{name}") + .to_return(kube_response({})) + end + def stub_kubeclient_put_role(api_url, name, namespace: 'default') WebMock.stub_request(:put, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/roles/#{name}") .to_return(kube_response({})) @@ -257,6 +272,20 @@ module KubernetesHelpers } end + def kube_v1_namespace_list_body + { + "kind" => "NamespaceList", + "apiVersion" => "v1", + "items" => [ + { + "metadata" => { + "name" => "knative-serving" + } + } + ] + } + end + def kube_v1beta1_discovery_body { "kind" => "APIResourceList", diff --git a/spec/support/helpers/position_tracer_helpers.rb b/spec/support/helpers/position_tracer_helpers.rb index bbf6e06dd40..7516694d4fe 100644 --- a/spec/support/helpers/position_tracer_helpers.rb +++ b/spec/support/helpers/position_tracer_helpers.rb @@ -50,7 +50,7 @@ module PositionTracerHelpers end def create_branch(new_name, branch_name) - CreateBranchService.new(project, current_user).execute(new_name, branch_name) + ::Branches::CreateService.new(project, current_user).execute(new_name, branch_name) end def create_file(branch_name, file_name, content) diff --git a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb index c24418b2f90..8962d98218a 100644 --- a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb +++ b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb @@ -74,7 +74,7 @@ shared_examples 'handle uploads' do end before do - expect(FileUploader).to receive(:generate_secret).and_return(secret) + allow(FileUploader).to receive(:generate_secret).and_return(secret) UploadService.new(model, jpg, uploader_class).execute end @@ -88,6 +88,18 @@ shared_examples 'handle uploads' do end end + context 'when the upload does not have a MIME type that Rails knows' do + let(:po) { fixture_file_upload('spec/fixtures/missing_metadata.po', 'text/plain') } + + it 'falls back to the null type' do + UploadService.new(model, po, uploader_class).execute + + get :show, params: params.merge(secret: secret, filename: 'missing_metadata.po') + + expect(response.headers['Content-Type']).to eq('application/octet-stream') + end + end + context "when the model is public" do before do model.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC) diff --git a/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb index c0db4cdde72..da966fd2200 100644 --- a/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb +++ b/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb @@ -8,11 +8,14 @@ RSpec.shared_examples 'a creatable merge request' do page.within '.dropdown-menu-user' do click_link user2.name end + expect(find('input[name="merge_request[assignee_ids][]"]', visible: false).value).to match(user2.id.to_s) page.within '.js-assignee-search' do expect(page).to have_content user2.name end + click_link 'Assign to me' + expect(find('input[name="merge_request[assignee_ids][]"]', visible: false).value).to match(user.id.to_s) page.within '.js-assignee-search' do expect(page).to have_content user.name @@ -22,6 +25,7 @@ RSpec.shared_examples 'a creatable merge request' do page.within '.issue-milestone' do click_link milestone.title end + expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s) page.within '.js-milestone-select' do expect(page).to have_content milestone.title @@ -32,6 +36,7 @@ RSpec.shared_examples 'a creatable merge request' do click_link label.title click_link label2.title end + page.within '.js-label-select' do expect(page).to have_content label.title end @@ -58,8 +63,9 @@ RSpec.shared_examples 'a creatable merge request' do it 'updates the branches when selecting a new target project', :js do target_project_member = target_project.owner - CreateBranchService.new(target_project, target_project_member) - .execute('a-brand-new-branch-to-test', 'master') + ::Branches::CreateService.new(target_project, target_project_member) + .execute('a-brand-new-branch-to-test', 'master') + visit project_new_merge_request_path(source_project) first('.js-target-project').click -- cgit v1.2.1