Class: IndexActionBaseTest

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_controller_should_render_indexObject



36
37
38
39
40
41
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 36

def test_controller_should_render_index
  User.stubs(:find).returns([mock_user])
  get :index
  assert_response :success
  assert_equal 'Index HTML', @response.body.strip
end

#test_expose_all_users_as_instance_variableObject



30
31
32
33
34
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 30

def test_expose_all_users_as_instance_variable
  User.expects(:find).with(:all).returns([mock_user])
  get :index
  assert_equal [mock_user], assigns(:users)
end

#test_render_all_users_as_xml_when_mime_type_is_xmlObject



43
44
45
46
47
48
49
50
# File 'lib/vendor/plugins/inherited_resources/test/base_test.rb', line 43

def test_render_all_users_as_xml_when_mime_type_is_xml
  @request.accept = 'application/xml'
  User.expects(:find).with(:all).returns(mock_user)
  mock_user.expects(:to_xml).returns('Generated XML')
  get :index
  assert_response :success
  assert_equal 'Generated XML', @response.body
end