mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: quote whole post button was broken
This commit is contained in:
parent
5fda4a613d
commit
dc0a758ec6
2 changed files with 30 additions and 16 deletions
|
@ -181,7 +181,7 @@ class PostSerializer < BasicPostSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_raw?
|
def include_raw?
|
||||||
@add_raw.present? && (scope.user.try(:staff?) || yours)
|
@add_raw.present? && (!object.hidden || scope.user.try(:staff?) || yours)
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_link_counts?
|
def include_link_counts?
|
||||||
|
|
|
@ -77,8 +77,7 @@ describe PostSerializer do
|
||||||
|
|
||||||
context "a hidden post with add_raw enabled" do
|
context "a hidden post with add_raw enabled" do
|
||||||
let(:user) { Fabricate.build(:user) }
|
let(:user) { Fabricate.build(:user) }
|
||||||
let(:raw) { "Offensive stuff here!" }
|
let(:raw) { "Raw contents of the post." }
|
||||||
let(:post) { Fabricate.build(:post, raw: raw, user: user, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached]) }
|
|
||||||
|
|
||||||
def serialized_post_for_user(u)
|
def serialized_post_for_user(u)
|
||||||
s = PostSerializer.new(post, scope: Guardian.new(u), root: false)
|
s = PostSerializer.new(post, scope: Guardian.new(u), root: false)
|
||||||
|
@ -86,6 +85,21 @@ describe PostSerializer do
|
||||||
s.as_json
|
s.as_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "a public post" do
|
||||||
|
let(:post) { Fabricate.build(:post, raw: raw, user: user) }
|
||||||
|
|
||||||
|
it "includes the raw post for everyone" do
|
||||||
|
serialized_post_for_user(user)[:raw].should == raw
|
||||||
|
serialized_post_for_user(nil)[:raw].should == raw
|
||||||
|
serialized_post_for_user(Fabricate(:user))[:raw].should == raw
|
||||||
|
serialized_post_for_user(Fabricate(:moderator))[:raw].should == raw
|
||||||
|
serialized_post_for_user(Fabricate(:admin))[:raw].should == raw
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "a hidden post" do
|
||||||
|
let(:post) { Fabricate.build(:post, raw: raw, user: user, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached]) }
|
||||||
|
|
||||||
it "shows the raw post only if authorized to see it" do
|
it "shows the raw post only if authorized to see it" do
|
||||||
serialized_post_for_user(user)[:raw].should == raw
|
serialized_post_for_user(user)[:raw].should == raw
|
||||||
serialized_post_for_user(nil)[:raw].should be_nil
|
serialized_post_for_user(nil)[:raw].should be_nil
|
||||||
|
@ -101,7 +115,7 @@ describe PostSerializer do
|
||||||
serialized_post_for_user(Fabricate(:moderator))[:can_view_edit_history].should == true
|
serialized_post_for_user(Fabricate(:moderator))[:can_view_edit_history].should == true
|
||||||
serialized_post_for_user(Fabricate(:admin))[:can_view_edit_history].should == true
|
serialized_post_for_user(Fabricate(:admin))[:can_view_edit_history].should == true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue