Skip to content

Commit

Permalink
Rails: Test variant
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Sep 18, 2023
1 parent 338dd67 commit f6c813e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/rails/app/controllers/slim_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def thread_options
end
end

def variant
request.variant = :testvariant
render :normal
end

def content_for
@hello = "Hello Slim!"
end
Expand Down
10 changes: 10 additions & 0 deletions test/rails/app/views/layouts/application.html+testvariant.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
doctype html

html
head
title Variant
= csrf_meta_tag

body
= yield :page_heading
.content= yield
8 changes: 8 additions & 0 deletions test/rails/test/test_slim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class TestSlim < ActionDispatch::IntegrationTest
assert_html "<h1>Hello Slim!</h1>"
end

test "variant" do
get "/slim/variant"
assert_response :success
assert_template "slim/normal"
assert_template "layouts/application"
assert_equal @response.body, "<!DOCTYPE html><html><head><title>Variant</title></head><body><div class=\"content\"><h1>Hello Slim!</h1></div></body></html>"
end

test "xml view" do
get "/slim/xml"
assert_response :success
Expand Down

0 comments on commit f6c813e

Please sign in to comment.