annotate test/functional/auth_sources_controller_test.rb @ 1082:997f6d7738f7 bug_531

In repo controller entry action, show the page for the file even if it's binary (so user still has access to history etc links). This makes it possible to use the entry action as the default when a file is clicked on
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 22 Nov 2012 18:04:17 +0000
parents cbb26bc654de
children 433d4f72a19b
rev   line source
Chris@119 1 require File.expand_path('../../test_helper', __FILE__)
Chris@0 2
Chris@0 3 class AuthSourcesControllerTest < ActionController::TestCase
Chris@0 4
Chris@0 5 def setup
Chris@0 6 @request.session[:user_id] = 1
Chris@0 7 end
Chris@0 8
Chris@0 9 context "get :index" do
Chris@0 10 setup do
Chris@0 11 get :index
Chris@0 12 end
Chris@0 13
Chris@0 14 should_assign_to :auth_sources
Chris@0 15 should_assign_to :auth_source_pages
Chris@0 16 should_respond_with :success
Chris@0 17 should_render_template :index
Chris@0 18 end
Chris@0 19
Chris@0 20 context "get :new" do
Chris@0 21 setup do
Chris@0 22 get :new
Chris@0 23 end
Chris@0 24
Chris@0 25 should_assign_to :auth_source
Chris@0 26 should_respond_with :success
Chris@0 27 should_render_template :new
Chris@0 28
Chris@0 29 should "initilize a new AuthSource" do
Chris@0 30 assert_equal AuthSource, assigns(:auth_source).class
Chris@0 31 assert assigns(:auth_source).new_record?
Chris@0 32 end
Chris@0 33 end
Chris@0 34
Chris@0 35 context "post :create" do
Chris@0 36 setup do
Chris@0 37 post :create, :auth_source => {:name => 'Test'}
Chris@0 38 end
Chris@0 39
Chris@0 40 should_respond_with :redirect
Chris@0 41 should_redirect_to("index") {{:action => 'index'}}
Chris@0 42 should_set_the_flash_to /success/i
Chris@0 43 end
Chris@0 44
Chris@0 45 context "get :edit" do
Chris@0 46 setup do
Chris@0 47 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@0 48 get :edit, :id => @auth_source.id
Chris@0 49 end
Chris@0 50
Chris@0 51 should_assign_to(:auth_source) {@auth_source}
Chris@0 52 should_respond_with :success
Chris@0 53 should_render_template :edit
Chris@0 54 end
Chris@0 55
Chris@0 56 context "post :update" do
Chris@0 57 setup do
Chris@0 58 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@0 59 post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'}
Chris@0 60 end
Chris@0 61
Chris@0 62 should_respond_with :redirect
Chris@0 63 should_redirect_to("index") {{:action => 'index'}}
Chris@0 64 should_set_the_flash_to /update/i
Chris@0 65 end
Chris@0 66
Chris@0 67 context "post :destroy" do
Chris@441 68 setup do
Chris@441 69 @auth_source = AuthSource.generate!(:name => 'TestEdit')
Chris@441 70 end
Chris@909 71
Chris@0 72 context "without users" do
Chris@0 73 setup do
Chris@0 74 post :destroy, :id => @auth_source.id
Chris@0 75 end
Chris@0 76
Chris@0 77 should_respond_with :redirect
Chris@0 78 should_redirect_to("index") {{:action => 'index'}}
Chris@0 79 should_set_the_flash_to /deletion/i
Chris@0 80 end
Chris@909 81
Chris@441 82 context "with users" do
Chris@441 83 setup do
Chris@441 84 User.generate!(:auth_source => @auth_source)
Chris@441 85 post :destroy, :id => @auth_source.id
Chris@441 86 end
Chris@909 87
Chris@441 88 should_respond_with :redirect
Chris@441 89 should "not destroy the AuthSource" do
Chris@441 90 assert AuthSource.find(@auth_source.id)
Chris@441 91 end
Chris@441 92 end
Chris@0 93 end
Chris@0 94 end