Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-12-01 04:51:10 +01:00
Merge pull request #281 from paviliondev/improve_subscription_classes_rspec_handling
DEV: Integrate subscription gem classes in rspec suite
Dieser Commit ist enthalten in:
Commit
4178b337a7
32 geänderte Dateien mit 7 neuen und 57 gelöschten Zeilen
|
@ -9,3 +9,6 @@ RSpec/DescribeClass:
|
||||||
|
|
||||||
Discourse/TimeEqMatcher:
|
Discourse/TimeEqMatcher:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Discourse/NoAddReferenceOrAliasesActiveRecordMigration:
|
||||||
|
Enabled: false
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
||||||
# version: 2.5.2
|
# version: 2.5.3
|
||||||
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
|
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact_emails: development@pavilion.tech
|
# contact_emails: development@pavilion.tech
|
||||||
# subscription_url: https://coop.pavilion.tech
|
# subscription_url: https://coop.pavilion.tech
|
||||||
|
|
||||||
gem 'liquid', '5.0.1', require: true
|
gem 'liquid', '5.0.1', require: true
|
||||||
gem "discourse_subscription_client", "0.1.0.pre15", require_name: "discourse_subscription_client"
|
gem "discourse_subscription_client", "0.1.1", require_name: "discourse_subscription_client"
|
||||||
gem 'discourse_plugin_statistics', '0.1.0.pre7', require: true
|
gem 'discourse_plugin_statistics', '0.1.0.pre7', require: true
|
||||||
register_asset 'stylesheets/common/admin.scss'
|
register_asset 'stylesheets/common/admin.scss'
|
||||||
register_asset 'stylesheets/common/wizard.scss'
|
register_asset 'stylesheets/common/wizard.scss'
|
||||||
|
|
|
@ -42,7 +42,6 @@ describe CustomWizard::Action do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +29,6 @@ describe CustomWizard::Builder do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +5,6 @@ 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
|
||||||
stub_out_subscription_classes
|
|
||||||
CustomWizard::CustomField.invalidate_cache
|
CustomWizard::CustomField.invalidate_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ describe CustomWizard::Submission do
|
||||||
let(:guest_id) { CustomWizard::Wizard.generate_guest_id }
|
let(:guest_id) { CustomWizard::Wizard.generate_guest_id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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
|
||||||
|
|
|
@ -14,10 +14,6 @@ describe CustomWizard::Subscription do
|
||||||
}
|
}
|
||||||
|
|
||||||
context "with subscription client gem mocked out" do
|
context "with subscription client gem mocked out" do
|
||||||
before do
|
|
||||||
stub_out_subscription_classes
|
|
||||||
end
|
|
||||||
|
|
||||||
context "without a subscription" do
|
context "without a subscription" do
|
||||||
before do
|
before do
|
||||||
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil)
|
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil)
|
||||||
|
@ -40,9 +36,9 @@ describe CustomWizard::Subscription do
|
||||||
|
|
||||||
def get_subscription_result(product_ids)
|
def get_subscription_result(product_ids)
|
||||||
result = DiscourseSubscriptionClient::Subscriptions::Result.new
|
result = DiscourseSubscriptionClient::Subscriptions::Result.new
|
||||||
result.supplier = SubscriptionClientSupplier.new(product_slugs)
|
result.supplier = SubscriptionClientSupplier.new(products: product_slugs)
|
||||||
result.resource = SubscriptionClientResource.new
|
result.resource = SubscriptionClientResource.new
|
||||||
result.subscriptions = product_ids.map { |product_id| ::SubscriptionClientSubscription.new(product_id) }
|
result.subscriptions = product_ids.map { |product_id| ::SubscriptionClientSubscription.new(product_id: product_id) }
|
||||||
result.products = product_slugs
|
result.products = product_slugs
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,6 @@ describe CustomWizard::Template do
|
||||||
fab!(:upload) { Fabricate(:upload) }
|
fab!(:upload) { Fabricate(:upload) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_classes
|
|
||||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,6 @@ 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
|
|
||||||
stub_out_subscription_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,7 +6,6 @@ describe CustomWizard::UpdateValidator do
|
||||||
let(:url_field) { get_wizard_fixture("field/url") }
|
let(:url_field) { get_wizard_fixture("field/url") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +10,6 @@ describe CustomWizard::Wizard do
|
||||||
let(:step_json) { get_wizard_fixture("step/step") }
|
let(:step_json) { get_wizard_fixture("step/step") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +11,6 @@ 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
|
||||||
stub_out_subscription_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,7 +7,6 @@ describe ExtraLocalesControllerCustomWizard, type: :request do
|
||||||
let(:permitted) { get_wizard_fixture("wizard/permitted") }
|
let(:permitted) { get_wizard_fixture("wizard/permitted") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_classes
|
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ describe ::Guardian do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +6,6 @@ describe InvitesControllerCustomWizard, type: :request do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_classes
|
|
||||||
@controller = InvitesController.new
|
@controller = InvitesController.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ describe CustomWizardUsersController, type: :request do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_classes
|
|
||||||
@controller = UsersController.new
|
@controller = UsersController.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,11 @@ def get_wizard_fixture(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable_subscription(type)
|
def enable_subscription(type)
|
||||||
stub_out_subscription_classes
|
|
||||||
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(true)
|
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(true)
|
||||||
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(true)
|
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_subscriptions
|
def disable_subscriptions
|
||||||
stub_out_subscription_classes
|
|
||||||
%w[
|
%w[
|
||||||
standard
|
standard
|
||||||
business
|
business
|
||||||
|
@ -25,12 +23,3 @@ def disable_subscriptions
|
||||||
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(false)
|
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unstub_out_subscription_classes
|
|
||||||
Object.send(:remove_const, :DiscourseSubscriptionClient) if Object.constants.include?(:DiscourseSubscriptionClient)
|
|
||||||
Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription)
|
|
||||||
end
|
|
||||||
|
|
||||||
def stub_out_subscription_classes
|
|
||||||
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
|
|
||||||
end
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ describe CustomWizard::AdminApiController do
|
||||||
let(:api_json) { get_wizard_fixture("api/api") }
|
let(:api_json) { get_wizard_fixture("api/api") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_classes
|
|
||||||
sign_in(admin_user)
|
sign_in(admin_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ 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
|
||||||
stub_out_subscription_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,7 +5,6 @@ describe CustomWizard::AdminLogsController do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +5,6 @@ describe CustomWizard::AdminManagerController do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_classes
|
|
||||||
sign_in(admin_user)
|
sign_in(admin_user)
|
||||||
|
|
||||||
template_2 = template.dup
|
template_2 = template.dup
|
||||||
|
|
|
@ -16,7 +16,6 @@ describe CustomWizard::SubscriptionController do
|
||||||
context "without a subscription" do
|
context "without a subscription" do
|
||||||
before do
|
before do
|
||||||
disable_subscriptions
|
disable_subscriptions
|
||||||
stub_out_subscription_classes
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the right subscription details" do
|
it "returns the right subscription details" do
|
||||||
|
@ -29,7 +28,6 @@ describe CustomWizard::SubscriptionController do
|
||||||
context "with a subscription" do
|
context "with a subscription" do
|
||||||
before do
|
before do
|
||||||
enable_subscription("standard")
|
enable_subscription("standard")
|
||||||
stub_out_subscription_classes
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the right subscription details" do
|
it "returns the right subscription details" do
|
||||||
|
|
|
@ -5,7 +5,6 @@ describe ApplicationController do
|
||||||
let(:wizard_template) { get_wizard_fixture("wizard") }
|
let(:wizard_template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +10,6 @@ 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
|
||||||
stub_out_subscription_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,7 +11,6 @@ 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
|
||||||
stub_out_subscription_classes
|
|
||||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ describe CustomWizard::WizardController do
|
||||||
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,10 +4,6 @@ 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
|
|
||||||
stub_out_subscription_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,10 +4,6 @@ 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
|
|
||||||
stub_out_subscription_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,7 +13,6 @@ describe CustomWizard::SubmissionSerializer do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +5,6 @@ describe CustomWizard::FieldSerializer do
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
let(:template) { get_wizard_fixture("wizard") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_out_subscription_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,7 +8,6 @@ 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
|
||||||
stub_out_subscription_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,7 +6,6 @@ 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
|
||||||
stub_out_subscription_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