From f6c813eec81501fee0e1859eb74471082b749505 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Mon, 18 Sep 2023 14:11:36 +0200 Subject: [PATCH] Rails: Test variant --- test/rails/app/controllers/slim_controller.rb | 5 +++++ .../views/layouts/application.html+testvariant.slim | 10 ++++++++++ test/rails/test/test_slim.rb | 8 ++++++++ 3 files changed, 23 insertions(+) create mode 100644 test/rails/app/views/layouts/application.html+testvariant.slim diff --git a/test/rails/app/controllers/slim_controller.rb b/test/rails/app/controllers/slim_controller.rb index 4258c3a5..288f96c9 100644 --- a/test/rails/app/controllers/slim_controller.rb +++ b/test/rails/app/controllers/slim_controller.rb @@ -32,6 +32,11 @@ def thread_options end end + def variant + request.variant = :testvariant + render :normal + end + def content_for @hello = "Hello Slim!" end diff --git a/test/rails/app/views/layouts/application.html+testvariant.slim b/test/rails/app/views/layouts/application.html+testvariant.slim new file mode 100644 index 00000000..44f78f70 --- /dev/null +++ b/test/rails/app/views/layouts/application.html+testvariant.slim @@ -0,0 +1,10 @@ +doctype html + +html + head + title Variant + = csrf_meta_tag + + body + = yield :page_heading + .content= yield diff --git a/test/rails/test/test_slim.rb b/test/rails/test/test_slim.rb index 08e2519f..2fbfb548 100644 --- a/test/rails/test/test_slim.rb +++ b/test/rails/test/test_slim.rb @@ -9,6 +9,14 @@ class TestSlim < ActionDispatch::IntegrationTest assert_html "

Hello Slim!

" end + test "variant" do + get "/slim/variant" + assert_response :success + assert_template "slim/normal" + assert_template "layouts/application" + assert_equal @response.body, "Variant

Hello Slim!

" + end + test "xml view" do get "/slim/xml" assert_response :success