From e1fb3483d6402bd66c41a12d158fd1c987fac983 Mon Sep 17 00:00:00 2001 From: Timo Schilling Date: Tue, 16 Dec 2014 11:30:24 +0100 Subject: allow reseting of request variants The current implementation of `variants=` don't allow a resetting to nil, wich is the default value. This results in the following code smell: ```ruby case request.user_agent when /iPhone/ request.variants = :phone when /iPad/ request.variants = :ipad end ``` With the ability to reset variants to nil, it could be: ```ruby request.variants = case request.user_agent when /iPhone/ :phone when /iPad/ :ipad end ``` --- actionpack/test/dispatch/request_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index beb9085abe..ee8e915610 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -1143,6 +1143,13 @@ class RequestVariant < BaseRequestTest end end + test "reset variant" do + request = stub_request + + request.variant = nil + assert_equal nil, request.variant + end + test "setting variant with non symbol value" do request = stub_request assert_raise ArgumentError do -- cgit v1.2.3