0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
Dieser Commit ist enthalten in:
angusmcleod 2021-09-07 20:11:50 +08:00
Ursprung 23c4b45195
Commit 7c9a0ef862
15 geänderte Dateien mit 23 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -39,10 +39,10 @@ class CustomWizard::AdminProController < CustomWizard::AdminController
render json: failed_json render json: failed_json
end end
end end
protected protected
def pro def pro
@pro ||= CustomWizard::Pro.new @pro ||= CustomWizard::Pro.new
end end
end end

Datei anzeigen

@ -3,7 +3,7 @@
class CustomWizard::UpdateProSubscription < ::Jobs::Scheduled class CustomWizard::UpdateProSubscription < ::Jobs::Scheduled
every 1.hour every 1.hour
def execute(args={}) def execute(args = {})
CustomWizard::Pro.update_subscription CustomWizard::Pro.update_subscription
end end
end end

Datei anzeigen

@ -752,7 +752,7 @@ class CustomWizard::Action
CustomWizard::Log.create(log) CustomWizard::Log.create(log)
end end
def pro_actions def pro_actions
%w[send_message watch_categories send_to_api create_group create_category] %w[send_message watch_categories send_to_api create_group create_category]
end end

Datei anzeigen

@ -183,4 +183,4 @@ class CustomWizard::Pro
PluginStore.remove(self.class.namespace, authentication_db_key) PluginStore.remove(self.class.namespace, authentication_db_key)
get_authentication get_authentication
end end
end end

Datei anzeigen

@ -1,3 +1,4 @@
# frozen_string_literal: true
class CustomWizard::ProAuthentication class CustomWizard::ProAuthentication
include ActiveModel::Serialization include ActiveModel::Serialization
@ -21,7 +22,7 @@ class CustomWizard::ProAuthentication
end end
def generate_keys(user_id, request_id) def generate_keys(user_id, request_id)
rsa = OpenSSL::PKey::RSA.generate(2048) rsa = OpenSSL::PKey::RSA.generate(2048)
nonce = SecureRandom.hex(32) nonce = SecureRandom.hex(32)
set_keys(request_id, user_id, rsa, nonce) set_keys(request_id, user_id, rsa, nonce)
@ -91,4 +92,4 @@ class CustomWizard::ProAuthentication
PluginStore.set(CustomWizard::Pro.namespace, client_id_db_key, client_id) PluginStore.set(CustomWizard::Pro.namespace, client_id_db_key, client_id)
client_id client_id
end end
end end

Datei anzeigen

@ -1,3 +1,4 @@
# frozen_string_literal: true
class CustomWizard::ProSubscription class CustomWizard::ProSubscription
include ActiveModel::Serialization include ActiveModel::Serialization
@ -18,4 +19,4 @@ class CustomWizard::ProSubscription
def active? def active?
types.include?(type) && updated_at.to_datetime > (Time.zone.now - 2.hours).to_datetime types.include?(type) && updated_at.to_datetime > (Time.zone.now - 2.hours).to_datetime
end end
end end

Datei anzeigen

@ -8,4 +8,4 @@ class CustomWizard::ProAuthenticationSerializer < ApplicationSerializer
def active def active
object.active? object.active?
end end
end end

Datei anzeigen

@ -7,4 +7,4 @@ class CustomWizard::ProSubscriptionSerializer < ApplicationSerializer
def active def active
object.active? object.active?
end end
end end

Datei anzeigen

@ -3,4 +3,4 @@ class CustomWizard::ProSerializer < ApplicationSerializer
attributes :server attributes :server
has_one :authentication, serializer: CustomWizard::ProAuthenticationSerializer, embed: :objects has_one :authentication, serializer: CustomWizard::ProAuthenticationSerializer, embed: :objects
has_one :subscription, serializer: CustomWizard::ProSubscriptionSerializer, embed: :objects has_one :subscription, serializer: CustomWizard::ProSubscriptionSerializer, embed: :objects
end end

Datei anzeigen

@ -178,7 +178,7 @@ describe CustomWizard::Action do
before do before do
enable_pro enable_pro
end end
it '#send_message' do it '#send_message' do
wizard_template['actions'] << send_message wizard_template['actions'] << send_message
update_template(wizard_template) update_template(wizard_template)

Datei anzeigen

@ -251,7 +251,7 @@ describe CustomWizard::Builder do
end end
end end
context "with condition" do context "with condition" do
before do before do
enable_pro enable_pro
@template[:steps][0][:condition] = user_condition_json['condition'] @template[:steps][0][:condition] = user_condition_json['condition']

Datei anzeigen

@ -192,7 +192,7 @@ describe CustomWizard::CustomField do
).exists? ).exists?
).to eq(false) ).to eq(false)
end end
it "does not save pro field types without a pro subscription" do it "does not save pro field types without a pro subscription" do
pro_field_json = custom_field_pro_json['custom_fields'].first pro_field_json = custom_field_pro_json['custom_fields'].first
custom_field = CustomWizard::CustomField.new(nil, pro_field_json) custom_field = CustomWizard::CustomField.new(nil, pro_field_json)

Datei anzeigen

@ -122,4 +122,4 @@ describe CustomWizard::Pro do
expect(@pro.authorized?).to eq(false) expect(@pro.authorized?).to eq(false)
end end
end end
end end

Datei anzeigen

@ -38,7 +38,7 @@ describe CustomWizard::AdminProController do
it "#destroy_authentication" do it "#destroy_authentication" do
request_id = SecureRandom.hex(32) request_id = SecureRandom.hex(32)
payload = generate_payload(request_id, admin_user.id) payload = generate_payload(request_id, admin_user.id)
@pro.authentication_response(request_id, payload) @pro.authentication_response(request_id, payload)
delete "/admin/wizards/pro/authorize.json" delete "/admin/wizards/pro/authorize.json"
@ -68,4 +68,4 @@ describe CustomWizard::AdminProController do
expect(CustomWizard::Pro.subscribed?).to eq(true) expect(CustomWizard::Pro.subscribed?).to eq(true)
end end
end end
end end

Datei anzeigen

@ -78,7 +78,7 @@ describe CustomWizard::StepsController do
put '/w/super-mega-fun-wizard/steps/step_1.json' put '/w/super-mega-fun-wizard/steps/step_1.json'
put '/w/super-mega-fun-wizard/steps/step_2.json' put '/w/super-mega-fun-wizard/steps/step_2.json'
put '/w/super-mega-fun-wizard/steps/step_3.json' put '/w/super-mega-fun-wizard/steps/step_3.json'
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(response.parsed_body['redirect_on_complete']).to eq("https://google.com") expect(response.parsed_body['redirect_on_complete']).to eq("https://google.com")
end end
@ -95,7 +95,7 @@ describe CustomWizard::StepsController do
} }
} }
put '/w/super-mega-fun-wizard/steps/step_2.json' put '/w/super-mega-fun-wizard/steps/step_2.json'
put '/w/super-mega-fun-wizard/steps/step_3.json' put '/w/super-mega-fun-wizard/steps/step_3.json'
wizard_id = response.parsed_body['wizard']['id'] wizard_id = response.parsed_body['wizard']['id']
wizard = CustomWizard::Wizard.create(wizard_id, user) wizard = CustomWizard::Wizard.create(wizard_id, user)