annotate test/functional/auth_sources_controller_test.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children 1d32c0a0efbf
rev   line source
Chris@0 1 require 'test_helper'
Chris@0 2
Chris@0 3 class AuthSourcesControllerTest < ActionController::TestCase
Chris@0 4 fixtures :all
Chris@0 5
Chris@0 6 def setup
Chris@0 7 @request.session[:user_id] = 1
Chris@0 8 end
Chris@0 9
Chris@0 10 context "get :index" do
Chris@0 11 setup do
Chris@0 12 get :index
Chris@0 13 end
Chris@0 14
Chris@0 15 should_assign_to :auth_sources
Chris@0 16 should_assign_to :auth_source_pages
Chris@0 17 should_respond_with :success
Chris@0 18 should_render_template :index
Chris@0 19 end
Chris@0 20
Chris@0 21 context "get :new" do
Chris@0 22 setup do
Chris@0 23 get :new
Chris@0 24 end
Chris@0 25
Chris@0 26 should_assign_to :auth_source
Chris@0 27 should_respond_with :success
Chris@0 28 should_render_template :new
Chris@0 29
Chris@0 30 should "initilize a new AuthSource" do
Chris@0 31 assert_equal AuthSource, assigns(:auth_source).class
Chris@0 32 assert assigns(:auth_source).new_record?
Chris@0 33 end
Chris@0 34 end
Chris@0 35
Chris@0 36 context "post :create" do
Chris@0 37 setup do
Chris@0 38 post :create, :auth_source => {:name => 'Test'}
Chris@0 39 end
Chris@0 40
Chris@0 41 should_respond_with :redirect
Chris@0 42 should_redirect_to("index") {{:action => 'index'}}
Chris@0 43 should_set_the_flash_to /success/i
Chris@0 44 end
Chris@0 45
Chris@0 46 context "get :edit" do
Chris@0 47 setup do
Chris@0 48 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@0 49 get :edit, :id => @auth_source.id
Chris@0 50 end
Chris@0 51
Chris@0 52 should_assign_to(:auth_source) {@auth_source}
Chris@0 53 should_respond_with :success
Chris@0 54 should_render_template :edit
Chris@0 55 end
Chris@0 56
Chris@0 57 context "post :update" do
Chris@0 58 setup do
Chris@0 59 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@0 60 post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'}
Chris@0 61 end
Chris@0 62
Chris@0 63 should_respond_with :redirect
Chris@0 64 should_redirect_to("index") {{:action => 'index'}}
Chris@0 65 should_set_the_flash_to /update/i
Chris@0 66 end
Chris@0 67
Chris@0 68 context "post :destroy" do
Chris@0 69 context "without users" do
Chris@0 70 setup do
Chris@0 71 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@0 72 post :destroy, :id => @auth_source.id
Chris@0 73 end
Chris@0 74
Chris@0 75 should_respond_with :redirect
Chris@0 76 should_redirect_to("index") {{:action => 'index'}}
Chris@0 77 should_set_the_flash_to /deletion/i
Chris@0 78
Chris@0 79 end
Chris@0 80
Chris@0 81 should "be tested with users"
Chris@0 82 end
Chris@0 83 end