Show the entire history of replies above a post when you expend "in reply to"

This commit is contained in:
Robin Ward
2013-08-06 17:42:36 -04:00
parent c74da0d262
commit 1c3804934e
19 changed files with 158 additions and 130 deletions

View File

@@ -13,7 +13,6 @@ describe PostsController do
end
describe 'show' do
let(:user) { log_in }
let(:post) { Fabricate(:post, user: user) }
@@ -52,9 +51,26 @@ describe PostsController do
end
end
end
describe 'reply_history' do
let(:user) { log_in }
let(:post) { Fabricate(:post, user: user) }
it 'ensures the user can see the post' do
Guardian.any_instance.expects(:can_see?).with(post).returns(false)
xhr :get, :reply_history, id: post.id
response.should be_forbidden
end
it 'suceeds' do
Post.any_instance.expects(:reply_history)
xhr :get, :reply_history, id: post.id
response.should be_success
end
end
describe 'versions' do
shared_examples 'posts_controller versions examples' do

View File

@@ -711,7 +711,6 @@ describe Post do
context 'sort_order' do
context 'regular topic' do
let!(:p1) { Fabricate(:post, post_args) }
@@ -722,6 +721,20 @@ describe Post do
Post.regular_order.should == [p1, p2, p3]
end
end
end
context "reply_history" do
let!(:p1) { Fabricate(:post, post_args) }
let!(:p2) { Fabricate(:post, post_args.merge(reply_to_post_number: p1.post_number)) }
let!(:p3) { Fabricate(:post, post_args) }
let!(:p4) { Fabricate(:post, post_args.merge(reply_to_post_number: p2.post_number)) }
it "returns the posts in reply to this post" do
p4.reply_history.should == [p1, p2]
p3.reply_history.should be_blank
p2.reply_history.should == [p1]
end
end