To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / functional / auth_sources_controller_test.rb @ 442:753f1380d6bc
History | View | Annotate | Download (2.2 KB)
| 1 | 119:8661b858af72 | Chris | require File.expand_path('../../test_helper', __FILE__) |
|---|---|---|---|
| 2 | 0:513646585e45 | Chris | |
| 3 | class AuthSourcesControllerTest < ActionController::TestCase |
||
| 4 | fixtures :all
|
||
| 5 | |||
| 6 | def setup |
||
| 7 | @request.session[:user_id] = 1 |
||
| 8 | end
|
||
| 9 | |||
| 10 | context "get :index" do |
||
| 11 | setup do
|
||
| 12 | get :index
|
||
| 13 | end
|
||
| 14 | |||
| 15 | should_assign_to :auth_sources
|
||
| 16 | should_assign_to :auth_source_pages
|
||
| 17 | should_respond_with :success
|
||
| 18 | should_render_template :index
|
||
| 19 | end
|
||
| 20 | |||
| 21 | context "get :new" do |
||
| 22 | setup do
|
||
| 23 | get :new
|
||
| 24 | end
|
||
| 25 | |||
| 26 | should_assign_to :auth_source
|
||
| 27 | should_respond_with :success
|
||
| 28 | should_render_template :new
|
||
| 29 | |||
| 30 | should "initilize a new AuthSource" do |
||
| 31 | assert_equal AuthSource, assigns(:auth_source).class |
||
| 32 | assert assigns(:auth_source).new_record?
|
||
| 33 | end
|
||
| 34 | end
|
||
| 35 | |||
| 36 | context "post :create" do |
||
| 37 | setup do
|
||
| 38 | post :create, :auth_source => {:name => 'Test'} |
||
| 39 | end
|
||
| 40 | |||
| 41 | should_respond_with :redirect
|
||
| 42 | should_redirect_to("index") {{:action => 'index'}} |
||
| 43 | should_set_the_flash_to /success/i
|
||
| 44 | end
|
||
| 45 | |||
| 46 | context "get :edit" do |
||
| 47 | setup do
|
||
| 48 | @auth_source = AuthSource.generate!(:name => 'TestEdit') |
||
| 49 | get :edit, :id => @auth_source.id |
||
| 50 | end
|
||
| 51 | |||
| 52 | should_assign_to(:auth_source) {@auth_source} |
||
| 53 | should_respond_with :success
|
||
| 54 | should_render_template :edit
|
||
| 55 | end
|
||
| 56 | |||
| 57 | context "post :update" do |
||
| 58 | setup do
|
||
| 59 | @auth_source = AuthSource.generate!(:name => 'TestEdit') |
||
| 60 | post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'} |
||
| 61 | end
|
||
| 62 | |||
| 63 | should_respond_with :redirect
|
||
| 64 | should_redirect_to("index") {{:action => 'index'}} |
||
| 65 | should_set_the_flash_to /update/i
|
||
| 66 | end
|
||
| 67 | |||
| 68 | context "post :destroy" do |
||
| 69 | 441:cbce1fd3b1b7 | Chris | setup do
|
| 70 | @auth_source = AuthSource.generate!(:name => 'TestEdit') |
||
| 71 | end
|
||
| 72 | |||
| 73 | 0:513646585e45 | Chris | context "without users" do |
| 74 | setup do
|
||
| 75 | post :destroy, :id => @auth_source.id |
||
| 76 | end
|
||
| 77 | |||
| 78 | should_respond_with :redirect
|
||
| 79 | should_redirect_to("index") {{:action => 'index'}} |
||
| 80 | should_set_the_flash_to /deletion/i
|
||
| 81 | end
|
||
| 82 | |||
| 83 | 441:cbce1fd3b1b7 | Chris | context "with users" do |
| 84 | setup do
|
||
| 85 | User.generate!(:auth_source => @auth_source) |
||
| 86 | post :destroy, :id => @auth_source.id |
||
| 87 | end
|
||
| 88 | |||
| 89 | should_respond_with :redirect
|
||
| 90 | should "not destroy the AuthSource" do |
||
| 91 | assert AuthSource.find(@auth_source.id) |
||
| 92 | end
|
||
| 93 | end
|
||
| 94 | 0:513646585e45 | Chris | end
|
| 95 | end |