Class: AliasesTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- AliasesTest
- Defined in:
- lib/vendor/plugins/inherited_resources/test/aliases_test.rb
Instance Method Summary collapse
- #test_assignments_before_calling_alias ⇒ Object
- #test_block_is_called_when_student_is_destroyed ⇒ Object
- #test_controller_should_render_edit ⇒ Object
- #test_controller_should_render_new ⇒ Object
- #test_dumb_responder_quietly_receives_everything_on_failure ⇒ Object
- #test_dumb_responder_quietly_receives_everything_on_success ⇒ Object
- #test_expose_the_resquested_user_on_edit ⇒ Object
- #test_html_is_the_default_when_only_xml_is_overwriten ⇒ Object
- #test_is_not_redirected_on_create_with_success_if_success_block_is_given ⇒ Object
- #test_options_are_used_in_respond_with ⇒ Object
- #test_render_xml_when_it_is_given_as_a_block ⇒ Object
- #test_wont_render_edit_template_on_update_with_failure_if_failure_block_is_given ⇒ Object
Instance Method Details
#test_assignments_before_calling_alias ⇒ Object
44 45 46 47 48 49 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 44 def test_assignments_before_calling_alias Student.stubs(:new).returns(mock_student) get :new assert_response :success assert_equal 'magical', assigns(:something) end |
#test_block_is_called_when_student_is_destroyed ⇒ Object
120 121 122 123 124 125 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 120 def test_block_is_called_when_student_is_destroyed Student.stubs(:find).returns(mock_student(:destroy => true)) delete :destroy assert_response :success assert_equal "Destroyed!", @response.body end |
#test_controller_should_render_edit ⇒ Object
65 66 67 68 69 70 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 65 def test_controller_should_render_edit Student.stubs(:find).returns(mock_student) get :edit assert_response :success assert_equal 'Edit HTML', @response.body.strip end |
#test_controller_should_render_new ⇒ Object
51 52 53 54 55 56 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 51 def test_controller_should_render_new Student.stubs(:new).returns(mock_student) get :new assert_response :success assert_equal 'New HTML', @response.body.strip end |
#test_dumb_responder_quietly_receives_everything_on_failure ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 88 def test_dumb_responder_quietly_receives_everything_on_failure @request.accept = 'text/html' Student.stubs(:new).returns(mock_student(:save => false, :errors => {:some => :error})) @controller.stubs(:resource_url).returns('http://test.host/') post :create assert_response :success assert_equal "New HTML", @response.body.strip end |
#test_dumb_responder_quietly_receives_everything_on_success ⇒ Object
113 114 115 116 117 118 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 113 def test_dumb_responder_quietly_receives_everything_on_success Student.stubs(:find).returns(mock_student(:update_attributes => true)) @controller.stubs(:resource_url).returns('http://test.host/') put :update, :id => '42', :student => {:these => 'params'} assert_equal mock_student, assigns(:student) end |
#test_expose_the_resquested_user_on_edit ⇒ Object
58 59 60 61 62 63 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 58 def test_expose_the_resquested_user_on_edit Student.expects(:find).with('42').returns(mock_student) get :edit, :id => '42' assert_equal mock_student, assigns(:student) assert_response :success end |
#test_html_is_the_default_when_only_xml_is_overwriten ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 97 def test_html_is_the_default_when_only_xml_is_overwriten @request.accept = '*/*' Student.stubs(:new).returns(mock_student(:save => false, :errors => {:some => :error})) @controller.stubs(:resource_url).returns('http://test.host/') post :create assert_response :success assert_equal "New HTML", @response.body.strip end |
#test_is_not_redirected_on_create_with_success_if_success_block_is_given ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 80 def test_is_not_redirected_on_create_with_success_if_success_block_is_given Student.stubs(:new).returns(mock_student(:save => true)) @controller.stubs(:resource_url).returns('http://test.host/') post :create assert_response :success assert_equal "I won't redirect!", @response.body end |
#test_options_are_used_in_respond_with ⇒ Object
127 128 129 130 131 132 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 127 def @request.accept = "application/xml" Student.stubs(:new).returns(mock_student(:save => true, :to_xml => "XML")) post :create assert_equal "http://test.host/", @response.location end |
#test_render_xml_when_it_is_given_as_a_block ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 72 def test_render_xml_when_it_is_given_as_a_block @request.accept = 'application/xml' Student.stubs(:find).returns(mock_student) get :edit assert_response :success assert_equal 'Render XML', @response.body end |
#test_wont_render_edit_template_on_update_with_failure_if_failure_block_is_given ⇒ Object
106 107 108 109 110 111 |
# File 'lib/vendor/plugins/inherited_resources/test/aliases_test.rb', line 106 def test_wont_render_edit_template_on_update_with_failure_if_failure_block_is_given Student.stubs(:find).returns(mock_student(:update_attributes => false)) put :update assert_response :success assert_equal "I won't render!", @response.body end |