Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Deprecated should_return_from_session in favor of should_set_session [#…

…146 state:resolved]
  • Loading branch information...
commit 738228fd017fde90be65a070f0d550d2714f203f 1 parent 33705c8
@jferris jferris authored
View
18 lib/shoulda/action_controller/macros.rb
@@ -152,14 +152,13 @@ def should_respond_with_content_type(content_type)
# set by the controller are available to the evaled string.
# Example:
#
- # should_return_from_session(:user_id) { '@user.id' }
- # should_return_from_session(:message) { "Free stuff" }
- def should_return_from_session(key, expected = nil, &block)
+ # should_set_session(:user_id) { '@user.id' }
+ # should_set_session(:message) { "Free stuff" }
+ def should_set_session(key, expected = nil, &block)
matcher = set_session(key)
if expected
- warn "[DEPRECATION] should_return_from_session :key, 'val' is " <<
- "deprecated. Use should_return_from_session(:key) { 'val' } " <<
- "instead."
+ warn "[DEPRECATION] should_set_session :key, 'val' is deprecated. " <<
+ "Use should_set_session(:key) { 'val' } instead."
end
should matcher.description do
if expected
@@ -178,6 +177,13 @@ def should_return_from_session(key, expected = nil, &block)
end
end
+ # Deprecated. See should_set_session
+ def should_return_from_session(key, expected)
+ warn "[DEPRECATION] should_require_attributes is deprecated. " <<
+ "Use should_set_session instead."
+ should_set_session(key, expected)
+ end
+
# Macro that creates a test asserting that the controller rendered the given template.
# Example:
#
View
7 test/functional/posts_controller_test.rb
@@ -70,10 +70,11 @@ def setup
should_respond_with_content_type :rss
should_respond_with_content_type /rss/
should_return_from_session :special, "'$2 off your next purchase'"
- should_return_from_session :special_user_id, '@user.id'
- should_return_from_session(:special_user_id) { @user.id }
+ should_set_session :special, "'$2 off your next purchase'"
+ should_set_session :special_user_id, '@user.id'
+ should_set_session(:special_user_id) { @user.id }
should_fail do
- should_return_from_session(:special_user_id) { 'value' }
+ should_set_session(:special_user_id) { 'value' }
end
should_assign_to :user, :posts
should_not_assign_to :foo, :bar
Please sign in to comment.
Something went wrong with that request. Please try again.