Class: BeginOfAssociationChainTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- BeginOfAssociationChainTest
- Defined in:
- lib/vendor/plugins/inherited_resources/test/association_chain_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_begin_of_association_chain_is_called_on_index ⇒ Object
- #test_begin_of_association_chain_is_called_on_new ⇒ Object
- #test_begin_of_association_chain_is_called_on_show ⇒ Object
- #test_begin_of_association_chain_is_included_in_chain ⇒ Object
- #test_instance_variable_should_not_be_set_if_already_defined ⇒ Object
- #test_model_is_not_initialized_with_nil ⇒ Object
Instance Method Details
#setup ⇒ Object
32 33 34 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 32 def setup @controller.current_user = mock() end |
#test_begin_of_association_chain_is_called_on_index ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 36 def test_begin_of_association_chain_is_called_on_index @controller.current_user.expects(:pets).returns(Pet) Pet.expects(:all).returns(mock_pet) get :index assert_response :success assert_equal 'Index HTML', @response.body.strip end |
#test_begin_of_association_chain_is_called_on_new ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 44 def test_begin_of_association_chain_is_called_on_new @controller.current_user.expects(:pets).returns(Pet) Pet.expects(:build).returns(mock_pet) get :new assert_response :success assert_equal 'New HTML', @response.body.strip end |
#test_begin_of_association_chain_is_called_on_show ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 52 def test_begin_of_association_chain_is_called_on_show @controller.current_user.expects(:pets).returns(Pet) Pet.expects(:find).with('47').returns(mock_pet) get :show, :id => '47' assert_response :success assert_equal 'Show HTML', @response.body.strip end |
#test_begin_of_association_chain_is_included_in_chain ⇒ Object
75 76 77 78 79 80 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 75 def test_begin_of_association_chain_is_included_in_chain @controller.current_user.expects(:pets).returns(Pet) Pet.expects(:build).with({}).returns(mock_pet) get :new assert_equal [@controller.current_user], @controller.send(:association_chain) end |
#test_instance_variable_should_not_be_set_if_already_defined ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 60 def test_instance_variable_should_not_be_set_if_already_defined @controller.current_user.expects(:pets).never Pet.expects(:find).never get :edit assert_response :success assert_equal 'new pet', assigns(:pet) end |
#test_model_is_not_initialized_with_nil ⇒ Object
68 69 70 71 72 73 |
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 68 def test_model_is_not_initialized_with_nil @controller.current_user.expects(:pets).returns(Pet) Pet.expects(:build).with({}).returns(mock_pet) get :new assert_equal mock_pet, assigns(:pet) end |