Class: UpdateActionBaseTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- UpdateActionBaseTest
- 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_redirect_to_the_created_user ⇒ Object
- #test_render_edit_template_when_user_cannot_be_saved ⇒ Object
- #test_show_flash_message_when_success ⇒ Object
- #test_update_the_requested_object ⇒ Object
Methods included from UserTestHelper
Instance Method Details
#test_dont_show_flash_message_when_user_cannot_be_saved ⇒ Object
189 190 191 192 193 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 189 def User.stubs(:find).returns(mock_user(:update_attributes => false, :errors => {:some => :error})) put :update assert flash.empty? end |
#test_redirect_to_the_created_user ⇒ Object
169 170 171 172 173 174 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 169 def test_redirect_to_the_created_user User.stubs(:find).returns(mock_user(:update_attributes => true)) @controller.expects(:resource_url).returns('http://test.host/') put :update assert_redirected_to 'http://test.host/' end |
#test_render_edit_template_when_user_cannot_be_saved ⇒ Object
182 183 184 185 186 187 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 182 def test_render_edit_template_when_user_cannot_be_saved User.stubs(:find).returns(mock_user(:update_attributes => false, :errors => {:some => :error})) put :update assert_response :success assert_equal "Edit HTML", @response.body.strip end |
#test_show_flash_message_when_success ⇒ Object
176 177 178 179 180 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 176 def User.stubs(:find).returns(mock_user(:update_attributes => true)) put :update assert_equal flash[:notice], 'User was successfully updated.' end |
#test_update_the_requested_object ⇒ Object
162 163 164 165 166 167 |
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 162 def test_update_the_requested_object User.expects(:find).with('42').returns(mock_user) mock_user.expects(:update_attributes).with({'these' => 'params'}).returns(true) put :update, :id => '42', :user => {:these => 'params'} assert_equal mock_user, assigns(:user) end |