Class: AssociationChainTest

Inherits:
ActionController::TestCase
  • Object
show all
Defined in:
lib/vendor/plugins/inherited_resources/test/association_chain_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



96
97
98
99
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 96

def setup
  @controller.stubs(:resource_url).returns('/')
  @controller.stubs(:collection_url).returns('/')
end

#test_parent_is_added_to_association_chainObject



101
102
103
104
105
106
107
108
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 101

def test_parent_is_added_to_association_chain
  Pet.expects(:find).with('37').returns(mock_pet)
  mock_pet.expects(:puppets).returns(Puppet)
  Puppet.expects(:find).with('42').returns(mock_puppet)
  mock_puppet.expects(:destroy)
  delete :destroy, :id => '42', :pet_id => '37'
  assert_equal [mock_pet], @controller.send(:association_chain)
end

#test_parent_is_added_to_association_chain_if_not_availableObject



110
111
112
113
114
115
# File 'lib/vendor/plugins/inherited_resources/test/association_chain_test.rb', line 110

def test_parent_is_added_to_association_chain_if_not_available
  Puppet.expects(:find).with('42').returns(mock_puppet)
  mock_puppet.expects(:destroy)
  delete :destroy, :id => '42'
  assert_equal [], @controller.send(:association_chain)
end