0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00
Dieser Commit ist enthalten in:
angusmcleod 2021-10-07 21:19:19 +08:00
Ursprung 925c8c009a
Commit b475e39ee9
4 geänderte Dateien mit 9 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,5 @@
{ {
"result": { "result": {
"line": 92.3 "line": 92.45
} }
} }

Datei anzeigen

@ -125,7 +125,7 @@ class CustomWizard::Notice
if PLUGIN_STATUSES_TO_WARN.include?(plugin_status[:status]) if PLUGIN_STATUSES_TO_WARN.include?(plugin_status[:status])
notice = { notice = {
message: PrettyText.cook(I18n.t('wizard.notice.compatibility_issue', domain: plugin_status_domain)), message: I18n.t('wizard.notice.compatibility_issue', domain: plugin_status_domain),
type: types[:plugin_status_warning], type: types[:plugin_status_warning],
created_at: plugin_status[:status_changed_at] created_at: plugin_status[:status_changed_at]
} }
@ -138,7 +138,7 @@ class CustomWizard::Notice
def self.notify_connection_errors(connection_type_key) def self.notify_connection_errors(connection_type_key)
domain = self.send("#{connection_type_key.to_s}_domain") domain = self.send("#{connection_type_key.to_s}_domain")
message = PrettyText.cook(I18n.t("wizard.notice.#{connection_type_key.to_s}.connection_error_limit", domain: domain)) message = I18n.t("wizard.notice.#{connection_type_key.to_s}.connection_error_limit", domain: domain)
notices = list(type: types[:connection_error], message: message) notices = list(type: types[:connection_error], message: message)
if notices.any? if notices.any?
@ -221,7 +221,7 @@ class CustomWizard::Notice
query = PluginStoreRow.where(plugin_name: namespace) query = PluginStoreRow.where(plugin_name: namespace)
query = query.where("(value::json->>'expired_at') IS NULL#{include_recently_expired ? " OR (value::json->>'expired_at')::date > now()::date - 1" : ""}") query = query.where("(value::json->>'expired_at') IS NULL#{include_recently_expired ? " OR (value::json->>'expired_at')::date > now()::date - 1" : ""}")
query = query.where("(value::json->>'type')::integer = ?", type) if type query = query.where("(value::json->>'type')::integer = ?", type) if type
query = query.where("(value::json->>'message') = ?", message) if message query = query.where("(value::json->>'message')::text = ?", message) if message
query.order("value::json->>'created_at' DESC") query.order("value::json->>'created_at' DESC")
end end

Datei anzeigen

@ -18,4 +18,8 @@ class CustomWizard::NoticeSerializer < ApplicationSerializer
def type def type
CustomWizard::Notice.types.key(object.type) CustomWizard::Notice.types.key(object.type)
end end
def messsage
PrettyText.cook(object.message)
end
end end

Datei anzeigen

@ -54,7 +54,7 @@ describe CustomWizard::Notice do
it "converts warning into notice" do it "converts warning into notice" do
notice = described_class.list.first notice = described_class.list.first
expect(notice.type).to eq(described_class.types[:plugin_status_warning]) expect(notice.type).to eq(described_class.types[:plugin_status_warning])
expect(notice.message).to eq(PrettyText.cook(I18n.t("wizard.notice.compatibility_issue", server: described_class.plugin_status_domain))) expect(notice.message).to eq(I18n.t("wizard.notice.compatibility_issue", domain: described_class.plugin_status_domain))
expect(notice.created_at.to_datetime).to be_within(1.second).of (plugin_status[:status_changed_at].to_datetime) expect(notice.created_at.to_datetime).to be_within(1.second).of (plugin_status[:status_changed_at].to_datetime)
end end