From 2073e28aa3ae19f6224f8554f2344b140ddb671c Mon Sep 17 00:00:00 2001 From: Mitchell Henke Date: Fri, 27 Oct 2023 13:18:45 -0500 Subject: [PATCH] add tests --- test/sandbox/test/integration_test.rb | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/sandbox/test/integration_test.rb b/test/sandbox/test/integration_test.rb index 3721b045cd..379dbb8f5c 100644 --- a/test/sandbox/test/integration_test.rb +++ b/test/sandbox/test/integration_test.rb @@ -670,6 +670,38 @@ def test_sets_the_compiler_mode_in_development_mode end end + def test_default_sets_frozen_string_literal_to_rails_action_view_frozen_string_literal_value_true + fake_application = OpenStruct.new(config: OpenStruct.new(view_component: ViewComponent::Config.new, action_view: OpenStruct.new(frozen_string_literal: true))) + ViewComponent::Engine.initializers.find { |i| i.name == "view_component.set_configs" }.run(fake_application) + assert_equal fake_application.config.view_component.frozen_string_literal, true + end + + def test_default_sets_frozen_string_literal_to_rails_action_view_frozen_string_literal_value_false + fake_application = OpenStruct.new(config: OpenStruct.new(view_component: ViewComponent::Config.new, action_view: OpenStruct.new(frozen_string_literal: false))) + ViewComponent::Engine.initializers.find { |i| i.name == "view_component.set_configs" }.run(fake_application) + assert_equal fake_application.config.view_component.frozen_string_literal, false + end + + def test_default_sets_frozen_string_literal_to_rails_action_view_frozen_string_literal_value_nil + fake_application = OpenStruct.new(config: OpenStruct.new(view_component: ViewComponent::Config.new, action_view: OpenStruct.new(frozen_string_literal: nil))) + ViewComponent::Engine.initializers.find { |i| i.name == "view_component.set_configs" }.run(fake_application) + assert_equal fake_application.config.view_component.frozen_string_literal, false + end + + def test_override_true_does_not_set_frozen_string_literal_to_rails_action_view_frozen_string_literal_value_false + fake_application = OpenStruct.new(config: OpenStruct.new(view_component: ViewComponent::Config.new, action_view: OpenStruct.new(frozen_string_literal: false))) + fake_application.config.view_component.frozen_string_literal = true + ViewComponent::Engine.initializers.find { |i| i.name == "view_component.set_configs" }.run(fake_application) + assert_equal fake_application.config.view_component.frozen_string_literal, true + end + + def test_override_false_does_not_set_frozen_string_literal_to_rails_action_view_frozen_string_literal_value_true + fake_application = OpenStruct.new(config: OpenStruct.new(view_component: ViewComponent::Config.new, action_view: OpenStruct.new(frozen_string_literal: true))) + fake_application.config.view_component.frozen_string_literal = false + ViewComponent::Engine.initializers.find { |i| i.name == "view_component.set_configs" }.run(fake_application) + assert_equal fake_application.config.view_component.frozen_string_literal, false + end + def test_link_to_helper get "/link_to_helper" assert_select "a > i,span"