Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
743aec2a
Commit
743aec2a
authored
Dec 15, 2018
by
Jasper Maes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove rails4 specific code
parent
d15c6b83
Changes
50
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
82 additions
and
348 deletions
+82
-348
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-4
app/controllers/concerns/invalid_utf8_error_handler.rb
app/controllers/concerns/invalid_utf8_error_handler.rb
+0
-27
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-11
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-2
app/models/concerns/enum_with_nil.rb
app/models/concerns/enum_with_nil.rb
+1
-2
app/models/concerns/redis_cacheable.rb
app/models/concerns/redis_cacheable.rb
+1
-5
app/models/event.rb
app/models/event.rb
+0
-13
app/models/service.rb
app/models/service.rb
+1
-5
changelogs/unreleased/remove-rails4-specific-code.yml
changelogs/unreleased/remove-rails4-specific-code.yml
+5
-0
config/application.rb
config/application.rb
+0
-6
db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
...grate/20160226114608_add_trigram_indexes_for_searching.rb
+1
-6
db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
...grate/20161207231620_fixup_environment_name_uniqueness.rb
+1
-2
db/migrate/20161207231626_add_environment_slug.rb
db/migrate/20161207231626_add_environment_slug.rb
+1
-2
db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
...1109150329_fix_project_records_with_invalid_visibility.rb
+1
-2
db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb
...0416_migrate_user_activities_to_users_last_activity_on.rb
+1
-2
ee/app/finders/epics_finder.rb
ee/app/finders/epics_finder.rb
+1
-5
ee/app/serializers/vulnerability_summary_entity.rb
ee/app/serializers/vulnerability_summary_entity.rb
+1
-2
ee/db/migrate/20170215151540_migrate_old_elasticsearch_settings.rb
...rate/20170215151540_migrate_old_elasticsearch_settings.rb
+1
-2
ee/lib/gitlab/background_migration/remove_comma_from_weight_system_notes.rb
...ground_migration/remove_comma_from_weight_system_notes.rb
+1
-3
ee/spec/controllers/boards/lists_controller_spec.rb
ee/spec/controllers/boards/lists_controller_spec.rb
+1
-5
ee/spec/controllers/projects/vulnerability_feedback_controller_spec.rb
...ollers/projects/vulnerability_feedback_controller_spec.rb
+1
-5
ee/spec/features/projects/new_project_spec.rb
ee/spec/features/projects/new_project_spec.rb
+1
-6
ee/spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
...b/gitlab/database/load_balancing/connection_proxy_spec.rb
+1
-1
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
+3
-9
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
.../lib/gitlab/database/load_balancing/load_balancer_spec.rb
+9
-22
ee/spec/models/prometheus_alert_event_spec.rb
ee/spec/models/prometheus_alert_event_spec.rb
+1
-1
ee/spec/services/applications/create_service_spec.rb
ee/spec/services/applications/create_service_spec.rb
+2
-7
lib/api/helpers.rb
lib/api/helpers.rb
+1
-1
lib/declarative_policy.rb
lib/declarative_policy.rb
+4
-8
lib/gitlab/database.rb
lib/gitlab/database.rb
+1
-5
lib/gitlab/database/arel_methods.rb
lib/gitlab/database/arel_methods.rb
+0
-20
lib/gitlab/database/median.rb
lib/gitlab/database/median.rb
+3
-14
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+1
-3
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
...atabase/rename_reserved_paths_migration/v1/rename_base.rb
+1
-3
lib/gitlab/database/sha_attribute.rb
lib/gitlab/database/sha_attribute.rb
+4
-33
lib/gitlab/database/subquery.rb
lib/gitlab/database/subquery.rb
+5
-9
lib/gitlab/gpg.rb
lib/gitlab/gpg.rb
+1
-7
lib/gitlab/middleware/correlation_id.rb
lib/gitlab/middleware/correlation_id.rb
+1
-5
lib/mysql_zero_date.rb
lib/mysql_zero_date.rb
+1
-1
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+2
-18
spec/controllers/boards/lists_controller_spec.rb
spec/controllers/boards/lists_controller_spec.rb
+1
-5
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-5
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+5
-13
spec/controllers/uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+1
-5
spec/helpers/storage_helper_spec.rb
spec/helpers/storage_helper_spec.rb
+1
-5
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+2
-7
spec/lib/gitlab/sql/glob_spec.rb
spec/lib/gitlab/sql/glob_spec.rb
+1
-2
spec/models/notification_setting_spec.rb
spec/models/notification_setting_spec.rb
+1
-6
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+4
-11
spec/support/helpers/test_request_helpers.rb
spec/support/helpers/test_request_helpers.rb
+1
-5
No files found.
app/controllers/application_controller.rb
View file @
743aec2a
...
...
@@ -12,9 +12,6 @@ class ApplicationController < ActionController::Base
include
EnforcesTwoFactorAuthentication
include
WithPerformanceBar
include
SessionlessAuthentication
# this can be removed after switching to rails 5
# https://gitlab.com/gitlab-org/gitlab-ce/issues/51908
include
InvalidUTF8ErrorHandler
unless
Gitlab
.
rails5?
before_action
:authenticate_user!
before_action
:enforce_terms!
,
if: :should_enforce_terms?
...
...
@@ -161,7 +158,7 @@ class ApplicationController < ActionController::Base
def
log_exception
(
exception
)
Gitlab
::
Sentry
.
track_acceptable_exception
(
exception
)
backtrace_cleaner
=
Gitlab
.
rails5?
?
request
.
env
[
"action_dispatch.backtrace_cleaner"
]
:
env
backtrace_cleaner
=
request
.
env
[
"action_dispatch.backtrace_cleaner"
]
application_trace
=
ActionDispatch
::
ExceptionWrapper
.
new
(
backtrace_cleaner
,
exception
).
application_trace
application_trace
.
map!
{
|
t
|
"
#{
t
}
\n
"
}
logger
.
error
"
\n
#{
exception
.
class
.
name
}
(
#{
exception
.
message
}
):
\n
#{
application_trace
.
join
}
"
...
...
app/controllers/concerns/invalid_utf8_error_handler.rb
deleted
100644 → 0
View file @
d15c6b83
# frozen_string_literal: true
module
InvalidUTF8ErrorHandler
extend
ActiveSupport
::
Concern
included
do
rescue_from
ArgumentError
,
with: :handle_invalid_utf8
end
private
def
handle_invalid_utf8
(
error
)
if
error
.
message
==
"invalid byte sequence in UTF-8"
render_412
else
raise
(
error
)
end
end
def
render_412
respond_to
do
|
format
|
format
.
html
{
render
"errors/precondition_failed"
,
layout:
"errors"
,
status:
412
}
format
.
js
{
render
json:
{
error:
'Invalid UTF-8'
},
status: :precondition_failed
,
content_type:
'application/json'
}
format
.
any
{
head
:precondition_failed
}
end
end
end
app/models/ci/pipeline.rb
View file @
743aec2a
...
...
@@ -56,11 +56,7 @@ module Ci
validates
:tag
,
inclusion:
{
in:
[
false
],
if: :merge_request?
}
validates
:status
,
presence:
{
unless: :importing?
}
validate
:valid_commit_sha
,
unless: :importing?
# Replace validator below with
# `validates :source, presence: { unless: :importing? }, on: :create`
# when removing Gitlab.rails5? code.
validate
:valid_source
,
unless: :importing?
,
on: :create
validates
:source
,
exclusion:
{
in:
%w(unknown)
,
unless: :importing?
},
on: :create
after_create
:keep_around_commits
,
unless: :importing?
...
...
@@ -738,12 +734,6 @@ module Ci
project
.
repository
.
keep_around
(
self
.
sha
,
self
.
before_sha
)
end
def
valid_source
if
source
.
nil?
||
source
==
"unknown"
errors
.
add
(
:source
,
"invalid source"
)
end
end
end
end
...
...
app/models/ci/runner.rb
View file @
743aec2a
...
...
@@ -58,8 +58,7 @@ module Ci
# BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb`
scope
:deprecated_shared
,
->
{
instance_type
}
# this should get replaced with `project_type.or(group_type)` once using Rails5
scope
:deprecated_specific
,
->
{
where
(
runner_type:
[
runner_types
[
:project_type
],
runner_types
[
:group_type
]])
}
scope
:deprecated_specific
,
->
{
project_type
.
or
(
group_type
)
}
scope
:belonging_to_project
,
->
(
project_id
)
{
joins
(
:runner_projects
).
where
(
ci_runner_projects:
{
project_id:
project_id
})
...
...
app/models/concerns/enum_with_nil.rb
View file @
743aec2a
...
...
@@ -16,7 +16,7 @@ module EnumWithNil
# E.g. for enum_with_nil failure_reason: { unknown_failure: nil }
# this overrides auto-generated method `unknown_failure?`
define_method
(
"
#{
key_with_nil
}
?"
)
do
Gitlab
.
rails5?
?
self
[
name
].
nil?
:
super
()
self
[
name
].
nil?
end
# E.g. for enum_with_nil failure_reason: { unknown_failure: nil }
...
...
@@ -24,7 +24,6 @@ module EnumWithNil
define_method
(
name
)
do
orig
=
super
()
return
orig
unless
Gitlab
.
rails5?
return
orig
unless
orig
.
nil?
self
.
class
.
public_send
(
name
.
to_s
.
pluralize
).
key
(
nil
)
# rubocop:disable GitlabSecurity/PublicSend
...
...
app/models/concerns/redis_cacheable.rb
View file @
743aec2a
...
...
@@ -49,10 +49,6 @@ module RedisCacheable
end
def
cast_value_from_cache
(
attribute
,
value
)
if
Gitlab
.
rails5?
self
.
class
.
type_for_attribute
(
attribute
.
to_s
).
cast
(
value
)
else
self
.
class
.
column_for_attribute
(
attribute
).
type_cast_from_database
(
value
)
end
self
.
class
.
type_for_attribute
(
attribute
.
to_s
).
cast
(
value
)
end
end
app/models/event.rb
View file @
743aec2a
...
...
@@ -114,19 +114,6 @@ class Event < ActiveRecord::Base
end
end
# Remove this method when removing Gitlab.rails5? code.
def
subclass_from_attributes
(
attrs
)
return
super
if
Gitlab
.
rails5?
# Without this Rails will keep calling this method on the returned class,
# resulting in an infinite loop.
return
unless
self
==
Event
action
=
attrs
.
with_indifferent_access
[
inheritance_column
].
to_i
PushEvent
if
action
==
PUSHED
end
# Update Gitlab::ContributionsCalendar#activity_dates if this changes
def
contributions
where
(
"action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)"
,
...
...
app/models/service.rb
View file @
743aec2a
...
...
@@ -210,11 +210,7 @@ class Service < ActiveRecord::Base
class_eval
%{
def #{arg}?
# '!!' is used because nil or empty string is converted to nil
if Gitlab.rails5?
!!ActiveRecord::Type::Boolean.new.cast(#{arg})
else
!!ActiveRecord::Type::Boolean.new.type_cast_from_database(#{arg})
end
!!ActiveRecord::Type::Boolean.new.cast(#{arg})
end
}
end
...
...
changelogs/unreleased/remove-rails4-specific-code.yml
0 → 100644
View file @
743aec2a
---
title
:
Remove rails4 specific code
merge_request
:
23847
author
:
Jasper Maes
type
:
other
config/application.rb
View file @
743aec2a
...
...
@@ -7,12 +7,6 @@ Bundler.require(:default, Rails.env)
require
'elasticsearch/rails/instrumentation'
module
Gitlab
# This method is used for smooth upgrading from the current Rails 4.x to Rails 5.0.
# https://gitlab.com/gitlab-org/gitlab-ce/issues/14286
def
self
.
rails5?
true
end
class
Application
<
Rails
::
Application
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/redis/wrapper'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/redis/cache'
)
...
...
db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
View file @
743aec2a
...
...
@@ -37,12 +37,7 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration[4.2]
res
=
execute
(
"SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;"
)
row
=
res
.
first
check
=
if
Gitlab
.
rails5?
true
else
't'
end
row
&&
row
[
'enabled'
]
==
check
?
true
:
false
row
&&
row
[
'enabled'
]
==
true
end
def
create_trigrams_extension
...
...
db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
View file @
743aec2a
class
FixupEnvironmentNameUniqueness
<
ActiveRecord
::
Migration
[
4.2
]
include
Gitlab
::
Database
::
ArelMethods
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
true
...
...
@@ -42,7 +41,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration[4.2]
conflicts
.
each
do
|
id
,
name
|
update_sql
=
arel_update_manager
Arel
::
UpdateManager
.
new
.
table
(
environments
)
.
set
(
environments
[
:name
]
=>
name
+
"-"
+
id
.
to_s
)
.
where
(
environments
[
:id
].
eq
(
id
))
...
...
db/migrate/20161207231626_add_environment_slug.rb
View file @
743aec2a
...
...
@@ -2,7 +2,6 @@
# for more information on how to write migrations for GitLab.
class
AddEnvironmentSlug
<
ActiveRecord
::
Migration
[
4.2
]
include
Gitlab
::
Database
::
ArelMethods
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
true
...
...
@@ -20,7 +19,7 @@ class AddEnvironmentSlug < ActiveRecord::Migration[4.2]
finder
=
environments
.
project
(
:id
,
:name
)
connection
.
exec_query
(
finder
.
to_sql
).
rows
.
each
do
|
id
,
name
|
updater
=
arel_update_manager
updater
=
Arel
::
UpdateManager
.
new
.
table
(
environments
)
.
set
(
environments
[
:slug
]
=>
generate_slug
(
name
))
.
where
(
environments
[
:id
].
eq
(
id
))
...
...
db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
View file @
743aec2a
class
FixProjectRecordsWithInvalidVisibility
<
ActiveRecord
::
Migration
[
4.2
]
include
Gitlab
::
Database
::
ArelMethods
include
Gitlab
::
Database
::
MigrationHelpers
BATCH_SIZE
=
500
...
...
@@ -34,7 +33,7 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration[4.2]
end
updates
.
each
do
|
visibility_level
,
project_ids
|
updater
=
arel_update_manager
updater
=
Arel
::
UpdateManager
.
new
.
table
(
projects
)
.
set
(
projects
[
:visibility_level
]
=>
visibility_level
)
.
where
(
projects
[
:id
].
in
(
project_ids
))
...
...
db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb
View file @
743aec2a
# rubocop:disable Migration/UpdateLargeTable
class
MigrateUserActivitiesToUsersLastActivityOn
<
ActiveRecord
::
Migration
[
4.2
]
include
Gitlab
::
Database
::
ArelMethods
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
...
...
@@ -40,7 +39,7 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration[4.2]
activities
=
activities
(
day
.
at_beginning_of_day
,
day
.
at_end_of_day
,
page:
page
)
update_sql
=
arel_update_manager
Arel
::
UpdateManager
.
new
.
table
(
users_table
)
.
set
(
users_table
[
:last_activity_on
]
=>
day
.
to_date
)
.
where
(
users_table
[
:username
].
in
(
activities
.
map
(
&
:first
)))
...
...
ee/app/finders/epics_finder.rb
View file @
743aec2a
...
...
@@ -55,11 +55,7 @@ class EpicsFinder < IssuableFinder
private
def
count_key
(
value
)
if
Gitlab
.
rails5?
Array
(
value
).
last
.
to_sym
else
Epic
.
states
.
invert
[
Array
(
value
).
last
].
to_sym
end
Array
(
value
).
last
.
to_sym
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
ee/app/serializers/vulnerability_summary_entity.rb
View file @
743aec2a
...
...
@@ -2,11 +2,10 @@
class
VulnerabilitySummaryEntity
<
Grape
::
Entity
Vulnerabilities
::
Occurrence
::
REPORT_TYPES
.
each
do
|
report_type_name
,
report_type
|
report_key
=
Gitlab
.
rails5?
?
report_type_name
:
report_type
expose
report_type_name
do
Vulnerabilities
::
Occurrence
::
LEVELS
.
each
do
|
severity_name
,
severity
|
expose
severity_name
do
|
group
|
grouped_vulnerabilities
[[
report_
key
,
severity
]]
||
0
grouped_vulnerabilities
[[
report_
type_name
,
severity
]]
||
0
end
end
end
...
...
ee/db/migrate/20170215151540_migrate_old_elasticsearch_settings.rb
View file @
743aec2a
class
MigrateOldElasticsearchSettings
<
ActiveRecord
::
Migration
[
4.2
]
include
Gitlab
::
Database
::
ArelMethods
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
...
...
@@ -24,7 +23,7 @@ class MigrateOldElasticsearchSettings < ActiveRecord::Migration[4.2]
end
updater
=
arel_update_manager
Arel
::
UpdateManager
.
new
.
table
(
settings
)
.
set
(
settings
[
:elasticsearch_url
]
=>
urls
.
join
(
','
))
.
where
(
settings
[
:id
].
eq
(
id
))
...
...
ee/lib/gitlab/background_migration/remove_comma_from_weight_system_notes.rb
View file @
743aec2a
...
...
@@ -3,8 +3,6 @@
module
Gitlab
module
BackgroundMigration
class
RemoveCommaFromWeightSystemNotes
include
::
Gitlab
::
Database
::
ArelMethods
def
perform
(
note_ids
)
notes_table
=
Arel
::
Table
.
new
(
:notes
)
...
...
@@ -13,7 +11,7 @@ module Gitlab
[
notes_table
[
:note_html
],
nil
]
]
update
=
arel_update_manager
update
=
Arel
::
UpdateManager
.
new
.
table
(
notes_table
)
.
set
(
update_values
)
.
where
(
notes_table
[
:id
].
in
(
note_ids
))
...
...
ee/spec/controllers/boards/lists_controller_spec.rb
View file @
743aec2a
...
...
@@ -156,11 +156,7 @@ describe Boards::ListsController do
format: :json
}
if
Gitlab
.
rails5?
patch
:update
,
params:
params
,
as: :json
else
patch
:update
,
params
end
patch
:update
,
params:
params
,
as: :json
end
end
...
...
ee/spec/controllers/projects/vulnerability_feedback_controller_spec.rb
View file @
743aec2a
...
...
@@ -167,11 +167,7 @@ describe Projects::VulnerabilityFeedbackController do
format: :json
}
if
Gitlab
.
rails5?
post
:create
,
params:
post_params
,
as: :json
else
post
:create
,
post_params
end
post
:create
,
params:
post_params
,
as: :json
end
end
...
...
ee/spec/features/projects/new_project_spec.rb
View file @
743aec2a
...
...
@@ -97,12 +97,7 @@ describe 'New project' do
created_project
=
Project
.
last
if
Gitlab
.
rails5?
expect
(
current_path
).
to
eq
(
project_import_path
(
created_project
))
else
expect
(
current_path
).
to
eq
(
project_path
(
created_project
))
end
expect
(
current_path
).
to
eq
(
project_import_path
(
created_project
))
expect
(
created_project
.
project_feature
).
to
be_issues_enabled
end
end
...
...
ee/spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
View file @
743aec2a
...
...
@@ -15,7 +15,7 @@ describe Gitlab::Database::LoadBalancing::ConnectionProxy do
let
(
:override_proxy
)
{
ActiveRecord
::
Base
.
connection
.
class
}
# We can't use :Gitlab::Utils::Override because this method is dynamically prepended
it
'method signatures match'
,
:rails5
do
it
'method signatures match'
do
expect
(
proxy
.
method
(
:select_all
).
parameters
).
to
eq
(
override_proxy
.
instance_method
(
:select_all
).
parameters
)
end
...
...
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
View file @
743aec2a
...
...
@@ -19,15 +19,9 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
end
def
wrapped_exception
(
wrapper
,
original
)
if
Gitlab
.
rails5?
begin
raise_and_wrap
(
wrapper
,
original
.
new
)
rescue
wrapper
=>
error
error
end
else
wrapper
.
new
(
'boom'
,
original
.
new
)
end
raise_and_wrap
(
wrapper
,
original
.
new
)
rescue
wrapper
=>
error
error
end
describe
'#connection'
do
...
...
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
View file @
743aec2a
...
...
@@ -19,32 +19,19 @@ describe Gitlab::Database::LoadBalancing::LoadBalancer do
end
def
wrapped_exception
(
wrapper
,
original
)
if
Gitlab
.
rails5?
begin
raise_and_wrap
(
wrapper
,
original
.
new
)
rescue
wrapper
=>
error
error
end
else
wrapper
.
new
(
'boop'
,
original
.
new
)
end
raise_and_wrap
(
wrapper
,
original
.
new
)
rescue
wrapper
=>
error
error
end
def
twice_wrapped_exception
(
top
,
middle
,
original
)
if
Gitlab
.
rails5?
begin
begin
raise_and_wrap
(
middle
,
original
.
new
)
rescue
middle
=>
middle_error
raise_and_wrap
(
top
,
middle_error
)
end
rescue
top
=>
top_error
top_error
end
else
middle_error
=
middle
.
new
(
'boop'
,
original
.
new
)
top
.
new
(
'boop'
,
middle_error
)
begin
raise_and_wrap
(
middle
,
original
.
new
)
rescue
middle
=>
middle_error
raise_and_wrap
(
top
,
middle_error
)
end
rescue
top
=>
top_error
top_error
end
describe
'#read'
do
...
...
ee/spec/models/prometheus_alert_event_spec.rb
View file @
743aec2a
...
...
@@ -13,7 +13,7 @@ describe PrometheusAlertEvent do
describe
'validations'
do
it
{
is_expected
.
to
be_valid
}
it
{
is_expected
.
to
validate_presence_of
(
:prometheus_alert
).
with_message
(
Gitlab
.
rails5?
?
:required
:
:blank
)
}
it
{
is_expected
.
to
validate_presence_of
(
:prometheus_alert
).
with_message
(
:required
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:payload_key
).
scoped_to
(
:prometheus_alert_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:started_at
)
}
...
...
ee/spec/services/applications/create_service_spec.rb
View file @
743aec2a
...
...
@@ -3,13 +3,8 @@ require 'spec_helper'
describe
::
Applications
::
CreateService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:params
)
{
attributes_for
(
:application
)
}
let
(
:request
)
do
if
Gitlab
.
rails5?
ActionController
::
TestRequest
.
new
({
remote_ip:
"127.0.0.1"
},
ActionController
::
TestSession
.
new
)
else
ActionController
::
TestRequest
.
new
(
remote_ip:
"127.0.0.1"
)
end
end
let
(
:request
)
{
ActionController
::
TestRequest
.
new
({
remote_ip:
"127.0.0.1"
},
ActionController
::
TestSession
.
new
)
}
subject
{
described_class
.
new
(
user
,
params
)
}
it
'creates an audit log'
do
...
...
lib/api/helpers.rb
View file @
743aec2a
...
...
@@ -304,7 +304,7 @@ module API
end
end
permitted_attrs
=
ActionController
::
Parameters
.
new
(
attrs
).
permit!
Gitlab
.
rails5?
?
permitted_attrs
.
to_h
:
permitted_attrs
permitted_attrs
.
to_h
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
lib/declarative_policy.rb
View file @
743aec2a
...
...
@@ -22,14 +22,10 @@ module DeclarativePolicy
key
=
Cache
.
policy_key
(
user
,
subject
)
cache
[
key
]
||=
if
Gitlab
.
rails5?
# to avoid deadlocks in multi-threaded environment when
# autoloading is enabled, we allow concurrent loads,
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48263
ActiveSupport
::
Dependencies
.
interlock
.
permit_concurrent_loads
do
class_for
(
subject
).
new
(
user
,
subject
,
opts
)
end
else
# to avoid deadlocks in multi-threaded environment when
# autoloading is enabled, we allow concurrent loads,
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48263
ActiveSupport
::
Dependencies
.
interlock
.
permit_concurrent_loads
do
class_for
(
subject
).
new
(
user
,
subject
,
opts
)
end
end
...
...
lib/gitlab/database.rb
View file @
743aec2a
...
...
@@ -236,11 +236,7 @@ module Gitlab
end
def
self
.
cached_table_exists?
(
table_name
)
if
Gitlab
.
rails5?
connection
.
schema_cache
.
data_source_exists?
(
table_name
)
else
connection
.
schema_cache
.
table_exists?
(
table_name
)
end
connection
.
schema_cache
.
data_source_exists?
(
table_name
)
end
private_class_method
:connection
...
...
lib/gitlab/database/arel_methods.rb
deleted
100644 → 0
View file @
d15c6b83
# frozen_string_literal: true
module
Gitlab
module
Database
module
ArelMethods
private
# In Arel 7.0.0 (Arel 7.1.4 is used in Rails 5.0) the `engine` parameter of `Arel::UpdateManager#initializer`
# was removed.
# Remove this file and inline this method when removing rails5? code.
def
arel_update_manager
if
Gitlab
.
rails5?
Arel
::
UpdateManager
.
new
else
Arel
::
UpdateManager
.
new
(
ActiveRecord
::
Base
)
end
end
end
end
end
lib/gitlab/database/median.rb
View file @
743aec2a
...
...
@@ -35,13 +35,7 @@ module Gitlab
end
def
mysql_median_datetime_sql
(
arel_table
,
query_so_far
,
column_sym
)
arel_from
=
if
Gitlab
.
rails5?
arel_table
.
from
else
arel_table
end
query
=
arel_from
query
=
arel_table
.
from
.
from
(
arel_table
.
project
(
Arel
.
sql
(
'*'
)).
order
(
arel_table
[
column_sym
]).
as
(
arel_table
.
table_name
))
.
project
(
average
([
arel_table
[
column_sym
]],
'median'
))
.
where
(
...
...
@@ -151,13 +145,8 @@ module Gitlab
.
order
(
arel_table
[
column_sym
])
).
as
(
'row_id'
)
arel_from
=
if
Gitlab
.
rails5?
arel_table
.
from
.
from
(
arel_table
.
alias
)
else
arel_table
.
from
(
arel_table
.
alias
)
end
count
=
arel_from
.
project
(
'COUNT(*)'
)
count
=
arel_table
.
from
.
from
(
arel_table
.
alias
)
.
project
(
'COUNT(*)'
)
.
where
(
arel_table
[
partition_column
].
eq
(
arel_table
.
alias
[
partition_column
]))
.
as
(
'ct'
)
...
...
lib/gitlab/database/migration_helpers.rb
View file @
743aec2a
...
...
@@ -3,8 +3,6 @@
module
Gitlab
module
Database
module
MigrationHelpers
include
Gitlab
::
Database
::
ArelMethods
BACKGROUND_MIGRATION_BATCH_SIZE
=
1000
# Number of rows to process per job
BACKGROUND_MIGRATION_JOB_BUFFER_SIZE
=
1000
# Number of jobs to bulk queue at a time
...
...
@@ -361,7 +359,7 @@ module Gitlab
stop_arel
=
yield
table
,
stop_arel
if
block_given?
stop_row
=
exec_query
(
stop_arel
.
to_sql
).
to_hash
.
first
update_arel
=
arel_update_manager
update_arel
=
Arel
::
UpdateManager
.
new
.
table
(
table
)
.
set
([[
table
[
column
],
value
]])
.
where
(
table
[
:id
].
gteq
(
start_id
))
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
View file @
743aec2a
...
...
@@ -5,8 +5,6 @@ module Gitlab
module
RenameReservedPathsMigration
module
V1
class
RenameBase
include
Gitlab
::
Database
::
ArelMethods
attr_reader
:paths
,
:migration
delegate
:update_column_in_batches
,
...
...
@@ -66,7 +64,7 @@ module Gitlab
old_full_path
,
new_full_path
)
update
=
arel_update_manager
update
=
Arel
::
UpdateManager
.
new
.
table
(
routes
)
.
set
([[
routes
[
:path
],
replace_statement
]])
.
where
(
Arel
::
Nodes
::
SqlLiteral
.
new
(
filter
))
...
...
lib/gitlab/database/sha_attribute.rb
View file @
743aec2a
...
...
@@ -8,14 +8,7 @@ module Gitlab
# behaviour from the default Binary type.
ActiveRecord
::
ConnectionAdapters
::
PostgreSQL
::
OID
::
Bytea
else
# In Rails 5.0 `Type` has been moved from `ActiveRecord` to `ActiveModel`
# https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6#diff-f8ba7983a51d687976e115adcd95822b
# Remove this method and leave just `ActiveModel::Type::Binary` when removing Gitlab.rails5? code.
if
Gitlab
.
rails5?
ActiveModel
::
Type
::
Binary
else
ActiveRecord
::
Type
::
Binary
end
ActiveModel
::
Type
::
Binary
end
# Class for casting binary data to hexadecimal SHA1 hashes (and vice-versa).
...
...
@@ -26,31 +19,9 @@ module Gitlab
class
ShaAttribute
<
BINARY_TYPE
PACK_FORMAT
=
'H*'
.
freeze
# It is called from activerecord-4.2.10/lib/active_record internal methods.
# Remove this method when removing Gitlab.rails5? code.
def
type_cast_from_database
(
value
)
unpack_sha
(
super
)
end
# It is called from activerecord-4.2.10/lib/active_record internal methods.
# Remove this method when removing Gitlab.rails5? code.
def
type_cast_for_database
(
value
)
serialize
(
value
)
end
# It is called from activerecord-5.0.6/lib/active_record/attribute.rb
# Remove this method when removing Gitlab.rails5? code..
def
deserialize
(
value
)
value
=
Gitlab
.
rails5?
?
super
:
method
(
:type_cast_from_database
).
super_method
.
call
(
value
)
unpack_sha
(
value
)
end
# Rename this method to `deserialize(value)` removing Gitlab.rails5? code.
# Casts binary data to a SHA1 in hexadecimal.
def
unpack_sha
(
value
)
# Uncomment this line when removing Gitlab.rails5? code.
# value = super
def
deserialize
(
value
)
value
=
super
(
value
)
value
?
value
.
unpack
(
PACK_FORMAT
)[
0
]
:
nil
end
...
...
@@ -58,7 +29,7 @@ module Gitlab
def
serialize
(
value
)
arg
=
value
?
[
value
].
pack
(
PACK_FORMAT
)
:
nil
Gitlab
.
rails5?
?
super
(
arg
)
:
method
(
:type_cast_for_database
).
super_method
.
call
(
arg
)
super
(
arg
)
end
end
end
...
...
lib/gitlab/database/subquery.rb
View file @
743aec2a
...
...
@@ -6,15 +6,11 @@ module Gitlab
class
<<
self
def
self_join
(
relation
)
t
=
relation
.
arel_table
t2
=
if
!
Gitlab
.
rails5?
relation
.
arel
.
as
(
't2'
)
else
# Work around a bug in Rails 5, where LIMIT causes trouble
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/51729
r
=
relation
.
limit
(
nil
).
arel
r
.
take
(
relation
.
limit_value
)
if
relation
.
limit_value
r
.
as
(
't2'
)
end
# Work around a bug in Rails 5, where LIMIT causes trouble
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/51729
r
=
relation
.
limit
(
nil
).
arel
r
.
take
(
relation
.
limit_value
)
if
relation
.
limit_value
t2
=
r
.
as
(
't2'
)
relation
.
unscoped
.
joins
(
t
.
join
(
t2
).
on
(
t
[
:id
].
eq
(
t2
[
:id
])).
join_sources
.
first
)
end
...
...
lib/gitlab/gpg.rb
View file @
743aec2a
...
...
@@ -73,13 +73,7 @@ module Gitlab
if
MUTEX
.
locked?
&&
MUTEX
.
owned?
optimistic_using_tmp_keychain
(
&
block
)
else
if
Gitlab
.
rails5?
ActiveSupport
::
Dependencies
.
interlock
.
permit_concurrent_loads
do
MUTEX
.
synchronize
do
optimistic_using_tmp_keychain
(
&
block
)
end
end
else
ActiveSupport
::
Dependencies
.
interlock
.
permit_concurrent_loads
do
MUTEX
.
synchronize
do
optimistic_using_tmp_keychain
(
&
block
)
end
...
...
lib/gitlab/middleware/correlation_id.rb
View file @
743aec2a
...
...
@@ -20,11 +20,7 @@ module Gitlab
private
def
correlation_id
(
env
)
if
Gitlab
.
rails5?
request
(
env
).
request_id
else
request
(
env
).
uuid
end
request
(
env
).
request_id
end
def
request
(
env
)
...
...
lib/mysql_zero_date.rb
View file @
743aec2a
...
...
@@ -17,4 +17,4 @@ module MysqlZeroDate
end
end
ActiveRecord
::
ConnectionAdapters
::
AbstractMysqlAdapter
.
prepend
(
MysqlZeroDate
)
if
Gitlab
.
rails5?
ActiveRecord
::
ConnectionAdapters
::
AbstractMysqlAdapter
.
prepend
(
MysqlZeroDate
)
spec/controllers/application_controller_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/controllers/boards/lists_controller_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/controllers/uploads_controller_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/helpers/storage_helper_spec.rb
View file @
743aec2a
...
...
@@ -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
spec/lib/gitlab/database_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/lib/gitlab/sql/glob_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/models/notification_setting_spec.rb
View file @
743aec2a
...
...
@@ -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
...
...
spec/requests/api/internal_spec.rb
View file @
743aec2a
...
...
@@ -967,17 +967,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
)
...
...
spec/support/helpers/test_request_helpers.rb
View file @
743aec2a
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment