FIX: You could set `reply_to_post_number` when replying as a new topic
This commit is contained in:
parent
9f89aefdd3
commit
79beb9f409
|
@ -431,6 +431,8 @@ const Composer = RestModel.extend({
|
||||||
if (!this.get('topic')) {
|
if (!this.get('topic')) {
|
||||||
this.set('topic', opts.post.get('topic'));
|
this.set('topic', opts.post.get('topic'));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.set('post', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
|
|
|
@ -56,6 +56,8 @@ class PostCreator
|
||||||
@opts = opts || {}
|
@opts = opts || {}
|
||||||
opts[:title] = pg_clean_up(opts[:title]) if opts[:title] && opts[:title].include?("\u0000")
|
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[: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
|
@spam = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,27 +38,29 @@ describe PostCreator do
|
||||||
expect { creator.create }.to raise_error(Discourse::InvalidAccess)
|
expect { creator.create }.to raise_error(Discourse::InvalidAccess)
|
||||||
end
|
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
|
context "invalid title" do
|
||||||
|
|
||||||
let(:creator_invalid_title) { PostCreator.new(user, basic_topic_params.merge(title: 'a')) }
|
let(:creator_invalid_title) { PostCreator.new(user, basic_topic_params.merge(title: 'a')) }
|
||||||
|
|
||||||
it "has errors" do
|
it "has errors" do
|
||||||
creator_invalid_title.create
|
creator_invalid_title.create
|
||||||
expect(creator_invalid_title.errors).to be_present
|
expect(creator_invalid_title.errors).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "invalid raw" do
|
context "invalid raw" do
|
||||||
|
|
||||||
let(:creator_invalid_raw) { PostCreator.new(user, basic_topic_params.merge(raw: '')) }
|
let(:creator_invalid_raw) { PostCreator.new(user, basic_topic_params.merge(raw: '')) }
|
||||||
|
|
||||||
it "has errors" do
|
it "has errors" do
|
||||||
creator_invalid_raw.create
|
creator_invalid_raw.create
|
||||||
expect(creator_invalid_raw.errors).to be_present
|
expect(creator_invalid_raw.errors).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "success" do
|
context "success" do
|
||||||
|
|
|
@ -618,7 +618,7 @@ describe PostsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "passes reply_to_post_number through" do
|
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')
|
expect(assigns(:manager_params)['reply_to_post_number']).to eq('6789')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ describe PostsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ensures regular user cannot see the revisions" do
|
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
|
xhr :get, :revisions, post_id: post_revision.post_id, revision: post_revision.number
|
||||||
expect(response).to be_forbidden
|
expect(response).to be_forbidden
|
||||||
end
|
end
|
||||||
|
@ -831,7 +831,7 @@ describe PostsController do
|
||||||
it "doesn't return secured categories for moderators if they don't have access" do
|
it "doesn't return secured categories for moderators if they don't have access" do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
admin = Fabricate(:admin)
|
admin = Fabricate(:admin)
|
||||||
moderator = Fabricate(:moderator)
|
Fabricate(:moderator)
|
||||||
|
|
||||||
group = Fabricate(:group)
|
group = Fabricate(:group)
|
||||||
group.add(user)
|
group.add(user)
|
||||||
|
@ -852,7 +852,7 @@ describe PostsController do
|
||||||
it "doesn't return PMs for moderators" do
|
it "doesn't return PMs for moderators" do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
admin = Fabricate(:admin)
|
admin = Fabricate(:admin)
|
||||||
moderator = Fabricate(:moderator)
|
Fabricate(:moderator)
|
||||||
|
|
||||||
pm_post = create_post(user: user, archetype: 'private_message', target_usernames: [admin.username])
|
pm_post = create_post(user: user, archetype: 'private_message', target_usernames: [admin.username])
|
||||||
PostDestroyer.new(admin, pm_post).destroy
|
PostDestroyer.new(admin, pm_post).destroy
|
||||||
|
@ -869,7 +869,7 @@ describe PostsController do
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
admin = Fabricate(:admin)
|
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_user = create_post(user: user)
|
||||||
post_deleted_by_admin = create_post(user: user)
|
post_deleted_by_admin = create_post(user: user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue