1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove an obsolete #dup call. avoid double negatives, to make the code easier to understand and explain

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5304 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2006-10-15 03:11:08 +00:00
parent 2049313e3c
commit 39963b4b9d
2 changed files with 11 additions and 10 deletions

View file

@ -317,7 +317,7 @@ module ActionController
# Write and compile a +generate+ method for this Route.
def write_generation
# Build the main body of the generation
body = "not_expired = true\n#{generation_extraction}\n#{generation_structure}"
body = "expired = false\n#{generation_extraction}\n#{generation_structure}"
# If we have conditions that must be tested first, nest the body inside an if
body = "if #{generation_requirements}\n#{body}\nend" if generation_requirements
@ -671,7 +671,7 @@ module ActionController
end
end
def expiry_statement
"not_expired, hash = false, options if not_expired && expire_on[:#{key}]"
"expired, hash = true, options if !expired && expire_on[:#{key}]"
end
def extraction_code
@ -1190,7 +1190,6 @@ module ActionController
def generate(options, recall = {}, method=:generate)
named_route_name = options.delete(:use_route)
if named_route_name
options = options.dup
named_route = named_routes[named_route_name]
options = named_route.parameter_shell.merge(options)
end

View file

@ -645,7 +645,7 @@ class DynamicSegmentTest < Test::Unit::TestCase
end
def test_expiry_should_not_trigger_once_expired
not_expired = false
expired = true
hash = merged = {:a => 2, :b => 3}
options = {:b => 3}
expire_on = Hash.new { raise 'No!!!' }
@ -656,18 +656,18 @@ class DynamicSegmentTest < Test::Unit::TestCase
end
def test_expiry_should_occur_according_to_expire_on
not_expired = true
expired = false
hash = merged = {:a => 2, :b => 3}
options = {:b => 3}
expire_on = {:b => true, :a => false}
eval(segment.expiry_statement)
assert not_expired
assert !expired
assert_equal({:a => 2, :b => 3}, hash)
expire_on = {:b => true, :a => true}
eval(segment.expiry_statement)
assert ! not_expired
assert expired
assert_equal({:b => 3}, hash)
end
@ -694,7 +694,8 @@ class DynamicSegmentTest < Test::Unit::TestCase
hash = merged = {:a => 'Hi', :b => '3'}
options = {:b => '3'}
a_value = nil
expired = true
eval(segment.extraction_code)
assert_equal 'Hi', a_value
end
@ -704,13 +705,14 @@ class DynamicSegmentTest < Test::Unit::TestCase
hash = merged = {:b => '3'}
options = {:b => '3'}
a_value = nil
expired = true
eval(segment.extraction_code)
assert_equal 'hi', a_value
end
def test_extraction_code_should_perform_expiry
not_expired = true
expired = false
hash = merged = {:a => 'Hi', :b => '3'}
options = {:b => '3'}
expire_on = {:a => true}
@ -718,7 +720,7 @@ class DynamicSegmentTest < Test::Unit::TestCase
eval(segment.extraction_code)
assert_equal 'Hi', a_value
assert ! not_expired
assert expired
assert_equal options, hash
end