mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Select +Replies for bulk operations
This commit is contained in:
@@ -163,10 +163,10 @@ describe PostsController do
|
||||
|
||||
let!(:poster) { log_in(:moderator) }
|
||||
let!(:post1) { Fabricate(:post, user: poster, post_number: 2) }
|
||||
let!(:post2) { Fabricate(:post, topic_id: post1.topic_id, user: poster, post_number: 3) }
|
||||
let!(:post2) { Fabricate(:post, topic_id: post1.topic_id, user: poster, post_number: 3, reply_to_post_number: post1.post_number) }
|
||||
|
||||
it "raises invalid parameters no post_ids" do
|
||||
lambda { xhr :delete, :destroy_many }.should raise_error(ActionController::ParameterMissing)
|
||||
lambda { xhr :delete, :destroy_many }.should raise_error(ActionController::ParameterMissing)
|
||||
end
|
||||
|
||||
it "raises invalid parameters with missing ids" do
|
||||
@@ -189,6 +189,19 @@ describe PostsController do
|
||||
xhr :delete, :destroy_many, post_ids: [post1.id, post2.id]
|
||||
end
|
||||
|
||||
describe "can delete replies" do
|
||||
|
||||
before do
|
||||
PostReply.create(post_id: post1.id, reply_id: post2.id)
|
||||
end
|
||||
|
||||
it "deletes the post and the reply to it" do
|
||||
Post.any_instance.expects(:destroy).twice
|
||||
xhr :delete, :destroy_many, post_ids: [post1.id], reply_post_ids: [post1.id]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -93,6 +93,27 @@ describe TopicsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "moving replied posts" do
|
||||
let!(:user) { log_in(:moderator) }
|
||||
let!(:p1) { Fabricate(:post, user: user) }
|
||||
let!(:topic) { p1.topic }
|
||||
let!(:p2) { Fabricate(:post, topic: topic, user: user, reply_to_post_number: p1.post_number ) }
|
||||
|
||||
context 'success' do
|
||||
|
||||
before do
|
||||
PostReply.create(post_id: p1.id, reply_id: p2.id)
|
||||
end
|
||||
|
||||
it "moves the child posts too" do
|
||||
Topic.any_instance.expects(:move_posts).with(user, [p1.id, p2.id], title: 'blah').returns(topic)
|
||||
xhr :post, :move_posts, topic_id: topic.id, title: 'blah', post_ids: [p1.id], reply_post_ids: [p1.id]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe 'moving to an existing topic' do
|
||||
let!(:user) { log_in(:moderator) }
|
||||
let(:p1) { Fabricate(:post, user: user) }
|
||||
|
||||
Reference in New Issue
Block a user