1
0
Fork 0

Merge branch 'main' into admin-acceptance-tests

Dieser Commit ist enthalten in:
jumagura 2023-06-06 15:23:30 -04:00
Commit c1f06c6fff
6 geänderte Dateien mit 34 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -2,9 +2,9 @@
describe CustomWizard::Log do
before do
CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message')
CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message')
CustomWizard::Log.create('third-test-wizard', 'perform_third_action', 'third_test_user', 'Third log message')
CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message', 5.minutes.ago)
CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message', 3.minutes.ago)
CustomWizard::Log.create('third-test-wizard', 'perform_third_action', 'third_test_user', 'Third log message', 1.minutes.ago)
end
it "creates logs" do

Datei anzeigen

@ -281,13 +281,13 @@ describe CustomWizard::Mapper do
it "avatar with valid size" do
avatar_inputs = inputs['interpolate_avatar'].dup
avatar_inputs[0]["output"] = "Avatar: ![avatar](u{avatar.120})"
avatar_inputs[0]["output"] = "Avatar: ![avatar](u{avatar.144})"
expect(CustomWizard::Mapper.new(
inputs: avatar_inputs,
data: data,
user: user1
).perform).to eq("Avatar: ![avatar](#{user1.avatar_template_url.gsub("{size}", "120")})")
).perform).to eq("Avatar: ![avatar](#{user1.avatar_template_url.gsub("{size}", "144")})")
end
end

Datei anzeigen

@ -13,15 +13,6 @@ describe CustomWizard::Subscription do
}
}
def undefine_client_classes
Object.send(:remove_const, :SubscriptionClient) if Object.constants.include?(:SubscriptionClient)
Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription)
end
def define_client_classes
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
end
after do
undefine_client_classes
end

Datei anzeigen

@ -12,3 +12,23 @@ def enable_subscription(type)
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(true)
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(true)
end
def disable_subscriptions
%w[
standard
business
community
].each do |type|
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(false)
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(false)
end
end
def undefine_client_classes
Object.send(:remove_const, :SubscriptionClient) if Object.constants.include?(:SubscriptionClient)
Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription)
end
def define_client_classes
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
end

Datei anzeigen

@ -14,18 +14,23 @@ describe CustomWizard::AdminController do
end
context "without a subscription" do
before do
disable_subscriptions
define_client_classes
end
it "returns the right subscription details" do
get "/admin/wizards.json"
expect(response.parsed_body["subscribed"]).to eq(false)
expect(response.parsed_body["subscription_attributes"]).to eq(CustomWizard::Subscription.attributes.as_json)
expect(response.parsed_body["subscription_client_installed"]).to eq(false)
expect(response.parsed_body["subscription_client_installed"]).to eq(true)
end
end
context "with a subscription" do
before do
enable_subscription("standard")
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
define_client_classes
end
it "returns the right subscription details" do

Datei anzeigen

@ -13,8 +13,8 @@ describe CustomWizard::AdminManagerController do
template_3["id"] = 'super_mega_fun_wizard_3'
@template_array = [template, template_2, template_3]
FileUtils.mkdir_p(file_from_fixtures_tmp_folder) unless Dir.exist?(file_from_fixtures_tmp_folder)
@tmp_file_path = File.join(file_from_fixtures_tmp_folder, SecureRandom.hex << 'wizards.json')
FileUtils.mkdir_p(concurrency_safe_tmp_dir) unless Dir.exist?(concurrency_safe_tmp_dir)
@tmp_file_path = File.join(concurrency_safe_tmp_dir, SecureRandom.hex << 'wizards.json')
File.write(@tmp_file_path, @template_array.to_json)
end