A platform for community discussion. Free, open, simple.
FIX: topic_creator accepts participant_count in import mode (#10632)
Krzysztof Kotlarekd260e42c8a00
diff --git a/lib/topic_creator.rb b/lib/topic_creator.rbindex e9a5ad14ccc..cfac39f6b31 100644--- a/lib/topic_creator.rb+++ b/lib/topic_creator.rb@@ -106,6 +106,10 @@ class TopicCreatortopic_params[:views] = @opts[:views].to_iend+ if topic_params[:import_mode] && @opts[:participant_count].to_i > 0+ topic_params[:participant_count] = @opts[:participant_count].to_i+ end+# Automatically give it a moderator warning subtype if specifiedtopic_params[:subtype] = TopicSubtype.moderator_warning if @opts[:is_warning]diff --git a/spec/components/topic_creator_spec.rb b/spec/components/topic_creator_spec.rbindex 9d7230ece14..ba60863cd12 100644--- a/spec/components/topic_creator_spec.rb+++ b/spec/components/topic_creator_spec.rb@@ -70,6 +70,16 @@ describe TopicCreator doexpect(topic).to be_validexpect(topic.category).to eq(category)end++ it "ignores participant_count without raising an error" do+ topic = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(participant_count: 3))+ expect(topic.participant_count).to eq(1)+ end++ it "accepts participant_count in import mode" do+ topic = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(import_mode: true, participant_count: 3))+ expect(topic.participant_count).to eq(3)+ endendend