mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: You could set reply_to_post_number
when replying as a new topic
This commit is contained in:
parent
9f89aefdd3
commit
79beb9f409
4 changed files with 15 additions and 9 deletions
|
@ -431,6 +431,8 @@ const Composer = RestModel.extend({
|
|||
if (!this.get('topic')) {
|
||||
this.set('topic', opts.post.get('topic'));
|
||||
}
|
||||
} else {
|
||||
this.set('post', null);
|
||||
}
|
||||
|
||||
this.setProperties({
|
||||
|
|
|
@ -56,6 +56,8 @@ class PostCreator
|
|||
@opts = opts || {}
|
||||
opts[:title] = pg_clean_up(opts[:title]) if opts[:title] && opts[:title].include?("\u0000")
|
||||
opts[:raw] = pg_clean_up(opts[:raw]) if opts[:raw] && opts[:raw].include?("\u0000")
|
||||
opts.delete(:reply_to_post_number) unless opts[:topic_id]
|
||||
|
||||
@spam = false
|
||||
end
|
||||
|
||||
|
|
|
@ -38,27 +38,29 @@ describe PostCreator do
|
|||
expect { creator.create }.to raise_error(Discourse::InvalidAccess)
|
||||
end
|
||||
|
||||
context "reply to post number" do
|
||||
it "omits reply to post number if received on a new topic" do
|
||||
p = PostCreator.new(user, basic_topic_params.merge(reply_to_post_number: 3)).create
|
||||
expect(p.reply_to_post_number).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "invalid title" do
|
||||
|
||||
let(:creator_invalid_title) { PostCreator.new(user, basic_topic_params.merge(title: 'a')) }
|
||||
|
||||
it "has errors" do
|
||||
creator_invalid_title.create
|
||||
expect(creator_invalid_title.errors).to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "invalid raw" do
|
||||
|
||||
let(:creator_invalid_raw) { PostCreator.new(user, basic_topic_params.merge(raw: '')) }
|
||||
|
||||
it "has errors" do
|
||||
creator_invalid_raw.create
|
||||
expect(creator_invalid_raw.errors).to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "success" do
|
||||
|
|
|
@ -618,7 +618,7 @@ describe PostsController do
|
|||
end
|
||||
|
||||
it "passes reply_to_post_number through" do
|
||||
xhr :post, :create, {raw: 'hello', reply_to_post_number: 6789}
|
||||
xhr :post, :create, {raw: 'hello', reply_to_post_number: 6789, topic_id: 1234}
|
||||
expect(assigns(:manager_params)['reply_to_post_number']).to eq('6789')
|
||||
end
|
||||
|
||||
|
@ -678,7 +678,7 @@ describe PostsController do
|
|||
end
|
||||
|
||||
it "ensures regular user cannot see the revisions" do
|
||||
u = log_in(:user)
|
||||
log_in(:user)
|
||||
xhr :get, :revisions, post_id: post_revision.post_id, revision: post_revision.number
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
@ -831,7 +831,7 @@ describe PostsController do
|
|||
it "doesn't return secured categories for moderators if they don't have access" do
|
||||
user = Fabricate(:user)
|
||||
admin = Fabricate(:admin)
|
||||
moderator = Fabricate(:moderator)
|
||||
Fabricate(:moderator)
|
||||
|
||||
group = Fabricate(:group)
|
||||
group.add(user)
|
||||
|
@ -852,7 +852,7 @@ describe PostsController do
|
|||
it "doesn't return PMs for moderators" do
|
||||
user = Fabricate(:user)
|
||||
admin = Fabricate(:admin)
|
||||
moderator = Fabricate(:moderator)
|
||||
Fabricate(:moderator)
|
||||
|
||||
pm_post = create_post(user: user, archetype: 'private_message', target_usernames: [admin.username])
|
||||
PostDestroyer.new(admin, pm_post).destroy
|
||||
|
@ -869,7 +869,7 @@ describe PostsController do
|
|||
user = Fabricate(:user)
|
||||
admin = Fabricate(:admin)
|
||||
|
||||
post_not_deleted = create_post(user: user)
|
||||
create_post(user: user)
|
||||
post_deleted_by_user = create_post(user: user)
|
||||
post_deleted_by_admin = create_post(user: user)
|
||||
|
||||
|
|
Loading…
Reference in a new issue