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
|
class CustomWizard::AdminController < ::Admin::AdminController
|
||||||
before_action :ensure_admin
|
before_action :ensure_admin
|
||||||
|
|
||||||
def index
|
# def index
|
||||||
subcription = CustomWizard::Subscription.new
|
# subcription = CustomWizard::Subscription.new
|
||||||
render_json_dump(
|
# render_json_dump(
|
||||||
subscribed: subcription.subscribed?,
|
# subscribed: subcription.subscribed?,
|
||||||
subscription_type: subcription.type,
|
# subscription_type: subcription.type,
|
||||||
subscription_attributes: CustomWizard::Subscription.attributes,
|
# subscription_attributes: CustomWizard::Subscription.attributes,
|
||||||
)
|
# )
|
||||||
end
|
# end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ describe CustomWizard::Action do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
Group.refresh_automatic_group!(:trust_level_2)
|
Group.refresh_automatic_group!(:trust_level_2)
|
||||||
update_template(wizard_template)
|
update_template(wizard_template)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,7 @@ describe CustomWizard::Builder do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
Group.refresh_automatic_group!(:trust_level_3)
|
Group.refresh_automatic_group!(:trust_level_3)
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
@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") }
|
let(:custom_field_subscription_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::CustomField.invalidate_cache
|
CustomWizard::CustomField.invalidate_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ describe CustomWizard::Submission do
|
||||||
let(:guest_id) { CustomWizard::Wizard.generate_guest_id }
|
let(:guest_id) { CustomWizard::Wizard.generate_guest_id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||||
@wizard = CustomWizard::Wizard.create(template_json["id"], user)
|
@wizard = CustomWizard::Wizard.create(template_json["id"], user)
|
||||||
described_class.new(@wizard, step_1_field_1: "I am user submission").save
|
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
|
before do
|
||||||
define_client_classes
|
define_client_classes
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ describe CustomWizard::Template do
|
||||||
fab!(:upload) { Fabricate(:upload) }
|
fab!(:upload) { Fabricate(:upload) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@ describe CustomWizard::TemplateValidator do
|
||||||
expect(validator.errors.first.message).to eq("Liquid syntax error in #{object_id}: #{message}")
|
expect(validator.errors.first.message).to eq("Liquid syntax error in #{object_id}: #{message}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
define_client_classes
|
||||||
|
end
|
||||||
|
|
||||||
it "validates valid templates" do
|
it "validates valid templates" do
|
||||||
expect(
|
expect(
|
||||||
CustomWizard::TemplateValidator.new(template).perform
|
CustomWizard::TemplateValidator.new(template).perform
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe CustomWizard::UpdateValidator do
|
||||||
let(:url_field) { get_wizard_fixture("field/url") }
|
let(:url_field) { get_wizard_fixture("field/url") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ describe CustomWizard::Wizard do
|
||||||
let(:step_json) { get_wizard_fixture("step/step") }
|
let(:step_json) { get_wizard_fixture("step/step") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
Group.refresh_automatic_group!(:trust_level_3)
|
Group.refresh_automatic_group!(:trust_level_3)
|
||||||
@permitted_template = template_json.dup
|
@permitted_template = template_json.dup
|
||||||
@permitted_template["permitted"] = permitted_json["permitted"]
|
@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") }
|
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
custom_field_json['custom_fields'].each do |field_json|
|
custom_field_json['custom_fields'].each do |field_json|
|
||||||
custom_field = CustomWizard::CustomField.new(nil, field_json)
|
custom_field = CustomWizard::CustomField.new(nil, field_json)
|
||||||
custom_field.save
|
custom_field.save
|
||||||
|
|
|
@ -7,6 +7,7 @@ describe ExtraLocalesControllerCustomWizard, type: :request do
|
||||||
let(:permitted) { get_wizard_fixture("wizard/permitted") }
|
let(:permitted) { get_wizard_fixture("wizard/permitted") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ describe ::Guardian do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe InvitesControllerCustomWizard, type: :request do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
@controller = InvitesController.new
|
@controller = InvitesController.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ describe CustomWizardUsersController, type: :request do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
@controller = UsersController.new
|
@controller = UsersController.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminApiController do
|
||||||
let(:api_json) { get_wizard_fixture("api/api") }
|
let(:api_json) { get_wizard_fixture("api/api") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
sign_in(admin_user)
|
sign_in(admin_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminCustomFieldsController do
|
||||||
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
custom_field_json['custom_fields'].each do |field_json|
|
custom_field_json['custom_fields'].each do |field_json|
|
||||||
CustomWizard::CustomField.new(nil, field_json).save
|
CustomWizard::CustomField.new(nil, field_json).save
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminLogsController do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
["first", "second", "third"].each_with_index do |key, index|
|
["first", "second", "third"].each_with_index do |key, index|
|
||||||
temp = template.dup
|
temp = template.dup
|
||||||
temp["id"] = "#{key}_test_wizard"
|
temp["id"] = "#{key}_test_wizard"
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminManagerController do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
sign_in(admin_user)
|
sign_in(admin_user)
|
||||||
|
|
||||||
template_2 = template.dup
|
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: "_") }) }
|
let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize(separator: "_") }) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
|
||||||
enable_subscription("standard")
|
enable_subscription("standard")
|
||||||
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
template_2 = template.dup
|
template_2 = template.dup
|
||||||
template_2["id"] = 'super_mega_fun_wizard_2'
|
template_2["id"] = 'super_mega_fun_wizard_2'
|
||||||
template_2["permitted"] = template_2['permitted']
|
template_2["permitted"] = template_2['permitted']
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe ApplicationController do
|
||||||
let(:wizard_template) { get_wizard_fixture("wizard") }
|
let(:wizard_template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ describe "custom field extensions" do
|
||||||
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
custom_field_json['custom_fields'].each do |field_json|
|
custom_field_json['custom_fields'].each do |field_json|
|
||||||
custom_field = CustomWizard::CustomField.new(nil, field_json)
|
custom_field = CustomWizard::CustomField.new(nil, field_json)
|
||||||
custom_field.save
|
custom_field.save
|
||||||
|
|
|
@ -11,6 +11,7 @@ describe CustomWizard::StepsController do
|
||||||
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
|
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe CustomWizard::WizardController do
|
||||||
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
@template = CustomWizard::Template.find("super_mega_fun_wizard")
|
@template = CustomWizard::Template.find("super_mega_fun_wizard")
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,10 @@ describe CustomWizard::BasicWizardSerializer do
|
||||||
fab!(:user) { Fabricate(:user) }
|
fab!(:user) { Fabricate(:user) }
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
|
before do
|
||||||
|
define_client_classes
|
||||||
|
end
|
||||||
|
|
||||||
it 'should return basic wizard attributes' do
|
it 'should return basic wizard attributes' do
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
json = CustomWizard::BasicWizardSerializer.new(
|
json = CustomWizard::BasicWizardSerializer.new(
|
||||||
|
|
|
@ -4,6 +4,10 @@ describe CustomWizard::CustomFieldSerializer do
|
||||||
fab!(:user) { Fabricate(:user) }
|
fab!(:user) { Fabricate(:user) }
|
||||||
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
||||||
|
|
||||||
|
before do
|
||||||
|
define_client_classes
|
||||||
|
end
|
||||||
|
|
||||||
it 'should return custom field attributes' do
|
it 'should return custom field attributes' do
|
||||||
custom_field_json['custom_fields'].each do |field_json|
|
custom_field_json['custom_fields'].each do |field_json|
|
||||||
CustomWizard::CustomField.new(nil, field_json).save
|
CustomWizard::CustomField.new(nil, field_json).save
|
||||||
|
|
|
@ -13,6 +13,7 @@ describe CustomWizard::SubmissionSerializer do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||||
|
|
||||||
wizard = CustomWizard::Wizard.create(template_json["id"], user1)
|
wizard = CustomWizard::Wizard.create(template_json["id"], user1)
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::FieldSerializer do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe CustomWizard::WizardSerializer do
|
||||||
let(:advanced_fields) { get_wizard_fixture("field/advanced_types") }
|
let(:advanced_fields) { get_wizard_fixture("field/advanced_types") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe CustomWizard::StepSerializer do
|
||||||
let(:required_data_json) { get_wizard_fixture("step/required_data") }
|
let(:required_data_json) { get_wizard_fixture("step/required_data") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
define_client_classes
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren