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
5f758aff
Commit
5f758aff
authored
Aug 17, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer polymorphism over `is_a?`
parent
9c22974c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
6 deletions
+14
-6
app/controllers/concerns/notes_actions.rb
app/controllers/concerns/notes_actions.rb
+2
-2
app/models/award_emoji.rb
app/models/award_emoji.rb
+1
-1
app/models/concerns/noteable.rb
app/models/concerns/noteable.rb
+4
-0
app/models/issue.rb
app/models/issue.rb
+4
-0
app/models/note.rb
app/models/note.rb
+3
-3
No files found.
app/controllers/concerns/notes_actions.rb
View file @
5f758aff
...
...
@@ -18,7 +18,7 @@ module NotesActions
@notes
=
prepare_notes_for_rendering
(
@notes
)
notes_json
[
:notes
]
=
if
noteable
.
is_a?
(
Issue
)
if
noteable
.
discussions_rendered_on_frontend?
note_serializer
.
represent
(
@notes
)
else
@notes
.
map
{
|
note
|
note_json
(
note
)
}
...
...
@@ -87,7 +87,7 @@ module NotesActions
if
note
.
persisted?
attrs
[
:valid
]
=
true
if
noteable
.
is_a?
(
Issue
)
if
noteable
.
discussions_rendered_on_frontend?
attrs
.
merge!
(
note_serializer
.
represent
(
note
))
else
attrs
.
merge!
(
...
...
app/models/award_emoji.rb
View file @
5f758aff
...
...
@@ -37,7 +37,7 @@ class AwardEmoji < ActiveRecord::Base
end
def
expire_etag_cache
return
unless
awardable
.
is_a?
(
Not
e
)
return
unless
awardable
.
respond_to?
(
:expire_etag_cach
e
)
awardable
.
expire_etag_cache
end
...
...
app/models/concerns/noteable.rb
View file @
5f758aff
...
...
@@ -24,6 +24,10 @@ module Noteable
DiscussionNote
::
NOTEABLE_TYPES
.
include?
(
base_class_name
)
end
def
discussions_rendered_on_frontend?
false
end
def
discussion_notes
notes
end
...
...
app/models/issue.rb
View file @
5f758aff
...
...
@@ -269,6 +269,10 @@ class Issue < ActiveRecord::Base
end
end
def
discussions_rendered_on_frontend?
true
end
private
# Returns `true` if the given User can read the current Issue.
...
...
app/models/note.rb
View file @
5f758aff
...
...
@@ -300,12 +300,12 @@ class Note < ActiveRecord::Base
end
def
expire_etag_cache
return
unless
for_issue
?
return
unless
noteable
.
discussions_rendered_on_frontend
?
key
=
Gitlab
::
Routing
.
url_helpers
.
project_noteable_notes_path
(
noteable
.
project
,
project
,
target_type:
noteable_type
.
underscore
,
target_id:
noteable
.
id
target_id:
noteable
_
id
)
Gitlab
::
EtagCaching
::
Store
.
new
.
touch
(
key
)
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