Class: NestedBelongsToTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- NestedBelongsToTest
- Defined in:
- lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_assigns_country_and_state_and_city_on_create ⇒ Object
- #test_assigns_country_and_state_and_city_on_destroy ⇒ Object
- #test_assigns_country_and_state_and_city_on_edit ⇒ Object
- #test_assigns_country_and_state_and_city_on_new ⇒ Object
- #test_assigns_country_and_state_and_city_on_show ⇒ Object
- #test_assigns_country_and_state_and_city_on_update ⇒ Object
Instance Method Details
#setup ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 20 def setup Country.expects(:find).with('13').returns(mock_country) mock_country.expects(:states).returns(State) State.expects(:find).with('37').returns(mock_state) mock_state.expects(:cities).returns(City) @controller.stubs(:resource_url).returns('/') @controller.stubs(:collection_url).returns('/') end |
#test_assigns_country_and_state_and_city_on_create ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 30 def test_assigns_country_and_state_and_city_on_create City.expects(:find).with(:all).returns([mock_city]) get :index, :state_id => '37', :country_id => '13' assert_equal mock_country, assigns(:country) assert_equal mock_state, assigns(:state) assert_equal [mock_city], assigns(:cities) end |
#test_assigns_country_and_state_and_city_on_destroy ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 86 def test_assigns_country_and_state_and_city_on_destroy City.expects(:find).with('42').returns(mock_city) mock_city.expects(:destroy) delete :destroy, :id => '42', :state_id => '37', :country_id => '13' assert_equal mock_country, assigns(:country) assert_equal mock_state, assigns(:state) assert_equal mock_city, assigns(:city) end |
#test_assigns_country_and_state_and_city_on_edit ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 57 def test_assigns_country_and_state_and_city_on_edit City.expects(:find).with('42').returns(mock_city) get :edit, :id => '42', :state_id => '37', :country_id => '13' assert_equal mock_country, assigns(:country) assert_equal mock_state, assigns(:state) assert_equal mock_city, assigns(:city) end |
#test_assigns_country_and_state_and_city_on_new ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 48 def test_assigns_country_and_state_and_city_on_new City.expects(:build).returns(mock_city) get :new, :state_id => '37', :country_id => '13' assert_equal mock_country, assigns(:country) assert_equal mock_state, assigns(:state) assert_equal mock_city, assigns(:city) end |
#test_assigns_country_and_state_and_city_on_show ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 39 def test_assigns_country_and_state_and_city_on_show City.expects(:find).with('42').returns(mock_city) get :show, :id => '42', :state_id => '37', :country_id => '13' assert_equal mock_country, assigns(:country) assert_equal mock_state, assigns(:state) assert_equal mock_city, assigns(:city) end |
#test_assigns_country_and_state_and_city_on_update ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/vendor/plugins/inherited_resources/test/nested_belongs_to_test.rb', line 76 def test_assigns_country_and_state_and_city_on_update City.expects(:find).with('42').returns(mock_city) mock_city.expects(:update_attributes).returns(true) put :update, :id => '42', :state_id => '37', :country_id => '13', :city => {:these => 'params'} assert_equal mock_country, assigns(:country) assert_equal mock_state, assigns(:state) assert_equal mock_city, assigns(:city) end |