diff options
author | Jasper Maes <jaspermaes.jm@gmail.com> | 2018-12-15 10:06:56 +0100 |
---|---|---|
committer | Jasper Maes <jaspermaes.jm@gmail.com> | 2018-12-16 10:48:41 +0100 |
commit | 56296f1edadf2bc5f7741cbb3f97cb41f090aac6 (patch) | |
tree | 5a21667acd7d431f155d12227181dcfc6d21cba8 /spec | |
parent | 8b4602041cf2c4a8738a4796d78720017249249f (diff) | |
download | gitlab-ce-56296f1edadf2bc5f7741cbb3f97cb41f090aac6.tar.gz |
Remove rails4 specific code
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 20 | ||||
-rw-r--r-- | spec/controllers/boards/lists_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/controllers/projects/pipeline_schedules_controller_spec.rb | 18 | ||||
-rw-r--r-- | spec/controllers/uploads_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/helpers/storage_helper_spec.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/sql/glob_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/notification_setting_spec.rb | 7 | ||||
-rw-r--r-- | spec/requests/api/internal_spec.rb | 15 | ||||
-rw-r--r-- | spec/support/helpers/test_request_helpers.rb | 6 |
11 files changed, 20 insertions, 82 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index c2bd7fd9808..945c9f97fc3 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -551,14 +551,7 @@ describe ApplicationController do subject { get :index, text: "hi \255" } it 'renders 412' do - if Gitlab.rails5? - expect { subject }.to raise_error(ActionController::BadRequest) - else - subject - - expect(response).to have_gitlab_http_status(412) - expect(response).to render_template :precondition_failed - end + expect { subject }.to raise_error(ActionController::BadRequest) end end @@ -566,16 +559,7 @@ describe ApplicationController do subject { get :index, text: "hi \255", format: :js } it 'renders 412' do - if Gitlab.rails5? - expect { subject }.to raise_error(ActionController::BadRequest) - else - subject - - json_response = JSON.parse(response.body) - - expect(response).to have_gitlab_http_status(412) - expect(json_response['error']).to eq('Invalid UTF-8') - end + expect { subject }.to raise_error(ActionController::BadRequest) end end end diff --git a/spec/controllers/boards/lists_controller_spec.rb b/spec/controllers/boards/lists_controller_spec.rb index 80631d2efb0..16ccf405247 100644 --- a/spec/controllers/boards/lists_controller_spec.rb +++ b/spec/controllers/boards/lists_controller_spec.rb @@ -163,11 +163,7 @@ describe Boards::ListsController do list: { position: position }, format: :json } - if Gitlab.rails5? - patch :update, params: params, as: :json - else - patch :update, params - end + patch :update, params: params, as: :json end end diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index a37a831ddbb..e837c99d19c 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -357,11 +357,7 @@ describe Projects::MergeRequestsController do context 'when the sha parameter matches the source SHA' do def merge_with_sha(params = {}) post_params = base_params.merge(sha: merge_request.diff_head_sha).merge(params) - if Gitlab.rails5? - post :merge, params: post_params, as: :json - else - post :merge, post_params - end + post :merge, params: post_params, as: :json end it 'returns :success' do diff --git a/spec/controllers/projects/pipeline_schedules_controller_spec.rb b/spec/controllers/projects/pipeline_schedules_controller_spec.rb index 7179423dde2..08e2c957d69 100644 --- a/spec/controllers/projects/pipeline_schedules_controller_spec.rb +++ b/spec/controllers/projects/pipeline_schedules_controller_spec.rb @@ -310,19 +310,11 @@ describe Projects::PipelineSchedulesController do end def go - if Gitlab.rails5? - put :update, params: { namespace_id: project.namespace.to_param, - project_id: project, - id: pipeline_schedule, - schedule: schedule }, - as: :html - - else - put :update, namespace_id: project.namespace.to_param, - project_id: project, - id: pipeline_schedule, - schedule: schedule - end + put :update, params: { namespace_id: project.namespace.to_param, + project_id: project, + id: pipeline_schedule, + schedule: schedule }, + as: :html end end diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index 6420b70a54f..832649e5886 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -8,11 +8,7 @@ end shared_examples 'content not cached without revalidation and no-store' do it 'ensures content will not be cached without revalidation' do # Fixed in newer versions of ActivePack, it will only output a single `private`. - if Gitlab.rails5? - expect(subject['Cache-Control']).to eq('max-age=0, private, must-revalidate, no-store') - else - expect(subject['Cache-Control']).to eq('max-age=0, private, must-revalidate, private, no-store') - end + expect(subject['Cache-Control']).to eq('max-age=0, private, must-revalidate, no-store') end end diff --git a/spec/helpers/storage_helper_spec.rb b/spec/helpers/storage_helper_spec.rb index c580b78c908..03df9deafa1 100644 --- a/spec/helpers/storage_helper_spec.rb +++ b/spec/helpers/storage_helper_spec.rb @@ -15,11 +15,7 @@ describe StorageHelper do end it "uses commas as thousands separator" do - if Gitlab.rails5? - expect(helper.storage_counter(100_000_000_000_000_000_000_000)).to eq("86,736.2 EB") - else - expect(helper.storage_counter(100_000_000_000_000_000)).to eq("90,949.5 TB") - end + expect(helper.storage_counter(100_000_000_000_000_000_000_000)).to eq("86,736.2 EB") end end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 0826bc3eeed..60106ee3c0b 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -400,13 +400,8 @@ describe Gitlab::Database do describe '.cached_table_exists?' do it 'only retrieves data once per table' do - if Gitlab.rails5? - expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:projects).once.and_call_original - expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:bogus_table_name).once.and_call_original - else - expect(ActiveRecord::Base.connection).to receive(:table_exists?).with(:projects).once.and_call_original - expect(ActiveRecord::Base.connection).to receive(:table_exists?).with(:bogus_table_name).once.and_call_original - end + expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:projects).once.and_call_original + expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:bogus_table_name).once.and_call_original 2.times do expect(described_class.cached_table_exists?(:projects)).to be_truthy diff --git a/spec/lib/gitlab/sql/glob_spec.rb b/spec/lib/gitlab/sql/glob_spec.rb index 1cf8935bfe3..3147b52dcc5 100644 --- a/spec/lib/gitlab/sql/glob_spec.rb +++ b/spec/lib/gitlab/sql/glob_spec.rb @@ -35,9 +35,8 @@ describe Gitlab::SQL::Glob do value = query("SELECT #{quote(string)} LIKE #{pattern}") .rows.flatten.first - check = Gitlab.rails5? ? true : 't' case value - when check, 1 + when true, 1 true else false diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index 771d834c4bc..c8ab564e3bc 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -42,12 +42,7 @@ RSpec.describe NotificationSetting do expect(notification_setting.new_issue).to eq(true) expect(notification_setting.close_issue).to eq(true) expect(notification_setting.merge_merge_request).to eq(true) - - # In Rails 5 assigning a value which is not explicitly `true` or `false` ("nil" in this case) - # to a boolean column transforms it to `true`. - # In Rails 4 it transforms the value to `false` with deprecation warning. - # Replace `eq(Gitlab.rails5?)` with `eq(true)` when removing rails5? code. - expect(notification_setting.close_merge_request).to eq(Gitlab.rails5?) + expect(notification_setting.close_merge_request).to eq(true) expect(notification_setting.reopen_merge_request).to eq(false) end end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 2ebcb787d06..3304dfdd909 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -969,17 +969,10 @@ describe API::Internal do env: env } - if Gitlab.rails5? - post( - api("/internal/allowed"), - params: params - ) - else - post( - api("/internal/allowed"), - params - ) - end + post( + api("/internal/allowed"), + params: params + ) end def archive(key, project) diff --git a/spec/support/helpers/test_request_helpers.rb b/spec/support/helpers/test_request_helpers.rb index 187a0e07891..5a84d67bdfc 100644 --- a/spec/support/helpers/test_request_helpers.rb +++ b/spec/support/helpers/test_request_helpers.rb @@ -2,10 +2,6 @@ module TestRequestHelpers def test_request(remote_ip: '127.0.0.1') - if Gitlab.rails5? - ActionController::TestRequest.new({ remote_ip: remote_ip }, ActionController::TestSession.new) - else - ActionController::TestRequest.new(remote_ip: remote_ip) - end + ActionController::TestRequest.new({ remote_ip: remote_ip }, ActionController::TestSession.new) end end |