Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gigadoc 2
diaspora
Commits
e74b524e
Unverified
Commit
e74b524e
authored
Feb 18, 2017
by
Steffen van Bergerem
Committed by
Benjamin Neff
Feb 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor likes index route
parent
2772cb6e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
16 deletions
+5
-16
app/controllers/likes_controller.rb
app/controllers/likes_controller.rb
+3
-7
app/views/likes/_likes.haml
app/views/likes/_likes.haml
+0
-6
app/views/likes/index.html.haml
app/views/likes/index.html.haml
+0
-1
spec/controllers/likes_controller_spec.rb
spec/controllers/likes_controller_spec.rb
+2
-2
No files found.
app/controllers/likes_controller.rb
View file @
e74b524e
...
...
@@ -31,13 +31,9 @@ class LikesController < ApplicationController
end
def
index
@likes
=
like_service
.
find_for_post
(
params
[
:post_id
]).
includes
(
author: :profile
)
@people
=
@likes
.
map
(
&
:author
)
respond_to
do
|
format
|
format
.
all
{
render
:layout
=>
false
}
format
.
json
{
render
:json
=>
@likes
.
as_api_response
(
:backbone
)
}
end
render
json:
like_service
.
find_for_post
(
params
[
:post_id
])
.
includes
(
author: :profile
)
.
as_api_response
(
:backbone
)
end
private
...
...
app/views/likes/_likes.haml
deleted
100644 → 0
View file @
2772cb6e
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-
@people
[
0
..
17
].
each
do
|
person
|
=
person_image_link
(
person
,
size: :thumb_small
)
app/views/likes/index.html.haml
deleted
100644 → 0
View file @
2772cb6e
=
render
'likes'
,
:likes
=>
@likes
spec/controllers/likes_controller_spec.rb
View file @
e74b524e
...
...
@@ -87,12 +87,12 @@ describe LikesController, type: :controller do
it
"returns an array of likes for a post"
do
bob
.
like!
(
@message
)
get
:index
,
post_id:
@message
.
id
expect
(
assigns
[
:likes
].
map
(
&
:id
)).
to
eq
(
@message
.
likes
.
map
(
&
:id
))
expect
(
JSON
.
parse
(
response
.
body
).
map
{
|
h
|
h
[
"id"
]
}).
to
match_array
(
@message
.
likes
.
map
(
&
:id
))
end
it
"returns an empty array for a post with no likes"
do
get
:index
,
post_id:
@message
.
id
expect
(
assigns
[
:likes
]
).
to
eq
([])
expect
(
JSON
.
parse
(
response
.
body
).
map
(
&
:id
)
).
to
eq
([])
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