Skip to content

Commit

Permalink
Adding a spec to test #1591 (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoertink authored Sep 6, 2022
1 parent 6ccf81a commit c303781
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spec/lucky/action_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ end

class OptionalRouteParams::Index < TestAction
get "/complex_posts/:required/?:optional_1/?:optional_2" do
plain_text "test"
opt = params.get?(:optional_1)
plain_text "test #{required} #{optional_1} #{optional_2} #{opt}"
end
end

Expand Down Expand Up @@ -375,6 +376,11 @@ describe Lucky::Action do
response = Tests::PlainActionWithCustomContentType.new(build_context, params).call
response.content_type.should eq "very/plain; charset=utf-8"
end

it "renders with optional path params" do
response = OptionalRouteParams::Index.new(build_context("/complex_posts/1/2/3"), {"required" => "1", "optional_1" => "2", "optional_2" => "3"}).call
response.body.to_s.should eq("test 1 2 3 2")
end
end

describe ".query_param_declarations" do
Expand Down

0 comments on commit c303781

Please sign in to comment.