Skip to content

Commit

Permalink
DEV: Update tests based on review feedback
Browse files Browse the repository at this point in the history
change plugin_initializer location

update spec with new tests to test integration with discourse-assign
  • Loading branch information
Grubba27 committed Apr 26, 2024
1 parent 3e0a596 commit 6603d84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion plugin.rb
Expand Up @@ -47,7 +47,7 @@ class Engine < ::Rails::Engine
require_relative "app/lib/web_hook_extension"
require_relative "app/serializers/concerns/topic_answer_mixin"

require_relative "app/lib/plugin_initializer"
require_relative "app/lib/plugin_initializers/assigned_reminder_exclude_solved"
DiscourseSolved::AssignsReminderForTopicsQuery.new(self).apply_plugin_api
module ::DiscourseSolved
def self.accept_answer!(post, acting_user, topic: nil)
Expand Down
33 changes: 14 additions & 19 deletions spec/integration/solved_spec.rb
Expand Up @@ -370,7 +370,6 @@
context "with discourse-assign installed", if: defined?(DiscourseAssign) do
let(:admin) { Fabricate(:admin) }
fab!(:group)

before do
SiteSetting.solved_enabled = true
SiteSetting.assign_enabled = true
Expand All @@ -396,31 +395,27 @@
expect(p1.reload.custom_fields["is_accepted_answer"]).to eq("true")
expect(p1.topic.assignment.reload.status).to eq("Done")
end
end

context "with using assigns_reminder_assigned_topics_query modifier" do
class DummyClass
def test
DiscoursePluginRegistry.apply_modifier(:assigns_reminder_assigned_topics_query, Topic.all)
end
end
it "should not include solved topics in the query" do
other_topic = Fabricate(:topic, title: "Topic that should be there")
post = Fabricate(:post, topic: other_topic, user: user)

before { SiteSetting.ignore_solved_topics_in_assigned_reminder = true }
assigner1 = Assigner.new(p1.topic, user)
result1 = assigner1.assign(user)
expect(result1[:success]).to eq(true)

it "should not include solved topics in the query" do
topic = Fabricate(:topic)
topic2 = Fabricate(:topic)
topic3 = Fabricate(:topic)
post = Fabricate(:post, topic: topic)
assigner2 = Assigner.new(post.topic, user)
result2 = assigner2.assign(user)
expect(result2[:success]).to eq(true)

DiscourseSolved.accept_answer!(post, Discourse.system_user)
DiscourseSolved.accept_answer!(p1, Discourse.system_user)

topics = DummyClass.new.test.to_a
reminder = PendingAssignsReminder.new
reminder.remind(user)
topics = reminder.send(:assigned_topics, user, order: :asc)

expect(topics).not_to include(topic)

expect(topics).to include(topic2)
expect(topics).to include(topic3)
expect(topics).to include(other_topic)
end
end
end

0 comments on commit 6603d84

Please sign in to comment.