diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-18 10:35:25 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-18 10:35:25 +0000 |
commit | e7a29380292902eae4799b2658507b3cfffb9cec (patch) | |
tree | 99a7cd3c7d720ef73f998c2756be1fef77ff0ee1 /actionservice/test/container_test.rb | |
parent | e39bf105941133d3d6699c52c18dbd3b9aa0bf5c (diff) | |
download | rails-e7a29380292902eae4799b2658507b3cfffb9cec.tar.gz rails-e7a29380292902eae4799b2658507b3cfffb9cec.tar.bz2 rails-e7a29380292902eae4799b2658507b3cfffb9cec.zip |
Added Action Service to the repository
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@658 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionservice/test/container_test.rb')
-rw-r--r-- | actionservice/test/container_test.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/actionservice/test/container_test.rb b/actionservice/test/container_test.rb new file mode 100644 index 0000000000..b222138087 --- /dev/null +++ b/actionservice/test/container_test.rb @@ -0,0 +1,53 @@ +require File.dirname(__FILE__) + '/abstract_unit' + +module ContainerTest + + $immediate_service = Object.new + $deferred_service = Object.new + + class DelegateContainer < ActionController::Base + service_dispatching_mode :delegated + + attr :flag + attr :previous_flag + + def initialize + @previous_flag = nil + @flag = true + end + + service :immediate_service, $immediate_service + service(:deferred_service) { @previous_flag = @flag; @flag = false; $deferred_service } + end + + class DirectContainer < ActionController::Base + service_dispatching_mode :direct + end +end + +class TC_Container < Test::Unit::TestCase + def setup + @delegate_container = ContainerTest::DelegateContainer.new + @direct_container = ContainerTest::DirectContainer.new + end + + def test_registration + assert(ContainerTest::DelegateContainer.has_service?(:immediate_service)) + assert(ContainerTest::DelegateContainer.has_service?(:deferred_service)) + assert(!ContainerTest::DelegateContainer.has_service?(:fake_service)) + end + + def test_service_object + assert(@delegate_container.flag == true) + assert(@delegate_container.service_object(:immediate_service) == $immediate_service) + assert(@delegate_container.previous_flag.nil?) + assert(@delegate_container.flag == true) + assert(@delegate_container.service_object(:deferred_service) == $deferred_service) + assert(@delegate_container.previous_flag == true) + assert(@delegate_container.flag == false) + end + + def test_direct_container + assert(ContainerTest::DirectContainer.service_dispatching_mode == :direct) + end +end |