diff options
author | Mark McSpadden <markmcspadden@gmail.com> | 2012-02-13 22:22:46 -0600 |
---|---|---|
committer | Mark McSpadden <markmcspadden@gmail.com> | 2012-02-13 22:22:46 -0600 |
commit | 0101d27de606db25c244aae2243f337cfbba6ed0 (patch) | |
tree | 6db4f6902dfa23833b29576ce2f4746feb3dcbff /activeresource/test/cases/base_test.rb | |
parent | 11d1bdc09e91f1d77c36b7afeef912de0b94f331 (diff) | |
download | rails-0101d27de606db25c244aae2243f337cfbba6ed0.tar.gz rails-0101d27de606db25c244aae2243f337cfbba6ed0.tar.bz2 rails-0101d27de606db25c244aae2243f337cfbba6ed0.zip |
Allow ActiveResource subclasses to inherit headers from parent
Diffstat (limited to 'activeresource/test/cases/base_test.rb')
-rw-r--r-- | activeresource/test/cases/base_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb index f5a58793d1..e89c5b19d3 100644 --- a/activeresource/test/cases/base_test.rb +++ b/activeresource/test/cases/base_test.rb @@ -437,6 +437,52 @@ class BaseTest < ActiveSupport::TestCase assert_not_equal(first_connection, second_connection, 'Connection should be re-created') end + def test_header_inheritance + fruit = Class.new(ActiveResource::Base) + apple = Class.new(fruit) + fruit.site = 'http://market' + + fruit.headers['key'] = 'value' + assert_equal 'value', apple.headers['key'] + end + + def test_header_inheritance_set_at_multiple_points + fruit = Class.new(ActiveResource::Base) + apple = Class.new(fruit) + fruit.site = 'http://market' + + fruit.headers['key'] = 'value' + assert_equal 'value', apple.headers['key'] + + apple.headers['key2'] = 'value2' + fruit.headers['key3'] = 'value3' + + assert_equal 'value', apple.headers['key'] + assert_equal 'value2', apple.headers['key2'] + assert_equal 'value3', apple.headers['key3'] + end + + def test_header_inheritance_should_not_leak_upstream + fruit = Class.new(ActiveResource::Base) + apple = Class.new(fruit) + fruit.site = 'http://market' + + fruit.headers['key'] = 'value' + + apple.headers['key2'] = 'value2' + assert_equal nil, fruit.headers['key2'] + end + + def test_header_inheritance_should_not_leak_upstream + fruit = Class.new(ActiveResource::Base) + apple = Class.new(fruit) + fruit.site = 'http://market' + + fruit.headers['key'] = 'value' + + apple.headers['key2'] = 'value2' + assert_equal nil, fruit.headers['key2'] + end ######################################################################## # Tests for setting up remote URLs for a given model (including adding |