mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 04:58:09 +08:00
FIX: allow destination categories to be set if not at first
This commit is contained in:
@ -465,31 +465,40 @@ RSpec.describe TopicsController do
|
||||
end
|
||||
|
||||
describe "#update_shared_draft" do
|
||||
let(:category) { Fabricate(:category) }
|
||||
let(:other_cat) { Fabricate(:category) }
|
||||
let(:category) { Fabricate(:category) }
|
||||
let(:topic) { Fabricate(:topic, category: shared_drafts_category, visible: false) }
|
||||
let!(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: category) }
|
||||
let(:moderator) { Fabricate(:moderator) }
|
||||
|
||||
context "anonymous" do
|
||||
it "doesn't allow staff to update the shared draft" do
|
||||
put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id }
|
||||
expect(response.code.to_i).to eq(403)
|
||||
topic.reload
|
||||
expect(topic.shared_draft.category_id).to eq(category.id)
|
||||
end
|
||||
end
|
||||
|
||||
context "as a moderator" do
|
||||
let(:moderator) { Fabricate(:moderator) }
|
||||
before do
|
||||
sign_in(moderator)
|
||||
end
|
||||
|
||||
it "allows staff to update the category id" do
|
||||
put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id }
|
||||
expect(response).to be_success
|
||||
topic.reload
|
||||
expect(topic.shared_draft.category_id).to eq(other_cat.id)
|
||||
context "with a shared draft" do
|
||||
let!(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: category) }
|
||||
it "allows staff to update the category id" do
|
||||
put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id }
|
||||
expect(response).to be_success
|
||||
topic.reload
|
||||
expect(topic.shared_draft.category_id).to eq(other_cat.id)
|
||||
end
|
||||
end
|
||||
|
||||
context "without a shared draft" do
|
||||
it "allows staff to update the category id" do
|
||||
put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id }
|
||||
expect(response).to be_success
|
||||
topic.reload
|
||||
expect(topic.shared_draft.category_id).to eq(other_cat.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user