0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 01:10:28 +01:00

specs: ensure sub client code is mocked out

Dieser Commit ist enthalten in:
merefield 2023-09-28 13:47:22 +01:00
Ursprung 4422badf6a
Commit da2a56adc6
31 geänderte Dateien mit 46 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -2,14 +2,14 @@
class CustomWizard::AdminController < ::Admin::AdminController
before_action :ensure_admin
def index
subcription = CustomWizard::Subscription.new
render_json_dump(
subscribed: subcription.subscribed?,
subscription_type: subcription.type,
subscription_attributes: CustomWizard::Subscription.attributes,
)
end
# def index
# subcription = CustomWizard::Subscription.new
# render_json_dump(
# subscribed: subcription.subscribed?,
# subscription_type: subcription.type,
# subscription_attributes: CustomWizard::Subscription.attributes,
# )
# end
private

Datei anzeigen

@ -42,6 +42,7 @@ describe CustomWizard::Action do
}
before do
define_client_classes
Group.refresh_automatic_group!(:trust_level_2)
update_template(wizard_template)
end

Datei anzeigen

@ -29,6 +29,7 @@ describe CustomWizard::Builder do
}
before do
define_client_classes
Group.refresh_automatic_group!(:trust_level_3)
CustomWizard::Template.save(wizard_template, skip_jobs: true)
@template = CustomWizard::Template.find('super_mega_fun_wizard')

Datei anzeigen

@ -5,6 +5,7 @@ describe CustomWizard::CustomField do
let(:custom_field_subscription_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
before do
define_client_classes
CustomWizard::CustomField.invalidate_cache
end

Datei anzeigen

@ -7,6 +7,7 @@ describe CustomWizard::Submission do
let(:guest_id) { CustomWizard::Wizard.generate_guest_id }
before do
define_client_classes
CustomWizard::Template.save(template_json, skip_jobs: true)
@wizard = CustomWizard::Wizard.create(template_json["id"], user)
described_class.new(@wizard, step_1_field_1: "I am user submission").save

Datei anzeigen

@ -13,7 +13,7 @@ describe CustomWizard::Subscription do
}
}
context "with subscription client gem" do
context "with subscription client gem mocked out" do
before do
define_client_classes
end

Datei anzeigen

@ -7,6 +7,7 @@ describe CustomWizard::Template do
fab!(:upload) { Fabricate(:upload) }
before do
define_client_classes
CustomWizard::Template.save(template_json, skip_jobs: true)
end

Datei anzeigen

@ -39,6 +39,10 @@ describe CustomWizard::TemplateValidator do
expect(validator.errors.first.message).to eq("Liquid syntax error in #{object_id}: #{message}")
end
before do
define_client_classes
end
it "validates valid templates" do
expect(
CustomWizard::TemplateValidator.new(template).perform

Datei anzeigen

@ -6,6 +6,7 @@ describe CustomWizard::UpdateValidator do
let(:url_field) { get_wizard_fixture("field/url") }
before do
define_client_classes
CustomWizard::Template.save(template, skip_jobs: true)
@template = CustomWizard::Template.find('super_mega_fun_wizard')
end

Datei anzeigen

@ -10,6 +10,7 @@ describe CustomWizard::Wizard do
let(:step_json) { get_wizard_fixture("step/step") }
before do
define_client_classes
Group.refresh_automatic_group!(:trust_level_3)
@permitted_template = template_json.dup
@permitted_template["permitted"] = permitted_json["permitted"]

Datei anzeigen

@ -11,6 +11,7 @@ describe "custom field extensions" do
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
before do
define_client_classes
custom_field_json['custom_fields'].each do |field_json|
custom_field = CustomWizard::CustomField.new(nil, field_json)
custom_field.save

Datei anzeigen

@ -7,6 +7,7 @@ describe ExtraLocalesControllerCustomWizard, type: :request do
let(:permitted) { get_wizard_fixture("wizard/permitted") }
before do
define_client_classes
CustomWizard::Template.save(template, skip_jobs: true)
end

Datei anzeigen

@ -33,6 +33,7 @@ describe ::Guardian do
end
before do
define_client_classes
CustomWizard::Template.save(wizard_template, skip_jobs: true)
@template = CustomWizard::Template.find('super_mega_fun_wizard')
end

Datei anzeigen

@ -6,6 +6,7 @@ describe InvitesControllerCustomWizard, type: :request do
let(:template) { get_wizard_fixture("wizard") }
before do
define_client_classes
@controller = InvitesController.new
end

Datei anzeigen

@ -4,6 +4,7 @@ describe CustomWizardUsersController, type: :request do
let(:template) { get_wizard_fixture("wizard") }
before do
define_client_classes
@controller = UsersController.new
end

Datei anzeigen

@ -5,6 +5,7 @@ describe CustomWizard::AdminApiController do
let(:api_json) { get_wizard_fixture("api/api") }
before do
define_client_classes
sign_in(admin_user)
end

Datei anzeigen

@ -5,6 +5,7 @@ describe CustomWizard::AdminCustomFieldsController do
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
before do
define_client_classes
custom_field_json['custom_fields'].each do |field_json|
CustomWizard::CustomField.new(nil, field_json).save
end

Datei anzeigen

@ -5,6 +5,7 @@ describe CustomWizard::AdminLogsController do
let(:template) { get_wizard_fixture("wizard") }
before do
define_client_classes
["first", "second", "third"].each_with_index do |key, index|
temp = template.dup
temp["id"] = "#{key}_test_wizard"

Datei anzeigen

@ -5,6 +5,7 @@ describe CustomWizard::AdminManagerController do
let(:template) { get_wizard_fixture("wizard") }
before do
define_client_classes
sign_in(admin_user)
template_2 = template.dup

Datei anzeigen

@ -8,9 +8,8 @@ describe CustomWizard::AdminWizardController do
let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize(separator: "_") }) }
before do
CustomWizard::Template.save(template, skip_jobs: true)
enable_subscription("standard")
CustomWizard::Template.save(template, skip_jobs: true)
template_2 = template.dup
template_2["id"] = 'super_mega_fun_wizard_2'
template_2["permitted"] = template_2['permitted']

