Skip to content

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

DEV: Clean up scope resolution operators in plugins (#34979)

Jarek Radosze372355fd088
diff --git a/plugins/automation/app/controllers/discourse_automation/admin_automations_controller.rb b/plugins/automation/app/controllers/discourse_automation/admin_automations_controller.rb
index ac317253edf..c32e60bcd17 100644
--- a/plugins/automation/app/controllers/discourse_automation/admin_automations_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/admin_automations_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class AdminAutomationsController < ::Admin::AdminController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
automations =
diff --git a/plugins/automation/app/controllers/discourse_automation/admin_controller.rb b/plugins/automation/app/controllers/discourse_automation/admin_controller.rb
index aa064b88e59..7e1bd56c283 100644
--- a/plugins/automation/app/controllers/discourse_automation/admin_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/admin_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class AdminController < ::Admin::AdminController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
end
diff --git a/plugins/automation/app/controllers/discourse_automation/admin_scriptables_controller.rb b/plugins/automation/app/controllers/discourse_automation/admin_scriptables_controller.rb
index 5ee3b81ff21..8cac8fe832e 100644
--- a/plugins/automation/app/controllers/discourse_automation/admin_scriptables_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/admin_scriptables_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class AdminScriptablesController < ::Admin::AdminController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
scriptables =
diff --git a/plugins/automation/app/controllers/discourse_automation/admin_triggerables_controller.rb b/plugins/automation/app/controllers/discourse_automation/admin_triggerables_controller.rb
index 3c6be2891e9..4c7c66173bb 100644
--- a/plugins/automation/app/controllers/discourse_automation/admin_triggerables_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/admin_triggerables_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class AdminTriggerablesController < ::Admin::AdminController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
if params[:automation_id].present?
diff --git a/plugins/automation/app/controllers/discourse_automation/append_last_checked_by_controller.rb b/plugins/automation/app/controllers/discourse_automation/append_last_checked_by_controller.rb
index b2c9c727f58..ab35bf7abba 100644
--- a/plugins/automation/app/controllers/discourse_automation/append_last_checked_by_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/append_last_checked_by_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class AppendLastCheckedByController < ApplicationController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
def post_checked
diff --git a/plugins/automation/app/controllers/discourse_automation/automations_controller.rb b/plugins/automation/app/controllers/discourse_automation/automations_controller.rb
index eb0147838e9..b2d85e96846 100644
--- a/plugins/automation/app/controllers/discourse_automation/automations_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/automations_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class AutomationsController < ApplicationController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_admin
def trigger
diff --git a/plugins/automation/app/controllers/discourse_automation/user_global_notices_controller.rb b/plugins/automation/app/controllers/discourse_automation/user_global_notices_controller.rb
index edadec9e4a0..3cdc75e4c8a 100644
--- a/plugins/automation/app/controllers/discourse_automation/user_global_notices_controller.rb
+++ b/plugins/automation/app/controllers/discourse_automation/user_global_notices_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAutomation
class UserGlobalNoticesController < ApplicationController
- requires_plugin DiscourseAutomation::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
def destroy
diff --git a/plugins/automation/app/jobs/regular/discourse_automation/call_zapier_webhook.rb b/plugins/automation/app/jobs/regular/discourse_automation/call_zapier_webhook.rb
index 0e9bc04520d..27d5629960a 100644
--- a/plugins/automation/app/jobs/regular/discourse_automation/call_zapier_webhook.rb
+++ b/plugins/automation/app/jobs/regular/discourse_automation/call_zapier_webhook.rb
@@ -1,24 +1,26 @@
# frozen_string_literal: true
module Jobs
- class DiscourseAutomation::CallZapierWebhook < ::Jobs::Base
- def execute(args)
- RateLimiter.new(nil, "discourse_automation_call_zapier", 5, 30).performed!
+ module DiscourseAutomation
+ class CallZapierWebhook < ::Jobs::Base
+ def execute(args)
+ RateLimiter.new(nil, "discourse_automation_call_zapier", 5, 30).performed!
- result =
- Excon.post(
- args["webhook_url"],
- body: args["context"].to_json,
- headers: {
- "Content-Type" => "application/json",
- "Accept" => "application/json",
- },
- )
+ result =
+ Excon.post(
+ args["webhook_url"],
+ body: args["context"].to_json,
+ headers: {
+ "Content-Type" => "application/json",
+ "Accept" => "application/json",
+ },
+ )
- if result.status != 200
- Rails.logger.warn(
- "Failed to call Zapier webhook at #{args["webhook_url"]} Status: #{result.status}: #{result.status_line}",
- )
+ if result.status != 200
+ Rails.logger.warn(
+ "Failed to call Zapier webhook at #{args["webhook_url"]} Status: #{result.status}: #{result.status_line}",
+ )
+ end
end
end
end
diff --git a/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb b/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb
index 5542963054a..bf19e90312b 100644
--- a/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb
+++ b/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb
@@ -1,32 +1,34 @@
# frozen_string_literal: true
module Jobs
- class DiscourseAutomation::Trigger < ::Jobs::Base
- RETRY_TIMES = [5.minute, 15.minute, 120.minute]
+ module DiscourseAutomation
+ class Trigger < ::Jobs::Base
+ RETRY_TIMES = [5.minute, 15.minute, 120.minute]
- sidekiq_options retry: RETRY_TIMES.size
+ sidekiq_options retry: RETRY_TIMES.size
- sidekiq_retry_in do |count, exception|
- # returning nil/0 will trigger the default sidekiq
- # retry formula
- #
- # See https://github.com/mperham/sidekiq/blob/3330df0ee37cfd3e0cd3ef01e3e66b584b99d488/lib/sidekiq/job_retry.rb#L216-L234
- case exception.wrapped
- when SocketError
- return RETRY_TIMES[count]
+ sidekiq_retry_in do |count, exception|
+ # returning nil/0 will trigger the default sidekiq
+ # retry formula
+ #
+ # See https://github.com/mperham/sidekiq/blob/3330df0ee37cfd3e0cd3ef01e3e66b584b99d488/lib/sidekiq/job_retry.rb#L216-L234
+ case exception.wrapped
+ when SocketError
+ return RETRY_TIMES[count]
+ end
end
- end
- def execute(args)
- automation =
- ::DiscourseAutomation::Automation.find_by(id: args[:automation_id], enabled: true)
+ def execute(args)
+ automation =
+ ::DiscourseAutomation::Automation.find_by(id: args[:automation_id], enabled: true)
- return if !automation
+ return if !automation
- context = ::DiscourseAutomation::Automation.deserialize_context(args[:context])
+ context = ::DiscourseAutomation::Automation.deserialize_context(args[:context])
- automation.running_in_background!
- automation.trigger!(context)
+ automation.running_in_background!
+ automation.trigger!(context)
+ end
end
end
end
diff --git a/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_topic_tracker.rb b/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_topic_tracker.rb
index 48237371f07..df3e2050d49 100644
--- a/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_topic_tracker.rb
+++ b/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_topic_tracker.rb
@@ -1,41 +1,43 @@
# frozen_string_literal: true
module Jobs
- class DiscourseAutomation::StalledTopicTracker < ::Jobs::Scheduled
- every 1.hour
+ module DiscourseAutomation
+ class StalledTopicTracker < ::Jobs::Scheduled
+ every 1.hour
- def execute(_args = nil)
- name = ::DiscourseAutomation::Triggers::STALLED_TOPIC
+ def execute(_args = nil)
+ name = ::DiscourseAutomation::Triggers::STALLED_TOPIC
- ::DiscourseAutomation::Automation
- .where(trigger: name, enabled: true)
- .find_each do |automation|
- fields = automation.serialized_fields
- stalled_after = fields.dig("stalled_after", "value")
- stalled_duration = ISO8601::Duration.new(stalled_after).to_seconds
- stalled_date = stalled_duration.seconds.ago
- categories = fields.dig("categories", "value")
- tags = fields.dig("tags", "value")
+ ::DiscourseAutomation::Automation
+ .where(trigger: name, enabled: true)
+ .find_each do |automation|
+ fields = automation.serialized_fields
+ stalled_after = fields.dig("stalled_after", "value")
+ stalled_duration = ISO8601::Duration.new(stalled_after).to_seconds
+ stalled_date = stalled_duration.seconds.ago
+ categories = fields.dig("categories", "value")
+ tags = fields.dig("tags", "value")
- ::DiscourseAutomation::StalledTopicFinder
- .call(stalled_date, categories: categories, tags: tags)
- .each do |result|
- topic = Topic.find_by(id: result.id)
- next unless topic
+ ::DiscourseAutomation::StalledTopicFinder
+ .call(stalled_date, categories: categories, tags: tags)
+ .each do |result|
+ topic = Topic.find_by(id: result.id)
+ next unless topic
- run_trigger(automation, topic)
- end
- end
- end
+ run_trigger(automation, topic)
+ end
+ end
+ end
- def run_trigger(automation, topic)
- automation.trigger!(
- "kind" => ::DiscourseAutomation::Triggers::STALLED_TOPIC,
- "topic" => topic,
- "placeholders" => {
- "topic_url" => topic.url,
- },
- )
+ def run_trigger(automation, topic)
+ automation.trigger!(
+ "kind" => ::DiscourseAutomation::Triggers::STALLED_TOPIC,
+ "topic" => topic,
+ "placeholders" => {
+ "topic_url" => topic.url,
+ },
+ )
+ end
end
end
end
diff --git a/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_wiki_tracker.rb b/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_wiki_tracker.rb
index dffdaefcb4d..46b9abd51c5 100644
--- a/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_wiki_tracker.rb
+++ b/plugins/automation/app/jobs/scheduled/discourse_automation/stalled_wiki_tracker.rb
@@ -1,56 +1,59 @@
# frozen_string_literal: true
module Jobs
- class DiscourseAutomation::StalledWikiTracker < ::Jobs::Scheduled
- every 10.minutes
-
- def execute(_args = nil)
- name = ::DiscourseAutomation::Triggers::STALLED_WIKI
+ module DiscourseAutomation
+ class StalledWikiTracker < ::Jobs::Scheduled
+ every 10.minutes
+
+ def execute(_args = nil)
+ name = ::DiscourseAutomation::Triggers::STALLED_WIKI
+
+ ::DiscourseAutomation::Automation
+ .where(trigger: name, enabled: true)
+ .find_each do |automation|
+ stalled_after = automation.trigger_field("stalled_after")
+ stalled_duration = ISO8601::Duration.new(stalled_after["value"]).to_seconds
+ finder =
+ Post.where("wiki = TRUE AND last_version_at <= ?", stalled_duration.seconds.ago)
- ::DiscourseAutomation::Automation
- .where(trigger: name, enabled: true)
- .find_each do |automation|
- stalled_after = automation.trigger_field("stalled_after")
- stalled_duration = ISO8601::Duration.new(stalled_after["value"]).to_seconds
- finder = Post.where("wiki = TRUE AND last_version_at <= ?", stalled_duration.seconds.ago)
+ restricted_category = automation.trigger_field("restricted_category")
+ if restricted_category["value"]
+ finder =
+ finder.joins(:topic).where("topics.category_id = ?", restricted_category["value"])
+ end
- restricted_category = automation.trigger_field("restricted_category")
- if restricted_category["value"]
- finder =
- finder.joins(:topic).where("topics.category_id = ?", restricted_category["value"])
- end
+ finder.each do |post|
+ last_trigger_date = post.custom_fields["stalled_wiki_triggered_at"]
+ if last_trigger_date
+ retriggered_after = automation.trigger_field("retriggered_after")
+ retrigger_duration = ISO8601::Duration.new(retriggered_after["value"]).to_seconds
- finder.each do |post|
- last_trigger_date = post.custom_fields["stalled_wiki_triggered_at"]
- if last_trigger_date
- retriggered_after = automation.trigger_field("retriggered_after")
- retrigger_duration = ISO8601::Duration.new(retriggered_after["value"]).to_seconds
+ next if Time.parse(last_trigger_date) + retrigger_duration >= Time.zone.now
+ end
- next if Time.parse(last_trigger_date) + retrigger_duration >= Time.zone.now
+ post.upsert_custom_fields(stalled_wiki_triggered_at: Time.zone.now)
+ run_trigger(automation, post)
end
-
- post.upsert_custom_fields(stalled_wiki_triggered_at: Time.zone.now)
- run_trigger(automation, post)
end
- end
- end
-
- def run_trigger(automation, post)
- user_ids =
- (
- post.post_revisions.order("post_revisions.created_at DESC").limit(5).pluck(:user_id) +
- [post.user_id]
- ).compact.uniq
-
- automation.trigger!(
- "kind" => ::DiscourseAutomation::Triggers::STALLED_WIKI,
- "post" => post,
- "topic" => post.topic,
- "usernames" => User.where(id: user_ids).pluck(:username),
- "placeholders" => {
- "wiki_url" => Discourse.base_url + post.url,
- },
- )
+ end
+
+ def run_trigger(automation, post)
+ user_ids =
+ (
+ post.post_revisions.order("post_revisions.created_at DESC").limit(5).pluck(:user_id) +
+ [post.user_id]
+ ).compact.uniq
+
+ automation.trigger!(
+ "kind" => ::DiscourseAutomation::Triggers::STALLED_WIKI,
+ "post" => post,
+ "topic" => post.topic,
+ "usernames" => User.where(id: user_ids).pluck(:username),
+ "placeholders" => {
+ "wiki_url" => Discourse.base_url + post.url,
+ },
+ )
+ end
end
end
end
diff --git a/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb b/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb
index c86a71e9d43..ae38059737c 100644
--- a/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb
+++ b/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb
@@ -1,65 +1,69 @@
# frozen_string_literal: true
module Jobs
- class DiscourseAutomation::Tracker < ::Jobs::Scheduled
- every 1.minute
+ module DiscourseAutomation
+ class Tracker < ::Jobs::Scheduled
+ every 1.minute
- BATCH_LIMIT = 300
+ BATCH_LIMIT = 300
- def execute(_args = nil)
- return unless SiteSetting.discourse_automation_enabled
+ def execute(_args = nil)
+ return unless SiteSetting.discourse_automation_enabled
- ::DiscourseAutomation::PendingAutomation
- .includes(:automation)
- .limit(BATCH_LIMIT)
- .where("execute_at < ?", Time.now)
- .find_each do |pending_automation|
- run_pending_automation(pending_automation)
- rescue => e
- Rails.logger.error("Error running automation #{pending_automation.automation.name}: #{e}")
- end
+ ::DiscourseAutomation::PendingAutomation
+ .includes(:automation)
+ .limit(BATCH_LIMIT)
+ .where("execute_at < ?", Time.now)
+ .find_each do |pending_automation|
+ run_pending_automation(pending_automation)
+ rescue => e
+ Rails.logger.error(
+ "Error running automation #{pending_automation.automation.name}: #{e}",
+ )
+ end
- ::DiscourseAutomation::PendingPm
- .includes(:automation)
- .limit(BATCH_LIMIT)
- .where("execute_at < ?", Time.now)
- .find_each do |pending_pm|
- send_pending_pm(pending_pm)
- rescue => e
- Rails.logger.error("Error sending PM for #{pending_pm.automation.name}: #{e}")
- end
- end
+ ::DiscourseAutomation::PendingPm
+ .includes(:automation)
+ .limit(BATCH_LIMIT)
+ .where("execute_at < ?", Time.now)
+ .find_each do |pending_pm|
+ send_pending_pm(pending_pm)
+ rescue => e
+ Rails.logger.error("Error sending PM for #{pending_pm.automation.name}: #{e}")
+ end
+ end
- def send_pending_pm(pending_pm)
- DistributedMutex.synchronize(
- "automation_send_pending_pm_#{pending_pm.id}",
- validity: 30.minutes,
- ) do
- next if !::DiscourseAutomation::PendingPm.exists?(pending_pm.id)
+ def send_pending_pm(pending_pm)
+ DistributedMutex.synchronize(
+ "automation_send_pending_pm_#{pending_pm.id}",
+ validity: 30.minutes,
+ ) do
+ next if !::DiscourseAutomation::PendingPm.exists?(pending_pm.id)
- ::DiscourseAutomation::Scriptable::Utils.send_pm(
- pending_pm.attributes.slice("target_usernames", "title", "raw"),
- sender: pending_pm.sender,
- prefers_encrypt: pending_pm.prefers_encrypt,
- )
+ ::DiscourseAutomation::Scriptable::Utils.send_pm(
+ pending_pm.attributes.slice("target_usernames", "title", "raw"),
+ sender: pending_pm.sender,
+ prefers_encrypt: pending_pm.prefers_encrypt,
+ )
- pending_pm.destroy!
+ pending_pm.destroy!
+ end
end
- end
- def run_pending_automation(pending_automation)
- DistributedMutex.synchronize(
- "process_pending_automation_#{pending_automation.id}",
- validity: 30.minutes,
- ) do
- next if !::DiscourseAutomation::PendingAutomation.exists?(pending_automation.id)
+ def run_pending_automation(pending_automation)
+ DistributedMutex.synchronize(
+ "process_pending_automation_#{pending_automation.id}",
+ validity: 30.minutes,
+ ) do
+ next if !::DiscourseAutomation::PendingAutomation.exists?(pending_automation.id)
- pending_automation.automation.trigger!(
- "kind" => pending_automation.automation.trigger,
- "execute_at" => pending_automation.execute_at,
- )
+ pending_automation.automation.trigger!(
+ "kind" => pending_automation.automation.trigger,
+ "execute_at" => pending_automation.execute_at,
+ )
- pending_automation.destroy!
+ pending_automation.destroy!
+ end
end
end
end
diff --git a/plugins/automation/lib/discourse_automation/engine.rb b/plugins/automation/lib/discourse_automation/engine.rb
index 640a4fb3634..40b614ab2a6 100644
--- a/plugins/automation/lib/discourse_automation/engine.rb
+++ b/plugins/automation/lib/discourse_automation/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAutomation
+module DiscourseAutomation
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseAutomation
diff --git a/plugins/chat/app/controllers/chat/admin/export_controller.rb b/plugins/chat/app/controllers/chat/admin/export_controller.rb
index 7872e46f61b..ea9bd56d053 100644
--- a/plugins/chat/app/controllers/chat/admin/export_controller.rb
+++ b/plugins/chat/app/controllers/chat/admin/export_controller.rb
@@ -3,7 +3,7 @@
module Chat
module Admin
class ExportController < ::Admin::AdminController
- requires_plugin Chat::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def export_messages
entity = "chat_message"
diff --git a/plugins/chat/app/controllers/chat/admin/incoming_webhooks_controller.rb b/plugins/chat/app/controllers/chat/admin/incoming_webhooks_controller.rb
index bbfcc41ff67..1eb61a18c25 100644
--- a/plugins/chat/app/controllers/chat/admin/incoming_webhooks_controller.rb
+++ b/plugins/chat/app/controllers/chat/admin/incoming_webhooks_controller.rb
@@ -3,7 +3,7 @@
module Chat
module Admin
class IncomingWebhooksController < ::Admin::AdminController
- requires_plugin Chat::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
render_serialized(
diff --git a/plugins/chat/app/controllers/chat/base_controller.rb b/plugins/chat/app/controllers/chat/base_controller.rb
index 865511caba1..8ea85a50e07 100644
--- a/plugins/chat/app/controllers/chat/base_controller.rb
+++ b/plugins/chat/app/controllers/chat/base_controller.rb
@@ -2,7 +2,7 @@
module Chat
class BaseController < ::ApplicationController
- requires_plugin Chat::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_logged_in
before_action :ensure_can_chat
diff --git a/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb b/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb
index 9c58de23a04..105525ad6af 100644
--- a/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb
+++ b/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb
@@ -2,7 +2,7 @@
module Chat
class IncomingWebhooksController < ::ApplicationController
- requires_plugin Chat::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
WEBHOOK_MESSAGES_PER_MINUTE_LIMIT = 10
diff --git a/plugins/chat/lib/chat/engine.rb b/plugins/chat/lib/chat/engine.rb
index 0bf36a36d2c..d541a4daac3 100644
--- a/plugins/chat/lib/chat/engine.rb
+++ b/plugins/chat/lib/chat/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Chat
+module Chat
HAS_CHAT_ENABLED = "has_chat_enabled"
LAST_CHAT_CHANNEL_ID = "last_chat_channel_id"
diff --git a/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ad_settings_controller.rb b/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ad_settings_controller.rb
index ca7920a159d..131021dce7b 100644
--- a/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ad_settings_controller.rb
+++ b/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ad_settings_controller.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-module ::AdPlugin
+module AdPlugin
class HouseAdSettingsController < ::ApplicationController
- requires_plugin AdPlugin::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def update
HouseAdSetting.update(params[:id], params[:value])
diff --git a/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ads_controller.rb b/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ads_controller.rb
index e7ab4dd8ee7..87964b42084 100644
--- a/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ads_controller.rb
+++ b/plugins/discourse-adplugin/app/controllers/ad_plugin/house_ads_controller.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-module ::AdPlugin
+module AdPlugin
class HouseAdsController < ::ApplicationController
- requires_plugin AdPlugin::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
render_json_dump(
diff --git a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb
index bfcbb820b5c..a1b5cb48317 100644
--- a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb
+++ b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::AdPlugin
+module AdPlugin
class HouseAd
include ActiveModel::Validations
diff --git a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb
index 9b50921c0e7..5de9ec4bafe 100644
--- a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb
+++ b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::AdPlugin
+module AdPlugin
class HouseAdSetting
DEFAULTS = {
topic_list_top: "",
diff --git a/plugins/discourse-adplugin/lib/adplugin/engine.rb b/plugins/discourse-adplugin/lib/adplugin/engine.rb
index d3387ffb5f6..3fb50adae0c 100644
--- a/plugins/discourse-adplugin/lib/adplugin/engine.rb
+++ b/plugins/discourse-adplugin/lib/adplugin/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::AdPlugin
+module AdPlugin
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace AdPlugin
diff --git a/plugins/discourse-adplugin/lib/adplugin/guardian_extensions.rb b/plugins/discourse-adplugin/lib/adplugin/guardian_extensions.rb
index 427c46c9f57..53120bb7a1a 100644
--- a/plugins/discourse-adplugin/lib/adplugin/guardian_extensions.rb
+++ b/plugins/discourse-adplugin/lib/adplugin/guardian_extensions.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::AdPlugin
+module AdPlugin
module GuardianExtensions
def show_dfp_ads?
!self.user.in_any_groups?(SiteSetting.dfp_exclude_groups_map)
diff --git a/plugins/discourse-adplugin/plugin.rb b/plugins/discourse-adplugin/plugin.rb
index a2bb2334885..d9a11d7c993 100755
--- a/plugins/discourse-adplugin/plugin.rb
+++ b/plugins/discourse-adplugin/plugin.rb
@@ -27,11 +27,11 @@ after_initialize do
require_relative "app/models/ad_plugin/house_ad"
require_relative "lib/adplugin/guardian_extensions"
- reloadable_patch { Guardian.prepend ::AdPlugin::GuardianExtensions }
+ reloadable_patch { Guardian.prepend AdPlugin::GuardianExtensions }
Discourse::Application.routes.append do
get "/ads.txt" => "adstxt#index"
- mount ::AdPlugin::Engine, at: "/admin/plugins/pluginad", constraints: AdminConstraint.new
+ mount AdPlugin::Engine, at: "/admin/plugins/pluginad", constraints: AdminConstraint.new
end
add_to_serializer :site, :house_creatives do
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_artifacts_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_artifacts_controller.rb
index 8ac7ef2e539..bd018cb9265 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_artifacts_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_artifacts_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiArtifactsController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
PER_PAGE_MAX = 100
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_embeddings_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_embeddings_controller.rb
index ceea81affdd..2eb51c82d5c 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_embeddings_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_embeddings_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiEmbeddingsController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
embedding_defs = EmbeddingDefinition.all.order(:display_name)
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_features_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_features_controller.rb
index d66e5b8b25a..320018a8154 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_features_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_features_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiFeaturesController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
render json: serialize_modules(DiscourseAi::Configuration::Module.all)
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb
index b5e89c8cc8a..9c15b0d9164 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiLlmQuotasController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
quotas = LlmQuota.includes(:group)
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llms_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llms_controller.rb
index 51ee5957c15..a5153cd531a 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llms_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llms_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiLlmsController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
llms = LlmModel.all.includes(:llm_quotas).order(:display_name)
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_personas_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_personas_controller.rb
index 56c96d56dcf..99345414a70 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_personas_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_personas_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiPersonasController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :find_ai_persona, only: %i[edit update destroy create_user export]
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_tools_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_tools_controller.rb
index e14ee0116cf..47d7c55e4a1 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_tools_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_tools_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class AiToolsController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :find_ai_tool, only: %i[test edit update destroy export]
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/dashboard_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/dashboard_controller.rb
index 9fed8f0869b..25a64a93a0a 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/dashboard_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/dashboard_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class DashboardController < ::Admin::StaffController
- requires_plugin DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def sentiment
end
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb
index d6ee53b4b46..014a3ee4aef 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Admin
class RagDocumentFragmentsController < ::Admin::AdminController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def indexing_status_check
if params[:target_type] == "AiPersona"
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifact_key_values_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifact_key_values_controller.rb
index 83b003f7d0d..7b7c8478f19 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifact_key_values_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifact_key_values_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module AiBot
class ArtifactKeyValuesController < ::ApplicationController
- requires_plugin DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_logged_in, only: %i[set destroy]
before_action :find_artifact
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifacts_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifacts_controller.rb
index 9ce89cef952..41e26703d9b 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifacts_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/artifacts_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module AiBot
class ArtifactsController < ApplicationController
- requires_plugin DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :require_site_settings!
skip_before_action :preload_json, :check_xhr, only: %i[show]
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb
index 5ea13795e79..c3a8e137487 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module AiBot
class BotController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
def show_debug_info_by_id
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/conversations_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/conversations_controller.rb
index 83863baf004..cc7af5c2640 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/conversations_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/conversations_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module AiBot
class ConversationsController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
def index
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/shared_ai_conversations_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/shared_ai_conversations_controller.rb
index 3d86b2d47c5..b56305b0edf 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/shared_ai_conversations_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/shared_ai_conversations_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module AiBot
class SharedAiConversationsController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login only: %i[create update destroy]
before_action :require_site_settings!
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb
index b626172122c..92117f81488 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module AiHelper
class AssistantController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
before_action :ensure_can_request_suggestions
before_action :rate_limiter_performed!
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/discord/bot_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/discord/bot_controller.rb
index d553aa275e5..bfb749cb3fd 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/discord/bot_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/discord/bot_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Discord
class BotController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
skip_before_action :verify_authenticity_token
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb
index a064930c192..cb5cd242938 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Discover
class DiscoveriesController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
def reply
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb
index 10273f2ade8..d3f7cfd25cc 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Embeddings
class EmbeddingsController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
SEMANTIC_SEARCH_TYPE = "semantic_search"
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/sentiment/sentiment_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/sentiment/sentiment_controller.rb
index 5dd289932e8..45aa2824645 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/sentiment/sentiment_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/sentiment/sentiment_controller.rb
@@ -4,7 +4,7 @@ module DiscourseAi
module Sentiment
class SentimentController < ::Admin::StaffController
include Constants
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
DEFAULT_POSTS_LIMIT = 50
MAX_POSTS_LIMIT = 100
@@ -46,7 +46,7 @@ module DiscourseAi
u.name,
u.uploaded_avatar_id,
c.id AS category_id,
- (CASE
+ (CASE
WHEN (cr.classification::jsonb->'positive')::float > :threshold THEN 'positive'
WHEN (cr.classification::jsonb->'negative')::float > :threshold THEN 'negative'
ELSE 'neutral'
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/summarization/chat_summary_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/summarization/chat_summary_controller.rb
index c66b1f2c7e5..264c2007d3d 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/summarization/chat_summary_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/summarization/chat_summary_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Summarization
class ChatSummaryController < ::Chat::ApiController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin DiscourseAi::PLUGIN_NAME
requires_plugin ::Chat::PLUGIN_NAME
VALID_SINCE_VALUES = [1, 3, 6, 12, 24, 72, 168]
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/summarization/summary_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/summarization/summary_controller.rb
index de8eb3f3fca..4381d526c4c 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/summarization/summary_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/summarization/summary_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Summarization
class SummaryController < ::ApplicationController
- requires_plugin ::DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def show
topic = Topic.find(params[:topic_id])
diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb
index 83032996937..3a1f8a96d5f 100644
--- a/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb
+++ b/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb
@@ -3,7 +3,7 @@
module DiscourseAi
module Translation
class TranslationController < ::ApplicationController
- requires_plugin DiscourseAi::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_logged_in
before_action :check_permissions
diff --git a/plugins/discourse-ai/app/jobs/regular/create_ai_chat_reply.rb b/plugins/discourse-ai/app/jobs/regular/create_ai_chat_reply.rb
index 61f824b64b6..05c2d84f747 100644
--- a/plugins/discourse-ai/app/jobs/regular/create_ai_chat_reply.rb
+++ b/plugins/discourse-ai/app/jobs/regular/create_ai_chat_reply.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class CreateAiChatReply < ::Jobs::Base
sidekiq_options retry: false
diff --git a/plugins/discourse-ai/app/jobs/regular/create_ai_reply.rb b/plugins/discourse-ai/app/jobs/regular/create_ai_reply.rb
index 14653a6150e..8d32796183a 100644
--- a/plugins/discourse-ai/app/jobs/regular/create_ai_reply.rb
+++ b/plugins/discourse-ai/app/jobs/regular/create_ai_reply.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class CreateAiReply < ::Jobs::Base
sidekiq_options retry: false
diff --git a/plugins/discourse-ai/app/jobs/regular/digest_rag_upload.rb b/plugins/discourse-ai/app/jobs/regular/digest_rag_upload.rb
index 4ac45971274..f1a1db8c38f 100644
--- a/plugins/discourse-ai/app/jobs/regular/digest_rag_upload.rb
+++ b/plugins/discourse-ai/app/jobs/regular/digest_rag_upload.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class DigestRagUpload < ::Jobs::Base
CHUNK_SIZE = 1024
CHUNK_OVERLAP = 64
diff --git a/plugins/discourse-ai/app/jobs/regular/fast_track_topic_gist.rb b/plugins/discourse-ai/app/jobs/regular/fast_track_topic_gist.rb
index 30f586da764..08f86cf191b 100644
--- a/plugins/discourse-ai/app/jobs/regular/fast_track_topic_gist.rb
+++ b/plugins/discourse-ai/app/jobs/regular/fast_track_topic_gist.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class FastTrackTopicGist < ::Jobs::Base
sidekiq_options retry: false
diff --git a/plugins/discourse-ai/app/jobs/regular/generate_rag_embeddings.rb b/plugins/discourse-ai/app/jobs/regular/generate_rag_embeddings.rb
index 775b849f649..f388c8379d8 100644
--- a/plugins/discourse-ai/app/jobs/regular/generate_rag_embeddings.rb
+++ b/plugins/discourse-ai/app/jobs/regular/generate_rag_embeddings.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class GenerateRagEmbeddings < ::Jobs::Base
sidekiq_options queue: "ultra_low"
# we could also restrict concurrency but this takes so long if it is not concurrent
diff --git a/plugins/discourse-ai/app/jobs/regular/manage_embedding_def_search_index.rb b/plugins/discourse-ai/app/jobs/regular/manage_embedding_def_search_index.rb
index 5baa526c45c..578761a2964 100644
--- a/plugins/discourse-ai/app/jobs/regular/manage_embedding_def_search_index.rb
+++ b/plugins/discourse-ai/app/jobs/regular/manage_embedding_def_search_index.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class ManageEmbeddingDefSearchIndex < ::Jobs::Base
def execute(args)
embedding_def = EmbeddingDefinition.find_by(id: args[:id])
diff --git a/plugins/discourse-ai/app/jobs/regular/post_sentiment_analysis.rb b/plugins/discourse-ai/app/jobs/regular/post_sentiment_analysis.rb
index 59b96a1bc5b..768a1d37c47 100644
--- a/plugins/discourse-ai/app/jobs/regular/post_sentiment_analysis.rb
+++ b/plugins/discourse-ai/app/jobs/regular/post_sentiment_analysis.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class PostSentimentAnalysis < ::Jobs::Base
sidekiq_options queue: "low"
diff --git a/plugins/discourse-ai/app/jobs/regular/shared_conversation_adjust_upload_security.rb b/plugins/discourse-ai/app/jobs/regular/shared_conversation_adjust_upload_security.rb
index 350ca0e70de..7510ca6ccd0 100644
--- a/plugins/discourse-ai/app/jobs/regular/shared_conversation_adjust_upload_security.rb
+++ b/plugins/discourse-ai/app/jobs/regular/shared_conversation_adjust_upload_security.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class SharedConversationAdjustUploadSecurity < ::Jobs::Base
def execute(args)
if args[:conversation_id].present?
diff --git a/plugins/discourse-ai/app/jobs/scheduled/summaries_backfill.rb b/plugins/discourse-ai/app/jobs/scheduled/summaries_backfill.rb
index d5a241e43ce..a1ed877cbbc 100644
--- a/plugins/discourse-ai/app/jobs/scheduled/summaries_backfill.rb
+++ b/plugins/discourse-ai/app/jobs/scheduled/summaries_backfill.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class SummariesBackfill < ::Jobs::Scheduled
every 5.minutes
cluster_concurrency 1
diff --git a/plugins/discourse-ai/app/models/ai_persona.rb b/plugins/discourse-ai/app/models/ai_persona.rb
index 694cde78027..f626d4d628a 100644
--- a/plugins/discourse-ai/app/models/ai_persona.rb
+++ b/plugins/discourse-ai/app/models/ai_persona.rb
@@ -41,7 +41,7 @@ class AiPersona < ActiveRecord::Base
before_update :regenerate_rag_fragments
def self.persona_cache
- @persona_cache ||= ::DiscourseAi::MultisiteHash.new("persona_cache")
+ @persona_cache ||= DiscourseAi::MultisiteHash.new("persona_cache")
end
scope :ordered, -> { order("priority DESC, lower(name) ASC") }
diff --git a/plugins/discourse-ai/config/routes.rb b/plugins/discourse-ai/config/routes.rb
index c295c940c2d..62cb9c43fa8 100644
--- a/plugins/discourse-ai/config/routes.rb
+++ b/plugins/discourse-ai/config/routes.rb
@@ -71,7 +71,7 @@ DiscourseAi::Engine.routes.draw do
end
Discourse::Application.routes.draw do
- mount ::DiscourseAi::Engine, at: "discourse-ai"
+ mount DiscourseAi::Engine, at: "discourse-ai"
get "admin/dashboard/sentiment" => "discourse_ai/admin/dashboard#sentiment",
:constraints => StaffConstraint.new
diff --git a/plugins/discourse-ai/lib/ai_bot/entry_point.rb b/plugins/discourse-ai/lib/ai_bot/entry_point.rb
index 2f4058f4e95..5bb16aaf5df 100644
--- a/plugins/discourse-ai/lib/ai_bot/entry_point.rb
+++ b/plugins/discourse-ai/lib/ai_bot/entry_point.rb
@@ -190,7 +190,7 @@ module DiscourseAi
scope.user.in_any_groups?(SiteSetting.ai_bot_allowed_groups_map)
end,
) do
- bots_map = ::DiscourseAi::AiBot::EntryPoint.enabled_user_ids_and_models_map
+ bots_map = DiscourseAi::AiBot::EntryPoint.enabled_user_ids_and_models_map
persona_users = AiPersona.persona_users(user: scope.user)
if persona_users.present?
diff --git a/plugins/discourse-ai/lib/ai_helper/assistant.rb b/plugins/discourse-ai/lib/ai_helper/assistant.rb
index 3926f2a792e..5dfe3c488ca 100644
--- a/plugins/discourse-ai/lib/ai_helper/assistant.rb
+++ b/plugins/discourse-ai/lib/ai_helper/assistant.rb
@@ -16,7 +16,7 @@ module DiscourseAi
IMAGE_CAPTION = "image_caption"
def self.prompt_cache
- @prompt_cache ||= ::DiscourseAi::MultisiteHash.new("prompt_cache")
+ @prompt_cache ||= DiscourseAi::MultisiteHash.new("prompt_cache")
end
def self.clear_prompt_cache!
diff --git a/plugins/discourse-ai/lib/ai_moderation/entry_point.rb b/plugins/discourse-ai/lib/ai_moderation/entry_point.rb
index fb42fee4fc1..71a678606ae 100644
--- a/plugins/discourse-ai/lib/ai_moderation/entry_point.rb
+++ b/plugins/discourse-ai/lib/ai_moderation/entry_point.rb
@@ -4,19 +4,19 @@ module DiscourseAi
module AiModeration
class EntryPoint
def inject_into(plugin)
- plugin.on(:post_created) { |post| ::DiscourseAi::AiModeration::SpamScanner.new_post(post) }
+ plugin.on(:post_created) { |post| DiscourseAi::AiModeration::SpamScanner.new_post(post) }
plugin.on(:post_edited) do |post, _, revisor|
if revisor.reviewable_content_changed?
- ::DiscourseAi::AiModeration::SpamScanner.edited_post(post)
+ DiscourseAi::AiModeration::SpamScanner.edited_post(post)
end
end
plugin.on(:post_process_cooked) do |_doc, post|
- ::DiscourseAi::AiModeration::SpamScanner.after_cooked_post(post)
+ DiscourseAi::AiModeration::SpamScanner.after_cooked_post(post)
end
plugin.on(:site_setting_changed) do |name, _old_value, new_value|
if name == :ai_spam_detection_enabled && new_value
- ::DiscourseAi::AiModeration::SpamScanner.ensure_flagging_user!
+ DiscourseAi::AiModeration::SpamScanner.ensure_flagging_user!
end
end
diff --git a/plugins/discourse-ai/lib/automation/report_context_generator.rb b/plugins/discourse-ai/lib/automation/report_context_generator.rb
index e54bf235e40..fb6c8ce5cd4 100644
--- a/plugins/discourse-ai/lib/automation/report_context_generator.rb
+++ b/plugins/discourse-ai/lib/automation/report_context_generator.rb
@@ -65,7 +65,7 @@ module DiscourseAi
@posts = @posts.where(topic_id: topic_ids_with_tags)
end
- if defined?(::DiscourseSolved)
+ if defined?(DiscourseSolved)
@solutions =
DiscourseSolved::SolvedTopic
.where(topic_id: @posts.select(:topic_id))
diff --git a/plugins/discourse-ai/lib/configuration/feature.rb b/plugins/discourse-ai/lib/configuration/feature.rb
index 65f5d1dfe63..0d443e9f73b 100644
--- a/plugins/discourse-ai/lib/configuration/feature.rb
+++ b/plugins/discourse-ai/lib/configuration/feature.rb
@@ -5,7 +5,7 @@ module DiscourseAi
class Feature
class << self
def feature_cache
- @feature_cache ||= ::DiscourseAi::MultisiteHash.new("feature_cache")
+ @feature_cache ||= DiscourseAi::MultisiteHash.new("feature_cache")
end
def summarization_features
diff --git a/plugins/discourse-ai/lib/database/connection.rb b/plugins/discourse-ai/lib/database/connection.rb
index f591e188c4a..93f9811eda4 100644
--- a/plugins/discourse-ai/lib/database/connection.rb
+++ b/plugins/discourse-ai/lib/database/connection.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Database
class Connection
def self.db
diff --git a/plugins/discourse-ai/lib/embeddings/entry_point.rb b/plugins/discourse-ai/lib/embeddings/entry_point.rb
index b1cf70857cb..c93b78929fe 100644
--- a/plugins/discourse-ai/lib/embeddings/entry_point.rb
+++ b/plugins/discourse-ai/lib/embeddings/entry_point.rb
@@ -20,7 +20,7 @@ module DiscourseAi
end
@related_topics ||=
- ::DiscourseAi::Embeddings::SemanticTopicQuery.new(@user).list_semantic_related_topics(
+ DiscourseAi::Embeddings::SemanticTopicQuery.new(@user).list_semantic_related_topics(
topic,
)
end
@@ -47,7 +47,7 @@ module DiscourseAi
end
plugin.register_html_builder("server:topic-show-after-posts-crawler") do |controller|
- ::DiscourseAi::Embeddings::SemanticRelated.related_topics_for_crawler(controller)
+ DiscourseAi::Embeddings::SemanticRelated.related_topics_for_crawler(controller)
end
# embeddings generation.
diff --git a/plugins/discourse-ai/lib/embeddings/semantic_related.rb b/plugins/discourse-ai/lib/embeddings/semantic_related.rb
index efc35cd08ed..869e4b5bfe0 100644
--- a/plugins/discourse-ai/lib/embeddings/semantic_related.rb
+++ b/plugins/discourse-ai/lib/embeddings/semantic_related.rb
@@ -30,12 +30,12 @@ module DiscourseAi
# Happens when the topic doesn't have any embeddings
# I'd rather not use Exceptions to control the flow, so this should be refactored soon
if candidate_ids.empty? || !candidate_ids.include?(topic.id)
- raise ::DiscourseAi::Embeddings::Schema::MissingEmbeddingError,
+ raise DiscourseAi::Embeddings::Schema::MissingEmbeddingError,
"No embeddings found for topic #{topic.id}"
end
end
end
- rescue ::DiscourseAi::Embeddings::Schema::MissingEmbeddingError
+ rescue DiscourseAi::Embeddings::Schema::MissingEmbeddingError
# avoid a flood of jobs when visiting topic
if Discourse.redis.set(
build_semantic_suggested_key(topic.id),
diff --git a/plugins/discourse-ai/lib/engine.rb b/plugins/discourse-ai/lib/engine.rb
index 6c43e22e222..a694a91e704 100644
--- a/plugins/discourse-ai/lib/engine.rb
+++ b/plugins/discourse-ai/lib/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseAi
diff --git a/plugins/discourse-ai/lib/inference/cloudflare_workers_ai.rb b/plugins/discourse-ai/lib/inference/cloudflare_workers_ai.rb
index adb9eb78dd4..5177aa23241 100644
--- a/plugins/discourse-ai/lib/inference/cloudflare_workers_ai.rb
+++ b/plugins/discourse-ai/lib/inference/cloudflare_workers_ai.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class CloudflareWorkersAi
def initialize(endpoint, api_token, referer = Discourse.base_url)
diff --git a/plugins/discourse-ai/lib/inference/discourse_reranker.rb b/plugins/discourse-ai/lib/inference/discourse_reranker.rb
index 35b09799514..11efd491895 100644
--- a/plugins/discourse-ai/lib/inference/discourse_reranker.rb
+++ b/plugins/discourse-ai/lib/inference/discourse_reranker.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class DiscourseReranker
def self.perform!(endpoint, model, content, candidates, api_key)
diff --git a/plugins/discourse-ai/lib/inference/gemini_embeddings.rb b/plugins/discourse-ai/lib/inference/gemini_embeddings.rb
index 24d4b35a785..a275dbdaa11 100644
--- a/plugins/discourse-ai/lib/inference/gemini_embeddings.rb
+++ b/plugins/discourse-ai/lib/inference/gemini_embeddings.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class GeminiEmbeddings
def initialize(embedding_url, api_key, dimensions = nil, referer = Discourse.base_url)
diff --git a/plugins/discourse-ai/lib/inference/hugging_face_text_embeddings.rb b/plugins/discourse-ai/lib/inference/hugging_face_text_embeddings.rb
index 67a964f88f7..66690ae7b86 100644
--- a/plugins/discourse-ai/lib/inference/hugging_face_text_embeddings.rb
+++ b/plugins/discourse-ai/lib/inference/hugging_face_text_embeddings.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class HuggingFaceTextEmbeddings
def initialize(endpoint, key, referer = Discourse.base_url)
diff --git a/plugins/discourse-ai/lib/inference/open_ai_embeddings.rb b/plugins/discourse-ai/lib/inference/open_ai_embeddings.rb
index ec1845d9cf0..8a0e4bb642c 100644
--- a/plugins/discourse-ai/lib/inference/open_ai_embeddings.rb
+++ b/plugins/discourse-ai/lib/inference/open_ai_embeddings.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class OpenAiEmbeddings
def initialize(endpoint, api_key, model, dimensions)
diff --git a/plugins/discourse-ai/lib/inference/open_ai_image_generator.rb b/plugins/discourse-ai/lib/inference/open_ai_image_generator.rb
index 83501989ae9..e6b725b62c6 100644
--- a/plugins/discourse-ai/lib/inference/open_ai_image_generator.rb
+++ b/plugins/discourse-ai/lib/inference/open_ai_image_generator.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class OpenAiImageGenerator
TIMEOUT = 60
diff --git a/plugins/discourse-ai/lib/inference/stability_generator.rb b/plugins/discourse-ai/lib/inference/stability_generator.rb
index 124f5d8acee..acf7ef01636 100644
--- a/plugins/discourse-ai/lib/inference/stability_generator.rb
+++ b/plugins/discourse-ai/lib/inference/stability_generator.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAi
+module DiscourseAi
module Inference
class StabilityGenerator
TIMEOUT = 120
diff --git a/plugins/discourse-ai/lib/personas/persona.rb b/plugins/discourse-ai/lib/personas/persona.rb
index 47ce08e7b71..fa71ecace2a 100644
--- a/plugins/discourse-ai/lib/personas/persona.rb
+++ b/plugins/discourse-ai/lib/personas/persona.rb
@@ -285,7 +285,7 @@ module DiscourseAi
return replaced if !context.format_dates
- ::DiscourseAi::AiHelper::DateFormatter.process_date_placeholders(replaced, context.user)
+ DiscourseAi::AiHelper::DateFormatter.process_date_placeholders(replaced, context.user)
end
def tool_instance(tool_call, bot_user:, llm:, context:, existing_tools:)
diff --git a/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake b/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake
index 30ed632e52a..aa866f99231 100644
--- a/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake
+++ b/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake
@@ -1,7 +1,7 @@
# frozen_string_literal: true
def classify(content)
- ::DiscourseAi::Inference::DiscourseClassifier.perform!(
+ DiscourseAi::Inference::DiscourseClassifier.perform!(
"#{SiteSetting.ai_toxicity_inference_service_api_endpoint}/api/v1/classify",
SiteSetting.ai_toxicity_inference_service_api_model,
content,
diff --git a/plugins/discourse-ai/plugin.rb b/plugins/discourse-ai/plugin.rb
index e56a9e0332b..8da569c363b 100644
--- a/plugins/discourse-ai/plugin.rb
+++ b/plugins/discourse-ai/plugin.rb
@@ -61,12 +61,12 @@ module ::DiscourseAi
end
end
-Rails.autoloaders.main.push_dir(File.join(__dir__, "lib"), namespace: ::DiscourseAi)
+Rails.autoloaders.main.push_dir(File.join(__dir__, "lib"), namespace: DiscourseAi)
require_relative "lib/engine"
require_relative "lib/configuration/module"
-::DiscourseAi::Configuration::Module::NAMES.each do |module_name|
+DiscourseAi::Configuration::Module::NAMES.each do |module_name|
register_site_setting_area("ai-features/#{module_name}")
end
diff --git a/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb b/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb
index 6d4dc8cfc80..3ea8b0c41ca 100644
--- a/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::DetectTranslatePost do
- fab!(:post)
subject(:job) { described_class.new }
+ fab!(:post)
+
let(:locales) { %w[en ja] }
before do
diff --git a/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb b/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb
index 32d952a1525..4a8bca9d368 100644
--- a/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::DetectTranslateTopic do
- fab!(:topic)
subject(:job) { described_class.new }
+ fab!(:topic)
+
let(:locales) { %w[en ja] }
before do
diff --git a/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb b/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb
index f2815e27b25..1670369ab62 100644
--- a/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::LocalizePosts do
- fab!(:post)
subject(:job) { described_class.new }
+ fab!(:post)
+
let(:locales) { %w[en ja de] }
before do
diff --git a/plugins/discourse-ai/spec/jobs/regular/localize_topics_spec.rb b/plugins/discourse-ai/spec/jobs/regular/localize_topics_spec.rb
index 1f2fe0d35bf..394854b2d7a 100644
--- a/plugins/discourse-ai/spec/jobs/regular/localize_topics_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/regular/localize_topics_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::LocalizeTopics do
- fab!(:topic)
subject(:job) { described_class.new }
+ fab!(:topic)
+
let(:locales) { %w[en ja de] }
before do
diff --git a/plugins/discourse-ai/spec/jobs/scheduled/categories_locale_detection_backfill_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/categories_locale_detection_backfill_spec.rb
index 3870c4a5750..313a94a4ad6 100644
--- a/plugins/discourse-ai/spec/jobs/scheduled/categories_locale_detection_backfill_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/scheduled/categories_locale_detection_backfill_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::CategoriesLocaleDetectionBackfill do
- fab!(:category) { Fabricate(:category, locale: nil) }
subject(:job) { described_class.new }
+ fab!(:category) { Fabricate(:category, locale: nil) }
+
before do
assign_fake_provider_to(:ai_default_llm_model)
enable_current_plugin
diff --git a/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb
index d5cf6a23f3f..d74ae6cd5f4 100644
--- a/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::PostsLocaleDetectionBackfill do
- fab!(:post) { Fabricate(:post, locale: nil) }
subject(:job) { described_class.new }
+ fab!(:post) { Fabricate(:post, locale: nil) }
+
before do
assign_fake_provider_to(:ai_default_llm_model)
enable_current_plugin
diff --git a/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb
index 4235689fa1a..518c00d96ae 100644
--- a/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
describe Jobs::TopicsLocaleDetectionBackfill do
- fab!(:topic) { Fabricate(:topic, locale: nil) }
subject(:job) { described_class.new }
+ fab!(:topic) { Fabricate(:topic, locale: nil) }
+
before do
assign_fake_provider_to(:ai_default_llm_model)
enable_current_plugin
diff --git a/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb b/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb
index f7fb968965f..c4b246ea74c 100644
--- a/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe DiscourseAi::Completions::Dialects::Dialect do
id: "123",
name: "echo",
content:
- "<function_results>\n<result>\n<tool_name>echo</tool_name>\n<json>\n\"test message\"\n</json>\n</result>\n</function_results>\n\n#{::DiscourseAi::Completions::Dialects::XmlTools::DONE_MESSAGE}",
+ "<function_results>\n<result>\n<tool_name>echo</tool_name>\n<json>\n\"test message\"\n</json>\n</result>\n</function_results>\n\n#{DiscourseAi::Completions::Dialects::XmlTools::DONE_MESSAGE}",
},
],
)
diff --git a/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb b/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb
index b9378d7dc8c..58d01d77faa 100644
--- a/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb
+++ b/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb
@@ -45,7 +45,7 @@ module DiscourseAi
before { enable_current_plugin }
- if defined?(::DiscourseSolved)
+ if defined?(DiscourseSolved)
it "will correctly denote solved topics" do
Fabricate(:solved_topic, topic: topic_with_likes, answer_post: post_with_likes2)
diff --git a/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb b/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb
index 31a776b3fed..5b41a45292e 100644
--- a/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb
+++ b/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb
@@ -2,7 +2,7 @@
module DiscourseAssign
class AssignController < ApplicationController
- requires_plugin DiscourseAssign::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
requires_login
before_action :ensure_logged_in, :ensure_assign_allowed
diff --git a/plugins/discourse-assign/config/routes.rb b/plugins/discourse-assign/config/routes.rb
index ef974f3d876..5d08284d0d5 100644
--- a/plugins/discourse-assign/config/routes.rb
+++ b/plugins/discourse-assign/config/routes.rb
@@ -10,7 +10,7 @@ DiscourseAssign::Engine.routes.draw do
end
Discourse::Application.routes.draw do
- mount ::DiscourseAssign::Engine, at: "/assign"
+ mount DiscourseAssign::Engine, at: "/assign"
get "topics/private-messages-assigned/:username" => "list#private_messages_assigned",
:as => "topics_private_messages_assigned",
diff --git a/plugins/discourse-assign/lib/discourse_assign/engine.rb b/plugins/discourse-assign/lib/discourse_assign/engine.rb
index 29cff854917..41a3ce967d9 100644
--- a/plugins/discourse-assign/lib/discourse_assign/engine.rb
+++ b/plugins/discourse-assign/lib/discourse_assign/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseAssign
+module DiscourseAssign
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseAssign
diff --git a/plugins/discourse-calendar/config/routes.rb b/plugins/discourse-calendar/config/routes.rb
index 74bd6b0ab90..5af4a238b54 100644
--- a/plugins/discourse-calendar/config/routes.rb
+++ b/plugins/discourse-calendar/config/routes.rb
@@ -19,8 +19,8 @@ DiscoursePostEvent::Engine.routes.draw do
end
Discourse::Application.routes.draw do
- mount ::DiscourseCalendar::Engine, at: "/"
- mount ::DiscoursePostEvent::Engine, at: "/"
+ mount DiscourseCalendar::Engine, at: "/"
+ mount DiscoursePostEvent::Engine, at: "/"
scope constraints: StaffConstraint.new do
get "/admin/plugins/calendar" => "admin/plugins#index"
diff --git a/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb b/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb
index c76439965d9..cdc4d28f7da 100644
--- a/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb
+++ b/plugins/discourse-calendar/jobs/scheduled/create_holiday_events.rb
@@ -1,122 +1,124 @@
# frozen_string_literal: true
module Jobs
- class ::DiscourseCalendar::CreateHolidayEvents < ::Jobs::Scheduled
- every 10.minutes
-
- def execute(args)
- return if !SiteSetting.calendar_enabled
- return if !SiteSetting.calendar_automatic_holidays_enabled
-
- return unless topic_id = SiteSetting.holiday_calendar_topic_id.presence
-
- require "holidays" if !defined?(Holidays)
-
- today = Date.today
-
- regions_and_user_ids = Hash.new { |h, k| h[k] = [] }
-
- UserCustomField
- .where(name: ::DiscourseCalendar::REGION_CUSTOM_FIELD)
- .pluck(:user_id, :value)
- .each { |user_id, region| regions_and_user_ids[region] << user_id if region.present? }
-
- usernames =
- User
- .real
- .activated
- .not_suspended
- .not_silenced
- .where(id: regions_and_user_ids.values.flatten)
- .pluck(:id, :username)
- .to_h
-
- timezones =
- UserOption
- .where(user_id: usernames.keys)
- .where.not(timezone: nil)
- .pluck(:user_id, :timezone)
- .map do |user_id, timezone|
- [
- user_id,
- (
- begin
- TZInfo::Timezone.get(timezone)
- rescue StandardError
- nil
+ module DiscourseCalendar
+ class CreateHolidayEvents < ::Jobs::Scheduled
+ every 10.minutes
+
+ def execute(args)
+ return if !SiteSetting.calendar_enabled
+ return if !SiteSetting.calendar_automatic_holidays_enabled
+
+ return unless topic_id = SiteSetting.holiday_calendar_topic_id.presence
+
+ require "holidays" if !defined?(Holidays)
+
+ today = Date.today
+
+ regions_and_user_ids = Hash.new { |h, k| h[k] = [] }
+
+ UserCustomField
+ .where(name: ::DiscourseCalendar::REGION_CUSTOM_FIELD)
+ .pluck(:user_id, :value)
+ .each { |user_id, region| regions_and_user_ids[region] << user_id if region.present? }
+
+ usernames =
+ User
+ .real
+ .activated
+ .not_suspended
+ .not_silenced
+ .where(id: regions_and_user_ids.values.flatten)
+ .pluck(:id, :username)
+ .to_h
+
+ timezones =
+ UserOption
+ .where(user_id: usernames.keys)
+ .where.not(timezone: nil)
+ .pluck(:user_id, :timezone)
+ .map do |user_id, timezone|
+ [
+ user_id,
+ (
+ begin
+ TZInfo::Timezone.get(timezone)
+ rescue StandardError
+ nil
+ end
+ ),
+ ]
+ end
+ .to_h
+
+ # Remove holidays for deactivated/suspended/silenced users
+ CalendarEvent.where(post_id: nil).where.not(user_id: usernames.keys).destroy_all
+
+ # Remove future holidays when users changed their region
+ CalendarEvent
+ .joins(user: :_custom_fields)
+ .where(post_id: nil)
+ .where("start_date > ?", today)
+ .where("user_custom_fields.name = ?", ::DiscourseCalendar::REGION_CUSTOM_FIELD)
+ .where("LENGTH(COALESCE(user_custom_fields.value, '')) > 0")
+ .where("user_custom_fields.value != calendar_events.region")
+ .destroy_all
+
+ regions_and_user_ids.each do |region, user_ids|
+ ::DiscourseCalendar::Holiday
+ .find_holidays_for(
+ region_code: region,
+ start_date: today,
+ end_date: 6.months.from_now,
+ show_holiday_observed_on_dates: true,
+ )
+ .filter { |holiday| (1..5) === holiday[:date].wday && holiday[:disabled] === false }
+ .each do |holiday|
+ user_ids.each do |user_id|
+ next unless usernames[user_id]
+
+ date = holiday[:date]
+
+ if tz = timezones[user_id]
+ date = holiday[:date].in_time_zone(tz)
+ date = date.change(hour_adjustment) if hour_adjustment
end
- ),
- ]
- end
- .to_h
-
- # Remove holidays for deactivated/suspended/silenced users
- CalendarEvent.where(post_id: nil).where.not(user_id: usernames.keys).destroy_all
-
- # Remove future holidays when users changed their region
- CalendarEvent
- .joins(user: :_custom_fields)
- .where(post_id: nil)
- .where("start_date > ?", today)
- .where("user_custom_fields.name = ?", ::DiscourseCalendar::REGION_CUSTOM_FIELD)
- .where("LENGTH(COALESCE(user_custom_fields.value, '')) > 0")
- .where("user_custom_fields.value != calendar_events.region")
- .destroy_all
-
- regions_and_user_ids.each do |region, user_ids|
- DiscourseCalendar::Holiday
- .find_holidays_for(
- region_code: region,
- start_date: today,
- end_date: 6.months.from_now,
- show_holiday_observed_on_dates: true,
- )
- .filter { |holiday| (1..5) === holiday[:date].wday && holiday[:disabled] === false }
- .each do |holiday|
- user_ids.each do |user_id|
- next unless usernames[user_id]
-
- date = holiday[:date]
-
- if tz = timezones[user_id]
- date = holiday[:date].in_time_zone(tz)
- date = date.change(hour_adjustment) if hour_adjustment
- end
- event =
- CalendarEvent
- .where(topic_id: topic_id, user_id: user_id, description: holiday[:name])
- .where(
- "start_date >= :from AND start_date <= :to",
- from: date - 1.day,
- to: date + 1.day,
- )
- .first_or_initialize
-
- event.update!(
- topic_id: topic_id,
- user_id: user_id,
- description: holiday[:name],
- start_date: date,
- region: region,
- username: usernames[user_id],
- timezone: tz&.name,
- )
+ event =
+ CalendarEvent
+ .where(topic_id: topic_id, user_id: user_id, description: holiday[:name])
+ .where(
+ "start_date >= :from AND start_date <= :to",
+ from: date - 1.day,
+ to: date + 1.day,
+ )
+ .first_or_initialize
+
+ event.update!(
+ topic_id: topic_id,
+ user_id: user_id,
+ description: holiday[:name],
+ start_date: date,
+ region: region,
+ username: usernames[user_id],
+ timezone: tz&.name,
+ )
+ end
end
- end
- end
- end
-
- def hour_adjustment
- if SiteSetting.all_day_event_start_time.empty? || SiteSetting.all_day_event_end_time.empty?
- return
+ end
end
- @holiday_hour ||=
- begin
- split = SiteSetting.all_day_event_start_time.split(":")
- { hour: split.first, min: split.second }
+ def hour_adjustment
+ if SiteSetting.all_day_event_start_time.empty? || SiteSetting.all_day_event_end_time.empty?
+ return
end
+
+ @holiday_hour ||=
+ begin
+ split = SiteSetting.all_day_event_start_time.split(":")
+ { hour: split.first, min: split.second }
+ end
+ end
end
end
end
diff --git a/plugins/discourse-calendar/jobs/scheduled/delete_expired_event_posts.rb b/plugins/discourse-calendar/jobs/scheduled/delete_expired_event_posts.rb
index b386a158c21..0b97a401bea 100644
--- a/plugins/discourse-calendar/jobs/scheduled/delete_expired_event_posts.rb
+++ b/plugins/discourse-calendar/jobs/scheduled/delete_expired_event_posts.rb
@@ -1,56 +1,58 @@
# frozen_string_literal: true
module Jobs
- class ::DiscourseCalendar::DeleteExpiredEventPosts < ::Jobs::Scheduled
- every 10.minutes
+ module DiscourseCalendar
+ class DeleteExpiredEventPosts < ::Jobs::Scheduled
+ every 10.minutes
- def execute(args)
- return unless SiteSetting.calendar_enabled
+ def execute(args)
+ return unless SiteSetting.calendar_enabled
- delay = SiteSetting.delete_expired_event_posts_after
- return if delay < 0
+ delay = SiteSetting.delete_expired_event_posts_after
+ return if delay < 0
- calendar_topic_ids =
- Post
- .joins(:_custom_fields)
- .where(post_custom_fields: { name: DiscourseCalendar::CALENDAR_CUSTOM_FIELD })
- .pluck(:topic_id)
+ calendar_topic_ids =
+ Post
+ .joins(:_custom_fields)
+ .where(post_custom_fields: { name: ::DiscourseCalendar::CALENDAR_CUSTOM_FIELD })
+ .pluck(:topic_id)
- post_events =
- CalendarEvent
- .joins(:post, :topic)
- .where(topic_id: calendar_topic_ids)
- .where("TRIM(COALESCE(calendar_events.recurrence, '')) = ''")
- .where("NOT topics.closed AND NOT topics.archived")
+ post_events =
+ CalendarEvent
+ .joins(:post, :topic)
+ .where(topic_id: calendar_topic_ids)
+ .where("TRIM(COALESCE(calendar_events.recurrence, '')) = ''")
+ .where("NOT topics.closed AND NOT topics.archived")
- event_post_ids = post_events.pluck(:post_id).to_set
+ event_post_ids = post_events.pluck(:post_id).to_set
- post_events.each do |event|
- end_date = event.end_date.presence || event.start_date + 24.hours
- next if end_date + delay.hour > Time.current
+ post_events.each do |event|
+ end_date = event.end_date.presence || event.start_date + 24.hours
+ next if end_date + delay.hour > Time.current
- # get all the replies to the post
- reply_ids = event.post.reply_ids(system_guardian)
- replies = Post.where(id: reply_ids.map { |r| r[:id] })
+ # get all the replies to the post
+ reply_ids = event.post.reply_ids(system_guardian)
+ replies = Post.where(id: reply_ids.map { |r| r[:id] })
- # only delete replies that have no event
- replies.each { |reply| destroy_post(reply) if !event_post_ids.include?(reply.id) }
+ # only delete replies that have no event
+ replies.each { |reply| destroy_post(reply) if !event_post_ids.include?(reply.id) }
- # delete the post
- destroy_post(event.post)
+ # delete the post
+ destroy_post(event.post)
+ end
end
- end
- def destroy_post(post)
- PostDestroyer.new(
- Discourse.system_user,
- post,
- context: I18n.t("discourse_calendar.event_expired"),
- ).destroy
- end
+ def destroy_post(post)
+ PostDestroyer.new(
+ Discourse.system_user,
+ post,
+ context: I18n.t("discourse_calendar.event_expired"),
+ ).destroy
+ end
- def system_guardian
- @system_guardian ||= Guardian.new(Discourse.system_user)
+ def system_guardian
+ @system_guardian ||= Guardian.new(Discourse.system_user)
+ end
end
end
end
diff --git a/plugins/discourse-calendar/jobs/scheduled/monitor_event_dates.rb b/plugins/discourse-calendar/jobs/scheduled/monitor_event_dates.rb
index a500264d8cb..4ca3d84e274 100644
--- a/plugins/discourse-calendar/jobs/scheduled/monitor_event_dates.rb
+++ b/plugins/discourse-calendar/jobs/scheduled/monitor_event_dates.rb
@@ -1,80 +1,84 @@
# frozen_string_literal: true
+
module Jobs
- class ::DiscourseCalendar::MonitorEventDates < ::Jobs::Scheduled
- every 1.minute
+ module DiscourseCalendar
+ class MonitorEventDates < ::Jobs::Scheduled
+ every 1.minute
- def execute(args)
- DiscoursePostEvent::EventDate.pending.find_each do |event_date|
- send_reminder(event_date)
- trigger_events(event_date)
- finish(event_date)
+ def execute(args)
+ DiscoursePostEvent::EventDate.pending.find_each do |event_date|
+ send_reminder(event_date)
+ trigger_events(event_date)
+ finish(event_date)
+ end
end
- end
- def send_reminder(event_date)
- due_reminders(event_date).each do |reminder|
- ::Jobs.enqueue(
- :discourse_post_event_send_reminder,
- event_id: event_date.event.id,
- reminder: reminder[:description],
- )
- event_date.update!(reminder_counter: event_date.reminder_counter + 1)
+ def send_reminder(event_date)
+ due_reminders(event_date).each do |reminder|
+ ::Jobs.enqueue(
+ :discourse_post_event_send_reminder,
+ event_id: event_date.event.id,
+ reminder: reminder[:description],
+ )
+ event_date.update!(reminder_counter: event_date.reminder_counter + 1)
+ end
end
- end
- def trigger_events(event_date)
- if event_date.starts_at - 1.hour <= Time.current && event_date.event_will_start_sent_at.blank?
- event_date.update!(event_will_start_sent_at: DateTime.now)
- DiscourseEvent.trigger(:discourse_post_event_event_will_start, event_date.event)
- end
+ def trigger_events(event_date)
+ if event_date.starts_at - 1.hour <= Time.current &&
+ event_date.event_will_start_sent_at.blank?
+ event_date.update!(event_will_start_sent_at: DateTime.now)
+ DiscourseEvent.trigger(:discourse_post_event_event_will_start, event_date.event)
+ end
- if event_date.started? && event_date.event_started_sent_at.blank?
- event_date.update!(event_started_sent_at: DateTime.now)
- DiscourseEvent.trigger(:discourse_post_event_event_started, event_date.event)
+ if event_date.started? && event_date.event_started_sent_at.blank?
+ event_date.update!(event_started_sent_at: DateTime.now)
+ DiscourseEvent.trigger(:discourse_post_event_event_started, event_date.event)
+ end
end
- end
- def finish(event_date)
- return if !event_date.ended?
- event_date.update!(finished_at: Time.current)
+ def finish(event_date)
+ return if !event_date.ended?
+ event_date.update!(finished_at: Time.current)
- DiscourseEvent.trigger(:discourse_post_event_event_ended, event_date.event)
- MessageBus.publish(
- "/topic/#{event_date.event.post.topic_id}",
- reload_topic: true,
- refresh_stream: true,
- )
+ DiscourseEvent.trigger(:discourse_post_event_event_ended, event_date.event)
+ MessageBus.publish(
+ "/topic/#{event_date.event.post.topic_id}",
+ reload_topic: true,
+ refresh_stream: true,
+ )
- return if event_date.event.recurrence.blank?
- event_date.event.set_next_date
- event_date.event.set_topic_bump
- end
+ return if event_date.event.recurrence.blank?
+ event_date.event.set_next_date
+ event_date.event.set_topic_bump
+ end
- def due_reminders(event_date)
- return [] if event_date.event.reminders.blank?
- event_date
- .event
- .reminders
- .split(",")
- .map do |reminder|
- unit, value, type = reminder.split(".").reverse
+ def due_reminders(event_date)
+ return [] if event_date.event.reminders.blank?
+ event_date
+ .event
+ .reminders
+ .split(",")
+ .map do |reminder|
+ unit, value, type = reminder.split(".").reverse
- next if type === "bumpTopic" || !validate_reminder_unit(unit)
- reminder = "notification.#{value}.#{unit}" if type.blank?
+ next if type === "bumpTopic" || !validate_reminder_unit(unit)
+ reminder = "notification.#{value}.#{unit}" if type.blank?
- date = event_date.starts_at - value.to_i.public_send(unit)
- { description: reminder, date: date }
- end
- .compact
- .select { |reminder| reminder[:date] <= Time.current }
- .sort_by { |reminder| reminder[:date] }
- .drop(event_date.reminder_counter)
- end
+ date = event_date.starts_at - value.to_i.public_send(unit)
+ { description: reminder, date: date }
+ end
+ .compact
+ .select { |reminder| reminder[:date] <= Time.current }
+ .sort_by { |reminder| reminder[:date] }
+ .drop(event_date.reminder_counter)
+ end
- private
+ private
- def validate_reminder_unit(input)
- ActiveSupport::Duration::PARTS.any? { |part| part.to_s == input }
+ def validate_reminder_unit(input)
+ ActiveSupport::Duration::PARTS.any? { |part| part.to_s == input }
+ end
end
end
end
diff --git a/plugins/discourse-calendar/jobs/scheduled/update_holiday_usernames.rb b/plugins/discourse-calendar/jobs/scheduled/update_holiday_usernames.rb
index b7c4b9a22bc..df2cd2e95b2 100644
--- a/plugins/discourse-calendar/jobs/scheduled/update_holiday_usernames.rb
+++ b/plugins/discourse-calendar/jobs/scheduled/update_holiday_usernames.rb
@@ -1,53 +1,55 @@
# frozen_string_literal: true
module Jobs
- class ::DiscourseCalendar::UpdateHolidayUsernames < ::Jobs::Scheduled
- every 10.minutes
+ module DiscourseCalendar
+ class UpdateHolidayUsernames < ::Jobs::Scheduled
+ every 10.minutes
- def execute(args)
- return unless SiteSetting.calendar_enabled
- return unless topic_id = SiteSetting.holiday_calendar_topic_id.presence
+ def execute(args)
+ return unless SiteSetting.calendar_enabled
+ return unless topic_id = SiteSetting.holiday_calendar_topic_id.presence
- events = CalendarEvent.where(topic_id: topic_id)
- users_on_holiday = DiscourseCalendar::UsersOnHoliday.from(events)
+ events = CalendarEvent.where(topic_id: topic_id)
+ users_on_holiday = ::DiscourseCalendar::UsersOnHoliday.from(events)
- DiscourseCalendar.users_on_holiday = users_on_holiday.values.map { |u| u[:username] }
- synchronize_user_custom_fields(users_on_holiday)
- set_holiday_statuses(users_on_holiday)
- end
+ ::DiscourseCalendar.users_on_holiday = users_on_holiday.values.map { |u| u[:username] }
+ synchronize_user_custom_fields(users_on_holiday)
+ set_holiday_statuses(users_on_holiday)
+ end
- private
+ private
- def synchronize_user_custom_fields(users_on_holiday)
- custom_field_name = DiscourseCalendar::HOLIDAY_CUSTOM_FIELD
+ def synchronize_user_custom_fields(users_on_holiday)
+ custom_field_name = ::DiscourseCalendar::HOLIDAY_CUSTOM_FIELD
- if users_on_holiday.present?
- user_ids = users_on_holiday.keys
- values = user_ids.map { |id| "(#{id}, '#{custom_field_name}', 't', now(), now())" }
+ if users_on_holiday.present?
+ user_ids = users_on_holiday.keys
+ values = user_ids.map { |id| "(#{id}, '#{custom_field_name}', 't', now(), now())" }
- DB.exec <<~SQL, custom_field_name
+ DB.exec <<~SQL, custom_field_name
INSERT INTO user_custom_fields (user_id, name, value, created_at, updated_at)
VALUES #{values.join(",")}
ON CONFLICT (user_id, name) WHERE (name = ?) DO NOTHING
SQL
- DB.exec <<~SQL, custom_field_name, user_ids
+ DB.exec <<~SQL, custom_field_name, user_ids
DELETE FROM user_custom_fields
WHERE name = ?
AND user_id NOT IN (?)
SQL
- else
- DB.exec("DELETE FROM user_custom_fields WHERE name = ?", custom_field_name)
+ else
+ DB.exec("DELETE FROM user_custom_fields WHERE name = ?", custom_field_name)
+ end
end
- end
- def set_holiday_statuses(users_on_holiday)
- return if !SiteSetting.enable_user_status
+ def set_holiday_statuses(users_on_holiday)
+ return if !SiteSetting.enable_user_status
- User
- .where(id: users_on_holiday.keys)
- .includes(:user_status)
- .each { |u| DiscourseCalendar::HolidayStatus.set!(u, users_on_holiday[u.id][:ends_at]) }
+ User
+ .where(id: users_on_holiday.keys)
+ .includes(:user_status)
+ .each { |u| ::DiscourseCalendar::HolidayStatus.set!(u, users_on_holiday[u.id][:ends_at]) }
+ end
end
end
end
diff --git a/plugins/discourse-calendar/lib/discourse_calendar/engine.rb b/plugins/discourse-calendar/lib/discourse_calendar/engine.rb
index 281db7e2c45..5efdc1f0aaf 100644
--- a/plugins/discourse-calendar/lib/discourse_calendar/engine.rb
+++ b/plugins/discourse-calendar/lib/discourse_calendar/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseCalendar
+module DiscourseCalendar
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseCalendar
diff --git a/plugins/discourse-calendar/spec/integration/post_spec.rb b/plugins/discourse-calendar/spec/integration/post_spec.rb
index 1c03ae07824..31c27e1df5e 100644
--- a/plugins/discourse-calendar/spec/integration/post_spec.rb
+++ b/plugins/discourse-calendar/spec/integration/post_spec.rb
@@ -687,7 +687,7 @@ describe Post do
raw = 'Vacation [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]'
post = create_post(raw: raw, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ Jobs::DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
# the job has set the holiday status:
status = post.user.user_status
@@ -708,7 +708,7 @@ describe Post do
raw = 'Vacation [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]'
post = create_post(raw: raw, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ Jobs::DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
# the job has set the holiday status:
status = post.user.user_status
diff --git a/plugins/discourse-calendar/spec/jobs/scheduled/create_holiday_events_spec.rb b/plugins/discourse-calendar/spec/jobs/scheduled/create_holiday_events_spec.rb
index d0d1b11e234..df5cd352653 100644
--- a/plugins/discourse-calendar/spec/jobs/scheduled/create_holiday_events_spec.rb
+++ b/plugins/discourse-calendar/spec/jobs/scheduled/create_holiday_events_spec.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
-describe DiscourseCalendar::CreateHolidayEvents do
+describe Jobs::DiscourseCalendar::CreateHolidayEvents do
+ subject(:job) { described_class.new }
+
let(:calendar_post) { create_post(raw: "[calendar]\n[/calendar]") }
let(:frenchy) do
@@ -21,7 +23,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
frenchy
freeze_time Time.zone.local(2019, 8, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.where(user_id: frenchy.id).count).to eq(0)
end
@@ -29,7 +31,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "adds all holidays in the next 6 months" do
frenchy
freeze_time Time.zone.local(2019, 8, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.pluck(:region, :description, :start_date, :user_id)).to match_array(
[
@@ -45,7 +47,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "checks for observed dates" do
aussie
freeze_time Time.zone.local(2020, 1, 20)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
# The "Australia Day" is always observed on a Monday
expect(CalendarEvent.pluck(:region, :description, :start_date, :user_id)).to match_array(
@@ -60,7 +62,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "only checks for holidays during business days" do
frenchy
freeze_time Time.zone.local(2019, 7, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
# The "Fête Nationale" is on July 14th but it's on a Sunday in 2019
expect(CalendarEvent.pluck(:region, :description, :start_date, :user_id)).to match_array(
@@ -104,48 +106,44 @@ describe DiscourseCalendar::CreateHolidayEvents do
},
)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.pluck(:region, :description, :start_date, :user_id)).to eq([])
end
it "does not create duplicates when username is changed" do
frenchy
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
created_event = CalendarEvent.last
expect(created_event.username).to eq(frenchy.username)
frenchy.update!(username: "new_username")
- expect { DiscourseCalendar::CreateHolidayEvents.new.execute(nil) }.not_to change {
- CalendarEvent.count
- }
+ expect { job.execute(nil) }.not_to change { CalendarEvent.count }
expect(created_event.reload.username).to eq("new_username")
end
it "does not create duplicates when timezone is changed" do
frenchy
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
created_event = CalendarEvent.last
expect(created_event.timezone).to eq(frenchy.user_option.timezone)
frenchy.user_option.update!(timezone: "Asia/Taipei")
- expect { DiscourseCalendar::CreateHolidayEvents.new.execute(nil) }.not_to change {
- CalendarEvent.count
- }
+ expect { job.execute(nil) }.not_to change { CalendarEvent.count }
expect(created_event.reload.timezone).to eq("Asia/Taipei")
end
it "cleans up holidays from deactivated/silenced/suspended users" do
frenchy
freeze_time Time.zone.local(2019, 8, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.exists?(user_id: frenchy.id)).to eq(true)
frenchy.active = false
frenchy.save!
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.exists?(user_id: frenchy.id)).to eq(false)
end
@@ -153,7 +151,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "cleans up holidays from users who changed their region" do
frenchy
freeze_time Time.zone.local(2019, 8, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.exists?(user_id: frenchy.id)).to eq(true)
@@ -162,7 +160,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
freeze_time Time.zone.local(2020, 1, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
# Past 'fr' holidays should not be removed
expect(
@@ -204,7 +202,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "only adds enabled holidays to the calendar" do
frenchy
freeze_time Time.zone.local(2019, 7, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.pluck(:region, :description, :start_date, :user_id)).to match_array(
[
@@ -218,7 +216,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "doesn't add disabled holidays to the calendar" do
frenchy
freeze_time Time.zone.local(2019, 7, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.pluck(:description)).not_to include(france_assomption[:holiday_name])
expect(CalendarEvent.pluck(:description)).not_to include(france_toussaint[:holiday_name])
@@ -229,7 +227,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "uses the user TZ when available" do
frenchy.user_option.update!(timezone: "Europe/Paris")
freeze_time Time.zone.local(2019, 8, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
calendar_event = CalendarEvent.first
expect(calendar_event.region).to eq("fr")
@@ -248,7 +246,7 @@ describe DiscourseCalendar::CreateHolidayEvents do
it "uses the user TZ when available" do
frenchy.user_option.update!(timezone: "Europe/Paris")
freeze_time Time.zone.local(2019, 8, 1)
- DiscourseCalendar::CreateHolidayEvents.new.execute(nil)
+ job.execute(nil)
calendar_event = CalendarEvent.first
expect(calendar_event.region).to eq("fr")
diff --git a/plugins/discourse-calendar/spec/jobs/scheduled/delete_expired_event_posts_spec.rb b/plugins/discourse-calendar/spec/jobs/scheduled/delete_expired_event_posts_spec.rb
index a9256230609..a7f0c13f8b1 100644
--- a/plugins/discourse-calendar/spec/jobs/scheduled/delete_expired_event_posts_spec.rb
+++ b/plugins/discourse-calendar/spec/jobs/scheduled/delete_expired_event_posts_spec.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
-describe DiscourseCalendar::DeleteExpiredEventPosts do
+describe Jobs::DiscourseCalendar::DeleteExpiredEventPosts do
+ subject(:job) { described_class.new }
+
before do
Jobs.run_immediately!
SiteSetting.calendar_enabled = true
@@ -25,7 +27,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
raw: "Summer ☀️ Solstice [date=#{Date.current.year + 1}-06-21]",
)
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(Post.exists?(post_with_one_date.id)).to eq(false)
expect(Post.exists?(post_with_two_dates.id)).to eq(false)
@@ -51,7 +53,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
description: "Matariki",
)
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(CalendarEvent.exists?(matariki.id)).to eq(true)
end
@@ -60,7 +62,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
post = create_post(raw: "Discourse 💬 Launch 🚀 on [date=2013-02-05]")
CalendarEvent.create!(topic: post.topic, post: post, start_date: Date.new(2013, 2, 5))
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(Post.exists?(post.id)).to eq(true)
end
@@ -72,7 +74,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
raw: 'WWW - Weekly Wednesday Watercooler [date=2022-01-05 recurring="1.week"] 🐸',
)
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(Post.exists?(post.id)).to eq(true)
end
@@ -86,7 +88,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
calendar_topic.update!(archived: true)
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(Post.exists?(post.id)).to eq(true)
end
@@ -100,7 +102,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
calendar_topic.update!(closed: true)
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(Post.exists?(post.id)).to eq(true)
end
@@ -151,7 +153,7 @@ describe DiscourseCalendar::DeleteExpiredEventPosts do
freeze_time Time.parse("2018-10-01 00:00:00 UTC")
- DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil)
+ job.execute(nil)
expect(Post.exists?(post.id)).to eq(false)
expect(Post.exists?(reply_without_event.id)).to eq(false)
diff --git a/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb b/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb
index 6259c9f11e3..a240873ed06 100644
--- a/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb
+++ b/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
-describe DiscourseCalendar::MonitorEventDates do
+describe Jobs::DiscourseCalendar::MonitorEventDates do
+ subject(:job) { described_class.new }
+
fab!(:post_1) { Fabricate(:post) }
fab!(:post_2) { Fabricate(:post) }
fab!(:post_3) { Fabricate(:post) }
@@ -31,9 +33,7 @@ describe DiscourseCalendar::MonitorEventDates do
describe "#send_reminder" do
it "lodge reminder jobs in correct times" do
- expect_not_enqueued_with(job: :discourse_post_event_send_reminder) do
- described_class.new.execute({})
- end
+ expect_not_enqueued_with(job: :discourse_post_event_send_reminder) { job.execute({}) }
freeze_time(7.days.after - 59.minutes)
expect_enqueued_with(
@@ -42,7 +42,7 @@ describe DiscourseCalendar::MonitorEventDates do
event_id: past_event.id,
reminder: "notification.1.hours",
},
- ) { described_class.new.execute({}) }
+ ) { job.execute({}) }
freeze_time(7.days.after - 14.minutes)
expect_enqueued_with(
@@ -51,7 +51,7 @@ describe DiscourseCalendar::MonitorEventDates do
event_id: past_event.id,
reminder: "notification.15.minutes",
},
- ) { described_class.new.execute({}) }
+ ) { job.execute({}) }
freeze_time(7.days.after - 9.minutes)
expect_not_enqueued_with(
@@ -60,26 +60,22 @@ describe DiscourseCalendar::MonitorEventDates do
event_id: past_event.id,
reminder: "notification.10.minutes",
},
- ) { described_class.new.execute({}) }
+ ) { job.execute({}) }
freeze_time 7.days.after
- expect_not_enqueued_with(job: :discourse_post_event_send_reminder) do
- described_class.new.execute({})
- end
+ expect_not_enqueued_with(job: :discourse_post_event_send_reminder) { job.execute({}) }
end
it "does not lodge reminder jobs when event is deleted" do
freeze_time(7.days.after - 59.minutes)
past_event.update!(deleted_at: Time.now)
- expect_not_enqueued_with(job: :discourse_post_event_send_reminder) do
- described_class.new.execute({})
- end
+ expect_not_enqueued_with(job: :discourse_post_event_send_reminder) { job.execute({}) }
end
end
describe "#trigger_events" do
it "sends singe event 1 hours before and when due" do
- events = DiscourseEvent.track_events { described_class.new.execute({}) }
+ events = DiscourseEvent.track_events { job.execute({}) }
expect(events).not_to include(
event_name: :discourse_post_event_event_will_start,
params: [past_event],
@@ -89,10 +85,10 @@ describe DiscourseCalendar::MonitorEventDates do
params: [past_event],
)
- events = DiscourseEvent.track_events { described_class.new.execute({}) }
+ events = DiscourseEvent.track_events { job.execute({}) }
freeze_time(7.days.after - 59.minutes)
- events = DiscourseEvent.track_events { described_class.new.execute({}) }
+ events = DiscourseEvent.track_events { job.execute({}) }
expect(events).to include(
event_name: :discourse_post_event_event_will_start,
params: [past_event],
@@ -103,7 +99,7 @@ describe DiscourseCalendar::MonitorEventDates do
)
freeze_time(7.days.after)
- events = DiscourseEvent.track_events { described_class.new.execute({}) }
+ events = DiscourseEvent.track_events { job.execute({}) }
expect(events).not_to include(
event_name: :discourse_post_event_event_will_start,
params: [past_event],
@@ -113,7 +109,7 @@ describe DiscourseCalendar::MonitorEventDates do
params: [past_event],
)
- events = DiscourseEvent.track_events { described_class.new.execute({}) }
+ events = DiscourseEvent.track_events { job.execute({}) }
expect(events).not_to include(
event_name: :discourse_post_event_event_will_start,
params: [past_event],
@@ -127,13 +123,13 @@ describe DiscourseCalendar::MonitorEventDates do
describe "#finish" do
it "finishes past event" do
- described_class.new.execute({})
+ job.execute({})
expect(future_date.finished_at).to eq(nil)
expect(past_date.finished_at).to eq(nil)
freeze_time 8.days.after
- described_class.new.execute({})
+ job.execute({})
future_date.reload
expect(future_date.finished_at).to eq(nil)
expect(past_event.event_dates.pending.count).to eq(0)
@@ -149,7 +145,7 @@ describe DiscourseCalendar::MonitorEventDates do
freeze_time 8.days.after
- events = DiscourseEvent.track_events { described_class.new.execute({}) }
+ events = DiscourseEvent.track_events { job.execute({}) }
expect(future_date.finished_at).to eq(nil)
expect(past_event.event_dates.pending.count).to eq(1)
@@ -193,10 +189,9 @@ describe DiscourseCalendar::MonitorEventDates do
it "doesn’t list events with invalid reminders" do
freeze_time(7.days.after - 1.minutes)
- event_dates_monitor = DiscourseCalendar::MonitorEventDates.new
- expect(event_dates_monitor.due_reminders(invalid_event.event_dates.first)).to be_blank
- expect(event_dates_monitor.due_reminders(valid_event.event_dates.first).length).to eq(1)
+ expect(job.due_reminders(invalid_event.event_dates.first)).to be_blank
+ expect(job.due_reminders(valid_event.event_dates.first).length).to eq(1)
end
end
end
diff --git a/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb b/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb
index 41381b483de..db3e05e690e 100644
--- a/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb
+++ b/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
-describe DiscourseCalendar::UpdateHolidayUsernames do
+describe Jobs::DiscourseCalendar::UpdateHolidayUsernames do
+ subject(:job) { described_class.new }
+
let(:calendar_post) { create_post(raw: "[calendar]\n[/calendar]") }
before do
@@ -15,12 +17,12 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]'
post = create_post(raw: raw, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
expect(DiscourseCalendar.users_on_holiday).to eq([post.user.username])
freeze_time Time.utc(2018, 6, 7, 18, 40)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
expect(DiscourseCalendar.users_on_holiday).to eq([])
end
@@ -34,7 +36,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
raw2 = 'Rome [date="2018-06-05"]' # the whole day
post2 = create_post(raw: raw2, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
expect(
UserCustomField.exists?(
name: DiscourseCalendar::HOLIDAY_CUSTOM_FIELD,
@@ -49,7 +51,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
).to be_truthy
freeze_time Time.utc(2018, 6, 6, 10, 00)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
expect(
UserCustomField.exists?(
name: DiscourseCalendar::HOLIDAY_CUSTOM_FIELD,
@@ -64,7 +66,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
).to be_falsey
freeze_time Time.utc(2018, 6, 7, 10, 00)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
expect(
UserCustomField.exists?(
name: DiscourseCalendar::HOLIDAY_CUSTOM_FIELD,
@@ -86,7 +88,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]'
post = create_post(raw: raw, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
post.user.reload
status = post.user.user_status
@@ -103,7 +105,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]'
post = create_post(raw: raw, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
post.user.reload
expect(post.user.user_status).to be_nil
@@ -118,7 +120,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
custom_status = { description: "I am working on holiday", emoji: "construction_worker_man" }
post.user.set_status!(custom_status[:description], custom_status[:emoji])
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
post.user.reload
status = post.user.user_status
@@ -149,7 +151,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
)
freeze_time tomorrow + 2.day
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
post.user.reload
status = post.user.user_status
@@ -166,7 +168,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]'
post = create_post(raw: raw, topic: calendar_post.topic)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
post.user.reload
expect(post.user.user_status).to be_present
@@ -178,7 +180,7 @@ describe DiscourseCalendar::UpdateHolidayUsernames do
{ raw: 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-12-10" time="10:20:00"]' },
revised_at: Time.now,
)
- DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil)
+ job.execute(nil)
post.user.reload
expect(post.user.user_status).to be_present
diff --git a/plugins/discourse-calendar/spec/lib/calendar_first_day_of_week_spec.rb b/plugins/discourse-calendar/spec/lib/calendar_first_day_of_week_spec.rb
index 176264d7712..c130dfb935f 100644
--- a/plugins/discourse-calendar/spec/lib/calendar_first_day_of_week_spec.rb
+++ b/plugins/discourse-calendar/spec/lib/calendar_first_day_of_week_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "rails_helper"
-
describe SiteSetting do
before { SiteSetting.calendar_enabled = true }
diff --git a/plugins/discourse-calendar/spec/serializers/post_serializer_spec.rb b/plugins/discourse-calendar/spec/serializers/post_serializer_spec.rb
index 31fa158013f..0dbf5266996 100644
--- a/plugins/discourse-calendar/spec/serializers/post_serializer_spec.rb
+++ b/plugins/discourse-calendar/spec/serializers/post_serializer_spec.rb
@@ -32,18 +32,18 @@ describe PostSerializer do
it "groups calendar events correctly" do
user = Fabricate(:user)
- user.upsert_custom_fields(::DiscourseCalendar::REGION_CUSTOM_FIELD => "ar")
+ user.upsert_custom_fields(DiscourseCalendar::REGION_CUSTOM_FIELD => "ar")
user.user_option.update!(timezone: "America/Buenos_Aires")
user2 = Fabricate(:user)
- user2.upsert_custom_fields(::DiscourseCalendar::REGION_CUSTOM_FIELD => "ar")
+ user2.upsert_custom_fields(DiscourseCalendar::REGION_CUSTOM_FIELD => "ar")
user2.user_option.update!(timezone: "America/Buenos_Aires")
post = create_post(raw: "[calendar]\n[/calendar]")
SiteSetting.holiday_calendar_topic_id = post.topic.id
freeze_time Date.new(2021, 4, 1)
- ::DiscourseCalendar::CreateHolidayEvents.new.execute({})
+ Jobs::DiscourseCalendar::CreateHolidayEvents.new.execute({})
json = PostSerializer.new(post.reload, scope: Guardian.new).as_json
expect(
@@ -64,7 +64,7 @@ describe PostSerializer do
)
freeze_time Date.new(2022, 4, 1)
- ::DiscourseCalendar::CreateHolidayEvents.new.execute({})
+ Jobs::DiscourseCalendar::CreateHolidayEvents.new.execute({})
json = PostSerializer.new(post.reload, scope: Guardian.new).as_json
expect(json[:post][:calendar_details].map { |x| { x[:from].year => x[:name] } }).to include(
diff --git a/plugins/discourse-chat-integration/app/controllers/chat_controller.rb b/plugins/discourse-chat-integration/app/controllers/chat_controller.rb
index 9d09cae3ece..ef0804f8377 100644
--- a/plugins/discourse-chat-integration/app/controllers/chat_controller.rb
+++ b/plugins/discourse-chat-integration/app/controllers/chat_controller.rb
@@ -9,7 +9,7 @@ class DiscourseChatIntegration::ChatController < ApplicationController
def list_providers
providers =
- ::DiscourseChatIntegration::Provider.enabled_providers.map do |x|
+ DiscourseChatIntegration::Provider.enabled_providers.map do |x|
{
name: x::PROVIDER_NAME,
id: x::PROVIDER_NAME,
@@ -26,8 +26,7 @@ class DiscourseChatIntegration::ChatController < ApplicationController
topic_id = params[:topic_id].to_i
channel = DiscourseChatIntegration::Channel.find(channel_id)
-
- provider = ::DiscourseChatIntegration::Provider.get_by_name(channel.provider)
+ provider = DiscourseChatIntegration::Provider.get_by_name(channel.provider)
raise Discourse::NotFound if !DiscourseChatIntegration::Provider.is_enabled(provider)
@@ -49,7 +48,7 @@ class DiscourseChatIntegration::ChatController < ApplicationController
end
def list_channels
- providers = ::DiscourseChatIntegration::Provider.enabled_provider_names
+ providers = DiscourseChatIntegration::Provider.enabled_provider_names
requested_provider = params[:provider]
raise Discourse::InvalidParameters if !providers.include?(requested_provider)
@@ -60,8 +59,7 @@ class DiscourseChatIntegration::ChatController < ApplicationController
def create_channel
begin
- providers =
- ::DiscourseChatIntegration::Provider.enabled_providers.map { |x| x::PROVIDER_NAME }
+ providers = DiscourseChatIntegration::Provider.enabled_providers.map { |x| x::PROVIDER_NAME }
if !defined?(params[:channel]) && defined?(params[:channel][:provider])
raise Discourse::InvalidParameters, "Provider is not valid"
diff --git a/plugins/discourse-chat-integration/app/initializers/discourse_chat_integration.rb b/plugins/discourse-chat-integration/app/initializers/discourse_chat_integration.rb
index e38dcd878e4..5f7d55b512b 100644
--- a/plugins/discourse-chat-integration/app/initializers/discourse_chat_integration.rb
+++ b/plugins/discourse-chat-integration/app/initializers/discourse_chat_integration.rb
@@ -1,16 +1,14 @@
# frozen_string_literal: true
-module ::DiscourseChatIntegration
- PLUGIN_NAME = "discourse-chat-integration".freeze
-
+module DiscourseChatIntegration
class AdminEngine < ::Rails::Engine
engine_name "#{PLUGIN_NAME}-admin"
- isolate_namespace ::DiscourseChatIntegration
+ isolate_namespace DiscourseChatIntegration
end
class PublicEngine < ::Rails::Engine
engine_name "#{PLUGIN_NAME}-public"
- isolate_namespace ::DiscourseChatIntegration
+ isolate_namespace DiscourseChatIntegration
end
def self.pstore_get(key)
diff --git a/plugins/discourse-chat-integration/app/jobs/regular/notify_chats.rb b/plugins/discourse-chat-integration/app/jobs/regular/notify_chats.rb
index fe7bbeee580..38d49292d16 100644
--- a/plugins/discourse-chat-integration/app/jobs/regular/notify_chats.rb
+++ b/plugins/discourse-chat-integration/app/jobs/regular/notify_chats.rb
@@ -6,7 +6,7 @@ module Jobs
def execute(args)
return if !SiteSetting.chat_integration_enabled?
- ::DiscourseChatIntegration::Manager.trigger_notifications(args[:post_id])
+ DiscourseChatIntegration::Manager.trigger_notifications(args[:post_id])
end
end
end
diff --git a/plugins/discourse-chat-integration/app/models/channel.rb b/plugins/discourse-chat-integration/app/models/channel.rb
index a27d5d8a378..f5126ad39c2 100644
--- a/plugins/discourse-chat-integration/app/models/channel.rb
+++ b/plugins/discourse-chat-integration/app/models/channel.rb
@@ -39,9 +39,9 @@ class DiscourseChatIntegration::Channel < DiscourseChatIntegration::PluginModel
def data_valid?
# If provider is invalid, don't try and check data
- return if ::DiscourseChatIntegration::Provider.provider_names.exclude? provider
+ return if DiscourseChatIntegration::Provider.provider_names.exclude? provider
- params = ::DiscourseChatIntegration::Provider.get_by_name(provider)::CHANNEL_PARAMETERS
+ params = DiscourseChatIntegration::Provider.get_by_name(provider)::CHANNEL_PARAMETERS
unless params.map { |p| p[:key] }.sort == data.keys.sort
errors.add(:data, "data does not match the required structure for provider #{provider}")
diff --git a/plugins/discourse-chat-integration/app/routes/discourse.rb b/plugins/discourse-chat-integration/app/routes/discourse.rb
index 8b4246052c8..7b1ab9b846e 100644
--- a/plugins/discourse-chat-integration/app/routes/discourse.rb
+++ b/plugins/discourse-chat-integration/app/routes/discourse.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
Discourse::Application.routes.append do
- mount ::DiscourseChatIntegration::AdminEngine,
+ mount DiscourseChatIntegration::AdminEngine,
at: "/admin/plugins/chat-integration",
constraints: AdminConstraint.new
- mount ::DiscourseChatIntegration::PublicEngine, at: "/chat-transcript/", as: "chat-transcript"
- mount ::DiscourseChatIntegration::Provider::HookEngine, at: "/chat-integration/"
+ mount DiscourseChatIntegration::PublicEngine, at: "/chat-transcript/", as: "chat-transcript"
+ mount DiscourseChatIntegration::Provider::HookEngine, at: "/chat-integration/"
# For backwards compatibility with Slack plugin
post "/slack/command" =>
diff --git a/plugins/discourse-chat-integration/app/routes/discourse_chat_integration.rb b/plugins/discourse-chat-integration/app/routes/discourse_chat_integration.rb
index 86a98c5977a..b473af8a2c6 100644
--- a/plugins/discourse-chat-integration/app/routes/discourse_chat_integration.rb
+++ b/plugins/discourse-chat-integration/app/routes/discourse_chat_integration.rb
@@ -2,7 +2,7 @@
require_dependency "admin_constraint"
-module ::DiscourseChatIntegration
+module DiscourseChatIntegration
AdminEngine.routes.draw do
get "" => "chat#respond"
get "/providers" => "chat#list_providers"
diff --git a/plugins/discourse-chat-integration/app/services/manager.rb b/plugins/discourse-chat-integration/app/services/manager.rb
index 95791b2658a..7ec6d59e895 100644
--- a/plugins/discourse-chat-integration/app/services/manager.rb
+++ b/plugins/discourse-chat-integration/app/services/manager.rb
@@ -102,8 +102,8 @@ module DiscourseChatIntegration
matching_rules.each do |rule|
# If there are any issues, skip to the next rule
next unless channel = rule.channel
- next unless provider = ::DiscourseChatIntegration::Provider.get_by_name(channel.provider)
- next unless is_enabled = ::DiscourseChatIntegration::Provider.is_enabled(provider)
+ next unless provider = DiscourseChatIntegration::Provider.get_by_name(channel.provider)
+ next unless is_enabled = DiscourseChatIntegration::Provider.is_enabled(provider)
begin
provider.trigger_notification(post, channel, rule)
diff --git a/plugins/discourse-chat-integration/app/services/problem_check/channel_errors.rb b/plugins/discourse-chat-integration/app/services/problem_check/channel_errors.rb
index 833a5053254..be29e149f1b 100644
--- a/plugins/discourse-chat-integration/app/services/problem_check/channel_errors.rb
+++ b/plugins/discourse-chat-integration/app/services/problem_check/channel_errors.rb
@@ -14,8 +14,7 @@ class ProblemCheck::ChannelErrors < ProblemCheck
def channel_errors?
DiscourseChatIntegration::Channel.find_each.any? do |channel|
- channel.error_key.present? &&
- ::DiscourseChatIntegration::Provider.is_enabled(channel.provider)
+ channel.error_key.present? && DiscourseChatIntegration::Provider.is_enabled(channel.provider)
end
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb
index 28427d7a77a..e3783dbf246 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb
@@ -42,12 +42,12 @@ module DiscourseChatIntegration
end
class HookEngine < ::Rails::Engine
- engine_name DiscourseChatIntegration::PLUGIN_NAME + "-hooks"
- isolate_namespace DiscourseChatIntegration::Provider
+ engine_name PLUGIN_NAME + "-hooks"
+ isolate_namespace Provider
end
class HookController < ::ApplicationController
- requires_plugin DiscourseChatIntegration::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
class ProviderDisabled < StandardError
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb
index e1d155a3524..456d3593cdf 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb
@@ -35,7 +35,7 @@ module DiscourseChatIntegration
end
def self.generate_discord_message(post)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
@@ -99,7 +99,7 @@ module DiscourseChatIntegration
end
if !response.kind_of?(Net::HTTPSuccess)
- raise ::DiscourseChatIntegration::ProviderError.new(
+ raise DiscourseChatIntegration::ProviderError.new(
info: {
error_key: nil,
message: message,
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/flowdock/flowdock_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/flowdock/flowdock_provider.rb
index 59c12f26563..b3722e6ed29 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/flowdock/flowdock_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/flowdock/flowdock_provider.rb
@@ -20,7 +20,7 @@ module DiscourseChatIntegration::Provider::FlowdockProvider
end
def self.generate_flowdock_message(post, flow_token)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
message = {
flow_token: flow_token,
@@ -54,11 +54,11 @@ module DiscourseChatIntegration::Provider::FlowdockProvider
unless response.kind_of?(Net::HTTPSuccess)
error_key = nil
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- message: message,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ message: message,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/gitter/gitter_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/gitter/gitter_provider.rb
index 430377ccc0d..c23d89e71fd 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/gitter/gitter_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/gitter/gitter_provider.rb
@@ -21,11 +21,11 @@ module DiscourseChatIntegration
response = Net::HTTP.post_form(URI(channel.data["webhook_url"]), message: message)
unless response.kind_of? Net::HTTPSuccess
error_key = nil
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- message: message,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ message: message,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/google/google_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/google/google_provider.rb
index fbe54dc80e4..9fba9720b65 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/google/google_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/google/google_provider.rb
@@ -28,11 +28,11 @@ module DiscourseChatIntegration
response = http.request(req)
unless response.kind_of? Net::HTTPSuccess
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb
index c87ed17bc86..23b31f35c99 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb
@@ -6,7 +6,7 @@ module DiscourseChatIntegration::Provider::GroupmeProvider
CHANNEL_PARAMETERS = [{ key: "groupme_instance_name", regex: '[\s\S]*', unique: true }]
def self.generate_groupme_message(post)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
@@ -77,7 +77,7 @@ module DiscourseChatIntegration::Provider::GroupmeProvider
if last_error_raised
successfully_sent = instance_names.length() - num_errors
last_error_raised[:success_rate] = "#{successfully_sent}/#{instance_names.length()}"
- raise ::DiscourseChatIntegration::ProviderError.new info: last_error_raised
+ raise DiscourseChatIntegration::ProviderError.new info: last_error_raised
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb
index 8292517fe0b..ae507f7063e 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb
@@ -22,7 +22,7 @@ module DiscourseChatIntegration
response = send_message(webhook_url, message)
if !response.kind_of?(Net::HTTPSuccess)
- raise ::DiscourseChatIntegration::ProviderError.new(
+ raise DiscourseChatIntegration::ProviderError.new(
info: {
error_key: nil,
message: message,
@@ -45,7 +45,7 @@ module DiscourseChatIntegration
end
)
end
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
icon_url =
if (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/matrix/matrix_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/matrix/matrix_provider.rb
index de6101af47b..e4d0b1d4cfe 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/matrix/matrix_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/matrix/matrix_provider.rb
@@ -35,7 +35,7 @@ module DiscourseChatIntegration
end
def self.generate_matrix_message(post)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
message = {
msgtype: SiteSetting.chat_integration_matrix_use_notice ? "m.notice" : "m.text",
@@ -81,11 +81,11 @@ module DiscourseChatIntegration
error_key = "chat_integration.provider.matrix.errors.unknown_room"
end
ensure
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- message: message,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ message: message,
+ response_body: response.body,
+ }
end
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller.rb
index 64549a27cad..52b3cb42191 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller.rb
@@ -2,7 +2,7 @@
module DiscourseChatIntegration::Provider::MattermostProvider
class MattermostCommandController < DiscourseChatIntegration::Provider::HookController
- requires_provider ::DiscourseChatIntegration::Provider::MattermostProvider::PROVIDER_NAME
+ requires_provider DiscourseChatIntegration::Provider::MattermostProvider::PROVIDER_NAME
before_action :mattermost_token_valid?, only: :command
@@ -49,7 +49,7 @@ module DiscourseChatIntegration::Provider::MattermostProvider
},
)
- ::DiscourseChatIntegration::Helper.process_command(channel, tokens)
+ DiscourseChatIntegration::Helper.process_command(channel, tokens)
end
def mattermost_token_valid?
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb
index 387b5e81f09..b768015e98a 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb
@@ -23,17 +23,17 @@ module DiscourseChatIntegration
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
def self.mattermost_message(post, channel)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb
index d66a344ea3f..7feacc12f0b 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb
@@ -26,12 +26,12 @@ module DiscourseChatIntegration::Provider::PowerAutomateProvider
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb
index 2a9ebd89c8f..4ee99f2560c 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb
@@ -8,7 +8,7 @@ module DiscourseChatIntegration::Provider::RocketchatProvider
CHANNEL_PARAMETERS = [{ key: "identifier", regex: '^[@#]\S*$', unique: true }]
def self.rocketchat_message(post, channel)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
@@ -67,12 +67,12 @@ module DiscourseChatIntegration::Provider::RocketchatProvider
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_command_controller.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_command_controller.rb
index 31d972d4ff7..9f3b73bc87c 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_command_controller.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_command_controller.rb
@@ -2,7 +2,7 @@
module DiscourseChatIntegration::Provider::SlackProvider
class SlackCommandController < DiscourseChatIntegration::Provider::HookController
- requires_provider ::DiscourseChatIntegration::Provider::SlackProvider::PROVIDER_NAME
+ requires_provider DiscourseChatIntegration::Provider::SlackProvider::PROVIDER_NAME
before_action :slack_token_valid?, only: :command
before_action :slack_payload_token_valid?, only: :interactive
@@ -66,7 +66,7 @@ module DiscourseChatIntegration::Provider::SlackProvider
params[:response_url],
)
else
- { text: ::DiscourseChatIntegration::Helper.process_command(channel, tokens) }
+ { text: DiscourseChatIntegration::Helper.process_command(channel, tokens) }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb
index 6c8ab9b5e3c..608a00d3e52 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb
@@ -31,7 +31,7 @@ module DiscourseChatIntegration::Provider::SlackProvider
end
def self.slack_message(post, channel, filter)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
@@ -88,7 +88,7 @@ module DiscourseChatIntegration::Provider::SlackProvider
end
def self.create_slack_message(context:, content:, url:, channel_name:)
- sender = ::DiscourseChatIntegration::Helper.formatted_display_name(Discourse.system_user)
+ sender = DiscourseChatIntegration::Helper.formatted_display_name(Discourse.system_user)
content = replace_placehoders(content, context) if context["kind"] ==
DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED
@@ -188,11 +188,11 @@ module DiscourseChatIntegration::Provider::SlackProvider
response = http.request(req)
unless response.kind_of? Net::HTTPSuccess
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- request: uri,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ request: uri,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
json = JSON.parse(response.body)
@@ -204,12 +204,12 @@ module DiscourseChatIntegration::Provider::SlackProvider
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: uri,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: uri,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
ts = json.dig("message", "thread_ts") || json["ts"]
@@ -237,12 +237,12 @@ module DiscourseChatIntegration::Provider::SlackProvider
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb
index 8b648b587bd..bfcec1a547c 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb
@@ -264,7 +264,7 @@ module DiscourseChatIntegration::Provider::SlackProvider
end
def fetch_user_data
- http = ::DiscourseChatIntegration::Provider::SlackProvider.slack_api_http
+ http = DiscourseChatIntegration::Provider::SlackProvider.slack_api_http
cursor = nil
req = Net::HTTP::Post.new(URI("https://slack.com/api/users.list"))
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb
index cac70da7b8d..deac9465812 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb
@@ -26,12 +26,12 @@ module DiscourseChatIntegration::Provider::TeamsProvider
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb
index 1b8ac8ed66c..f4e39b27568 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_command_controller.rb
@@ -2,7 +2,7 @@
module DiscourseChatIntegration::Provider::TelegramProvider
class TelegramCommandController < DiscourseChatIntegration::Provider::HookController
- requires_provider ::DiscourseChatIntegration::Provider::TelegramProvider::PROVIDER_NAME
+ requires_provider DiscourseChatIntegration::Provider::TelegramProvider::PROVIDER_NAME
before_action :telegram_token_valid?, only: :command
@@ -94,7 +94,7 @@ module DiscourseChatIntegration::Provider::TelegramProvider
tokens[0][0] = "" # Remove the slash from the first token
tokens[0] = tokens[0].split("@")[0] # Remove the bot name from the command (necessary for group chats)
- ::DiscourseChatIntegration::Helper.process_command(channel, tokens)
+ DiscourseChatIntegration::Helper.process_command(channel, tokens)
end
def telegram_token_valid?
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_provider.rb
index 9bb56a5fa31..ccb3e85f92b 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_provider.rb
@@ -51,7 +51,7 @@ module DiscourseChatIntegration
end
def self.message_text(post)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
@@ -104,11 +104,11 @@ module DiscourseChatIntegration
elsif response["description"].include? "Forbidden"
error_key = "chat_integration.provider.telegram.errors.forbidden"
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- message: message,
- response_body: response,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ message: message,
+ response_body: response,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb
index 94ace863a8d..171a5e614e6 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb
@@ -31,17 +31,17 @@ module DiscourseChatIntegration::Provider::WebexProvider
else
error_key = nil
end
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- request: req.body,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ request: req.body,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
def self.get_message(post)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
topic = post.topic
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb
index 9e33cc0d95e..b731274d97f 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb
@@ -30,7 +30,7 @@ module DiscourseChatIntegration
end
def self.generate_zulip_message(post, stream, subject)
- display_name = ::DiscourseChatIntegration::Helper.formatted_display_name(post.user)
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
message =
I18n.t(
@@ -64,12 +64,12 @@ module DiscourseChatIntegration
"chat_integration.provider.zulip.errors.does_not_exist" if response.body.include?(
"does not exist",
)
- raise ::DiscourseChatIntegration::ProviderError.new info: {
- error_key: error_key,
- message: message,
- response_code: response.code,
- response_body: response.body,
- }
+ raise DiscourseChatIntegration::ProviderError.new info: {
+ error_key: error_key,
+ message: message,
+ response_code: response.code,
+ response_body: response.body,
+ }
end
end
diff --git a/plugins/discourse-chat-integration/plugin.rb b/plugins/discourse-chat-integration/plugin.rb
index 886bad98a47..2f3f63b412a 100644
--- a/plugins/discourse-chat-integration/plugin.rb
+++ b/plugins/discourse-chat-integration/plugin.rb
@@ -14,6 +14,10 @@ register_asset "stylesheets/chat-integration.scss"
register_svg_icon "rocket" if respond_to?(:register_svg_icon)
register_svg_icon "arrow-circle-o-right" if respond_to?(:register_svg_icon)
+module ::DiscourseChatIntegration
+ PLUGIN_NAME = "discourse-chat-integration".freeze
+end
+
# Site setting validators must be loaded before initialize
require_relative "lib/discourse_chat_integration/provider/slack/slack_enabled_setting_validator"
require_relative "lib/discourse_chat_integration/chat_integration_reference_post"
diff --git a/plugins/discourse-chat-integration/spec/dummy_provider.rb b/plugins/discourse-chat-integration/spec/dummy_provider.rb
index fcd6b3a5bef..aca39bc2b62 100644
--- a/plugins/discourse-chat-integration/spec/dummy_provider.rb
+++ b/plugins/discourse-chat-integration/spec/dummy_provider.rb
@@ -2,7 +2,7 @@
RSpec.shared_context "with dummy provider" do
before(:each) do
- module ::DiscourseChatIntegration::Provider::DummyProvider
+ module DiscourseChatIntegration::Provider::DummyProvider
PROVIDER_NAME = "dummy".freeze
PROVIDER_ENABLED_SETTING = :chat_integration_enabled # Tie to main plugin enabled setting
CHANNEL_PARAMETERS = []
@@ -30,14 +30,14 @@ RSpec.shared_context "with dummy provider" do
end
end
- after(:each) { ::DiscourseChatIntegration::Provider.send(:remove_const, :DummyProvider) }
+ after(:each) { DiscourseChatIntegration::Provider.send(:remove_const, :DummyProvider) }
- let(:provider) { ::DiscourseChatIntegration::Provider::DummyProvider }
+ let(:provider) { DiscourseChatIntegration::Provider::DummyProvider }
end
RSpec.shared_context "with validated dummy provider" do
before(:each) do
- module ::DiscourseChatIntegration::Provider::Dummy2Provider
+ module DiscourseChatIntegration::Provider::Dummy2Provider
PROVIDER_NAME = "dummy2".freeze
PROVIDER_ENABLED_SETTING = :chat_integration_enabled # Tie to main plugin enabled setting
CHANNEL_IDENTIFIER_KEY = "val".freeze
@@ -62,7 +62,7 @@ RSpec.shared_context "with validated dummy provider" do
end
end
- after(:each) { ::DiscourseChatIntegration::Provider.send(:remove_const, :Dummy2Provider) }
+ after(:each) { DiscourseChatIntegration::Provider.send(:remove_const, :Dummy2Provider) }
- let(:validated_provider) { ::DiscourseChatIntegration::Provider::Dummy2Provider }
+ let(:validated_provider) { DiscourseChatIntegration::Provider::Dummy2Provider }
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/discord/discord_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/discord/discord_provider_spec.rb
index 5ebe049260c..348178cbfc9 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/discord/discord_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/discord/discord_provider_spec.rb
@@ -43,7 +43,7 @@ RSpec.describe DiscourseChatIntegration::Provider::DiscordProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/flowdock/flowdock_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/flowdock/flowdock_provider_spec.rb
index cf1d7289d77..a37097c99a1 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/flowdock/flowdock_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/flowdock/flowdock_provider_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe DiscourseChatIntegration::Provider::FlowdockProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/gitter/gitter_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/gitter/gitter_provider_spec.rb
index 2ccac9054eb..65db5f2b12c 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/gitter/gitter_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/gitter/gitter_provider_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe DiscourseChatIntegration::Provider::GitterProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/google/google_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/google/google_provider_spec.rb
index 0c34647acc8..11520d82350 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/google/google_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/google/google_provider_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe DiscourseChatIntegration::Provider::GoogleProvider do
stub1 = stub_request(:post, chan1.data["webhook_url"]).to_return(status: 400, body: "{}")
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/groupme/groupme_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/groupme/groupme_provider_spec.rb
index 0fb3012ed3e..b6b03fa8240 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/groupme/groupme_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/groupme/groupme_provider_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe DiscourseChatIntegration::Provider::GroupmeProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/guilded/guilded_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/guilded/guilded_provider_spec.rb
index 059fe212b40..5f68767e3e6 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/guilded/guilded_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/guilded/guilded_provider_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe DiscourseChatIntegration::Provider::GuildedProvider do
stub_request(:post, "https://media.guilded.gg/webhooks/1234/abcd").to_return(status: 400)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/matrix/matrix_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/matrix/matrix_provider_spec.rb
index 5a14897c91e..628675c8d07 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/matrix/matrix_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/matrix/matrix_provider_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe DiscourseChatIntegration::Provider::MatrixProvider do
).to_return(status: 400, body: '{"errmsg":"M_UNKNOWN"}')
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb
index 8629b35a3a1..6f9dbf2a10d 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe DiscourseChatIntegration::Provider::MattermostProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider_spec.rb
index 5fdfaa00d02..9ddfc91533d 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe DiscourseChatIntegration::Provider::PowerAutomateProvider do
stub1 = stub_request(:post, chan1.data["webhook_url"]).to_return(status: 400, body: "{}")
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider_spec.rb
index ecdb52402a5..c21a99252fe 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe DiscourseChatIntegration::Provider::RocketchatProvider do
stub1 = stub_request(:post, "https://example.com/abcd").to_return(status: 400, body: "{}")
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb
index 367930e2965..fd18cc33bfb 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb
@@ -87,7 +87,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
@@ -201,7 +201,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
},
)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(@stub2).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/teams/teams_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/teams/teams_provider_spec.rb
index ce5fd892b23..5600368e827 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/teams/teams_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/teams/teams_provider_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe DiscourseChatIntegration::Provider::TeamsProvider do
stub1 = stub_request(:post, chan1.data["webhook_url"]).to_return(status: 400, body: "{}")
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_provider_spec.rb
index 963cf16b502..b505126293f 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_provider_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe DiscourseChatIntegration::Provider::TelegramProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/webex/webex_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/webex/webex_provider_spec.rb
index 7c8cd72555b..b77d0cbcaa8 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/webex/webex_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/webex/webex_provider_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe DiscourseChatIntegration::Provider::WebexProvider do
stub1 = stub_request(:post, chan1.data["webhook_url"]).to_return(status: 400, body: "{}")
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/zulip/zulip_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/zulip/zulip_provider_spec.rb
index e66697076f4..d33cdda4d54 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/zulip/zulip_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/zulip/zulip_provider_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe DiscourseChatIntegration::Provider::ZulipProvider do
)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1, nil) }.to raise_exception(
- ::DiscourseChatIntegration::ProviderError,
+ DiscourseChatIntegration::ProviderError,
)
expect(stub1).to have_been_requested.once
end
diff --git a/plugins/discourse-chat-integration/spec/services/manager_spec.rb b/plugins/discourse-chat-integration/spec/services/manager_spec.rb
index 92a21467e81..ed038859ab5 100644
--- a/plugins/discourse-chat-integration/spec/services/manager_spec.rb
+++ b/plugins/discourse-chat-integration/spec/services/manager_spec.rb
@@ -4,7 +4,8 @@ require_dependency "post_creator"
require_relative "../dummy_provider"
RSpec.describe DiscourseChatIntegration::Manager do
- let(:manager) { ::DiscourseChatIntegration::Manager }
+ subject(:manager) { described_class }
+
let(:category) { Fabricate(:category) }
let(:group) { Fabricate(:group) }
let(:group2) { Fabricate(:group) }
diff --git a/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb b/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb
index 80689b39cee..6102aa682a9 100644
--- a/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb
+++ b/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe "Create channel", type: :system do
fab!(:admin)
include_context "with dummy provider"
- let(:manager) { ::DiscourseChatIntegration::Manager }
+ let(:manager) { DiscourseChatIntegration::Manager }
let(:chan1) { DiscourseChatIntegration::Channel.create!(provider: "dummy") }
let(:category) { Fabricate(:category) }
let(:topic) { Fabricate(:topic, category_id: category.id) }
diff --git a/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb b/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb
index 0092822e3cc..dc0fc1fc08f 100644
--- a/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb
+++ b/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryController < ApplicationController
requires_plugin PLUGIN_NAME
diff --git a/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query.rb b/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query.rb
index bf23fb9a02d..253a62095d6 100644
--- a/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query.rb
+++ b/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryFinder
def self.find(id)
default_query = Queries.default[id.to_s]
diff --git a/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query_group.rb b/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query_group.rb
index b261f1448ac..c3e87fd8b08 100644
--- a/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query_group.rb
+++ b/plugins/discourse-data-explorer/app/models/discourse_data_explorer/query_group.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryGroup < ActiveRecord::Base
self.table_name = "data_explorer_query_groups"
diff --git a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_details_serializer.rb b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_details_serializer.rb
index d211777b9a0..8abb2eabd4a 100644
--- a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_details_serializer.rb
+++ b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_details_serializer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryDetailsSerializer < QuerySerializer
attributes :sql, :param_info, :created_at, :hidden
diff --git a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_bookmark_serializer.rb b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_bookmark_serializer.rb
index 3e45f70f4a2..eee3f7de03c 100644
--- a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_bookmark_serializer.rb
+++ b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_bookmark_serializer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryGroupBookmarkSerializer < UserBookmarkBaseSerializer
def title
fancy_title
diff --git a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_serializer.rb b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_serializer.rb
index a99c26d66d7..882bdf4dfaf 100644
--- a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_serializer.rb
+++ b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_serializer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryGroupSerializer < ActiveModel::Serializer
attributes :id, :group_id, :query_id, :bookmark
diff --git a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_serializer.rb b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_serializer.rb
index 724e2556ea7..0ba23d5386a 100644
--- a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_serializer.rb
+++ b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_serializer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QuerySerializer < ActiveModel::Serializer
attributes :id, :name, :description, :username, :group_ids, :last_run_at, :user_id
diff --git a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/small_post_with_excerpt_serializer.rb b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/small_post_with_excerpt_serializer.rb
index 1663de4d3c5..9b5a5247700 100644
--- a/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/small_post_with_excerpt_serializer.rb
+++ b/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/small_post_with_excerpt_serializer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class SmallPostWithExcerptSerializer < ApplicationSerializer
attributes :id, :topic_id, :post_number, :excerpt, :username, :avatar_template
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/data_explorer.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/data_explorer.rb
index ff43fa5da23..73ba38d9c53 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/data_explorer.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/data_explorer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
module DataExplorer
# Used for ftype calls, see https://www.rubydoc.info/gems/pg/0.17.1/PG%2FResult:ftype
# and /usr/include/postgresql/server/catalog/pg_type_d.h
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/engine.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/engine.rb
index 0b423308efb..ed13993aa9c 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/engine.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseDataExplorer
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb
index 961962531c4..f8b3d77b1d3 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class Parameter
attr_accessor :identifier, :type, :default, :nullable
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/queries.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/queries.rb
index 2849aa65d0f..d5860d58be8 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/queries.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/queries.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class Queries
def self.default
# WARNING: Edit the query hash carefully
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb
index b63d86f3efa..fc7e9eacf54 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/query_group_bookmarkable.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class QueryGroupBookmarkable < BaseBookmarkable
def self.model
QueryGroup
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/report_generator.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/report_generator.rb
index a518b1422d4..e6459006ed5 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/report_generator.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/report_generator.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class ReportGenerator
def self.generate(query_id, query_params, recipients, opts = {})
query = DiscourseDataExplorer::Query.find(query_id)
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_format_converter.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_format_converter.rb
index 258f07fbabd..be2ecd267f2 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_format_converter.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_format_converter.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class ResultFormatConverter
def self.convert(file_type, result, opts = {})
self.new(result, opts).send("to_#{file_type}")
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_to_markdown.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_to_markdown.rb
index bc4acd778d5..44e00179576 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_to_markdown.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/result_to_markdown.rb
@@ -2,7 +2,7 @@
include HasSanitizableFields
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class ResultToMarkdown
def self.convert(pg_result, render_url_columns = false)
relations, colrender = DataExplorer.add_extra_data(pg_result)
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/validation_error.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/validation_error.rb
index ba15df8d63c..defd2f07aa8 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/validation_error.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/validation_error.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseDataExplorer
+module DiscourseDataExplorer
class ValidationError < StandardError
end
end
diff --git a/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb b/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb
index ea300038b63..c639f833f7d 100644
--- a/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb
+++ b/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe DiscourseDataExplorer::Parameter do
it "raises error for not-nullable blank string" do
expect { param("param123", :string, nil, false).cast_to_ruby("") }.to raise_error(
- ::DiscourseDataExplorer::ValidationError,
+ DiscourseDataExplorer::ValidationError,
)
end
@@ -21,7 +21,7 @@ RSpec.describe DiscourseDataExplorer::Parameter do
it "raises an error if not a double" do
expect { double_param.cast_to_ruby("abcd") }.to raise_error(
- ::DiscourseDataExplorer::ValidationError,
+ DiscourseDataExplorer::ValidationError,
)
end
@@ -61,7 +61,7 @@ RSpec.describe DiscourseDataExplorer::Parameter do
it "raises an error if no such post exists" do
post.destroy
expect { param("post_id", :post_id, nil, false).cast_to_ruby(post.url) }.to raise_error(
- ::DiscourseDataExplorer::ValidationError,
+ DiscourseDataExplorer::ValidationError,
)
end
end
@@ -69,7 +69,7 @@ RSpec.describe DiscourseDataExplorer::Parameter do
context "when the value provided is an integer" do
it "raises an error if no such post exists" do
expect { param("post_id", :post_id, nil, false).cast_to_ruby("-999") }.to raise_error(
- ::DiscourseDataExplorer::ValidationError,
+ DiscourseDataExplorer::ValidationError,
)
end
@@ -85,7 +85,7 @@ RSpec.describe DiscourseDataExplorer::Parameter do
context "when the value provided is an integer" do
it "raises an error if no such group exists" do
expect { param("group_id", :group_id, nil, false).cast_to_ruby("-999") }.to raise_error(
- ::DiscourseDataExplorer::ValidationError,
+ DiscourseDataExplorer::ValidationError,
)
end
@@ -102,10 +102,10 @@ RSpec.describe DiscourseDataExplorer::Parameter do
it "raises an error if no such user exists" do
expect {
param("user_id", :user_id, nil, false).cast_to_ruby("user_not_exist")
- }.to raise_error(::DiscourseDataExplorer::ValidationError)
+ }.to raise_error(DiscourseDataExplorer::ValidationError)
expect {
param("user_id", :user_id, nil, false).cast_to_ruby("[email protected]")
- }.to raise_error(::DiscourseDataExplorer::ValidationError)
+ }.to raise_error(DiscourseDataExplorer::ValidationError)
end
it "returns the user id if the user exists" do
diff --git a/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb b/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb
index fa043522d62..6b6867e86b6 100644
--- a/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb
+++ b/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb
@@ -311,7 +311,7 @@ describe DiscourseDataExplorer::QueryController do
# Manual Test - change out the following line:
#
- # module ::DiscourseDataExplorer
+ # module DiscourseDataExplorer
# def self.run_query(...)
# if query.sql =~ /;/
#
diff --git a/plugins/discourse-data-explorer/spec/system/param_input_spec.rb b/plugins/discourse-data-explorer/spec/system/param_input_spec.rb
index b25c0625cec..67ebff2c8dc 100644
--- a/plugins/discourse-data-explorer/spec/system/param_input_spec.rb
+++ b/plugins/discourse-data-explorer/spec/system/param_input_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe "Param input", type: :system do
it "correctly displays parameter input boxes" do
visit("/admin/plugins/explorer/queries/#{all_params_query.id}")
- ::DiscourseDataExplorer::Parameter
+ DiscourseDataExplorer::Parameter
.create_from_sql(ALL_PARAMS_SQL)
.each do |param|
expect(page).to have_css(".query-params .param [name=\"#{param.identifier}\"]")
diff --git a/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb b/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb
index eb9ea6406f2..f7afd831df9 100644
--- a/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb
+++ b/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class GamificationLeaderboardController < ::ApplicationController
requires_plugin PLUGIN_NAME
diff --git a/plugins/discourse-gamification/app/models/discourse_gamification/deleted_gamification_leaderboard.rb b/plugins/discourse-gamification/app/models/discourse_gamification/deleted_gamification_leaderboard.rb
index e4ca5b5a503..f9da41a2578 100644
--- a/plugins/discourse-gamification/app/models/discourse_gamification/deleted_gamification_leaderboard.rb
+++ b/plugins/discourse-gamification/app/models/discourse_gamification/deleted_gamification_leaderboard.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class DeletedGamificationLeaderboard
attr_reader :id
diff --git a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_leaderboard.rb b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_leaderboard.rb
index 8e901718b5a..8c5f376a890 100644
--- a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_leaderboard.rb
+++ b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_leaderboard.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class GamificationLeaderboard < ::ActiveRecord::Base
PAGE_SIZE = 100
diff --git a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb
index f8b84a1bb6b..f9040bb7876 100644
--- a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb
+++ b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class GamificationScore < ::ActiveRecord::Base
self.table_name = "gamification_scores"
diff --git a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score_event.rb b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score_event.rb
index 3bd0d2d5ee9..83bc1a22626 100644
--- a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score_event.rb
+++ b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score_event.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class GamificationScoreEvent < ::ActiveRecord::Base
self.table_name = "gamification_score_events"
diff --git a/plugins/discourse-gamification/config/routes.rb b/plugins/discourse-gamification/config/routes.rb
index a13bdc7af76..871d70eed7a 100644
--- a/plugins/discourse-gamification/config/routes.rb
+++ b/plugins/discourse-gamification/config/routes.rb
@@ -6,7 +6,7 @@ DiscourseGamification::Engine.routes.draw do
end
Discourse::Application.routes.draw do
- mount ::DiscourseGamification::Engine, at: "/leaderboard"
+ mount DiscourseGamification::Engine, at: "/leaderboard"
scope "/admin/plugins/discourse-gamification", constraints: StaffConstraint.new do
get "/leaderboards" => "discourse_gamification/admin_gamification_leaderboard#index"
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/directory_integration.rb b/plugins/discourse-gamification/lib/discourse_gamification/directory_integration.rb
index 6f172eb3524..4afb53748c6 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/directory_integration.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/directory_integration.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class DirectoryIntegration
def self.query
<<~SQL
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/engine.rb b/plugins/discourse-gamification/lib/discourse_gamification/engine.rb
index 4aa3b4ed3d7..b9295750832 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/engine.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseGamification
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/guardian_extension.rb b/plugins/discourse-gamification/lib/discourse_gamification/guardian_extension.rb
index 8bb66a05e4c..4b938e1d924 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/guardian_extension.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/guardian_extension.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
module GuardianExtension
def can_see_leaderboard?(leaderboard)
return true if leaderboard.visible_to_groups_ids.empty?
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/leaderboard_cached_view.rb b/plugins/discourse-gamification/lib/discourse_gamification/leaderboard_cached_view.rb
index 12e9b05bbc7..e3cce21a91f 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/leaderboard_cached_view.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/leaderboard_cached_view.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class LeaderboardCachedView
class NotReadyError < StandardError
end
@@ -142,7 +142,7 @@ module ::DiscourseGamification
u.staged = FALSE
AND
u.active
- AND
+ AND
(u.suspended_till IS NULL OR u.suspended_till < CURRENT_TIMESTAMP)
AND
u.id > 0
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_message_created.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_message_created.rb
index edec45dc02a..fd1e8c98b0e 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_message_created.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_message_created.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class ChatMessageCreated < Scorable
def self.enabled?
SiteSetting.chat_enabled && score_multiplier > 0
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_given.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_given.rb
index 490fa5681e7..fa9648f120c 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_given.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_given.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class ChatReactionGiven < Scorable
def self.enabled?
SiteSetting.chat_enabled && score_multiplier > 0
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_received.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_received.rb
index 458b3e82592..20f3a92e4ae 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_received.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/chat_reaction_received.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class ChatReactionReceived < Scorable
def self.enabled?
SiteSetting.chat_enabled && score_multiplier > 0
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/day_visited.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/day_visited.rb
index 77547f4efb9..dab6a175780 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/day_visited.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/day_visited.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class DayVisited < Scorable
def self.score_multiplier
SiteSetting.day_visited_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/flag_created.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/flag_created.rb
index d782411c094..111a295fa5f 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/flag_created.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/flag_created.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class FlagCreated < Scorable
def self.score_multiplier
SiteSetting.flag_created_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_given.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_given.rb
index 1ee4ad1aadd..4f44e310fda 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_given.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_given.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class LikeGiven < Scorable
def self.score_multiplier
SiteSetting.like_given_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_received.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_received.rb
index 9c66ee2d0d8..021d855a2c9 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_received.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/like_received.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class LikeReceived < Scorable
def self.score_multiplier
SiteSetting.like_received_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_created.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_created.rb
index 463799bcf31..d47f1703e93 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_created.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_created.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class PostCreated < Scorable
def self.score_multiplier
SiteSetting.post_created_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_read.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_read.rb
index 61951141848..fa3732e0215 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_read.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/post_read.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class PostRead < Scorable
def self.score_multiplier
SiteSetting.post_read_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_given.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_given.rb
index abad6606f16..14a54de55a3 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_given.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_given.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class ReactionGiven < Scorable
def self.enabled?
- defined?(::DiscourseReactions) && SiteSetting.discourse_reactions_enabled &&
+ defined?(DiscourseReactions) && SiteSetting.discourse_reactions_enabled &&
score_multiplier > 0
end
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_received.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_received.rb
index f906d034e62..9250193adc7 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_received.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/reaction_received.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class ReactionReceived < Scorable
def self.enabled?
- defined?(::DiscourseReactions) && SiteSetting.discourse_reactions_enabled &&
+ defined?(DiscourseReactions) && SiteSetting.discourse_reactions_enabled &&
score_multiplier > 0
end
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb
index 292e377efb5..6ef263a89e4 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class Scorable
class << self
def enabled?
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/solutions.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/solutions.rb
index 87a084bb613..252c6d2de8c 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/solutions.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/solutions.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class Solutions < Scorable
def self.enabled?
defined?(DiscourseSolved) && SiteSetting.solved_enabled && super
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/time_read.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/time_read.rb
index a639f7855a9..23bb94071d0 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/time_read.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/time_read.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class TimeRead < Scorable
def self.score_multiplier
SiteSetting.time_read_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/topic_created.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/topic_created.rb
index d40cf3d4bde..9388043ed8f 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/topic_created.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/topic_created.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class TopicCreated < Scorable
def self.score_multiplier
SiteSetting.topic_created_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/user_invited.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/user_invited.rb
index 85e138e1c72..61a55b87828 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/user_invited.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/user_invited.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
class UserInvited < Scorable
def self.score_multiplier
SiteSetting.user_invited_score_value
diff --git a/plugins/discourse-gamification/lib/discourse_gamification/user_extension.rb b/plugins/discourse-gamification/lib/discourse_gamification/user_extension.rb
index bc88bf5be9e..232762683fe 100644
--- a/plugins/discourse-gamification/lib/discourse_gamification/user_extension.rb
+++ b/plugins/discourse-gamification/lib/discourse_gamification/user_extension.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-module ::DiscourseGamification
+module DiscourseGamification
module UserExtension
extend ActiveSupport::Concern
prepended do
has_many :gamification_scores,
- class_name: "::DiscourseGamification::GamificationScore",
+ class_name: "DiscourseGamification::GamificationScore",
dependent: :destroy
end
diff --git a/plugins/discourse-gamification/spec/fabricators/gamification_leaderboard.rb b/plugins/discourse-gamification/spec/fabricators/gamification_leaderboard.rb
index 74399753205..800cefed080 100644
--- a/plugins/discourse-gamification/spec/fabricators/gamification_leaderboard.rb
+++ b/plugins/discourse-gamification/spec/fabricators/gamification_leaderboard.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-Fabricator(:gamification_leaderboard, from: ::DiscourseGamification::GamificationLeaderboard) do
+Fabricator(:gamification_leaderboard, from: DiscourseGamification::GamificationLeaderboard) do
name { sequence(:name) { |i| "leaderboard#{i + 1}" } }
created_by_id { Fabricate(:user).id }
from_date { nil }
diff --git a/plugins/discourse-gamification/spec/fabricators/gamification_score.rb b/plugins/discourse-gamification/spec/fabricators/gamification_score.rb
index d545b771af3..57d9226ae40 100644
--- a/plugins/discourse-gamification/spec/fabricators/gamification_score.rb
+++ b/plugins/discourse-gamification/spec/fabricators/gamification_score.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-Fabricator(:gamification_score, from: ::DiscourseGamification::GamificationScore) do
+Fabricator(:gamification_score, from: DiscourseGamification::GamificationScore) do
user_id { Fabricate(:user).id }
score { 0 }
date { Date.today }
diff --git a/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb b/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb
index 1686e8bc72f..a7b918fefac 100755
--- a/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb
+++ b/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb
@@ -81,7 +81,7 @@ RSpec.shared_examples "No Score Value" do
end
end
-RSpec.describe ::DiscourseGamification::LikeReceived do
+RSpec.describe DiscourseGamification::LikeReceived do
it_behaves_like "Scorable Type" do
before do
Fabricate.times(10, :post, user: current_user)
@@ -118,7 +118,7 @@ RSpec.describe ::DiscourseGamification::LikeReceived do
end
end
-RSpec.describe ::DiscourseGamification::LikeGiven do
+RSpec.describe DiscourseGamification::LikeGiven do
it_behaves_like "Scorable Type" do
before do
Fabricate.times(10, :post, user: other_user)
@@ -161,7 +161,7 @@ RSpec.describe ::DiscourseGamification::LikeGiven do
end
end
-RSpec.describe ::DiscourseGamification::PostCreated do
+RSpec.describe DiscourseGamification::PostCreated do
it_behaves_like "Scorable Type" do
before do
Fabricate.times(2, :post, user: current_user, post_number: 2)
@@ -212,7 +212,7 @@ RSpec.describe ::DiscourseGamification::PostCreated do
end
end
-RSpec.describe ::DiscourseGamification::DayVisited do
+RSpec.describe DiscourseGamification::DayVisited do
it_behaves_like "Scorable Type" do
before do
(Date.new(2022, 01, 01)..Date.new(2022, 01, 30)).each do |date|
@@ -225,7 +225,7 @@ RSpec.describe ::DiscourseGamification::DayVisited do
end
end
-RSpec.describe ::DiscourseGamification::PostRead do
+RSpec.describe DiscourseGamification::PostRead do
it_behaves_like "Scorable Type" do
before do
(Date.new(2022, 01, 01)..Date.new(2022, 01, 30)).each do |date|
@@ -238,7 +238,7 @@ RSpec.describe ::DiscourseGamification::PostRead do
end
end
-RSpec.describe ::DiscourseGamification::TimeRead do
+RSpec.describe DiscourseGamification::TimeRead do
it_behaves_like "Scorable Type" do
before do
(Date.new(2022, 01, 01)..Date.new(2022, 01, 30)).each do |date|
@@ -251,7 +251,7 @@ RSpec.describe ::DiscourseGamification::TimeRead do
end
end
-RSpec.describe ::DiscourseGamification::FlagCreated do
+RSpec.describe DiscourseGamification::FlagCreated do
it_behaves_like "Scorable Type" do
before do
Fabricate.times(10, :reviewable, created_by: current_user) do
@@ -264,7 +264,7 @@ RSpec.describe ::DiscourseGamification::FlagCreated do
end
end
-RSpec.describe ::DiscourseGamification::TopicCreated do
+RSpec.describe DiscourseGamification::TopicCreated do
it_behaves_like "Scorable Type" do
before { Fabricate.times(10, :topic, user: current_user) }
@@ -287,7 +287,7 @@ RSpec.describe ::DiscourseGamification::TopicCreated do
end
end
-RSpec.describe ::DiscourseGamification::UserInvited do
+RSpec.describe DiscourseGamification::UserInvited do
it_behaves_like "Scorable Type" do
before do
stub_request(
@@ -310,7 +310,7 @@ RSpec.describe ::DiscourseGamification::UserInvited do
end
end
-RSpec.describe ::DiscourseGamification::ChatReactionReceived do
+RSpec.describe DiscourseGamification::ChatReactionReceived do
it_behaves_like "Scorable Type" do
before do
Fabricate.times(10, :chat_message, user: current_user)
@@ -336,7 +336,7 @@ RSpec.describe ::DiscourseGamification::ChatReactionReceived do
end
end
-RSpec.describe ::DiscourseGamification::ChatReactionGiven do
+RSpec.describe DiscourseGamification::ChatReactionGiven do
it_behaves_like "Scorable Type" do
before do
Fabricate.times(10, :chat_message, user: other_user)
@@ -368,7 +368,7 @@ RSpec.describe ::DiscourseGamification::ChatReactionGiven do
end
end
-RSpec.describe ::DiscourseGamification::ChatMessageCreated do
+RSpec.describe DiscourseGamification::ChatMessageCreated do
it_behaves_like "Scorable Type" do
before { Fabricate.times(10, :chat_message, user: current_user) }
diff --git a/plugins/discourse-gamification/spec/plugin_spec.rb b/plugins/discourse-gamification/spec/plugin_spec.rb
index 624b59929e3..8cf43b7cae2 100644
--- a/plugins/discourse-gamification/spec/plugin_spec.rb
+++ b/plugins/discourse-gamification/spec/plugin_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-describe ::DiscourseGamification do
+describe DiscourseGamification do
let(:user) { Fabricate(:user) }
let!(:gamification_score) { Fabricate(:gamification_score, user_id: user.id) }
@@ -21,7 +21,7 @@ describe ::DiscourseGamification do
end
end
-describe ::DiscourseGamification do
+describe DiscourseGamification do
let(:guardian) { Guardian.new }
let!(:default_gamification_leaderboard) { Fabricate(:gamification_leaderboard) }
diff --git a/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb b/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb
index ccbb1900541..d721f03b69e 100644
--- a/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb
+++ b/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb
@@ -34,7 +34,7 @@ describe "Admin leaderboards", type: :system do
expect(page).to have_content(I18n.t("js.gamification.leaderboard.save_success"))
- expect(::DiscourseGamification::GamificationLeaderboard.last).to have_attributes(
+ expect(DiscourseGamification::GamificationLeaderboard.last).to have_attributes(
name: "My leaderboard",
from_date: 12.months.ago.end_of_month.to_date,
to_date: 11.months.ago.end_of_month.to_date,
@@ -67,7 +67,7 @@ describe "Admin leaderboards", type: :system do
dialog.click_danger
expect(page).to have_content(I18n.t("js.gamification.leaderboard.delete_success"))
- expect(::DiscourseGamification::GamificationLeaderboard.exists?(leaderboard.id)).to eq(false)
+ expect(DiscourseGamification::GamificationLeaderboard.exists?(leaderboard.id)).to eq(false)
end
end
end
diff --git a/plugins/discourse-github/app/lib/github_permalinks.rb b/plugins/discourse-github/app/lib/github_permalinks.rb
index 5d9bcf3d9a4..70b931b5de6 100644
--- a/plugins/discourse-github/app/lib/github_permalinks.rb
+++ b/plugins/discourse-github/app/lib/github_permalinks.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::GithubPermalinks
+module GithubPermalinks
def self.replace_github_non_permalinks(post)
# replaces github non-permalinks with permalinks containing a specific commit id
regex = %r{https?://github\.com/[^/]+/[^/\s]+/blob/[^\s]+}i
diff --git a/plugins/discourse-graphviz/plugin.rb b/plugins/discourse-graphviz/plugin.rb
index cd6d9a7b2f8..fc19d1b7bdd 100644
--- a/plugins/discourse-graphviz/plugin.rb
+++ b/plugins/discourse-graphviz/plugin.rb
@@ -11,22 +11,20 @@ enabled_site_setting :discourse_graphviz_enabled
register_asset "stylesheets/common/graphviz.scss"
-after_initialize do
- module DiscourseGraphviz
- class << self
- def context
- context = MiniRacer::Context.new
- context.load("#{Rails.root}/plugins/discourse-graphviz/public/javascripts/viz-3.0.1.js")
- context
- end
+module ::DiscourseGraphviz
+ def self.context
+ context = MiniRacer::Context.new
+ context.load("#{Rails.root}/plugins/discourse-graphviz/public/javascripts/viz-3.0.1.js")
+ context
+ end
- def allowed_svg_xpath
- @@allowed_svg_xpath ||=
- "//*[#{UploadCreator::ALLOWED_SVG_ELEMENTS.map { |e| "name()!='#{e}'" }.join(" and ")}]"
- end
- end
+ def self.allowed_svg_xpath
+ @@allowed_svg_xpath ||=
+ "//*[#{UploadCreator::ALLOWED_SVG_ELEMENTS.map { |e| "name()!='#{e}'" }.join(" and ")}]"
end
+end
+after_initialize do
on(:before_post_process_cooked) do |doc, post|
if SiteSetting.discourse_graphviz_enabled
doc
diff --git a/plugins/discourse-hcaptcha/app/controllers/discourse_hcaptcha/hcaptcha_controller.rb b/plugins/discourse-hcaptcha/app/controllers/discourse_hcaptcha/hcaptcha_controller.rb
index eda834ec03e..0c35a0266c6 100644
--- a/plugins/discourse-hcaptcha/app/controllers/discourse_hcaptcha/hcaptcha_controller.rb
+++ b/plugins/discourse-hcaptcha/app/controllers/discourse_hcaptcha/hcaptcha_controller.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-module ::DiscourseHcaptcha
+module DiscourseHcaptcha
class HcaptchaController < ::ApplicationController
- requires_plugin DiscourseHcaptcha::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_config
skip_before_action :redirect_to_login_if_required
diff --git a/plugins/discourse-hcaptcha/config/routes.rb b/plugins/discourse-hcaptcha/config/routes.rb
index c99a7736cb9..47fe13566e2 100644
--- a/plugins/discourse-hcaptcha/config/routes.rb
+++ b/plugins/discourse-hcaptcha/config/routes.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-Discourse::Application.routes.draw { mount ::DiscourseHcaptcha::Engine, at: "hcaptcha" }
+Discourse::Application.routes.draw { mount DiscourseHcaptcha::Engine, at: "hcaptcha" }
DiscourseHcaptcha::Engine.routes.draw { post "/create" => "hcaptcha#create" }
diff --git a/plugins/discourse-hcaptcha/lib/discourse_hcaptcha/engine.rb b/plugins/discourse-hcaptcha/lib/discourse_hcaptcha/engine.rb
index a099a7730f5..af574807c34 100644
--- a/plugins/discourse-hcaptcha/lib/discourse_hcaptcha/engine.rb
+++ b/plugins/discourse-hcaptcha/lib/discourse_hcaptcha/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseHcaptcha
+module DiscourseHcaptcha
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseHcaptcha
diff --git a/plugins/discourse-lazy-videos/plugin.rb b/plugins/discourse-lazy-videos/plugin.rb
index 98d93219965..49a8d489aa9 100644
--- a/plugins/discourse-lazy-videos/plugin.rb
+++ b/plugins/discourse-lazy-videos/plugin.rb
@@ -10,6 +10,9 @@ enabled_site_setting :lazy_videos_enabled
register_asset "stylesheets/lazy-videos.scss"
+module ::DiscourseLazyVideos
+end
+
require_relative "lib/discourse_lazy_videos/lazy_youtube"
require_relative "lib/discourse_lazy_videos/lazy_vimeo"
require_relative "lib/discourse_lazy_videos/lazy_tiktok"
diff --git a/plugins/discourse-local-dates/lib/discourse_local_dates/engine.rb b/plugins/discourse-local-dates/lib/discourse_local_dates/engine.rb
index 2eac83b876f..946d00cb3d6 100644
--- a/plugins/discourse-local-dates/lib/discourse_local_dates/engine.rb
+++ b/plugins/discourse-local-dates/lib/discourse_local_dates/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseLocalDates
+module DiscourseLocalDates
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseLocalDates
diff --git a/plugins/discourse-local-dates/plugin.rb b/plugins/discourse-local-dates/plugin.rb
index 6dad2042cfa..e90fed1af92 100644
--- a/plugins/discourse-local-dates/plugin.rb
+++ b/plugins/discourse-local-dates/plugin.rb
@@ -11,12 +11,12 @@ register_asset "moment-timezone.js", :vendored_core_pretty_text
enabled_site_setting :discourse_local_dates_enabled
-after_initialize do
- module ::DiscourseLocalDates
- PLUGIN_NAME = "discourse-local-dates".freeze
- POST_CUSTOM_FIELD = "local_dates".freeze
- end
+module ::DiscourseLocalDates
+ PLUGIN_NAME = "discourse-local-dates".freeze
+ POST_CUSTOM_FIELD = "local_dates".freeze
+end
+after_initialize do
require_relative "lib/discourse_local_dates/engine"
register_post_custom_field_type(DiscourseLocalDates::POST_CUSTOM_FIELD, :json)
diff --git a/plugins/discourse-lti/lib/discourse_lti/lti_authenticator.rb b/plugins/discourse-lti/lib/discourse_lti/lti_authenticator.rb
index 6a458e07c05..aad37df3305 100644
--- a/plugins/discourse-lti/lib/discourse_lti/lti_authenticator.rb
+++ b/plugins/discourse-lti/lib/discourse_lti/lti_authenticator.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class ::DiscourseLti::LtiAuthenticator < Auth::ManagedAuthenticator
+class DiscourseLti::LtiAuthenticator < Auth::ManagedAuthenticator
def name
"lti"
end
@@ -24,7 +24,7 @@ class ::DiscourseLti::LtiAuthenticator < Auth::ManagedAuthenticator
end
def register_middleware(omniauth)
- omniauth.provider ::DiscourseLti::LtiOmniauthStrategy,
+ omniauth.provider DiscourseLti::LtiOmniauthStrategy,
name: :lti,
setup:
lambda { |env|
diff --git a/plugins/discourse-lti/plugin.rb b/plugins/discourse-lti/plugin.rb
index fa4e038592a..4546e2afbd3 100644
--- a/plugins/discourse-lti/plugin.rb
+++ b/plugins/discourse-lti/plugin.rb
@@ -33,11 +33,11 @@ after_initialize do
)
next if uaa.nil?
- custom_data = uaa.extra.dig("raw_info", ::DiscourseLti::CUSTOM_DATA_CLAIM)
+ custom_data = uaa.extra.dig("raw_info", DiscourseLti::CUSTOM_DATA_CLAIM)
next if custom_data.nil?
invite = nil
- ::DiscourseLti::DISCOURSE_INVITE_KEYS.each { |k| break if invite = custom_data[k] }
+ DiscourseLti::DISCOURSE_INVITE_KEYS.each { |k| break if invite = custom_data[k] }
next if invite.nil?
parsed =
@@ -58,12 +58,12 @@ after_initialize do
on(:after_auth) do |authenticator, auth_result, session, cookies|
next if !(authenticator.name.to_sym == :lti)
if !auth_result.user && cookies["_t"] # User (probably) already logged in
- raise ::DiscourseLti::ShouldReconnect.new
+ raise DiscourseLti::ShouldReconnect.new
end
end
reloadable_patch do
- ::Users::OmniauthCallbacksController.rescue_from(::DiscourseLti::ShouldReconnect) do
+ ::Users::OmniauthCallbacksController.rescue_from(DiscourseLti::ShouldReconnect) do
session[:auth_reconnect] = true
complete
end
@@ -73,4 +73,4 @@ end
require_relative "lib/discourse_lti/lti_omniauth_strategy"
require_relative "lib/discourse_lti/lti_authenticator"
-auth_provider authenticator: ::DiscourseLti::LtiAuthenticator.new
+auth_provider authenticator: DiscourseLti::LtiAuthenticator.new
diff --git a/plugins/discourse-math/plugin.rb b/plugins/discourse-math/plugin.rb
index 3b09b8f83ed..85943751cc0 100644
--- a/plugins/discourse-math/plugin.rb
+++ b/plugins/discourse-math/plugin.rb
@@ -12,6 +12,9 @@ register_asset "stylesheets/ext/discourse-chat.scss"
enabled_site_setting :discourse_math_enabled
+module ::DiscourseMath
+end
+
after_initialize do
if respond_to?(:chat) && SiteSetting.chat_enabled
chat&.enable_markdown_feature("discourse-math")
diff --git a/plugins/discourse-narrative-bot/app/controllers/discourse_narrative_bot/certificates_controller.rb b/plugins/discourse-narrative-bot/app/controllers/discourse_narrative_bot/certificates_controller.rb
index fc2043c49bb..bcff16bf3d2 100644
--- a/plugins/discourse-narrative-bot/app/controllers/discourse_narrative_bot/certificates_controller.rb
+++ b/plugins/discourse-narrative-bot/app/controllers/discourse_narrative_bot/certificates_controller.rb
@@ -2,7 +2,7 @@
module DiscourseNarrativeBot
class CertificatesController < ::ApplicationController
- requires_plugin DiscourseNarrativeBot::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
layout false
skip_before_action :check_xhr
requires_login
diff --git a/plugins/discourse-narrative-bot/app/jobs/regular/bot_input.rb b/plugins/discourse-narrative-bot/app/jobs/regular/bot_input.rb
index 9cfb0b4079e..36bcba06ee8 100644
--- a/plugins/discourse-narrative-bot/app/jobs/regular/bot_input.rb
+++ b/plugins/discourse-narrative-bot/app/jobs/regular/bot_input.rb
@@ -8,7 +8,7 @@ module Jobs
return unless user = User.find_by(id: args[:user_id])
I18n.with_locale(user.effective_locale) do
- ::DiscourseNarrativeBot::TrackSelector.new(
+ DiscourseNarrativeBot::TrackSelector.new(
args[:input].to_sym,
user,
post_id: args[:post_id],
diff --git a/plugins/discourse-narrative-bot/app/jobs/regular/send_default_welcome_message.rb b/plugins/discourse-narrative-bot/app/jobs/regular/send_default_welcome_message.rb
index 078ee7b06d2..3b179e67805 100644
--- a/plugins/discourse-narrative-bot/app/jobs/regular/send_default_welcome_message.rb
+++ b/plugins/discourse-narrative-bot/app/jobs/regular/send_default_welcome_message.rb
@@ -9,7 +9,7 @@ module Jobs
title = I18n.t("system_messages.#{type}.subject_template", params)
raw = I18n.t("system_messages.#{type}.text_body_template", params)
- discobot_user = ::DiscourseNarrativeBot::Base.new.discobot_user
+ discobot_user = DiscourseNarrativeBot::Base.new.discobot_user
post =
PostCreator.create!(
diff --git a/plugins/discourse-narrative-bot/config/routes.rb b/plugins/discourse-narrative-bot/config/routes.rb
index 65e512d23ec..e5e93384a3a 100644
--- a/plugins/discourse-narrative-bot/config/routes.rb
+++ b/plugins/discourse-narrative-bot/config/routes.rb
@@ -4,4 +4,4 @@ DiscourseNarrativeBot::Engine.routes.draw do
get "/certificate" => "certificates#generate", :format => :svg
end
-Discourse::Application.routes.draw { mount ::DiscourseNarrativeBot::Engine, at: "/discobot" }
+Discourse::Application.routes.draw { mount DiscourseNarrativeBot::Engine, at: "/discobot" }
diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/certificate_generator.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/certificate_generator.rb
index 0d485417e48..7e761eb99cf 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/certificate_generator.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/certificate_generator.rb
@@ -18,7 +18,7 @@ module DiscourseNarrativeBot
end
@date = I18n.l(date, format: :date_only)
- @discobot_user = ::DiscourseNarrativeBot::Base.new.discobot_user
+ @discobot_user = DiscourseNarrativeBot::Base.new.discobot_user
end
def new_user_track
diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/post_guardian_extension.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/post_guardian_extension.rb
index 0e96a6bcb62..30675c06f4b 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/post_guardian_extension.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/post_guardian_extension.rb
@@ -10,7 +10,7 @@ module DiscourseNarrativeBot
def can_create_post?(parent)
if SiteSetting.discourse_narrative_bot_enabled &&
parent.try(:subtype) == "system_message" &&
- parent.try(:user) == ::DiscourseNarrativeBot::Base.new.discobot_user
+ parent.try(:user) == DiscourseNarrativeBot::Base.new.discobot_user
return true
end
diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rb
index 1a04596b53e..99d4e291423 100644
--- a/plugins/discourse-narrative-bot/plugin.rb
+++ b/plugins/discourse-narrative-bot/plugin.rb
@@ -185,13 +185,13 @@ after_initialize do
raw =
I18n.t(
"discourse_narrative_bot.tl2_promotion_message.text_body_template",
- discobot_username: ::DiscourseNarrativeBot::Base.new.discobot_username,
+ discobot_username: DiscourseNarrativeBot::Base.new.discobot_username,
reset_trigger:
- "#{::DiscourseNarrativeBot::TrackSelector.reset_trigger} #{::DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}",
+ "#{DiscourseNarrativeBot::TrackSelector.reset_trigger} #{DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}",
)
PostCreator.create!(
- ::DiscourseNarrativeBot::Base.new.discobot_user,
+ DiscourseNarrativeBot::Base.new.discobot_user,
title: I18n.t("discourse_narrative_bot.tl2_promotion_message.subject_template"),
raw: raw,
skip_validations: true,
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
index af349ee4ffb..67f5a564a28 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
- fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
+ fab!(:narrative_bot) { DiscourseNarrativeBot::Base.new }
fab!(:discobot_user) { narrative_bot.discobot_user }
fab!(:discobot_username) { narrative_bot.discobot_username }
fab!(:first_post) { Fabricate(:post, user: discobot_user) }
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
index f7c9ec1f4c8..a298c691925 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
fab!(:welcome_topic) { Fabricate(:topic, title: "Welcome to Discourse") }
- fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
+ fab!(:narrative_bot) { DiscourseNarrativeBot::Base.new }
fab!(:discobot_user) { narrative_bot.discobot_user }
fab!(:discobot_username) { narrative_bot.discobot_username }
fab!(:first_post) { Fabricate(:post, user: discobot_user) }
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
index 4a346568fab..5fc221aaaf6 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:user) { Fabricate(:user) }
- let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
+ let(:narrative_bot) { DiscourseNarrativeBot::Base.new }
let(:discobot_user) { narrative_bot.discobot_user }
let(:discobot_username) { narrative_bot.discobot_username }
let(:narrative) { DiscourseNarrativeBot::NewUserNarrative.new }
diff --git a/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb b/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb
index ba8217caa25..691ee1a2da2 100644
--- a/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe SiteSetting do
- let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
+ let(:narrative_bot) { DiscourseNarrativeBot::Base.new }
let(:discobot_user) { narrative_bot.discobot_user }
before { SiteSetting.discourse_narrative_bot_enabled = true }
diff --git a/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb b/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb
index 22cdd10f680..410a88f46dc 100644
--- a/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb
+++ b/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb
@@ -2,7 +2,7 @@
require "omniauth-oauth2"
-module ::OmniAuth
+module OmniAuth
module OpenIDConnect
class DiscoveryError < Error
end
@@ -39,7 +39,7 @@ module ::OmniAuth
def discover!
discovery_document = options[:discovery_document]
if discovery_document.nil?
- raise ::OmniAuth::OpenIDConnect::DiscoveryError.new("Discovery document is missing")
+ raise OmniAuth::OpenIDConnect::DiscoveryError.new("Discovery document is missing")
end
discovery_params = {
@@ -51,7 +51,7 @@ module ::OmniAuth
discovery_params.each do |internal_key, external_key|
val = discovery_document[external_key]
if val.nil? || val.empty?
- raise ::OmniAuth::OpenIDConnect::DiscoveryError.new(
+ raise OmniAuth::OpenIDConnect::DiscoveryError.new(
"missing discovery parameter #{external_key}",
)
end
@@ -78,7 +78,7 @@ module ::OmniAuth
def request_phase
begin
discover! if options[:discovery]
- rescue ::OmniAuth::OpenIDConnect::DiscoveryError => e
+ rescue OmniAuth::OpenIDConnect::DiscoveryError => e
return fail!(:openid_connect_discovery_error, e)
end
@@ -131,7 +131,7 @@ module ::OmniAuth
return oauth2_callback_phase if env["omniauth.error"]
oauth2_callback_phase
- rescue ::OmniAuth::OpenIDConnect::DiscoveryError => e
+ rescue OmniAuth::OpenIDConnect::DiscoveryError => e
fail!(:openid_connect_discovery_error, e)
rescue ::JWT::DecodeError => e
fail!(:jwt_decode_failed, e)
diff --git a/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb b/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb
index fce6b1c4a01..ae8b25f6590 100644
--- a/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb
+++ b/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb
@@ -12,8 +12,8 @@ class Patreon::PatreonAdminController < Admin::AdminController
def list
filters = PluginStore.get(Patreon::PLUGIN_NAME, "filters") || {}
- rewards = ::Patreon::Reward.all
- last_sync = ::Patreon.get("last_sync") || {}
+ rewards = Patreon::Reward.all
+ last_sync = Patreon.get("last_sync") || {}
groups = ::Group.all.pluck(:id)
@@ -23,7 +23,7 @@ class Patreon::PatreonAdminController < Admin::AdminController
end
def rewards
- rewards = ::Patreon::Reward.all
+ rewards = Patreon::Reward.all
render json: rewards
end
@@ -84,7 +84,7 @@ class Patreon::PatreonAdminController < Admin::AdminController
StaffActionLogger.new(current_user).log_check_email(user, context: params[:context])
end
- render json: { email: ::Patreon::Patron.attr("email", user) }
+ render json: { email: Patreon::Patron.attr("email", user) }
end
def patreon_tokens_present?
diff --git a/plugins/discourse-patreon/app/jobs/regular/sync_patron_groups.rb b/plugins/discourse-patreon/app/jobs/regular/sync_patron_groups.rb
index ebbbfaafa0f..d9767f458c7 100644
--- a/plugins/discourse-patreon/app/jobs/regular/sync_patron_groups.rb
+++ b/plugins/discourse-patreon/app/jobs/regular/sync_patron_groups.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class SyncPatronGroups < ::Jobs::Base
def execute(args)
- ::Patreon::Patron.sync_groups_by(patreon_id: args[:patreon_id])
+ Patreon::Patron.sync_groups_by(patreon_id: args[:patreon_id])
end
end
end
diff --git a/plugins/discourse-patreon/app/jobs/scheduled/patreon_sync_patrons_to_groups.rb b/plugins/discourse-patreon/app/jobs/scheduled/patreon_sync_patrons_to_groups.rb
index 76bd7880889..a77149b3839 100644
--- a/plugins/discourse-patreon/app/jobs/scheduled/patreon_sync_patrons_to_groups.rb
+++ b/plugins/discourse-patreon/app/jobs/scheduled/patreon_sync_patrons_to_groups.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class PatreonSyncPatronsToGroups < ::Jobs::Scheduled
every 6.hours
sidekiq_options retry: false
@@ -11,8 +11,8 @@ module ::Jobs
return
end
- ::Patreon::Patron.update!
- ::Patreon.set("last_sync", at: Time.now)
+ Patreon::Patron.update!
+ Patreon.set("last_sync", at: Time.now)
end
end
end
diff --git a/plugins/discourse-patreon/app/jobs/scheduled/patreon_update_tokens.rb b/plugins/discourse-patreon/app/jobs/scheduled/patreon_update_tokens.rb
index 1e1129265d7..240070cd411 100644
--- a/plugins/discourse-patreon/app/jobs/scheduled/patreon_update_tokens.rb
+++ b/plugins/discourse-patreon/app/jobs/scheduled/patreon_update_tokens.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class PatreonUpdateTokens < ::Jobs::Scheduled
every 7.days
def execute(args)
if SiteSetting.patreon_enabled && SiteSetting.patreon_creator_access_token &&
SiteSetting.patreon_creator_refresh_token
- ::Patreon::Tokens.update!
+ Patreon::Tokens.update!
end
end
end
diff --git a/plugins/discourse-patreon/lib/api.rb b/plugins/discourse-patreon/lib/api.rb
index 7a46d86cf72..997fdebf102 100644
--- a/plugins/discourse-patreon/lib/api.rb
+++ b/plugins/discourse-patreon/lib/api.rb
@@ -2,7 +2,7 @@
require "json"
-module ::Patreon
+module Patreon
class InvalidApiResponse < ::StandardError
end
@@ -43,7 +43,7 @@ module ::Patreon
when 401
ProblemCheckTracker[:access_token_invalid].problem!
else
- e = ::Patreon::InvalidApiResponse.new(response.body.presence || "")
+ e = Patreon::InvalidApiResponse.new(response.body.presence || "")
e.set_backtrace(caller)
Discourse.warn_exception(e, message: I18n.t(INVALID_RESPONSE), env: { api_uri: uri })
end
diff --git a/plugins/discourse-patreon/lib/campaign.rb b/plugins/discourse-patreon/lib/campaign.rb
index b9b20b8e6a3..2ae6ae3369b 100644
--- a/plugins/discourse-patreon/lib/campaign.rb
+++ b/plugins/discourse-patreon/lib/campaign.rb
@@ -2,14 +2,14 @@
require "json"
-module ::Patreon
+module Patreon
class Campaign
def self.update!
rewards = {}
campaign_rewards = []
pledges_uris = []
- response = ::Patreon::Api.campaign_data
+ response = Patreon::Api.campaign_data
return false if response.blank? || response["data"].blank?
diff --git a/plugins/discourse-patreon/lib/discourse_patreon/engine.rb b/plugins/discourse-patreon/lib/discourse_patreon/engine.rb
index 7b10381ef5d..a6cd15d22aa 100644
--- a/plugins/discourse-patreon/lib/discourse_patreon/engine.rb
+++ b/plugins/discourse-patreon/lib/discourse_patreon/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Patreon
+module Patreon
USER_DETAIL_FIELDS = %w[id amount_cents rewards declined_since].freeze
class Engine < ::Rails::Engine
diff --git a/plugins/discourse-patreon/lib/patron.rb b/plugins/discourse-patreon/lib/patron.rb
index 95e24a3dddd..856d1fe1a45 100644
--- a/plugins/discourse-patreon/lib/patron.rb
+++ b/plugins/discourse-patreon/lib/patron.rb
@@ -2,7 +2,7 @@
require "json"
-module ::Patreon
+module Patreon
class Patron
def self.update!
return unless Patreon::Campaign.update!
diff --git a/plugins/discourse-patreon/lib/pledge.rb b/plugins/discourse-patreon/lib/pledge.rb
index 346dd063e8f..2137e84f9cc 100644
--- a/plugins/discourse-patreon/lib/pledge.rb
+++ b/plugins/discourse-patreon/lib/pledge.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Patreon
+module Patreon
class Pledge
def self.create!(pledge_data)
save!([pledge_data], true)
@@ -39,7 +39,7 @@ module ::Patreon
pledges_data = []
uris.each do |uri|
- pledge_data = ::Patreon::Api.get(uri)
+ pledge_data = Patreon::Api.get(uri)
# get next page if necessary and add to the current loop
if pledge_data["links"] && pledge_data["links"]["next"]
diff --git a/plugins/discourse-patreon/lib/seed.rb b/plugins/discourse-patreon/lib/seed.rb
index 9817e544fd7..883c452721a 100644
--- a/plugins/discourse-patreon/lib/seed.rb
+++ b/plugins/discourse-patreon/lib/seed.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Patreon
+module Patreon
class Seed
def self.seed_content!
flair =
@@ -43,7 +43,7 @@ module ::Patreon
badge.save!
basic_filter = { default_group.id.to_s => ["0"] }
- ::Patreon.set("filters", basic_filter)
+ Patreon.set("filters", basic_filter)
end
end
end
diff --git a/plugins/discourse-patreon/lib/tokens.rb b/plugins/discourse-patreon/lib/tokens.rb
index 37a6a3ac535..f9e5160a29f 100644
--- a/plugins/discourse-patreon/lib/tokens.rb
+++ b/plugins/discourse-patreon/lib/tokens.rb
@@ -2,7 +2,7 @@
require "json"
-module ::Patreon
+module Patreon
class Tokens
def self.update!
conn = Faraday.new(url: "https://api.patreon.com")
diff --git a/plugins/discourse-patreon/plugin.rb b/plugins/discourse-patreon/plugin.rb
index 262fe806361..9e590031adc 100644
--- a/plugins/discourse-patreon/plugin.rb
+++ b/plugins/discourse-patreon/plugin.rb
@@ -40,7 +40,7 @@ after_initialize do
require_relative "lib/patron"
require_relative "lib/tokens"
- Discourse::Application.routes.prepend { mount ::Patreon::Engine, at: "/patreon" }
+ Discourse::Application.routes.prepend { mount Patreon::Engine, at: "/patreon" }
add_admin_route "patreon.title", "patreon"
@@ -55,7 +55,7 @@ after_initialize do
end
on(:user_created) do |user|
- filters = PluginStore.get(::Patreon::PLUGIN_NAME, "filters")
+ filters = PluginStore.get(Patreon::PLUGIN_NAME, "filters")
patreon_id = Patreon::Patron.all.key(user.email)
if filters.present? && patreon_id.present?
@@ -76,21 +76,21 @@ after_initialize do
end
end
- ::Patreon::USER_DETAIL_FIELDS.each do |attribute|
+ Patreon::USER_DETAIL_FIELDS.each do |attribute|
add_to_serializer(
:admin_detailed_user,
"patreon_#{attribute}".to_sym,
include_condition: -> do
- ::Patreon::Patron.attr(attribute, object).present? &&
+ Patreon::Patron.attr(attribute, object).present? &&
(attribute != "amount_cents" || scope.is_admin?)
end,
- ) { ::Patreon::Patron.attr(attribute, object) }
+ ) { Patreon::Patron.attr(attribute, object) }
end
add_to_serializer(
:admin_detailed_user,
:patreon_email_exists,
- include_condition: -> { ::Patreon::Patron.attr("email", object).present? },
+ include_condition: -> { Patreon::Patron.attr("email", object).present? },
) { true }
add_to_serializer(:current_user, :show_donation_prompt?) do
diff --git a/plugins/discourse-patreon/spec/integration/patreon_spec.rb b/plugins/discourse-patreon/spec/integration/patreon_spec.rb
index d07e2a75585..7e702cc6378 100644
--- a/plugins/discourse-patreon/spec/integration/patreon_spec.rb
+++ b/plugins/discourse-patreon/spec/integration/patreon_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe ::Patreon do
+RSpec.describe Patreon do
let(:user1) { Fabricate(:user) }
let(:user2) { Fabricate(:user) }
let(:group) { Fabricate(:group) }
diff --git a/plugins/discourse-patreon/spec/lib/api_spec.rb b/plugins/discourse-patreon/spec/lib/api_spec.rb
index 7e7cfab3593..2f84ec68413 100644
--- a/plugins/discourse-patreon/spec/lib/api_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/api_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe ::Patreon::Api do
+RSpec.describe Patreon::Api do
let(:url) do
"https://api.patreon.com/oauth2/api/current_user/campaigns?include=rewards,creator,goals,pledges&page%5Bcount%5D=100"
end
diff --git a/plugins/discourse-patreon/spec/lib/campaign_spec.rb b/plugins/discourse-patreon/spec/lib/campaign_spec.rb
index 8e67cb6368d..2d3e9b8c25e 100644
--- a/plugins/discourse-patreon/spec/lib/campaign_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/campaign_spec.rb
@@ -2,7 +2,7 @@
require_relative "../spec_helper"
-RSpec.describe ::Patreon::Campaign do
+RSpec.describe Patreon::Campaign do
before do
campaigns_url =
"https://api.patreon.com/oauth2/api/current_user/campaigns?include=rewards,creator,goals,pledges&page%5Bcount%5D=100"
diff --git a/plugins/discourse-patreon/spec/lib/patron_spec.rb b/plugins/discourse-patreon/spec/lib/patron_spec.rb
index c10ea7a700d..fa369c62430 100644
--- a/plugins/discourse-patreon/spec/lib/patron_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/patron_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe ::Patreon::Patron do
+RSpec.describe Patreon::Patron do
Fabricator(:patreon_user_info, class_name: :user_associated_account) do
provider_name "patreon"
user
diff --git a/plugins/discourse-patreon/spec/lib/seed_spec.rb b/plugins/discourse-patreon/spec/lib/seed_spec.rb
index 16dbb9f49be..419d3165855 100644
--- a/plugins/discourse-patreon/spec/lib/seed_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/seed_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-RSpec.describe ::Patreon::Seed do
+RSpec.describe Patreon::Seed do
it "should seed contents correctly" do
described_class.seed_content!
group = Group.last
expect(group.name).to eq("patrons")
expect(group.flair_upload).to be_present
expect(Badge.last.name).to eq("Patron")
- expect(::Patreon.get("filters")).to eq(group.id.to_s => ["0"])
+ expect(Patreon.get("filters")).to eq(group.id.to_s => ["0"])
end
it "should not raise error if group already exists" do
group = Fabricate(:group, name: "patrons")
described_class.seed_content!
- expect(::Patreon.get("filters")).to eq(group.id.to_s => ["0"])
+ expect(Patreon.get("filters")).to eq(group.id.to_s => ["0"])
end
it "should not raise error if badge already exists" do
diff --git a/plugins/discourse-patreon/spec/requests/patreon_webhook_controller_spec.rb b/plugins/discourse-patreon/spec/requests/patreon_webhook_controller_spec.rb
index f0df1de96fa..096aba3bdcf 100644
--- a/plugins/discourse-patreon/spec/requests/patreon_webhook_controller_spec.rb
+++ b/plugins/discourse-patreon/spec/requests/patreon_webhook_controller_spec.rb
@@ -4,7 +4,7 @@ require "openssl"
require "json"
require_relative "../spec_helper"
-RSpec.describe ::Patreon::PatreonWebhookController do
+RSpec.describe Patreon::PatreonWebhookController do
before do
SiteSetting.patreon_enabled = true
SiteSetting.login_required = true
diff --git a/plugins/discourse-policy/jobs/scheduled/check_policy.rb b/plugins/discourse-policy/jobs/scheduled/check_policy.rb
index 7374487191a..78845fcd35d 100644
--- a/plugins/discourse-policy/jobs/scheduled/check_policy.rb
+++ b/plugins/discourse-policy/jobs/scheduled/check_policy.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
module Jobs
- class ::DiscoursePolicy::CheckPolicy < ::Jobs::Scheduled
- every 6.hours
+ module DiscoursePolicy
+ class CheckPolicy < ::Jobs::Scheduled
+ every 6.hours
- def execute(args = nil)
- sql = <<~SQL
+ def execute(args = nil)
+ sql = <<~SQL
SELECT p.id
FROM post_policies pp
JOIN posts p ON p.id = pp.post_id
@@ -20,54 +21,54 @@ module Jobs
)
SQL
- post_ids = DB.query_single(sql, weekly: 1.week.ago, daily: 1.day.ago)
+ post_ids = DB.query_single(sql, weekly: 1.week.ago, daily: 1.day.ago)
- if post_ids.size > 0
- Post
- .where(id: post_ids)
- .find_each do |post|
- post.post_policy.update(last_reminded_at: Time.zone.now)
+ if post_ids.size > 0
+ Post
+ .where(id: post_ids)
+ .find_each do |post|
+ post.post_policy.update(last_reminded_at: Time.zone.now)
- missing_users(post).find_each do |user|
- clear_existing_notification(user, post)
- user.notifications.create!(
- notification_type: Notification.types[:topic_reminder],
- topic_id: post.topic_id,
- post_number: post.post_number,
- data: { topic_title: post.topic.title, display_username: user.username }.to_json,
- high_priority: true,
- )
- end
+ missing_users(post).find_each do |user|
+ clear_existing_notification(user, post)
+ user.notifications.create!(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: post.post_number,
+ data: { topic_title: post.topic.title, display_username: user.username }.to_json,
+ high_priority: true,
+ )
+ end
- users_to_email(post).find_each do |user|
- DiscoursePolicy::PolicyMailer.send_email(user, post)
+ users_to_email(post).find_each do |user|
+ DiscoursePolicy::PolicyMailer.send_email(user, post)
+ end
end
- end
- end
+ end
- PostPolicy
- .where("next_renew_at < ?", Time.zone.now)
- .find_each do |policy|
- policy
- .policy_users
- .accepted
- .where("accepted_at < ?", policy.next_renew_at)
- .update_all(expired_at: Time.zone.now)
- next_renew = policy.renew_start
+ PostPolicy
+ .where("next_renew_at < ?", Time.zone.now)
+ .find_each do |policy|
+ policy
+ .policy_users
+ .accepted
+ .where("accepted_at < ?", policy.next_renew_at)
+ .update_all(expired_at: Time.zone.now)
+ next_renew = policy.renew_start
- if policy.renew_days.to_i < 1 &&
- !PostPolicy.renew_intervals.keys.include?(policy.renew_interval)
- Rails.logger.warn("Invalid policy on post #{policy.post_id}")
- elsif next_renew.present?
- while next_renew < Time.zone.now
- next_renew = calculate_next_renew_date(next_renew, policy)
+ if policy.renew_days.to_i < 1 &&
+ !PostPolicy.renew_intervals.keys.include?(policy.renew_interval)
+ Rails.logger.warn("Invalid policy on post #{policy.post_id}")
+ elsif next_renew.present?
+ while next_renew < Time.zone.now
+ next_renew = calculate_next_renew_date(next_renew, policy)
+ end
end
- end
- policy.update(next_renew_at: next_renew)
- end
+ policy.update(next_renew_at: next_renew)
+ end
- DB.exec <<~SQL,
+ DB.exec <<~SQL,
UPDATE policy_users pu
SET expired_at = :now
FROM post_policies pp
@@ -85,43 +86,44 @@ module Jobs
(pp.renew_interval = :yearly AND pu.accepted_at < :now::timestamp - (INTERVAL '1 year'))
)
SQL
- now: Time.zone.now,
- monthly: PostPolicy.renew_intervals["monthly"],
- quarterly: PostPolicy.renew_intervals["quarterly"],
- yearly: PostPolicy.renew_intervals["yearly"]
- end
+ now: Time.zone.now,
+ monthly: PostPolicy.renew_intervals["monthly"],
+ quarterly: PostPolicy.renew_intervals["quarterly"],
+ yearly: PostPolicy.renew_intervals["yearly"]
+ end
- def calculate_next_renew_date(date, policy)
- case policy.renew_interval
- when "monthly"
- date + 1.month
- when "quarterly"
- date + 3.months
- when "yearly"
- date + 1.year
- else
- date + policy.renew_days.to_i.days
+ def calculate_next_renew_date(date, policy)
+ case policy.renew_interval
+ when "monthly"
+ date + 1.month
+ when "quarterly"
+ date + 3.months
+ when "yearly"
+ date + 1.year
+ else
+ date + policy.renew_days.to_i.days
+ end
end
- end
- def missing_users(post)
- post.post_policy.not_accepted_by
- end
+ def missing_users(post)
+ post.post_policy.not_accepted_by
+ end
- def users_to_email(post)
- post.post_policy.emailed_by
- end
+ def users_to_email(post)
+ post.post_policy.emailed_by
+ end
- def clear_existing_notification(user, post)
- existing_notification =
- Notification.find_by(
- notification_type: Notification.types[:topic_reminder],
- topic_id: post.topic_id,
- post_number: post.post_number,
- user: user,
- )
- return if existing_notification.blank?
- existing_notification.delete
+ def clear_existing_notification(user, post)
+ existing_notification =
+ Notification.find_by(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: post.post_number,
+ user: user,
+ )
+ return if existing_notification.blank?
+ existing_notification.delete
+ end
end
end
end
diff --git a/plugins/discourse-policy/lib/discourse_policy/engine.rb b/plugins/discourse-policy/lib/discourse_policy/engine.rb
index 772947229dc..660f6056200 100644
--- a/plugins/discourse-policy/lib/discourse_policy/engine.rb
+++ b/plugins/discourse-policy/lib/discourse_policy/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscoursePolicy
+module DiscoursePolicy
HAS_POLICY = "HasPolicy"
POLICY_USER_DEFAULT_LIMIT = 25
diff --git a/plugins/discourse-policy/plugin.rb b/plugins/discourse-policy/plugin.rb
index 98f6d9dfb0f..49af1901f31 100644
--- a/plugins/discourse-policy/plugin.rb
+++ b/plugins/discourse-policy/plugin.rb
@@ -34,7 +34,7 @@ after_initialize do
require_relative "lib/extensions/user_option_extension"
require_relative "lib/policy_mailer"
- Discourse::Application.routes.append { mount ::DiscoursePolicy::Engine, at: "/policy" }
+ Discourse::Application.routes.append { mount DiscoursePolicy::Engine, at: "/policy" }
Post.prepend DiscoursePolicy::PostExtension
PostSerializer.prepend DiscoursePolicy::PostSerializerExtension
diff --git a/plugins/discourse-policy/spec/lib/check_policy_spec.rb b/plugins/discourse-policy/spec/lib/check_policy_spec.rb
index 914e9007c58..e33e7767577 100644
--- a/plugins/discourse-policy/spec/lib/check_policy_spec.rb
+++ b/plugins/discourse-policy/spec/lib/check_policy_spec.rb
@@ -1,10 +1,7 @@
# frozen_string_literal: true
-describe DiscoursePolicy::CheckPolicy do
- before do
- enable_current_plugin
- Jobs.run_immediately!
- end
+describe Jobs::DiscoursePolicy::CheckPolicy do
+ subject(:job) { described_class.new }
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
@@ -16,6 +13,11 @@ describe DiscoursePolicy::CheckPolicy do
group
end
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+ end
+
def accept_policy(post)
[user1, user2].each { |u| PolicyUser.add!(u, post.post_policy) }
end
@@ -35,13 +37,13 @@ describe DiscoursePolicy::CheckPolicy do
accept_policy(post)
freeze_time Time.utc(2022)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
freeze_time Time.utc(2023)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to be_empty
@@ -63,7 +65,7 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time Time.utc(2022)
PolicyUser.where(user_id: user2.id).update(accepted_at: Time.now)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to contain_exactly(user2)
@@ -92,7 +94,7 @@ describe DiscoursePolicy::CheckPolicy do
accept_policy(post2)
freeze_time Time.utc(2022)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to be_empty
@@ -113,7 +115,7 @@ describe DiscoursePolicy::CheckPolicy do
accept_policy(post)
freeze_time Time.utc(2020)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
# did not hit renew start
@@ -121,7 +123,7 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time Time.utc(2020, 10, 18)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to be_empty
@@ -132,7 +134,7 @@ describe DiscoursePolicy::CheckPolicy do
PolicyUser.add!(user2, post.post_policy)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to contain_exactly(user2)
@@ -163,14 +165,14 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time Time.utc(2020, 10, 17)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
freeze_time Time.utc(2020, 10, 18)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to be_empty
@@ -203,14 +205,14 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time Time.utc(2020, 10, 30)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
freeze_time Time.utc(2020, 10, 16) + period + 1.day
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
post.reload
expect(post.post_policy.accepted_by).to be_empty
@@ -230,7 +232,7 @@ describe DiscoursePolicy::CheckPolicy do
post = create_post(raw: raw, user: Fabricate(:admin))
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
expect(
user1.notifications.where(notification_type: Notification.types[:topic_reminder]).count,
@@ -241,8 +243,8 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time 2.weeks.from_now
- DiscoursePolicy::CheckPolicy.new.execute
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
+ job.execute
user1_notifications =
user1.notifications.where(
@@ -274,7 +276,7 @@ describe DiscoursePolicy::CheckPolicy do
post = create_post(raw: raw, user: Fabricate(:admin))
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
expect(
user1.notifications.where(notification_type: Notification.types[:topic_reminder]).count,
@@ -282,7 +284,7 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time 2.weeks.from_now
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
user1_notification =
user1
@@ -297,7 +299,7 @@ describe DiscoursePolicy::CheckPolicy do
freeze_time 2.weeks.from_now
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
expect(
user1
@@ -315,7 +317,7 @@ describe DiscoursePolicy::CheckPolicy do
it "clears the next_renew_at when renew_start is nil" do
policy = Fabricate(:post_policy, next_renew_at: 3.hours.ago, renew_start: nil, renew_days: 10)
- DiscoursePolicy::CheckPolicy.new.execute
+ job.execute
expect(policy.reload.next_renew_at).to be_nil
end
diff --git a/plugins/discourse-policy/spec/lib/pretty_text_spec.rb b/plugins/discourse-policy/spec/lib/pretty_text_spec.rb
index 0bcf1735b6b..88e9e5b9f24 100644
--- a/plugins/discourse-policy/spec/lib/pretty_text_spec.rb
+++ b/plugins/discourse-policy/spec/lib/pretty_text_spec.rb
@@ -76,11 +76,11 @@ describe PrettyText do
PolicyUser.add!(user, post.post_policy)
freeze_time(199.days.from_now)
- ::DiscoursePolicy::CheckPolicy.new.execute(nil)
+ Jobs::DiscoursePolicy::CheckPolicy.new.execute(nil)
expect(post.post_policy.accepted_by).to eq([user])
freeze_time(2.days.from_now)
- ::DiscoursePolicy::CheckPolicy.new.execute(nil)
+ Jobs::DiscoursePolicy::CheckPolicy.new.execute(nil)
expect(post.post_policy.accepted_by).to be_empty
end
diff --git a/plugins/discourse-post-voting/config/routes.rb b/plugins/discourse-post-voting/config/routes.rb
index 916b31e4ec5..21eeb2d8bbf 100644
--- a/plugins/discourse-post-voting/config/routes.rb
+++ b/plugins/discourse-post-voting/config/routes.rb
@@ -13,4 +13,4 @@ PostVoting::Engine.routes.draw do
delete "vote/comment" => "votes#destroy_comment_vote"
end
-Discourse::Application.routes.append { mount ::PostVoting::Engine, at: "post_voting" }
+Discourse::Application.routes.append { mount PostVoting::Engine, at: "post_voting" }
diff --git a/plugins/discourse-post-voting/lib/post_voting/engine.rb b/plugins/discourse-post-voting/lib/post_voting/engine.rb
index e5172b1eb73..34884a1dafc 100644
--- a/plugins/discourse-post-voting/lib/post_voting/engine.rb
+++ b/plugins/discourse-post-voting/lib/post_voting/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::PostVoting
+module PostVoting
CREATE_AS_POST_VOTING_DEFAULT = "create_as_post_voting_default"
ONLY_POST_VOTING_IN_THIS_CATEGORY = "only_post_voting_in_this_category"
diff --git a/plugins/discourse-reactions/lib/discourse_reactions/engine.rb b/plugins/discourse-reactions/lib/discourse_reactions/engine.rb
index 251088575b3..1e8f676a046 100644
--- a/plugins/discourse-reactions/lib/discourse_reactions/engine.rb
+++ b/plugins/discourse-reactions/lib/discourse_reactions/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseReactions
+module DiscourseReactions
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseReactions
diff --git a/plugins/discourse-reactions/plugin.rb b/plugins/discourse-reactions/plugin.rb
index 2c1cd10f975..e3a7a581746 100644
--- a/plugins/discourse-reactions/plugin.rb
+++ b/plugins/discourse-reactions/plugin.rb
@@ -60,7 +60,7 @@ after_initialize do
Notification.singleton_class.prepend DiscourseReactions::NotificationExtension
end
- Discourse::Application.routes.append { mount ::DiscourseReactions::Engine, at: "/" }
+ Discourse::Application.routes.append { mount DiscourseReactions::Engine, at: "/" }
add_to_serializer(:post, :reactions) do
reactions = []
diff --git a/plugins/discourse-reactions/spec/plugin_spec.rb b/plugins/discourse-reactions/spec/plugin_spec.rb
index 31bf72a7171..adcca014e14 100644
--- a/plugins/discourse-reactions/spec/plugin_spec.rb
+++ b/plugins/discourse-reactions/spec/plugin_spec.rb
@@ -26,7 +26,7 @@ describe DiscourseReactions do
describe "on_setting_change(discourse_reactions_excluded_from_like)" do
it "kicks off the background job to sync post actions when site setting changes" do
- expect_enqueued_with(job: ::Jobs::DiscourseReactions::LikeSynchronizer) do
+ expect_enqueued_with(job: Jobs::DiscourseReactions::LikeSynchronizer) do
SiteSetting.discourse_reactions_excluded_from_like = "confetti_ball|-1"
end
end
diff --git a/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb b/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb
index f9d2ba04227..7d0257d05f4 100644
--- a/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb
+++ b/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "rails_helper"
-
describe DiscourseReactions::CustomReactionsController do
fab!(:user)
fab!(:post_1) { Fabricate(:post) }
diff --git a/plugins/discourse-rss-polling/plugin.rb b/plugins/discourse-rss-polling/plugin.rb
index 8626f42b854..808672df27c 100644
--- a/plugins/discourse-rss-polling/plugin.rb
+++ b/plugins/discourse-rss-polling/plugin.rb
@@ -18,5 +18,5 @@ end
require_relative "lib/discourse_rss_polling/engine"
Discourse::Application.routes.append do
- mount ::DiscourseRssPolling::Engine, at: "/admin/plugins/rss_polling"
+ mount DiscourseRssPolling::Engine, at: "/admin/plugins/rss_polling"
end
diff --git a/plugins/discourse-rss-polling/spec/jobs/poll_all_feeds_spec.rb b/plugins/discourse-rss-polling/spec/jobs/poll_all_feeds_spec.rb
index d0a5b7383da..0f4248a07cf 100644
--- a/plugins/discourse-rss-polling/spec/jobs/poll_all_feeds_spec.rb
+++ b/plugins/discourse-rss-polling/spec/jobs/poll_all_feeds_spec.rb
@@ -1,8 +1,9 @@
# frozen_string_literal: true
RSpec.describe Jobs::DiscourseRssPolling::PollAllFeeds do
- SiteSetting.rss_polling_enabled = true
- let(:job) { Jobs::DiscourseRssPolling::PollAllFeeds.new }
+ subject(:job) { described_class.new }
+
+ before { SiteSetting.rss_polling_enabled = true }
describe "#execute" do
before do
diff --git a/plugins/discourse-rss-polling/spec/jobs/poll_feed_spec.rb b/plugins/discourse-rss-polling/spec/jobs/poll_feed_spec.rb
index 522f6654c54..1b02efe6a69 100644
--- a/plugins/discourse-rss-polling/spec/jobs/poll_feed_spec.rb
+++ b/plugins/discourse-rss-polling/spec/jobs/poll_feed_spec.rb
@@ -1,11 +1,13 @@
# frozen_string_literal: true
RSpec.describe Jobs::DiscourseRssPolling::PollFeed do
- SiteSetting.rss_polling_enabled = true
+ subject(:job) { described_class.new }
+
let(:feed_url) { "https://blog.discourse.org/feed/" }
let(:author) { Fabricate(:user, trust_level: 1) }
let(:raw_feed) { file_from_fixtures("feed.rss", "feed") }
- let(:job) { Jobs::DiscourseRssPolling::PollFeed.new }
+
+ before { SiteSetting.rss_polling_enabled = true }
describe "#execute" do
before do
diff --git a/plugins/discourse-solved/config/routes.rb b/plugins/discourse-solved/config/routes.rb
index 2569aa2193b..201333c398d 100644
--- a/plugins/discourse-solved/config/routes.rb
+++ b/plugins/discourse-solved/config/routes.rb
@@ -7,4 +7,4 @@ DiscourseSolved::Engine.routes.draw do
get "/by_user" => "solved_topics#by_user"
end
-Discourse::Application.routes.draw { mount ::DiscourseSolved::Engine, at: "solution" }
+Discourse::Application.routes.draw { mount DiscourseSolved::Engine, at: "solution" }
diff --git a/plugins/discourse-solved/lib/discourse_solved/accepted_answer_cache.rb b/plugins/discourse-solved/lib/discourse_solved/accepted_answer_cache.rb
index a25b2c2d85d..672abe5a776 100644
--- a/plugins/discourse-solved/lib/discourse_solved/accepted_answer_cache.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/accepted_answer_cache.rb
@@ -8,7 +8,7 @@ module DiscourseSolved
@@allowed_accepted_cache["allowed"] = begin
Set.new(
CategoryCustomField.where(
- name: ::DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
+ name: DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
value: "true",
).pluck(:category_id),
)
diff --git a/plugins/discourse-solved/lib/discourse_solved/category_extension.rb b/plugins/discourse-solved/lib/discourse_solved/category_extension.rb
index 80dd9ae2fd0..57772cb52a8 100644
--- a/plugins/discourse-solved/lib/discourse_solved/category_extension.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/category_extension.rb
@@ -8,6 +8,6 @@ module DiscourseSolved::CategoryExtension
private
def reset_accepted_cache
- ::DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache
+ DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache
end
end
diff --git a/plugins/discourse-solved/lib/discourse_solved/engine.rb b/plugins/discourse-solved/lib/discourse_solved/engine.rb
index 6c41a5eeff6..162f775b368 100644
--- a/plugins/discourse-solved/lib/discourse_solved/engine.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseSolved
+module DiscourseSolved
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseSolved
diff --git a/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb b/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb
index 6ea7fec9f49..ecccdc5766f 100644
--- a/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb
@@ -13,10 +13,10 @@ module DiscourseSolved
end
return false if category_id.blank?
- if !::DiscourseSolved::AcceptedAnswerCache.allowed
- ::DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache
+ if !DiscourseSolved::AcceptedAnswerCache.allowed
+ DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache
end
- ::DiscourseSolved::AcceptedAnswerCache.allowed.include?(category_id)
+ DiscourseSolved::AcceptedAnswerCache.allowed.include?(category_id)
end
def can_accept_answer?(topic, post)
diff --git a/plugins/discourse-solved/lib/discourse_solved/register_filters.rb b/plugins/discourse-solved/lib/discourse_solved/register_filters.rb
index 027a7fac9f4..ed0163e3df5 100644
--- a/plugins/discourse-solved/lib/discourse_solved/register_filters.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/register_filters.rb
@@ -26,7 +26,7 @@ module DiscourseSolved
FROM topics t
JOIN category_custom_fields cc
ON t.category_id = cc.category_id
- AND cc.name = '#{::DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD}'
+ AND cc.name = '#{DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD}'
AND cc.value = 'true'
)
OR
diff --git a/plugins/discourse-solved/plugin.rb b/plugins/discourse-solved/plugin.rb
index 09b7835d318..4c256b5bb98 100644
--- a/plugins/discourse-solved/plugin.rb
+++ b/plugins/discourse-solved/plugin.rb
@@ -186,7 +186,7 @@ after_initialize do
register_category_list_topics_preloader_associations(:solved) if SiteSetting.solved_enabled
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::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD
add_api_key_scope(
:solved,
@@ -273,7 +273,7 @@ after_initialize do
add_to_serializer(:post, :accepted_answer) { topic&.solved&.answer_post_id == object.id }
add_to_serializer(:post, :topic_accepted_answer) { topic&.solved&.present? }
- on(:post_destroyed) { |post| ::DiscourseSolved.unaccept_answer!(post) }
+ on(:post_destroyed) { |post| DiscourseSolved.unaccept_answer!(post) }
on(:filter_auto_bump_topics) do |_category, filters|
filters.push(
diff --git a/plugins/discourse-solved/spec/integration/solved_spec.rb b/plugins/discourse-solved/spec/integration/solved_spec.rb
index 96a10bc87bc..6184939b878 100644
--- a/plugins/discourse-solved/spec/integration/solved_spec.rb
+++ b/plugins/discourse-solved/spec/integration/solved_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe "Managing Posts solved status" do
CategoryCustomField.create(
category_id: category.id,
- name: ::DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
+ name: DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
value: "true",
)
@@ -142,7 +142,7 @@ RSpec.describe "Managing Posts solved status" do
category_custom_field =
CategoryCustomField.new(
category_id: category.id,
- name: ::DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
+ name: DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
value: "true",
)
category_custom_field.save
@@ -153,7 +153,7 @@ RSpec.describe "Managing Posts solved status" do
category_custom_field =
CategoryCustomField.new(
category_id: category.id,
- name: ::DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
+ name: DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
value: "false",
)
category_custom_field.save
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/coupons_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/coupons_controller.rb
index 1ef1d5f0aba..72adf183e36 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/coupons_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/coupons_controller.rb
@@ -6,7 +6,7 @@ module DiscourseSubscriptions
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :set_api_key
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/plans_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/plans_controller.rb
index 7867581d2aa..fb5f8ea6471 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/plans_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/plans_controller.rb
@@ -5,7 +5,7 @@ module DiscourseSubscriptions
class PlansController < ::Admin::AdminController
include DiscourseSubscriptions::Stripe
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :set_api_key
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/products_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/products_controller.rb
index d2d21fbb475..2c644c5d9c1 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/products_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/products_controller.rb
@@ -5,7 +5,7 @@ module DiscourseSubscriptions
class ProductsController < ::Admin::AdminController
include DiscourseSubscriptions::Stripe
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :set_api_key
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb
index 5e0b0756968..a4250b539e2 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb
@@ -3,7 +3,7 @@
module DiscourseSubscriptions
module Admin
class SubscriptionsController < ::Admin::AdminController
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb
index 4efa4240d0a..c5d69b95384 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb
@@ -2,7 +2,7 @@
module DiscourseSubscriptions
class AdminController < ::Admin::AdminController
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
head 200
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb
index 15a9d7b4b93..5f7b8cf0ea8 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb
@@ -5,7 +5,7 @@ module DiscourseSubscriptions
include DiscourseSubscriptions::Group
include DiscourseSubscriptions::Stripe
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
layout false
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb
index eca32e407b5..d2ae713f785 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb
@@ -2,7 +2,7 @@
module DiscourseSubscriptions
class PricingtableController < ::ApplicationController
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def index
head 200
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb
index 9721698eaba..2991bfee38b 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb
@@ -5,7 +5,7 @@ module DiscourseSubscriptions
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :set_api_key
requires_login except: %i[index contributors show]
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/payments_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/payments_controller.rb
index 7bc4712e0cb..55325ceeee7 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/payments_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/payments_controller.rb
@@ -5,7 +5,7 @@ module DiscourseSubscriptions
class PaymentsController < ::ApplicationController
include DiscourseSubscriptions::Stripe
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :set_api_key
requires_login
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/subscriptions_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/subscriptions_controller.rb
index 913207eac38..68b85673810 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/subscriptions_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/user/subscriptions_controller.rb
@@ -6,7 +6,7 @@ module DiscourseSubscriptions
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
- requires_plugin DiscourseSubscriptions::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :set_api_key
requires_login
diff --git a/plugins/discourse-subscriptions/app/jobs/regular/manually_update_campaign_data.rb b/plugins/discourse-subscriptions/app/jobs/regular/manually_update_campaign_data.rb
index 7a3cc175c2f..806ed250422 100644
--- a/plugins/discourse-subscriptions/app/jobs/regular/manually_update_campaign_data.rb
+++ b/plugins/discourse-subscriptions/app/jobs/regular/manually_update_campaign_data.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class ManuallyUpdateCampaignData < ::Jobs::Base
def execute(args)
return unless SiteSetting.discourse_subscriptions_campaign_enabled
diff --git a/plugins/discourse-subscriptions/app/jobs/scheduled/refresh_subscriptions_campaign_data.rb b/plugins/discourse-subscriptions/app/jobs/scheduled/refresh_subscriptions_campaign_data.rb
index 46ef0a46dc3..febaeb8ad4d 100644
--- a/plugins/discourse-subscriptions/app/jobs/scheduled/refresh_subscriptions_campaign_data.rb
+++ b/plugins/discourse-subscriptions/app/jobs/scheduled/refresh_subscriptions_campaign_data.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-module ::Jobs
+module Jobs
class RefreshSubscriptionsCampaignData < ::Jobs::Scheduled
- include ::DiscourseSubscriptions::Stripe
+ include DiscourseSubscriptions::Stripe
every 30.minutes
def execute(args)
diff --git a/plugins/discourse-subscriptions/lib/discourse_subscriptions/engine.rb b/plugins/discourse-subscriptions/lib/discourse_subscriptions/engine.rb
index d11dc5851ae..7a4410a0292 100644
--- a/plugins/discourse-subscriptions/lib/discourse_subscriptions/engine.rb
+++ b/plugins/discourse-subscriptions/lib/discourse_subscriptions/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseSubscriptions
+module DiscourseSubscriptions
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseSubscriptions
diff --git a/plugins/discourse-subscriptions/plugin.rb b/plugins/discourse-subscriptions/plugin.rb
index 439a18fab0b..57d0918f6fe 100644
--- a/plugins/discourse-subscriptions/plugin.rb
+++ b/plugins/discourse-subscriptions/plugin.rb
@@ -75,7 +75,7 @@ after_initialize do
url: "https://github.com/discourse/discourse-subscriptions",
)
- Discourse::Application.routes.append { mount ::DiscourseSubscriptions::Engine, at: "s" }
+ Discourse::Application.routes.append { mount DiscourseSubscriptions::Engine, at: "s" }
add_to_serializer(:site, :show_campaign_banner) do
begin
diff --git a/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb b/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb
index 353942c5f14..c3710a2107c 100644
--- a/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb
+++ b/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do
end
it "is not subscribed" do
- ::DiscourseSubscriptions::Customer.delete_all
+ DiscourseSubscriptions::Customer.delete_all
::Stripe::Product
.expects(:list)
.with({ ids: product_ids, active: true })
diff --git a/plugins/discourse-templates/lib/discourse_templates/engine.rb b/plugins/discourse-templates/lib/discourse_templates/engine.rb
index d031465cbbc..d73abfdd3b0 100644
--- a/plugins/discourse-templates/lib/discourse_templates/engine.rb
+++ b/plugins/discourse-templates/lib/discourse_templates/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseTemplates
+module DiscourseTemplates
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseTemplates
diff --git a/plugins/discourse-templates/plugin.rb b/plugins/discourse-templates/plugin.rb
index 97f5cc1c2b0..ad5b62ad1d8 100644
--- a/plugins/discourse-templates/plugin.rb
+++ b/plugins/discourse-templates/plugin.rb
@@ -29,7 +29,7 @@ after_initialize do
require_relative "lib/discourse_templates/user_extension"
Discourse::Application.routes.append do
- mount ::DiscourseTemplates::Engine, at: "/discourse_templates"
+ mount DiscourseTemplates::Engine, at: "/discourse_templates"
end
reloadable_patch do |plugin|
diff --git a/plugins/discourse-topic-voting/app/controllers/discourse_topic_voting/votes_controller.rb b/plugins/discourse-topic-voting/app/controllers/discourse_topic_voting/votes_controller.rb
index 0832d4ee038..1ba02306fb3 100644
--- a/plugins/discourse-topic-voting/app/controllers/discourse_topic_voting/votes_controller.rb
+++ b/plugins/discourse-topic-voting/app/controllers/discourse_topic_voting/votes_controller.rb
@@ -2,7 +2,7 @@
module DiscourseTopicVoting
class VotesController < ::ApplicationController
- requires_plugin DiscourseTopicVoting::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_logged_in
diff --git a/plugins/discourse-topic-voting/lib/discourse_topic_voting/engine.rb b/plugins/discourse-topic-voting/lib/discourse_topic_voting/engine.rb
index 8d98f813f7c..de6180bd7e3 100644
--- a/plugins/discourse-topic-voting/lib/discourse_topic_voting/engine.rb
+++ b/plugins/discourse-topic-voting/lib/discourse_topic_voting/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseTopicVoting
+module DiscourseTopicVoting
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseTopicVoting
diff --git a/plugins/discourse-topic-voting/plugin.rb b/plugins/discourse-topic-voting/plugin.rb
index 0b993cc3c20..e2d1eaeb5d9 100755
--- a/plugins/discourse-topic-voting/plugin.rb
+++ b/plugins/discourse-topic-voting/plugin.rb
@@ -216,7 +216,7 @@ after_initialize do
end
Discourse::Application.routes.append do
- mount ::DiscourseTopicVoting::Engine, at: "/voting"
+ mount DiscourseTopicVoting::Engine, at: "/voting"
get "topics/voted-by/:username" => "list#voted_by",
:as => "voted_by",
diff --git a/plugins/discourse-user-notes/app/controllers/discourse_user_notes/user_notes_controller.rb b/plugins/discourse-user-notes/app/controllers/discourse_user_notes/user_notes_controller.rb
index c6d1e37bd31..21171bf76b3 100644
--- a/plugins/discourse-user-notes/app/controllers/discourse_user_notes/user_notes_controller.rb
+++ b/plugins/discourse-user-notes/app/controllers/discourse_user_notes/user_notes_controller.rb
@@ -2,7 +2,7 @@
module DiscourseUserNotes
class UserNotesController < ::ApplicationController
- requires_plugin DiscourseUserNotes::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
before_action :ensure_logged_in
before_action :ensure_staff
@@ -10,7 +10,7 @@ module DiscourseUserNotes
user = User.where(id: params[:user_id]).first
raise Discourse::NotFound if user.blank?
- notes = ::DiscourseUserNotes.notes_for(params[:user_id])
+ notes = DiscourseUserNotes.notes_for(params[:user_id])
render json: { extras: { username: user.username }, user_notes: create_json(notes.reverse) }
end
@@ -23,7 +23,7 @@ module DiscourseUserNotes
end
user_note =
- ::DiscourseUserNotes.add_note(user, params[:user_note][:raw], current_user.id, extras)
+ DiscourseUserNotes.add_note(user, params[:user_note][:raw], current_user.id, extras)
render json: create_json(user_note)
end
@@ -34,7 +34,7 @@ module DiscourseUserNotes
raise Discourse::InvalidAccess.new unless guardian.can_delete_user_notes?
- ::DiscourseUserNotes.remove_note(user, params[:id])
+ DiscourseUserNotes.remove_note(user, params[:id])
render json: success_json
end
diff --git a/plugins/discourse-user-notes/lib/discourse_user_notes/engine.rb b/plugins/discourse-user-notes/lib/discourse_user_notes/engine.rb
index 6fbb04e9ac5..0df12b7e4a1 100644
--- a/plugins/discourse-user-notes/lib/discourse_user_notes/engine.rb
+++ b/plugins/discourse-user-notes/lib/discourse_user_notes/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscourseUserNotes
+module DiscourseUserNotes
COUNT_FIELD = "user_notes_count"
class Engine < ::Rails::Engine
diff --git a/plugins/discourse-user-notes/plugin.rb b/plugins/discourse-user-notes/plugin.rb
index 70713cda5d6..889533dadfd 100644
--- a/plugins/discourse-user-notes/plugin.rb
+++ b/plugins/discourse-user-notes/plugin.rb
@@ -25,7 +25,7 @@ after_initialize do
require_relative "app/serializers/user_note_serializer"
require_relative "app/controllers/discourse_user_notes/user_notes_controller"
- Discourse::Application.routes.append { mount ::DiscourseUserNotes::Engine, at: "/user_notes" }
+ Discourse::Application.routes.append { mount DiscourseUserNotes::Engine, at: "/user_notes" }
allow_staff_user_custom_field(DiscourseUserNotes::COUNT_FIELD)
@@ -49,12 +49,7 @@ after_initialize do
warning_link: "[#{warning_topic.title}](#{warning_topic.url})",
)
end
- ::DiscourseUserNotes.add_note(
- user,
- raw_note,
- Discourse::SYSTEM_USER_ID,
- topic_id: self.topic_id,
- )
+ DiscourseUserNotes.add_note(user, raw_note, Discourse::SYSTEM_USER_ID, topic_id: self.topic_id)
# Fire event after note is created for other plugins to hook into
DiscourseEvent.trigger(:user_warning_created, self)
diff --git a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/issues_controller.rb b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/issues_controller.rb
index fd1f32f6886..9384c3414cb 100644
--- a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/issues_controller.rb
+++ b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/issues_controller.rb
@@ -2,14 +2,14 @@
module DiscourseZendeskPlugin
class IssuesController < ApplicationController
- include ::DiscourseZendeskPlugin::Helper
+ include DiscourseZendeskPlugin::Helper
- requires_plugin ::DiscourseZendeskPlugin::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
def create
topic = Topic.find(params[:topic_id])
- if topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD].blank?
+ if topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD].blank?
create_ticket(topic.first_post)
end
diff --git a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb
index 8e95839a0e1..6d803bc9000 100644
--- a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb
+++ b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb
@@ -2,9 +2,9 @@
module DiscourseZendeskPlugin
class SyncController < ApplicationController
- include ::DiscourseZendeskPlugin::Helper
+ include DiscourseZendeskPlugin::Helper
- requires_plugin ::DiscourseZendeskPlugin::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
layout false
before_action :zendesk_token_valid?, only: :webhook
@@ -30,7 +30,7 @@ module DiscourseZendeskPlugin
if latest_comment.present?
existing_comment =
PostCustomField.where(
- name: ::DiscourseZendeskPlugin::ZENDESK_ID_FIELD,
+ name: DiscourseZendeskPlugin::ZENDESK_ID_FIELD,
value: latest_comment.id,
).first
diff --git a/plugins/discourse-zendesk-plugin/app/jobs/regular/zendesk_job.rb b/plugins/discourse-zendesk-plugin/app/jobs/regular/zendesk_job.rb
index 4ec994a3415..46dcb368d2f 100644
--- a/plugins/discourse-zendesk-plugin/app/jobs/regular/zendesk_job.rb
+++ b/plugins/discourse-zendesk-plugin/app/jobs/regular/zendesk_job.rb
@@ -3,7 +3,7 @@
module Jobs
class ZendeskJob < ::Jobs::Base
sidekiq_options backtrace: true
- include ::DiscourseZendeskPlugin::Helper
+ include DiscourseZendeskPlugin::Helper
def execute(args)
return unless SiteSetting.zendesk_enabled?
@@ -30,11 +30,11 @@ module Jobs
def push_post!(post_id)
post = Post.find_by(id: post_id)
return if !post || post.user_id < 1
- return if post.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD].present?
+ return if post.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD].present?
return if !DiscourseZendeskPlugin::Helper.autogeneration_category?(post.topic.category_id)
return if !SiteSetting.zendesk_job_push_all_posts? && post.post_number > 1
- ticket_id = post.topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD]
+ ticket_id = post.topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD]
if ticket_id.present?
add_comment(post, ticket_id) if comment_eligible_for_sync?(post)
else
diff --git a/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb b/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb
index 9bce6df2c17..fd93fae3c2a 100644
--- a/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb
+++ b/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb
@@ -80,15 +80,15 @@ module DiscourseZendeskPlugin
end
def update_topic_custom_fields(topic, ticket)
- topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD] = ticket["id"]
- topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_API_URL_FIELD] = ticket["url"]
+ topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD] = ticket["id"]
+ topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_API_URL_FIELD] = ticket["url"]
topic.save_custom_fields
end
def update_post_custom_fields(post, comment)
return if comment.blank?
- post.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD] = comment["id"]
+ post.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD] = comment["id"]
post.save_custom_fields
end
diff --git a/plugins/discourse-zendesk-plugin/plugin.rb b/plugins/discourse-zendesk-plugin/plugin.rb
index 972aa901948..7803314f2e4 100644
--- a/plugins/discourse-zendesk-plugin/plugin.rb
+++ b/plugins/discourse-zendesk-plugin/plugin.rb
@@ -38,16 +38,16 @@ after_initialize do
add_to_serializer(
:topic_view,
- ::DiscourseZendeskPlugin::ZENDESK_ID_FIELD.to_sym,
+ DiscourseZendeskPlugin::ZENDESK_ID_FIELD.to_sym,
respect_plugin_enabled: false,
- ) { object.topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD] }
+ ) { object.topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD] }
add_to_serializer(
:topic_view,
- ::DiscourseZendeskPlugin::ZENDESK_URL_FIELD.to_sym,
+ DiscourseZendeskPlugin::ZENDESK_URL_FIELD.to_sym,
respect_plugin_enabled: false,
) do
- id = object.topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD]
+ id = object.topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD]
uri = URI.parse(SiteSetting.zendesk_url)
"#{uri.scheme}://#{uri.host}/agent/tickets/#{id}"
end
diff --git a/plugins/discourse-zendesk-plugin/spec/jobs/regular/zendesk_job_spec.rb b/plugins/discourse-zendesk-plugin/spec/jobs/regular/zendesk_job_spec.rb
index 0d3bd918680..7f2a6069805 100644
--- a/plugins/discourse-zendesk-plugin/spec/jobs/regular/zendesk_job_spec.rb
+++ b/plugins/discourse-zendesk-plugin/spec/jobs/regular/zendesk_job_spec.rb
@@ -10,8 +10,8 @@ RSpec.describe Jobs::ZendeskJob do
let(:post_user) { topic_user }
let(:topic) do
Fabricate(:topic, user: topic_user).tap do |topic|
- topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_ID_FIELD] = ticket_id
- topic.custom_fields[::DiscourseZendeskPlugin::ZENDESK_API_URL_FIELD] = ticket_url
+ topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD] = ticket_id
+ topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_API_URL_FIELD] = ticket_url
topic.save_custom_fields
end
end
diff --git a/plugins/poll/lib/poll/engine.rb b/plugins/poll/lib/poll/engine.rb
index 8b14aee4a5b..0e3ff9f2f2f 100644
--- a/plugins/poll/lib/poll/engine.rb
+++ b/plugins/poll/lib/poll/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::DiscoursePoll
+module DiscoursePoll
DATA_PREFIX = "data-poll-"
HAS_POLLS = "has_polls"
DEFAULT_POLL_NAME = "poll"
diff --git a/plugins/poll/lib/polls_validator.rb b/plugins/poll/lib/polls_validator.rb
index 8a0846906c8..ff5745fd701 100644
--- a/plugins/poll/lib/polls_validator.rb
+++ b/plugins/poll/lib/polls_validator.rb
@@ -62,7 +62,7 @@ module DiscoursePoll
def unique_poll_name?(polls, poll)
if polls.has_key?(poll["name"])
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(:base, I18n.t("poll.multiple_polls_without_name"))
else
@post.errors.add(:base, I18n.t("poll.multiple_polls_with_same_name", name: poll["name"]))
@@ -76,7 +76,7 @@ module DiscoursePoll
def unique_options?(poll)
if poll["options"].map { |o| o["id"] }.uniq.size != poll["options"].size
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(:base, I18n.t("poll.default_poll_must_have_different_options"))
else
@post.errors.add(
@@ -93,7 +93,7 @@ module DiscoursePoll
def any_blank_options?(poll)
if poll["options"].any? { |o| o["html"].blank? }
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(:base, I18n.t("poll.default_poll_must_not_have_any_empty_options"))
else
@post.errors.add(
@@ -110,7 +110,7 @@ module DiscoursePoll
def at_least_one_option?(poll)
if poll["options"].size < 1
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(:base, I18n.t("poll.default_poll_must_have_at_least_1_option"))
else
@post.errors.add(
@@ -127,7 +127,7 @@ module DiscoursePoll
def valid_number_of_options?(poll)
if poll["options"].size > SiteSetting.poll_maximum_options
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(
:base,
I18n.t(
@@ -159,7 +159,7 @@ module DiscoursePoll
max = (poll["max"].presence || options).to_i
if min > max || min <= 0 || max <= 0 || max > options || min >= options
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(
:base,
I18n.t("poll.default_poll_with_multiple_choices_has_invalid_parameters"),
@@ -210,7 +210,7 @@ module DiscoursePoll
@post.errors.add(:base, "Step #{I18n.t("errors.messages.greater_than", count: 0)}")
valid = false
elsif ((max - min + 1) / step) < 2
- if poll["name"] == ::DiscoursePoll::DEFAULT_POLL_NAME
+ if poll["name"] == DiscoursePoll::DEFAULT_POLL_NAME
@post.errors.add(:base, I18n.t("poll.default_poll_must_have_at_least_1_option"))
else
@post.errors.add(
diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb
index ca5691ccaf2..8c11179f021 100644
--- a/plugins/poll/plugin.rb
+++ b/plugins/poll/plugin.rb
@@ -37,7 +37,7 @@ after_initialize do
require_relative "lib/post_extension"
require_relative "lib/user_extension"
- Discourse::Application.routes.append { mount ::DiscoursePoll::Engine, at: "/polls" }
+ Discourse::Application.routes.append { mount DiscoursePoll::Engine, at: "/polls" }
allow_new_queued_post_payload_attribute("is_poll")
register_post_custom_field_type(DiscoursePoll::HAS_POLLS, :boolean)
diff --git a/plugins/poll/spec/controllers/polls_controller_spec.rb b/plugins/poll/spec/controllers/polls_controller_spec.rb
index a97a04209ca..dfa14025546 100644
--- a/plugins/poll/spec/controllers/polls_controller_spec.rb
+++ b/plugins/poll/spec/controllers/polls_controller_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-RSpec.describe ::DiscoursePoll::PollsController do
- routes { ::DiscoursePoll::Engine.routes }
+RSpec.describe DiscoursePoll::PollsController do
+ routes { DiscoursePoll::Engine.routes }
let!(:user) { log_in }
let(:topic) { Fabricate(:topic) }
diff --git a/plugins/poll/spec/lib/polls_validator_spec.rb b/plugins/poll/spec/lib/polls_validator_spec.rb
index 7d022f545cd..53f5d81ef0b 100644
--- a/plugins/poll/spec/lib/polls_validator_spec.rb
+++ b/plugins/poll/spec/lib/polls_validator_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe ::DiscoursePoll::PollsValidator do
+RSpec.describe DiscoursePoll::PollsValidator do
subject(:validator) { described_class.new(post) }
let(:post) { Fabricate(:post) }
diff --git a/plugins/poll/spec/models/poll_spec.rb b/plugins/poll/spec/models/poll_spec.rb
index 6e577f1f5d7..1ffa24c40be 100644
--- a/plugins/poll/spec/models/poll_spec.rb
+++ b/plugins/poll/spec/models/poll_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-RSpec.describe ::DiscoursePoll::Poll do
+RSpec.describe DiscoursePoll::Poll do
describe ".transform_for_user_field_override" do
it "Transforms UserField name if a matching CustomUserField is present" do
user_field_name = "Something Cool"
user_field = Fabricate(:user_field, name: user_field_name)
- expect(::DiscoursePoll::Poll.transform_for_user_field_override(user_field_name)).to eq(
+ expect(DiscoursePoll::Poll.transform_for_user_field_override(user_field_name)).to eq(
"user_field_#{user_field.id}",
)
end
@@ -13,7 +13,7 @@ RSpec.describe ::DiscoursePoll::Poll do
it "does not transform UserField name if a matching CustomUserField is not present" do
user_field_name = "Something Cool"
user_field = Fabricate(:user_field, name: "Something Else!")
- expect(::DiscoursePoll::Poll.transform_for_user_field_override(user_field_name)).to eq(
+ expect(DiscoursePoll::Poll.transform_for_user_field_override(user_field_name)).to eq(
user_field_name,
)
end
diff --git a/plugins/styleguide/app/controllers/styleguide/styleguide_controller.rb b/plugins/styleguide/app/controllers/styleguide/styleguide_controller.rb
index 48acab9e0ea..82e18b1acdf 100644
--- a/plugins/styleguide/app/controllers/styleguide/styleguide_controller.rb
+++ b/plugins/styleguide/app/controllers/styleguide/styleguide_controller.rb
@@ -2,7 +2,7 @@
module Styleguide
class StyleguideController < ApplicationController
- requires_plugin Styleguide::PLUGIN_NAME
+ requires_plugin PLUGIN_NAME
skip_before_action :check_xhr
def index
diff --git a/plugins/styleguide/lib/styleguide/engine.rb b/plugins/styleguide/lib/styleguide/engine.rb
index 588775eb66f..1fb69f5db71 100644
--- a/plugins/styleguide/lib/styleguide/engine.rb
+++ b/plugins/styleguide/lib/styleguide/engine.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module ::Styleguide
+module Styleguide
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace Styleguide
diff --git a/plugins/styleguide/plugin.rb b/plugins/styleguide/plugin.rb
index cfe0840b4bd..c48c7ed0ad9 100644
--- a/plugins/styleguide/plugin.rb
+++ b/plugins/styleguide/plugin.rb
@@ -15,7 +15,7 @@ end
require_relative "lib/styleguide/engine"
-Discourse::Application.routes.append { mount ::Styleguide::Engine, at: "/styleguide" }
+Discourse::Application.routes.append { mount Styleguide::Engine, at: "/styleguide" }
after_initialize do
register_asset_filter do |type, request, opts|
diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb
index fdb6104506e..a45a6dfb15d 100644
--- a/script/bulk_import/base.rb
+++ b/script/bulk_import/base.rb
@@ -315,7 +315,7 @@ class BulkImport::Base
@chat_message_mapping = load_index(MAPPING_TYPES[:chat_message])
@last_chat_message_id = last_id(Chat::Message)
- if defined?(::DiscourseReactions)
+ if defined?(DiscourseReactions)
puts "Loading reaction indexes..."
@discourse_reaction_mapping = load_index(MAPPING_TYPES[:discourse_reactions_reaction])
@last_discourse_reaction_id = last_id(DiscourseReactions::Reaction)
@@ -516,7 +516,7 @@ class BulkImport::Base
created_at
updated_at
]
- GROUP_COLUMNS << :assignable_level if defined?(::DiscourseAssign)
+ GROUP_COLUMNS << :assignable_level if defined?(DiscourseAssign)
USER_COLUMNS = %i[
id
diff --git a/script/bulk_import/generic_bulk.rb b/script/bulk_import/generic_bulk.rb
index 69317bf5dd1..78028f3fe7d 100644
--- a/script/bulk_import/generic_bulk.rb
+++ b/script/bulk_import/generic_bulk.rb
@@ -371,7 +371,7 @@ class BulkImport::Generic < BulkImport::Base
puts "", "Importing category moderation groups..."
moderation_groups = query(<<~SQL)
- SELECT c.id AS category_id,
+ SELECT c.id AS category_id,
m.value AS group_id
FROM categories c,
JSON_EACH(c.moderation_group_ids) m
@@ -1125,15 +1125,15 @@ class BulkImport::Generic < BulkImport::Base
end
def event_bbcode(event)
- return unless defined?(::DiscoursePostEvent)
+ return unless defined?(DiscoursePostEvent)
starts_at = to_datetime(event["starts_at"])
ends_at = to_datetime(event["ends_at"])
- status = ::DiscoursePostEvent::Event.statuses[event["status"]].to_s
+ status = DiscoursePostEvent::Event.statuses[event["status"]].to_s
name =
if (name = event["name"].presence)
- name.ljust(::DiscoursePostEvent::Event::MIN_NAME_LENGTH, ".").truncate(
- ::DiscoursePostEvent::Event::MAX_NAME_LENGTH,
+ name.ljust(DiscoursePostEvent::Event::MIN_NAME_LENGTH, ".").truncate(
+ DiscoursePostEvent::Event::MAX_NAME_LENGTH,
)
end
url = event["url"]
@@ -1648,7 +1648,7 @@ class BulkImport::Generic < BulkImport::Base
def import_user_notes
puts "", "Importing user notes..."
- unless defined?(::DiscourseUserNotes)
+ unless defined?(DiscourseUserNotes)
puts " Skipping import of user notes because the plugin is not installed."
return
end
@@ -1701,7 +1701,7 @@ class BulkImport::Generic < BulkImport::Base
def import_user_note_counts
puts "", "Importing user note counts..."
- unless defined?(::DiscourseUserNotes)
+ unless defined?(DiscourseUserNotes)
puts " Skipping import of user notes because the plugin is not installed."
return
end
@@ -2095,7 +2095,7 @@ class BulkImport::Generic < BulkImport::Base
def import_post_voting_votes
puts "", "Importing votes for posts..."
- unless defined?(::PostVoting)
+ unless defined?(PostVoting)
puts " Skipping import of votes for posts because the plugin is not installed."
return
end
@@ -2150,7 +2150,7 @@ class BulkImport::Generic < BulkImport::Base
end
def import_topic_voting_votes
- unless defined?(::DiscourseTopicVoting)
+ unless defined?(DiscourseTopicVoting)
puts "", "Skipping topic voting votes, because the topic voting plugin is not installed."
return
end
@@ -2222,7 +2222,7 @@ class BulkImport::Generic < BulkImport::Base
end
def import_answers
- unless defined?(::DiscourseSolved)
+ unless defined?(DiscourseSolved)
puts " Skipping import of solved topics"
return
end
@@ -2285,7 +2285,7 @@ class BulkImport::Generic < BulkImport::Base
def import_gamification_scores
puts "", "Importing gamification scores..."
- unless defined?(::DiscourseGamification)
+ unless defined?(DiscourseGamification)
puts " Skipping import of gamification scores because the plugin is not installed."
return
end
@@ -2327,7 +2327,7 @@ class BulkImport::Generic < BulkImport::Base
def import_post_events
puts "", "Importing events..."
- unless defined?(::DiscoursePostEvent)
+ unless defined?(DiscoursePostEvent)
puts " Skipping import of events because the plugin is not installed."
return
end
@@ -2340,7 +2340,7 @@ class BulkImport::Generic < BulkImport::Base
default_custom_fields = "{}"
timezone = "UTC"
- public_group_invitees = "{#{::DiscoursePostEvent::Event::PUBLIC_GROUP}}"
+ public_group_invitees = "{#{DiscoursePostEvent::Event::PUBLIC_GROUP}}"
standalone_invitees = "{}"
existing_events = DiscoursePostEvent::Event.pluck(:id).to_set
@@ -2360,7 +2360,7 @@ class BulkImport::Generic < BulkImport::Base
timezone: timezone,
raw_invitees:
(
- if row["status"] == ::DiscoursePostEvent::Event.statuses[:public]
+ if row["status"] == DiscoursePostEvent::Event.statuses[:public]
public_group_invitees
else
standalone_invitees
@@ -3171,7 +3171,7 @@ class BulkImport::Generic < BulkImport::Base
end
def import_reaction_users
- unless defined?(::DiscourseReactions)
+ unless defined?(DiscourseReactions)
puts "",
"Skipping reaction users import, because the Discourse Reactions plugin is not installed."
return
@@ -3211,7 +3211,7 @@ class BulkImport::Generic < BulkImport::Base
end
def import_reactions
- unless defined?(::DiscourseReactions)
+ unless defined?(DiscourseReactions)
puts "", "Skipping reactions import, because the Discourse Reactions plugin is not installed."
return
end
@@ -3253,7 +3253,7 @@ class BulkImport::Generic < BulkImport::Base
end
def import_reaction_shadow_likes
- unless defined?(::DiscourseReactions)
+ unless defined?(DiscourseReactions)
puts "",
"Skipping reaction shadow likes import, because the Discourse Reactions plugin is not installed."
return
diff --git a/spec/jobs/crawl_topic_link_spec.rb b/spec/jobs/crawl_topic_link_spec.rb
index 95818fb2341..6904c2d2c64 100644
--- a/spec/jobs/crawl_topic_link_spec.rb
+++ b/spec/jobs/crawl_topic_link_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::CrawlTopicLink do
- let(:job) { Jobs::CrawlTopicLink.new }
+ subject(:job) { described_class.new }
it "needs a topic_link_id" do
expect { job.execute({}) }.to raise_error(Discourse::InvalidParameters)
diff --git a/spec/jobs/process_post_spec.rb b/spec/jobs/process_post_spec.rb
index 0053cab8f3a..bbc6b933b67 100644
--- a/spec/jobs/process_post_spec.rb
+++ b/spec/jobs/process_post_spec.rb
@@ -99,8 +99,9 @@ RSpec.describe Jobs::ProcessPost do
end
describe "#enqueue_pull_hotlinked_images" do
+ subject(:job) { described_class.new }
+
fab!(:post) { Fabricate(:post, created_at: 20.days.ago) }
- let(:job) { Jobs::ProcessPost.new }
it "runs even when download_remote_images_to_local is disabled" do
# We want to run it to pull hotlinked optimized images
diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb
index a854ef0a1e5..cf9fffaa89e 100644
--- a/spec/jobs/pull_hotlinked_images_spec.rb
+++ b/spec/jobs/pull_hotlinked_images_spec.rb
@@ -638,8 +638,9 @@ RSpec.describe Jobs::PullHotlinkedImages do
end
describe "#disable_if_low_on_disk_space" do
+ subject(:job) { described_class.new }
+
fab!(:post) { Fabricate(:post, user: user, created_at: 20.days.ago) }
- let(:job) { Jobs::PullHotlinkedImages.new }
before do
SiteSetting.download_remote_images_to_local = true
diff --git a/spec/jobs/update_topic_hot_scores_spec.rb b/spec/jobs/update_topic_hot_scores_spec.rb
index 50feb31d81b..7ba777857ad 100644
--- a/spec/jobs/update_topic_hot_scores_spec.rb
+++ b/spec/jobs/update_topic_hot_scores_spec.rb
@@ -3,7 +3,7 @@
require "file_store/s3_store"
RSpec.describe Jobs::UpdateTopicHotScores do
- let(:job) { subject }
+ subject(:job) { described_class.new }
fab!(:topic) { Fabricate(:topic, created_at: 1.day.ago) }