To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 69 / 6985b7da5db7388f839f13e1c4ad6f39ec6acc94.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (2.17 KB)

1
require File.expand_path('../../test_helper', __FILE__)
2

    
3
class AuthSourcesControllerTest < ActionController::TestCase
4

    
5
  def setup
6
    @request.session[:user_id] = 1
7
  end
8

    
9
  context "get :index" do
10
    setup do
11
      get :index
12
    end
13

    
14
    should_assign_to :auth_sources
15
    should_assign_to :auth_source_pages
16
    should_respond_with :success
17
    should_render_template :index
18
  end
19

    
20
  context "get :new" do
21
    setup do
22
      get :new
23
    end
24

    
25
    should_assign_to :auth_source
26
    should_respond_with :success
27
    should_render_template :new
28

    
29
    should "initilize a new AuthSource" do
30
      assert_equal AuthSource, assigns(:auth_source).class
31
      assert assigns(:auth_source).new_record?
32
    end
33
  end
34

    
35
  context "post :create" do
36
    setup do
37
      post :create, :auth_source => {:name => 'Test'}
38
    end
39

    
40
    should_respond_with :redirect
41
    should_redirect_to("index") {{:action => 'index'}}
42
    should_set_the_flash_to /success/i
43
  end
44

    
45
  context "get :edit" do
46
    setup do
47
      @auth_source = AuthSource.generate!(:name => 'TestEdit')
48
      get :edit, :id => @auth_source.id
49
    end
50

    
51
    should_assign_to(:auth_source) {@auth_source}
52
    should_respond_with :success
53
    should_render_template :edit
54
  end
55

    
56
  context "post :update" do
57
    setup do
58
      @auth_source = AuthSource.generate!(:name => 'TestEdit')
59
      post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'}
60
    end
61

    
62
    should_respond_with :redirect
63
    should_redirect_to("index") {{:action => 'index'}}
64
    should_set_the_flash_to /update/i
65
  end
66

    
67
  context "post :destroy" do
68
    setup do
69
      @auth_source = AuthSource.generate!(:name => 'TestEdit')
70
    end
71

    
72
    context "without users" do
73
      setup do
74
        post :destroy, :id => @auth_source.id
75
      end
76

    
77
      should_respond_with :redirect
78
      should_redirect_to("index") {{:action => 'index'}}
79
      should_set_the_flash_to /deletion/i
80
    end
81

    
82
    context "with users" do
83
      setup do
84
        User.generate!(:auth_source => @auth_source)
85
        post :destroy, :id => @auth_source.id
86
      end
87

    
88
      should_respond_with :redirect
89
      should "not destroy the AuthSource" do
90
        assert AuthSource.find(@auth_source.id)
91
      end
92
    end
93
  end
94
end