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
350e2486
Unverified
Commit
350e2486
authored
Aug 27, 2017
by
Benjamin Neff
Committed by
Steffen van Bergerem
Aug 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to load likes and reshares without login
parent
d130697c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
3 deletions
+18
-3
app/controllers/likes_controller.rb
app/controllers/likes_controller.rb
+1
-1
app/controllers/reshares_controller.rb
app/controllers/reshares_controller.rb
+1
-1
spec/controllers/likes_controller_spec.rb
spec/controllers/likes_controller_spec.rb
+9
-1
spec/controllers/reshares_controller_spec.rb
spec/controllers/reshares_controller_spec.rb
+7
-0
No files found.
app/controllers/likes_controller.rb
View file @
350e2486
...
...
@@ -4,7 +4,7 @@
class
LikesController
<
ApplicationController
include
ApplicationHelper
before_action
:authenticate_user!
before_action
:authenticate_user!
,
except: :index
respond_to
:html
,
:mobile
,
...
...
app/controllers/reshares_controller.rb
View file @
350e2486
class
ResharesController
<
ApplicationController
before_action
:authenticate_user!
before_action
:authenticate_user!
,
except: :index
respond_to
:json
def
create
...
...
spec/controllers/likes_controller_spec.rb
View file @
350e2486
...
...
@@ -91,7 +91,15 @@ describe LikesController, type: :controller do
it
"returns an empty array for a post with no likes"
do
get
:index
,
params:
{
post_id:
@message
.
id
}
expect
(
JSON
.
parse
(
response
.
body
).
map
(
&
:id
)).
to
eq
([])
expect
(
JSON
.
parse
(
response
.
body
)).
to
eq
([])
end
it
"returns likes for a public post without login"
do
post
=
alice
.
post
(
:status_message
,
text:
"hey"
,
public:
true
)
bob
.
like!
(
post
)
sign_out
:user
get
:index
,
params:
{
post_id:
post
.
id
},
format: :json
expect
(
JSON
.
parse
(
response
.
body
).
map
{
|
h
|
h
[
"id"
]
}).
to
match_array
(
post
.
likes
.
map
(
&
:id
))
end
end
...
...
spec/controllers/reshares_controller_spec.rb
View file @
350e2486
...
...
@@ -101,6 +101,13 @@ describe ResharesController, :type => :controller do
get
:index
,
params:
{
post_id:
@post
.
id
},
format: :json
expect
(
JSON
.
parse
(
response
.
body
)).
to
eq
([])
end
it
"returns reshares without login"
do
bob
.
reshare!
(
@post
)
sign_out
:user
get
:index
,
params:
{
post_id:
@post
.
id
},
format: :json
expect
(
JSON
.
parse
(
response
.
body
).
map
{
|
h
|
h
[
"id"
]
}).
to
match_array
(
@post
.
reshares
.
map
(
&
:id
))
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