Class: UpdateActionBaseTest

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

Instance Method Summary collapse

Methods included from UserTestHelper

#setup

Instance Method Details

#test_dont_show_flash_message_when_user_cannot_be_savedObject



189
190
191
192
193
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 189

def test_dont_show_flash_message_when_user_cannot_be_saved
  User.stubs(:find).returns(mock_user(:update_attributes => false, :errors => {:some => :error}))
  put :update
  assert flash.empty?
end

#test_redirect_to_the_created_userObject



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_savedObject



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_successObject



176
177
178
179
180
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 176

def test_show_flash_message_when_success
  User.stubs(:find).returns(mock_user(:update_attributes => true))
  put :update
  assert_equal flash[:notice], 'User was successfully updated.'
end

#test_update_the_requested_objectObject



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