0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 20:02:54 +01:00

Revert "Remove unused ExtraLocaleController extension"

This reverts commit 37c18ff324.
Dieser Commit ist enthalten in:
Angus McLeod 2020-11-23 10:11:45 +11:00
Ursprung 542195a0e0
Commit e066ee4b00
3 geänderte Dateien mit 44 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,16 @@
module ExtraLocalesControllerCustomWizard
def show
if request.referer && URI(request.referer).path.include?('/w/')
bundle = params[:bundle]
if params[:v]&.size == 32
hash = ::ExtraLocalesController.bundle_js_hash(bundle)
immutable_for(1.year) if hash == params[:v]
end
render plain: ::ExtraLocalesController.bundle_js(bundle), content_type: "application/javascript"
else
super
end
end
end

Datei anzeigen

@ -77,6 +77,7 @@ after_initialize do
../serializers/custom_wizard/wizard_step_serializer.rb ../serializers/custom_wizard/wizard_step_serializer.rb
../serializers/custom_wizard/wizard_serializer.rb ../serializers/custom_wizard/wizard_serializer.rb
../serializers/custom_wizard/log_serializer.rb ../serializers/custom_wizard/log_serializer.rb
../extensions/extra_locales_controller.rb
../extensions/invites_controller.rb ../extensions/invites_controller.rb
../extensions/users_controller.rb ../extensions/users_controller.rb
../extensions/wizard_field.rb ../extensions/wizard_field.rb
@ -157,6 +158,7 @@ after_initialize do
redirect_to_wizard_if_required if current_user redirect_to_wizard_if_required if current_user
end end
::ExtraLocalesController.prepend ExtraLocalesControllerCustomWizard
::InvitesController.prepend InvitesControllerCustomWizard ::InvitesController.prepend InvitesControllerCustomWizard
::UsersController.prepend CustomWizardUsersController ::UsersController.prepend CustomWizardUsersController
::Wizard::Field.prepend CustomWizardFieldExtension ::Wizard::Field.prepend CustomWizardFieldExtension

Datei anzeigen

@ -0,0 +1,26 @@
require 'rails_helper'
describe ExtraLocalesControllerCustomWizard, type: :request do
before do
CustomWizard::Template.save(
JSON.parse(File.open(
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/wizard.json"
).read),
skip_jobs: true)
end
before do
@controller = ExtraLocalesController.new
end
it "returns locales when requested by wizard" do
@controller.request = ActionController::TestRequest.create(@controller.class)
@controller.request.env['HTTP_REFERER'] = "/w/super-mega-fun-wizard"
expect(
ExtraLocalesController.url("wizard")
).to eq(
"#{Discourse.base_path}/extra-locales/wizard?v=#{ExtraLocalesController.bundle_js_hash("wizard")}"
)
end
end