blob: e0953cc5df5272aa2b3f8ea26c445c9422e7a37c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
require File.dirname(__FILE__) + '/../spec_helper'
describe <%= session_plural_class_name %>Controller do
fixtures :all
render_views
it "new action should render new template" do
get :new
response.should render_template(:new)
end
<%- if options[:authlogic] -%>
it "create action should render new template when authentication is invalid" do
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
response.should render_template(:new)
<%= session_class_name %>.find.should be_nil
end
it "create action should redirect when authentication is valid" do
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
response.should redirect_to(root_url)
<%= session_class_name %>.find.<%= user_singular_name %>.should == <%= user_plural_name %>(:foo)
end
<%- else -%>
it "create action should render new template when authentication is invalid" do
<%= user_class_name %>.stubs(:authenticate).returns(nil)
post :create
response.should render_template(:new)
session['<%= user_singular_name %>_id'].should be_nil
end
it "create action should redirect when authentication is valid" do
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
post :create
response.should redirect_to(root_url)
session['<%= user_singular_name %>_id'].should == <%= user_class_name %>.first.id
end
<%- end -%>
end
|