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