Datei anzeigen

@ -5,6 +5,7 @@ describe ApplicationController do
let(:wizard_template) { get_wizard_fixture("wizard") }
before do
define_client_classes
CustomWizard::Template.save(wizard_template, skip_jobs: true)
@template = CustomWizard::Template.find('super_mega_fun_wizard')
end

Datei anzeigen

@ -10,6 +10,7 @@ describe "custom field extensions" do
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
before do
define_client_classes
custom_field_json['custom_fields'].each do |field_json|
custom_field = CustomWizard::CustomField.new(nil, field_json)
custom_field.save

Datei anzeigen

@ -11,6 +11,7 @@ describe CustomWizard::StepsController do
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
before do
define_client_classes
CustomWizard::Template.save(wizard_template, skip_jobs: true)
end

Datei anzeigen

@ -6,6 +6,7 @@ describe CustomWizard::WizardController do
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
before do
define_client_classes
CustomWizard::Template.save(wizard_template, skip_jobs: true)
@template = CustomWizard::Template.find("super_mega_fun_wizard")
end

Datei anzeigen

@ -4,6 +4,10 @@ describe CustomWizard::BasicWizardSerializer do
fab!(:user) { Fabricate(:user) }
let(:template) { get_wizard_fixture("wizard") }
before do
define_client_classes
end
it 'should return basic wizard attributes' do
CustomWizard::Template.save(template, skip_jobs: true)
json = CustomWizard::BasicWizardSerializer.new(

Datei anzeigen

@ -4,6 +4,10 @@ describe CustomWizard::CustomFieldSerializer do
fab!(:user) { Fabricate(:user) }
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
before do
define_client_classes
end
it 'should return custom field attributes' do
custom_field_json['custom_fields'].each do |field_json|
CustomWizard::CustomField.new(nil, field_json).save

Datei anzeigen

@ -13,6 +13,7 @@ describe CustomWizard::SubmissionSerializer do
}
before do
define_client_classes
CustomWizard::Template.save(template_json, skip_jobs: true)
wizard = CustomWizard::Wizard.create(template_json["id"], user1)

Datei anzeigen

@ -5,6 +5,7 @@ describe CustomWizard::FieldSerializer do
let(:template) { get_wizard_fixture("wizard") }
before do
define_client_classes
CustomWizard::Template.save(template, skip_jobs: true)
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
end

Datei anzeigen

@ -8,6 +8,7 @@ describe CustomWizard::WizardSerializer do
let(:advanced_fields) { get_wizard_fixture("field/advanced_types") }
before do
define_client_classes
CustomWizard::Template.save(template, skip_jobs: true)
@template = CustomWizard::Template.find('super_mega_fun_wizard')
end

Datei anzeigen

@ -6,6 +6,7 @@ describe CustomWizard::StepSerializer do
let(:required_data_json) { get_wizard_fixture("step/required_data") }
before do
define_client_classes
CustomWizard::Template.save(wizard_template, skip_jobs: true)
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
end