annotate .svn/pristine/69/6985b7da5db7388f839f13e1c4ad6f39ec6acc94.svn-base @ 1628:9c5f8e24dadc live tip

Quieten this cron script
author Chris Cannam
date Tue, 25 Aug 2020 11:38:49 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 require File.expand_path('../../test_helper', __FILE__)
Chris@909 2
Chris@909 3 class AuthSourcesControllerTest < ActionController::TestCase
Chris@909 4
Chris@909 5 def setup
Chris@909 6 @request.session[:user_id] = 1
Chris@909 7 end
Chris@909 8
Chris@909 9 context "get :index" do
Chris@909 10 setup do
Chris@909 11 get :index
Chris@909 12 end
Chris@909 13
Chris@909 14 should_assign_to :auth_sources
Chris@909 15 should_assign_to :auth_source_pages
Chris@909 16 should_respond_with :success
Chris@909 17 should_render_template :index
Chris@909 18 end
Chris@909 19
Chris@909 20 context "get :new" do
Chris@909 21 setup do
Chris@909 22 get :new
Chris@909 23 end
Chris@909 24
Chris@909 25 should_assign_to :auth_source
Chris@909 26 should_respond_with :success
Chris@909 27 should_render_template :new
Chris@909 28
Chris@909 29 should "initilize a new AuthSource" do
Chris@909 30 assert_equal AuthSource, assigns(:auth_source).class
Chris@909 31 assert assigns(:auth_source).new_record?
Chris@909 32 end
Chris@909 33 end
Chris@909 34
Chris@909 35 context "post :create" do
Chris@909 36 setup do
Chris@909 37 post :create, :auth_source => {:name => 'Test'}
Chris@909 38 end
Chris@909 39
Chris@909 40 should_respond_with :redirect
Chris@909 41 should_redirect_to("index") {{:action => 'index'}}
Chris@909 42 should_set_the_flash_to /success/i
Chris@909 43 end
Chris@909 44
Chris@909 45 context "get :edit" do
Chris@909 46 setup do
Chris@909 47 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@909 48 get :edit, :id => @auth_source.id
Chris@909 49 end
Chris@909 50
Chris@909 51 should_assign_to(:auth_source) {@auth_source}
Chris@909 52 should_respond_with :success
Chris@909 53 should_render_template :edit
Chris@909 54 end
Chris@909 55
Chris@909 56 context "post :update" do
Chris@909 57 setup do
Chris@909 58 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@909 59 post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'}
Chris@909 60 end
Chris@909 61
Chris@909 62 should_respond_with :redirect
Chris@909 63 should_redirect_to("index") {{:action => 'index'}}
Chris@909 64 should_set_the_flash_to /update/i
Chris@909 65 end
Chris@909 66
Chris@909 67 context "post :destroy" do
Chris@909 68 setup do
Chris@909 69 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@909 70 end
Chris@909 71
Chris@909 72 context "without users" do
Chris@909 73 setup do
Chris@909 74 post :destroy, :id => @auth_source.id
Chris@909 75 end
Chris@909 76
Chris@909 77 should_respond_with :redirect
Chris@909 78 should_redirect_to("index") {{:action => 'index'}}
Chris@909 79 should_set_the_flash_to /deletion/i
Chris@909 80 end
Chris@909 81
Chris@909 82 context "with users" do
Chris@909 83 setup do
Chris@909 84 User.generate!(:auth_source => @auth_source)
Chris@909 85 post :destroy, :id => @auth_source.id
Chris@909 86 end
Chris@909 87
Chris@909 88 should_respond_with :redirect
Chris@909 89 should "not destroy the AuthSource" do
Chris@909 90 assert AuthSource.find(@auth_source.id)
Chris@909 91 end
Chris@909 92 end
Chris@909 93 end
Chris@909 94 end