Skip to content

A platform for community discussion. Free, open, simple.

UX: Downgrade site settings to category custom fields in solved plugin (#38402)

Martin Brennanff83da79bdb8
diff --git a/app/services/categories/types/base.rb b/app/services/categories/types/base.rb
index 2a6e3008b07..90f062d1705 100644
--- a/app/services/categories/types/base.rb
+++ b/app/services/categories/types/base.rb
@@ -212,7 +212,7 @@ module Categories
def configure_custom_fields(category, guardian:, configuration_values: {})
configuration_schema[:category_custom_fields]&.each do |field_name, config|
value = configuration_values.fetch(field_name.to_s, config[:default])
- category.custom_fields[field_name.to_s] = value
+ category.custom_fields[field_name.to_s] = value.to_s
end
category.save_custom_fields
diff --git a/plugins/discourse-solved/app/serializers/concerns/discourse_solved/topic_answer_mixin.rb b/plugins/discourse-solved/app/serializers/concerns/discourse_solved/topic_answer_mixin.rb
index 3eb1d38bc41..f2f73c066c4 100644
--- a/plugins/discourse-solved/app/serializers/concerns/discourse_solved/topic_answer_mixin.rb
+++ b/plugins/discourse-solved/app/serializers/concerns/discourse_solved/topic_answer_mixin.rb
@@ -21,7 +21,7 @@ module DiscourseSolved
end
def include_can_have_answer?
- SiteSetting.solved_enabled && SiteSetting.empty_box_on_unsolved
+ SiteSetting.solved_enabled && object.category&.empty_box_on_unsolved?
end
end
end
diff --git a/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb b/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb
index 378a1028011..9eae1591396 100644
--- a/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb
+++ b/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb
@@ -90,7 +90,7 @@ class DiscourseSolved::AcceptAnswer
end
def should_notify_topic_owner(topic:, guardian:)
- return unless SiteSetting.notify_on_staff_accept_solved
+ return if !topic.category&.notify_on_staff_accept_solved?
return if guardian.user.id == topic.user_id || !User.exists?(topic.user_id)
screener =
UserCommScreener.new(acting_user_id: guardian.user.id, target_user_ids: topic.user_id)
diff --git a/plugins/discourse-solved/app/services/discourse_solved/categories/types/support.rb b/plugins/discourse-solved/app/services/discourse_solved/categories/types/support.rb
index 5a9027c9b5c..45d75ab3a32 100644
--- a/plugins/discourse-solved/app/services/discourse_solved/categories/types/support.rb
+++ b/plugins/discourse-solved/app/services/discourse_solved/categories/types/support.rb
@@ -12,7 +12,7 @@ module DiscourseSolved
end
def category_matches?(category)
- category.custom_fields[DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD] == "true"
+ category.enable_accepted_answers?
end
def find_matches
@@ -26,6 +26,10 @@ module DiscourseSolved
end
def configure_category(category, guardian:, configuration_values: {})
+ configuration_values.reverse_merge!(
+ DiscourseSolved::NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD => "true",
+ DiscourseSolved::EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD => "true",
+ )
configuration_values.merge!(
DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD => "true",
)
@@ -59,8 +63,6 @@ module DiscourseSolved
},
site_settings: {
show_filter_by_solved_status: true,
- notify_on_staff_accept_solved: true,
- empty_box_on_unsolved: true,
},
category_custom_fields: {
DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD => {
@@ -83,6 +85,17 @@ module DiscourseSolved
"discourse_solved.category_type.solved_topics_auto_close_duration.description",
),
},
+ DiscourseSolved::NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD => {
+ default: true,
+ type: :bool,
+ label:
+ I18n.t("discourse_solved.category_type.notify_on_staff_accept_solved.label"),
+ },
+ DiscourseSolved::EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD => {
+ default: true,
+ type: :bool,
+ label: I18n.t("discourse_solved.category_type.empty_box_on_unsolved.label"),
+ },
},
}
end
diff --git a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs b/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs
index bdc1a68d04a..8b816e20204 100644
--- a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs
+++ b/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs
@@ -24,11 +24,34 @@ export default class SolvedSettingsUpsert extends Component {
return value?.toString() === "true";
}
+ get notifyOnStaffAcceptSolved() {
+ const value =
+ this.args.outletArgs.transientData?.custom_fields
+ ?.notify_on_staff_accept_solved;
+ return value?.toString() !== "false";
+ }
+
+ get emptyBoxOnUnsolved() {
+ const value =
+ this.args.outletArgs.transientData?.custom_fields?.empty_box_on_unsolved;
+ return value?.toString() !== "false";
+ }
+
@action
async onToggleAcceptedAnswers(_, { set, name }) {
await set(name, this.enableAcceptedAnswers ? "false" : "true");
}
+ @action
+ async onToggleNotifyOnStaffAcceptSolved(_, { set, name }) {
+ await set(name, this.notifyOnStaffAcceptSolved ? "false" : "true");
+ }
+
+ @action
+ async onToggleEmptyBoxOnUnsolved(_, { set, name }) {
+ await set(name, this.emptyBoxOnUnsolved ? "false" : "true");
+ }
+
<template>
{{#let @outletArgs.form as |form|}}
<form.Section @title={{i18n "solved.title"}}>
@@ -51,6 +74,24 @@ export default class SolvedSettingsUpsert extends Component {
>
<field.Input @type="number" min="0" />
</customFields.Field>
+
+ <customFields.Field
+ @name="notify_on_staff_accept_solved"
+ @title={{i18n "solved.notify_on_staff_accept_solved"}}
+ @onSet={{this.onToggleNotifyOnStaffAcceptSolved}}
+ as |field|
+ >
+ <field.Checkbox checked={{this.notifyOnStaffAcceptSolved}} />
+ </customFields.Field>
+
+ <customFields.Field
+ @name="empty_box_on_unsolved"
+ @title={{i18n "solved.empty_box_on_unsolved"}}
+ @onSet={{this.onToggleEmptyBoxOnUnsolved}}
+ as |field|
+ >
+ <field.Checkbox checked={{this.emptyBoxOnUnsolved}} />
+ </customFields.Field>
</form.Object>
</form.Section>
{{/let}}
diff --git a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs b/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs
index 9196d31f985..56b1b8f4dab 100644
--- a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs
+++ b/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs
@@ -18,6 +18,16 @@ export default class SolvedSettings extends Component {
this.args.outletArgs.category.custom_fields.enable_accepted_answers ===
"true";
+ @tracked
+ notifyOnStaffAcceptSolved =
+ this.args.outletArgs.category.custom_fields
+ ?.notify_on_staff_accept_solved !== "false";
+
+ @tracked
+ emptyBoxOnUnsolved =
+ this.args.outletArgs.category.custom_fields?.empty_box_on_unsolved !==
+ "false";
+
get customFields() {
return this.args.outletArgs.category.custom_fields;
}
@@ -28,6 +38,18 @@ export default class SolvedSettings extends Component {
this.customFields.enable_accepted_answers = value ? "true" : "false";
}
+ @action
+ onChangeNotifyOnStaffAcceptSolved(value) {
+ this.notifyOnStaffAcceptSolved = value;
+ this.customFields.notify_on_staff_accept_solved = value ? "true" : "false";
+ }
+
+ @action
+ onChangeEmptyBoxOnUnsolved(value) {
+ this.emptyBoxOnUnsolved = value;
+ this.customFields.empty_box_on_unsolved = value ? "true" : "false";
+ }
+
@action
onChangeAutoCloseHours(value) {
this.customFields.solved_topics_auto_close_hours = value;
@@ -67,6 +89,42 @@ export default class SolvedSettings extends Component {
id="auto-close-solved-topics"
/>
</section>
+
+ <section class="field">
+ <div class="notify-on-staff-accept-solved">
+ <label class="checkbox-label">
+ <input
+ {{on
+ "change"
+ (withEventValue
+ this.onChangeNotifyOnStaffAcceptSolved "target.checked"
+ )
+ }}
+ checked={{this.notifyOnStaffAcceptSolved}}
+ type="checkbox"
+ />
+ {{i18n "solved.notify_on_staff_accept_solved"}}
+ </label>
+ </div>
+ </section>
+
+ <section class="field">
+ <div class="empty-box-on-unsolved">
+ <label class="checkbox-label">
+ <input
+ {{on
+ "change"
+ (withEventValue
+ this.onChangeEmptyBoxOnUnsolved "target.checked"
+ )
+ }}
+ checked={{this.emptyBoxOnUnsolved}}
+ type="checkbox"
+ />
+ {{i18n "solved.empty_box_on_unsolved"}}
+ </label>
+ </div>
+ </section>
</div>
</template>
}
diff --git a/plugins/discourse-solved/config/locales/client.en.yml b/plugins/discourse-solved/config/locales/client.en.yml
index 14da644ed2d..ed0721ac513 100644
--- a/plugins/discourse-solved/config/locales/client.en.yml
+++ b/plugins/discourse-solved/config/locales/client.en.yml
@@ -15,6 +15,8 @@ en:
title: "Solved"
allow_accepted_answers: "Allow topic owner and staff to mark a reply as the solution"
solved_topics_auto_close_hours: "Auto close topic (n) hours after the last reply once the topic has been marked as solved."
+ notify_on_staff_accept_solved: "Notify topic creator when staff marks a solution"
+ empty_box_on_unsolved: "Display an empty checkbox next to unsolved topics in the topic list"
accept_answer: "Select if this reply solves the problem"
accepted_description: "This is the accepted solution to this topic"
has_no_accepted_answer: "This topic has no solution"
diff --git a/plugins/discourse-solved/config/locales/server.en.yml b/plugins/discourse-solved/config/locales/server.en.yml
index 363f7fd97c5..9ebe0fcef2b 100644
--- a/plugins/discourse-solved/config/locales/server.en.yml
+++ b/plugins/discourse-solved/config/locales/server.en.yml
@@ -14,6 +14,10 @@ en:
solved_topics_auto_close_hours:
label: "Auto close solved topics (hours)"
description: "Automatically close topic after this many hours once marked as solved. Set to 0 to disable."
+ notify_on_staff_accept_solved:
+ label: "Notify topic creator when staff marks a solution"
+ empty_box_on_unsolved:
+ label: "Display an empty checkbox next to unsolved topics in the topic list"
solved_topics_auto_close_duration:
label: "Auto close solved topics"
description: "Automatically close topic after this duration once marked as solved. Set to 0 to disable."
diff --git a/plugins/discourse-solved/config/settings.yml b/plugins/discourse-solved/config/settings.yml
index c328bdfa821..cdd44f7546d 100644
--- a/plugins/discourse-solved/config/settings.yml
+++ b/plugins/discourse-solved/config/settings.yml
@@ -28,7 +28,7 @@ discourse_solved:
validator: "AtLeastOneGroupValidator"
empty_box_on_unsolved:
default: false
- client: true
+ hidden: true
solved_quote_length:
default: 300
client: false
@@ -41,6 +41,7 @@ discourse_solved:
client: true
notify_on_staff_accept_solved:
default: false
+ hidden: true
disable_solved_education_message:
default: false
accept_solutions_topic_author:
diff --git a/plugins/discourse-solved/db/migrate/20260310120000_populate_solved_category_custom_fields_from_site_settings.rb b/plugins/discourse-solved/db/migrate/20260310120000_populate_solved_category_custom_fields_from_site_settings.rb
new file mode 100644
index 00000000000..b707d8ddf13
--- /dev/null
+++ b/plugins/discourse-solved/db/migrate/20260310120000_populate_solved_category_custom_fields_from_site_settings.rb
@@ -0,0 +1,64 @@
+# frozen_string_literal: true
+
+class PopulateSolvedCategoryCustomFieldsFromSiteSettings < ActiveRecord::Migration[7.2]
+ def up
+ notify_value =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'notify_on_staff_accept_solved'",
+ ).first
+
+ notify_value = (notify_value == "t").to_s
+
+ empty_box_value =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'empty_box_on_unsolved'").first
+
+ empty_box_value = (empty_box_value == "t").to_s
+
+ allow_solved_on_all =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'allow_solved_on_all_topics'",
+ ).first
+
+ # When allow_solved_on_all_topics is enabled, every category can have solved topics,
+ # so populate custom fields for all categories. Otherwise only populate for categories
+ # that have enable_accepted_answers set.
+ category_ids_sql =
+ if allow_solved_on_all == "t"
+ "SELECT id AS category_id FROM categories"
+ else
+ <<~SQL
+ SELECT category_id FROM category_custom_fields
+ WHERE name = 'enable_accepted_answers' AND value = 'true'
+ SQL
+ end
+
+ DB.exec(<<~SQL, notify_value:)
+ INSERT INTO category_custom_fields (category_id, name, value, created_at, updated_at)
+ SELECT solved_cats.category_id, 'notify_on_staff_accept_solved', :notify_value, NOW(), NOW()
+ FROM (#{category_ids_sql}) solved_cats
+ WHERE NOT EXISTS (
+ SELECT 1 FROM category_custom_fields existing
+ WHERE existing.category_id = solved_cats.category_id
+ AND existing.name = 'notify_on_staff_accept_solved'
+ )
+ SQL
+
+ DB.exec(<<~SQL, empty_box_value:)
+ INSERT INTO category_custom_fields (category_id, name, value, created_at, updated_at)
+ SELECT solved_cats.category_id, 'empty_box_on_unsolved', :empty_box_value, NOW(), NOW()
+ FROM (#{category_ids_sql}) solved_cats
+ WHERE NOT EXISTS (
+ SELECT 1 FROM category_custom_fields existing
+ WHERE existing.category_id = solved_cats.category_id
+ AND existing.name = 'empty_box_on_unsolved'
+ )
+ SQL
+ end
+
+ def down
+ execute <<~SQL
+ DELETE FROM category_custom_fields
+ WHERE name IN ('notify_on_staff_accept_solved', 'empty_box_on_unsolved')
+ SQL
+ end
+end
diff --git a/plugins/discourse-solved/lib/discourse_solved/category_extension.rb b/plugins/discourse-solved/lib/discourse_solved/category_extension.rb
index 1921d5196e1..f3cd07d22e8 100644
--- a/plugins/discourse-solved/lib/discourse_solved/category_extension.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/category_extension.rb
@@ -10,8 +10,41 @@ module DiscourseSolved::CategoryExtension
[hours, DiscourseSolved::MAX_AUTO_CLOSE_HOURS].min
end
+ def enable_accepted_answers?
+ custom_fields[DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD] == "true"
+ end
+
+ def enable_accepted_answers=(value)
+ custom_fields[DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD] = coerce_boolean_value(
+ value,
+ )
+ end
+
+ def notify_on_staff_accept_solved?
+ custom_fields[DiscourseSolved::NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD] == "true"
+ end
+
+ def notify_on_staff_accept_solved=(value)
+ custom_fields[
+ DiscourseSolved::NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD
+ ] = coerce_boolean_value(value)
+ end
+
+ def empty_box_on_unsolved?
+ custom_fields[DiscourseSolved::EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD] == "true"
+ end
+
+ def empty_box_on_unsolved=(value)
+ custom_fields[DiscourseSolved::EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD] = coerce_boolean_value(value)
+ end
+
private
+ def coerce_boolean_value(value)
+ return "false" if value.blank?
+ %w[true false].include?(value.to_s) ? value.to_s : "false"
+ end
+
def reset_accepted_cache
DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache
end
diff --git a/plugins/discourse-solved/plugin.rb b/plugins/discourse-solved/plugin.rb
index 04331def5ba..c41474a241d 100644
--- a/plugins/discourse-solved/plugin.rb
+++ b/plugins/discourse-solved/plugin.rb
@@ -19,6 +19,8 @@ register_asset "stylesheets/mobile/solutions.scss", :mobile
module ::DiscourseSolved
PLUGIN_NAME = "discourse-solved"
ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD = "enable_accepted_answers"
+ NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD = "notify_on_staff_accept_solved"
+ EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD = "empty_box_on_unsolved"
MAX_AUTO_CLOSE_HOURS = 20.years.to_i / 1.hour.to_i
def self.accept_answer!(post, acting_user, topic: nil)
@@ -66,6 +68,8 @@ after_initialize do
register_topic_preloader_associations(:solved) if SiteSetting.solved_enabled
Search.custom_topic_eager_load { [:solved] } if SiteSetting.solved_enabled
Site.preloaded_category_custom_fields << DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD
+ Site.preloaded_category_custom_fields << DiscourseSolved::NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD
+ Site.preloaded_category_custom_fields << DiscourseSolved::EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD
add_api_key_scope(
:solved,
diff --git a/plugins/discourse-solved/spec/integration/solved_spec.rb b/plugins/discourse-solved/spec/integration/solved_spec.rb
index 0d208ce172b..a807742b0b9 100644
--- a/plugins/discourse-solved/spec/integration/solved_spec.rb
+++ b/plugins/discourse-solved/spec/integration/solved_spec.rb
@@ -300,9 +300,10 @@ RSpec.describe "Managing Posts solved status" do
end
it "sends notifications to correct users" do
- SiteSetting.notify_on_staff_accept_solved = true
user = Fabricate(:user)
topic = Fabricate(:topic, user: user)
+ topic.category.notify_on_staff_accept_solved = true
+ topic.category.save_custom_fields
post = Fabricate(:post, post_number: 2, topic: topic)
op = topic.user
@@ -332,13 +333,12 @@ RSpec.describe "Managing Posts solved status" do
fab!(:solution_accepter) { Fabricate(:user, trust_level: 4) }
fab!(:author, :user)
- before do
- SiteSetting.notify_on_staff_accept_solved = true
- MutedUser.create!(user_id: author.id, muted_user_id: solution_accepter.id)
- end
+ before { MutedUser.create!(user_id: author.id, muted_user_id: solution_accepter.id) }
it "does not send notification to post author" do
topic = Fabricate(:topic, user: Fabricate(:user))
+ topic.category.notify_on_staff_accept_solved = true
+ topic.category.save_custom_fields
post = Fabricate(:post, post_number: 2, topic: topic, user: author)
expect {
@@ -353,6 +353,8 @@ RSpec.describe "Managing Posts solved status" do
it "does not send notification to topic author" do
topic = Fabricate(:topic, user: author)
+ topic.category.notify_on_staff_accept_solved = true
+ topic.category.save_custom_fields
post = Fabricate(:post, post_number: 2, topic: topic, user: Fabricate(:user))
expect {
@@ -378,7 +380,8 @@ RSpec.describe "Managing Posts solved status" do
end
it "works when the topic author has been deleted" do
- SiteSetting.notify_on_staff_accept_solved = true
+ topic.category.notify_on_staff_accept_solved = true
+ topic.category.save_custom_fields
SiteSetting.solved_topics_auto_close_hours = 0
topic.user.destroy!
topic.reload
diff --git a/plugins/discourse-solved/spec/models/discourse_solved/categories_types_support_spec.rb b/plugins/discourse-solved/spec/models/discourse_solved/categories_types_support_spec.rb
index 2fd1a4c1b42..83ac32f5116 100644
--- a/plugins/discourse-solved/spec/models/discourse_solved/categories_types_support_spec.rb
+++ b/plugins/discourse-solved/spec/models/discourse_solved/categories_types_support_spec.rb
@@ -26,8 +26,6 @@ RSpec.describe DiscourseSolved::Categories::Types::Support do
described_class.configure_site_settings(category, guardian: admin.guardian)
expect(SiteSetting.show_filter_by_solved_status).to eq(true)
- expect(SiteSetting.notify_on_staff_accept_solved).to eq(true)
- expect(SiteSetting.empty_box_on_unsolved).to eq(true)
end
it "uses provided configuration_values over defaults" do
@@ -36,13 +34,10 @@ RSpec.describe DiscourseSolved::Categories::Types::Support do
guardian: admin.guardian,
configuration_values: {
"show_filter_by_solved_status" => false,
- "empty_box_on_unsolved" => false,
},
)
expect(SiteSetting.show_filter_by_solved_status).to eq(false)
- expect(SiteSetting.notify_on_staff_accept_solved).to eq(true)
- expect(SiteSetting.empty_box_on_unsolved).to eq(false)
end
end
@@ -87,6 +82,22 @@ RSpec.describe DiscourseSolved::Categories::Types::Support do
expect(category.custom_fields["solved_topics_auto_close_hours"]).to eq("72")
end
+
+ it "sets notify_on_staff_accept_solved custom field" do
+ described_class.configure_category(category, guardian: admin.guardian)
+
+ expect(
+ category.custom_fields[DiscourseSolved::NOTIFY_ON_STAFF_ACCEPT_SOLVED_CUSTOM_FIELD],
+ ).to eq("true")
+ end
+
+ it "sets empty_box_on_unsolved custom field" do
+ described_class.configure_category(category, guardian: admin.guardian)
+
+ expect(category.custom_fields[DiscourseSolved::EMPTY_BOX_ON_UNSOLVED_CUSTOM_FIELD]).to eq(
+ "true",
+ )
+ end
end
describe ".find_matches" do
diff --git a/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb b/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb
index eb0be5789c8..0756e26d8a5 100644
--- a/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb
+++ b/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe DiscourseSolved::AcceptAnswer do
- describe described_class::Contract, type: :model do
+ describe ::DiscourseSolved::AcceptAnswer::Contract, type: :model do
it { is_expected.to validate_presence_of(:post_id) }
end
@@ -135,7 +135,10 @@ RSpec.describe DiscourseSolved::AcceptAnswer do
end
context "when notify_on_staff_accept_solved is enabled" do
- before { SiteSetting.notify_on_staff_accept_solved = true }
+ before do
+ category.notify_on_staff_accept_solved = true
+ category.save_custom_fields
+ end
context "when a staff member accepts on behalf of the topic owner" do
fab!(:acting_user, :admin)
@@ -163,7 +166,10 @@ RSpec.describe DiscourseSolved::AcceptAnswer do
end
context "when notify_on_staff_accept_solved is disabled" do
- before { SiteSetting.notify_on_staff_accept_solved = false }
+ before do
+ category.notify_on_staff_accept_solved = false
+ category.save_custom_fields
+ end
it "does not notify the topic owner" do
expect { result }.not_to change {
diff --git a/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb b/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb
index 91c8a91e098..17418635048 100644
--- a/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb
+++ b/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe DiscourseSolved::UnacceptAnswer do
- describe described_class::Contract, type: :model do
+ describe ::DiscourseSolved::UnacceptAnswer::Contract, type: :model do
it { is_expected.to validate_presence_of(:post_id) }
end
diff --git a/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb b/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb
index 4b8a4d0197f..a08c9d6ce17 100644
--- a/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb
+++ b/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb
@@ -35,11 +35,11 @@ RSpec.describe "Support Category Type Setup", type: :system do
expect(page).to have_content(I18n.t("js.category.edit_dialog_title", categoryName: "Support"))
expect(SiteSetting.solved_enabled).to eq(true)
expect(SiteSetting.show_filter_by_solved_status).to eq(true)
- expect(SiteSetting.notify_on_staff_accept_solved).to eq(true)
- expect(SiteSetting.empty_box_on_unsolved).to eq(true)
category = Category.find_by(name: "Support")
expect(category.custom_fields["enable_accepted_answers"]).to eq("true")
expect(category.custom_fields["solved_topics_auto_close_hours"]).to eq("48")
+ expect(category.custom_fields["notify_on_staff_accept_solved"]).to eq("true")
+ expect(category.custom_fields["empty_box_on_unsolved"]).to eq("true")
end
context "when there is a support category already configured" do