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
5d548151
Commit
5d548151
authored
Nov 17, 2018
by
Jasper Maes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rails5: Passing a class as a value in an Active Record query is deprecated
parent
29d8179b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
10 deletions
+15
-10
app/finders/events_finder.rb
app/finders/events_finder.rb
+1
-1
app/models/ci/build.rb
app/models/ci/build.rb
+2
-2
app/models/concerns/avatarable.rb
app/models/concerns/avatarable.rb
+1
-1
app/services/todos/destroy/entity_leave_service.rb
app/services/todos/destroy/entity_leave_service.rb
+1
-1
app/services/todos/destroy/private_features_service.rb
app/services/todos/destroy/private_features_service.rb
+3
-3
changelogs/unreleased/rails5-active-record-class-value.yml
changelogs/unreleased/rails5-active-record-class-value.yml
+5
-0
spec/finders/pending_todos_finder_spec.rb
spec/finders/pending_todos_finder_spec.rb
+1
-1
spec/models/todo_spec.rb
spec/models/todo_spec.rb
+1
-1
No files found.
app/finders/events_finder.rb
View file @
5d548151
...
@@ -58,7 +58,7 @@ class EventsFinder
...
@@ -58,7 +58,7 @@ class EventsFinder
def
by_target_type
(
events
)
def
by_target_type
(
events
)
return
events
unless
Event
::
TARGET_TYPES
[
params
[
:target_type
]]
return
events
unless
Event
::
TARGET_TYPES
[
params
[
:target_type
]]
events
.
where
(
target_type:
Event
::
TARGET_TYPES
[
params
[
:target_type
]])
events
.
where
(
target_type:
Event
::
TARGET_TYPES
[
params
[
:target_type
]]
.
name
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/models/ci/build.rb
View file @
5d548151
...
@@ -98,7 +98,7 @@ module Ci
...
@@ -98,7 +98,7 @@ module Ci
scope
:matches_tag_ids
,
->
(
tag_ids
)
do
scope
:matches_tag_ids
,
->
(
tag_ids
)
do
matcher
=
::
ActsAsTaggableOn
::
Tagging
matcher
=
::
ActsAsTaggableOn
::
Tagging
.
where
(
taggable_type:
CommitStatus
)
.
where
(
taggable_type:
CommitStatus
.
name
)
.
where
(
context:
'tags'
)
.
where
(
context:
'tags'
)
.
where
(
'taggable_id = ci_builds.id'
)
.
where
(
'taggable_id = ci_builds.id'
)
.
where
.
not
(
tag_id:
tag_ids
).
select
(
'1'
)
.
where
.
not
(
tag_id:
tag_ids
).
select
(
'1'
)
...
@@ -108,7 +108,7 @@ module Ci
...
@@ -108,7 +108,7 @@ module Ci
scope
:with_any_tags
,
->
do
scope
:with_any_tags
,
->
do
matcher
=
::
ActsAsTaggableOn
::
Tagging
matcher
=
::
ActsAsTaggableOn
::
Tagging
.
where
(
taggable_type:
CommitStatus
)
.
where
(
taggable_type:
CommitStatus
.
name
)
.
where
(
context:
'tags'
)
.
where
(
context:
'tags'
)
.
where
(
'taggable_id = ci_builds.id'
).
select
(
'1'
)
.
where
(
'taggable_id = ci_builds.id'
).
select
(
'1'
)
...
...
app/models/concerns/avatarable.rb
View file @
5d548151
...
@@ -86,7 +86,7 @@ module Avatarable
...
@@ -86,7 +86,7 @@ module Avatarable
params
[
:model
].
upload_paths
(
params
[
:identifier
])
params
[
:model
].
upload_paths
(
params
[
:identifier
])
end
end
Upload
.
where
(
uploader:
AvatarUploader
,
path:
paths
).
find_each
do
|
upload
|
Upload
.
where
(
uploader:
AvatarUploader
.
name
,
path:
paths
).
find_each
do
|
upload
|
model
=
model_class
.
instantiate
(
'id'
=>
upload
.
model_id
)
model
=
model_class
.
instantiate
(
'id'
=>
upload
.
model_id
)
loader
.
call
({
model:
model
,
identifier:
File
.
basename
(
upload
.
path
)
},
upload
)
loader
.
call
({
model:
model
,
identifier:
File
.
basename
(
upload
.
path
)
},
upload
)
...
...
app/services/todos/destroy/entity_leave_service.rb
View file @
5d548151
...
@@ -45,7 +45,7 @@ module Todos
...
@@ -45,7 +45,7 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
remove_confidential_issue_todos
def
remove_confidential_issue_todos
Todo
.
where
(
Todo
.
where
(
target_id:
confidential_issues
.
select
(
:id
),
target_type:
Issue
,
user_id:
user
.
id
target_id:
confidential_issues
.
select
(
:id
),
target_type:
Issue
.
name
,
user_id:
user
.
id
).
delete_all
).
delete_all
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/services/todos/destroy/private_features_service.rb
View file @
5d548151
...
@@ -14,9 +14,9 @@ module Todos
...
@@ -14,9 +14,9 @@ module Todos
def
execute
def
execute
ProjectFeature
.
where
(
project_id:
project_ids
).
each
do
|
project_features
|
ProjectFeature
.
where
(
project_id:
project_ids
).
each
do
|
project_features
|
target_types
=
[]
target_types
=
[]
target_types
<<
Issue
if
private
?(
project_features
.
issues_access_level
)
target_types
<<
Issue
.
name
if
private
?(
project_features
.
issues_access_level
)
target_types
<<
MergeRequest
if
private
?(
project_features
.
merge_requests_access_level
)
target_types
<<
MergeRequest
.
name
if
private
?(
project_features
.
merge_requests_access_level
)
target_types
<<
Commit
if
private
?(
project_features
.
repository_access_level
)
target_types
<<
Commit
.
name
if
private
?(
project_features
.
repository_access_level
)
next
if
target_types
.
empty?
next
if
target_types
.
empty?
...
...
changelogs/unreleased/rails5-active-record-class-value.yml
0 → 100644
View file @
5d548151
---
title
:
'
Rails5:
Passing
a
class
as
a
value
in
an
Active
Record
query
is
deprecated'
merge_request
:
23164
author
:
Jasper Maes
type
:
other
spec/finders/pending_todos_finder_spec.rb
View file @
5d548151
...
@@ -46,7 +46,7 @@ describe PendingTodosFinder do
...
@@ -46,7 +46,7 @@ describe PendingTodosFinder do
create
(
:todo
,
:pending
,
user:
user
,
target:
note
)
create
(
:todo
,
:pending
,
user:
user
,
target:
note
)
todos
=
described_class
.
new
(
user
,
target_type:
issue
.
class
).
execute
todos
=
described_class
.
new
(
user
,
target_type:
issue
.
class
.
name
).
execute
expect
(
todos
).
to
eq
([
todo
])
expect
(
todos
).
to
eq
([
todo
])
end
end
...
...
spec/models/todo_spec.rb
View file @
5d548151
...
@@ -226,7 +226,7 @@ describe Todo do
...
@@ -226,7 +226,7 @@ describe Todo do
create
(
:todo
,
target:
create
(
:merge_request
))
create
(
:todo
,
target:
create
(
:merge_request
))
expect
(
described_class
.
for_type
(
Issue
)).
to
eq
([
todo
])
expect
(
described_class
.
for_type
(
Issue
.
name
)).
to
eq
([
todo
])
end
end
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