diff options
Diffstat (limited to 'spec/controllers/concerns')
4 files changed, 7 insertions, 184 deletions
diff --git a/spec/controllers/concerns/controller_with_feature_category_spec.rb b/spec/controllers/concerns/controller_with_feature_category_spec.rb deleted file mode 100644 index 55e84755f5c..00000000000 --- a/spec/controllers/concerns/controller_with_feature_category_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' -require_relative "../../../app/controllers/concerns/controller_with_feature_category" - -RSpec.describe ControllerWithFeatureCategory do - describe ".feature_category_for_action" do - let(:base_controller) do - Class.new do - include ControllerWithFeatureCategory - end - end - - let(:controller) do - Class.new(base_controller) do - feature_category :foo, %w(update edit) - feature_category :bar, %w(index show) - feature_category :quux, %w(destroy) - end - end - - let(:subclass) do - Class.new(controller) do - feature_category :baz, %w(subclass_index) - end - end - - it "is nil when nothing was defined" do - expect(base_controller.feature_category_for_action("hello")).to be_nil - end - - it "returns the expected category", :aggregate_failures do - expect(controller.feature_category_for_action("update")).to eq(:foo) - expect(controller.feature_category_for_action("index")).to eq(:bar) - expect(controller.feature_category_for_action("destroy")).to eq(:quux) - end - - it "returns the expected category for categories defined in subclasses" do - expect(subclass.feature_category_for_action("subclass_index")).to eq(:baz) - end - - it "raises an error when defining for the controller and for individual actions" do - expect do - Class.new(base_controller) do - feature_category :hello - feature_category :goodbye, [:world] - end - end.to raise_error(ArgumentError, "hello is defined for all actions, but other categories are set") - end - - it "raises an error when multiple calls define the same action" do - expect do - Class.new(base_controller) do - feature_category :hello, [:world] - feature_category :goodbye, ["world"] - end - end.to raise_error(ArgumentError, "Actions have multiple feature categories: world") - end - end -end diff --git a/spec/controllers/concerns/lfs_request_spec.rb b/spec/controllers/concerns/lfs_request_spec.rb deleted file mode 100644 index 3bafd761a3e..00000000000 --- a/spec/controllers/concerns/lfs_request_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe LfsRequest do - include ProjectForksHelper - - controller(Repositories::GitHttpClientController) do - # `described_class` is not available in this context - include LfsRequest - - def show - head :ok - end - - def project - @project ||= Project.find_by(id: params[:id]) - end - - def download_request? - true - end - - def upload_request? - false - end - - def ci? - false - end - end - - let(:project) { create(:project, :public) } - - before do - stub_lfs_setting(enabled: true) - end - - context 'user is authenticated without access to lfs' do - before do - allow(controller).to receive(:authenticate_user) - allow(controller).to receive(:authentication_result) do - Gitlab::Auth::Result.new - end - end - - context 'with access to the project' do - it 'returns 403' do - get :show, params: { id: project.id } - - expect(response).to have_gitlab_http_status(:forbidden) - end - end - - context 'without access to the project' do - context 'project does not exist' do - it 'returns 404' do - get :show, params: { id: 'does not exist' } - - expect(response).to have_gitlab_http_status(:not_found) - end - end - - context 'project is private' do - let(:project) { create(:project, :private) } - - it 'returns 404' do - get :show, params: { id: project.id } - - expect(response).to have_gitlab_http_status(:not_found) - end - end - end - end -end diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb index 8a4d8828aaa..83546403ce5 100644 --- a/spec/controllers/concerns/metrics_dashboard_spec.rb +++ b/spec/controllers/concerns/metrics_dashboard_spec.rb @@ -155,6 +155,7 @@ RSpec.describe MetricsDashboard do '.gitlab/dashboards/errors.yml' => dashboard_yml } end + let_it_be(:project) { create(:project, :custom_repo, files: dashboards) } before do diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb index 747ccd7ba1b..f9a6afb95ea 100644 --- a/spec/controllers/concerns/send_file_upload_spec.rb +++ b/spec/controllers/concerns/send_file_upload_spec.rb @@ -70,61 +70,18 @@ RSpec.describe SendFileUpload do allow(uploader).to receive(:model).and_return(image_owner) end - context 'when boths FFs are enabled' do - before do - stub_feature_flags(dynamic_image_resizing_requester: image_requester) - stub_feature_flags(dynamic_image_resizing_owner: image_owner) - end - - it_behaves_like 'handles image resize requests allowed by FFs' - end - - context 'when boths FFs are enabled globally' do - before do - stub_feature_flags(dynamic_image_resizing_requester: true) - stub_feature_flags(dynamic_image_resizing_owner: true) - end - - it_behaves_like 'handles image resize requests allowed by FFs' - - context 'when current_user is nil' do - before do - allow(controller).to receive(:current_user).and_return(nil) - end - - it_behaves_like 'handles image resize requests allowed by FFs' - end - end - - context 'when only FF based on content requester is enabled for current user' do - before do - stub_feature_flags(dynamic_image_resizing_requester: image_requester) - stub_feature_flags(dynamic_image_resizing_owner: false) - end - - it_behaves_like 'bypasses image resize requests not allowed by FFs' - end - - context 'when only FF based on content owner is enabled for requested avatar owner' do - before do - stub_feature_flags(dynamic_image_resizing_requester: false) - stub_feature_flags(dynamic_image_resizing_owner: image_owner) - end - - it_behaves_like 'bypasses image resize requests not allowed by FFs' - end + it_behaves_like 'handles image resize requests allowed by FF' - context 'when both FFs are disabled' do + context 'when FF is disabled' do before do - stub_feature_flags(dynamic_image_resizing_requester: false) - stub_feature_flags(dynamic_image_resizing_owner: false) + stub_feature_flags(dynamic_image_resizing: false) end - it_behaves_like 'bypasses image resize requests not allowed by FFs' + it_behaves_like 'bypasses image resize requests not allowed by FF' end end - shared_examples 'bypasses image resize requests not allowed by FFs' do + shared_examples 'bypasses image resize requests not allowed by FF' do it 'does not write workhorse command header' do expect(headers).not_to receive(:store).with(Gitlab::Workhorse::SEND_DATA_HEADER, /^send-scaled-img:/) @@ -132,7 +89,7 @@ RSpec.describe SendFileUpload do end end - shared_examples 'handles image resize requests allowed by FFs' do + shared_examples 'handles image resize requests allowed by FF' do context 'with valid width parameter' do it 'renders OK with workhorse command header' do expect(controller).not_to receive(:send_file) |