blob: fe2a65b53ab6ba498dc86aee9a86e3f1375840b5 (
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
|
require 'test_helper'
class <%= session_plural_class_name %>ControllerTest < ActionController::TestCase
def test_new
get :new
assert_template 'new'
end
<%- if options[:authlogic] -%>
def test_create_invalid
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
assert_template 'new'
assert_nil <%= session_class_name %>.find
end
def test_create_valid
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
assert_redirected_to root_url
assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
end
<%- else -%>
def test_create_invalid
<%= user_class_name %>.stubs(:authenticate).returns(nil)
post :create
assert_template 'new'
assert_nil session['<%= user_singular_name %>_id']
end
def test_create_valid
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
post :create
assert_redirected_to root_url
assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
end
<%- end -%>
end
|