Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed set_session not matching false values. [#174 state:resolved]

  • Loading branch information...
commit 272ad4ee1df0e54861112d1a5a81e32729f4ede0 1 parent 78e2347
@lmarburger lmarburger authored jferris committed
View
2  lib/shoulda/action_controller/matchers/set_session_matcher.rb
@@ -46,7 +46,7 @@ def description
private
def assigned_value?
- !assigned_value.blank?
+ !assigned_value.nil?
end
def cleared_value?
View
1  test/functional/posts_controller_test.rb
@@ -70,6 +70,7 @@ def setup
should_set_session(:mischief) { nil }
should_set_session(:special) { '$2 off your next purchase' }
should_set_session(:special_user_id) { @user.id }
+ should_set_session(:false_var) { false }
should_fail do
should_set_session(:special_user_id) { 'value' }
end
View
9 test/matchers/controller/set_session_matcher_test.rb
@@ -4,7 +4,10 @@ class SetSessionMatcherTest < ActionController::TestCase # :nodoc:
context "a controller that sets a session variable" do
setup do
- @controller = build_response { session[:var] = 'value' }
+ @controller = build_response do
+ session[:var] = 'value'
+ session[:false_var] = false
+ end
end
should "accept assigning to that variable" do
@@ -26,6 +29,10 @@ class SetSessionMatcherTest < ActionController::TestCase # :nodoc:
should "accept assigning nil to another variable" do
assert_accepts set_session(:other).to(nil), @controller
end
+
+ should "accept assigning false to that variable" do
+ assert_accepts set_session(:false_var).to(false), @controller
+ end
end
end
View
1  test/rails_root/app/controllers/posts_controller.rb
@@ -12,6 +12,7 @@ def index
headers['Content-Type'] = 'application/rss+xml'
session[:special] = '$2 off your next purchase'
session[:special_user_id] = @user.id
+ session[:false_var] = false
head :ok
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.