Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 11:52:54 +01:00
specs: ensure sub client code is mocked out
Dieser Commit ist enthalten in:
Ursprung
4422badf6a
Commit
da2a56adc6
31 geänderte Dateien mit 46 neuen und 11 gelöschten Zeilen
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,6 +6,7 @@ describe InvitesControllerCustomWizard, type: :request do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
define_client_classes
|
||||
@controller = InvitesController.new
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe CustomWizardUsersController, type: :request do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
define_client_classes
|
||||
@controller = UsersController.new
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Laden …
In neuem Issue referenzieren