Allow to load likes and reshares without login
This commit is contained in:
parent
d130697ce2
commit
350e24863f
4 changed files with 18 additions and 3 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class LikesController < ApplicationController
|
||||
include ApplicationHelper
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_user!, except: :index
|
||||
|
||||
respond_to :html,
|
||||
:mobile,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class ResharesController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_user!, except: :index
|
||||
respond_to :json
|
||||
|
||||
def create
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue