Loading app/controllers/likes_controller.rb +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ class LikesController < ApplicationController include ApplicationHelper before_action :authenticate_user! before_action :authenticate_user!, except: :index respond_to :html, :mobile, Loading app/controllers/reshares_controller.rb +1 −1 Original line number Diff line number Diff line class ResharesController < ApplicationController before_action :authenticate_user! before_action :authenticate_user!, except: :index respond_to :json def create Loading spec/controllers/likes_controller_spec.rb +9 −1 Original line number Diff line number Diff line Loading @@ -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 Loading spec/controllers/reshares_controller_spec.rb +7 −0 Original line number Diff line number Diff line Loading @@ -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
app/controllers/likes_controller.rb +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ class LikesController < ApplicationController include ApplicationHelper before_action :authenticate_user! before_action :authenticate_user!, except: :index respond_to :html, :mobile, Loading
app/controllers/reshares_controller.rb +1 −1 Original line number Diff line number Diff line class ResharesController < ApplicationController before_action :authenticate_user! before_action :authenticate_user!, except: :index respond_to :json def create Loading
spec/controllers/likes_controller_spec.rb +9 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
spec/controllers/reshares_controller_spec.rb +7 −0 Original line number Diff line number Diff line Loading @@ -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