Merge branch 'next-minor' into develop
This commit is contained in:
commit
f9029dbdaf
7 changed files with 44 additions and 4 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
* Fix mixed username and timestamp with LTR/RTL scripts [#7575](https://github.com/diaspora/diaspora/pull/7575)
|
* Fix mixed username and timestamp with LTR/RTL scripts [#7575](https://github.com/diaspora/diaspora/pull/7575)
|
||||||
* Prevent users from zooming in IE Mobile [#7589](https://github.com/diaspora/diaspora/pull/7589)
|
* Prevent users from zooming in IE Mobile [#7589](https://github.com/diaspora/diaspora/pull/7589)
|
||||||
* Fix recipient prefill on contacts and profile page [#7599](https://github.com/diaspora/diaspora/pull/7599)
|
* Fix recipient prefill on contacts and profile page [#7599](https://github.com/diaspora/diaspora/pull/7599)
|
||||||
|
* Display likes and reshares without login [#7583](https://github.com/diaspora/diaspora/pull/7583)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ class CommentsController < ApplicationController
|
||||||
head :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from Diaspora::NonPublic do
|
||||||
|
authenticate_user!
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
begin
|
begin
|
||||||
comment = comment_service.create(params[:post_id], params[:text])
|
comment = comment_service.create(params[:post_id], params[:text])
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@
|
||||||
|
|
||||||
class LikesController < ApplicationController
|
class LikesController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!, except: :index
|
||||||
|
|
||||||
respond_to :html,
|
respond_to :html,
|
||||||
:mobile,
|
:mobile,
|
||||||
:json
|
:json
|
||||||
|
|
||||||
|
rescue_from Diaspora::NonPublic do
|
||||||
|
authenticate_user!
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
like = like_service.create(params[:post_id])
|
like = like_service.create(params[:post_id])
|
||||||
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class ResharesController < ApplicationController
|
class ResharesController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!, except: :index
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
describe CommentsController, :type => :controller do
|
describe CommentsController, :type => :controller do
|
||||||
before do
|
before do
|
||||||
allow(@controller).to receive(:current_user).and_return(alice)
|
|
||||||
sign_in alice, scope: :user
|
sign_in alice, scope: :user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -62,6 +61,7 @@ describe CommentsController, :type => :controller do
|
||||||
aspect_to_post = eve.aspects.where(:name => "generic").first
|
aspect_to_post = eve.aspects.where(:name => "generic").first
|
||||||
@post = eve.post :status_message, :text => 'GIANTS', :to => aspect_to_post
|
@post = eve.post :status_message, :text => 'GIANTS', :to => aspect_to_post
|
||||||
|
|
||||||
|
allow(@controller).to receive(:current_user).and_return(alice)
|
||||||
expect(alice).not_to receive(:comment)
|
expect(alice).not_to receive(:comment)
|
||||||
post :create, params: comment_hash
|
post :create, params: comment_hash
|
||||||
expect(response.code).to eq("404")
|
expect(response.code).to eq("404")
|
||||||
|
|
@ -102,6 +102,7 @@ describe CommentsController, :type => :controller do
|
||||||
it "lets the user delete their comment" do
|
it "lets the user delete their comment" do
|
||||||
comment = alice.comment!(@message, "hey")
|
comment = alice.comment!(@message, "hey")
|
||||||
|
|
||||||
|
allow(@controller).to receive(:current_user).and_return(alice)
|
||||||
expect(alice).to receive(:retract).with(comment)
|
expect(alice).to receive(:retract).with(comment)
|
||||||
delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
|
delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
|
||||||
expect(response.status).to eq(204)
|
expect(response.status).to eq(204)
|
||||||
|
|
@ -111,6 +112,7 @@ describe CommentsController, :type => :controller do
|
||||||
comment1 = bob.comment!(@message, "hey")
|
comment1 = bob.comment!(@message, "hey")
|
||||||
comment2 = eve.comment!(@message, "hey")
|
comment2 = eve.comment!(@message, "hey")
|
||||||
|
|
||||||
|
allow(@controller).to receive(:current_user).and_return(alice)
|
||||||
expect(alice).not_to receive(:retract).with(comment1)
|
expect(alice).not_to receive(:retract).with(comment1)
|
||||||
delete :destroy, params: {post_id: 1, id: comment2.id}, format: :js
|
delete :destroy, params: {post_id: 1, id: comment2.id}, format: :js
|
||||||
expect(response.status).to eq(403)
|
expect(response.status).to eq(403)
|
||||||
|
|
@ -154,5 +156,12 @@ describe CommentsController, :type => :controller do
|
||||||
get :index, params: {post_id: message.id}, format: :json
|
get :index, params: {post_id: message.id}, format: :json
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns a 401 for a private post when logged out" do
|
||||||
|
bob.comment!(@message, "hey")
|
||||||
|
sign_out :user
|
||||||
|
get :index, params: {post_id: @message.id}, format: :json
|
||||||
|
expect(response.status).to eq(401)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,22 @@ describe LikesController, type: :controller do
|
||||||
|
|
||||||
it "returns an empty array for a post with no likes" do
|
it "returns an empty array for a post with no likes" do
|
||||||
get :index, params: {post_id: @message.id}
|
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
|
||||||
|
|
||||||
|
it "returns a 401 for a private post when logged out" do
|
||||||
|
bob.like!(@message)
|
||||||
|
sign_out :user
|
||||||
|
get :index, params: {post_id: @message.id}, format: :json
|
||||||
|
expect(response.status).to eq(401)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,13 @@ describe ResharesController, :type => :controller do
|
||||||
get :index, params: {post_id: @post.id}, format: :json
|
get :index, params: {post_id: @post.id}, format: :json
|
||||||
expect(JSON.parse(response.body)).to eq([])
|
expect(JSON.parse(response.body)).to eq([])
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue