Class: OauthClientsControllerCreateTest

Inherits:
ActionController::TestCase
  • Object
show all
Includes:
OAuthControllerTestHelper
Defined in:
lib/generators/test_unit/templates/clients_controller_test.rb

Instance Method Summary collapse

Instance Method Details

#do_invalid_postObject



175
176
177
178
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 175

def do_invalid_post
  @client_application.expects(:save).returns(false)
  post :create,:client_application=>{:name=>'my site'}
end

#do_valid_postObject



170
171
172
173
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 170

def do_valid_post
  @client_application.expects(:save).returns(true)
  post :create,'client_application'=>{'name'=>'my site'}
end

#setupObject



160
161
162
163
164
165
166
167
168
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 160

def setup
  @controller = OauthClientsController.new
  @request    = ActionController::TestRequest.new
  @response   = ActionController::TestResponse.new

  
  @client_applications.stubs(:build).returns(@client_application)
  @client_application.stubs(:save).returns(true)
end

#test_should_assign_client_applicationsObject



191
192
193
194
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 191

def test_should_assign_client_applications
  do_invalid_post
  assert_equal @client_application, assigns(:client_application)
end

#test_should_query_current_users_client_applicationsObject



180
181
182
183
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 180

def test_should_query_current_users_client_applications
  @client_applications.expects(:build).returns(@client_application)
  do_valid_post
end

#test_should_redirect_to_new_client_applicationObject



185
186
187
188
189
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 185

def test_should_redirect_to_new_client_application
  do_valid_post
  assert_response :redirect
  assert_redirected_to(:action => "show", :id => @client_application.id)
end

#test_should_render_show_templateObject



196
197
198
199
# File 'lib/generators/test_unit/templates/clients_controller_test.rb', line 196

def test_should_render_show_template
  do_invalid_post
  assert_template('new')
end