Class: CreateActionBaseTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- CreateActionBaseTest
- Includes:
- UserTestHelper
- Defined in:
- lib/vendor/plugins/inherited_resources/test/base_test.rb
Instance Method Summary collapse
- #test_dont_show_flash_message_when_user_cannot_be_saved ⇒ Object
- #test_expose_a_newly_create_user_when_saved_with_success ⇒ Object
- #test_redirect_to_the_created_user ⇒ Object
- #test_render_new_template_when_user_cannot_be_saved ⇒ Object
- #test_show_flash_message_when_success ⇒ Object
Methods included from UserTestHelper
Instance Method Details
#test_dont_show_flash_message_when_user_cannot_be_saved ⇒ Object
152 153 154 155 156 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 152 def User.stubs(:new).returns(mock_user(:save => false, :errors => {:some => :error})) post :create assert flash.empty? end |
#test_expose_a_newly_create_user_when_saved_with_success ⇒ Object
126 127 128 129 130 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 126 def test_expose_a_newly_create_user_when_saved_with_success User.expects(:new).with({'these' => 'params'}).returns(mock_user(:save => true)) post :create, :user => {:these => 'params'} assert_equal mock_user, assigns(:user) end |
#test_redirect_to_the_created_user ⇒ Object
132 133 134 135 136 137 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 132 def test_redirect_to_the_created_user User.stubs(:new).returns(mock_user(:save => true)) @controller.expects(:resource_url).returns('http://test.host/') post :create assert_redirected_to 'http://test.host/' end |
#test_render_new_template_when_user_cannot_be_saved ⇒ Object
145 146 147 148 149 150 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 145 def test_render_new_template_when_user_cannot_be_saved User.stubs(:new).returns(mock_user(:save => false, :errors => {:some => :error})) post :create assert_response :success assert_equal "New HTML", @response.body.strip end |
#test_show_flash_message_when_success ⇒ Object
139 140 141 142 143 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 139 def User.stubs(:new).returns(mock_user(:save => true)) post :create assert_equal flash[:notice], 'User was successfully created.' end |