forked from lokka/lokka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login_spec.rb
45 lines (37 loc) · 1.29 KB
/
login_spec.rb
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
40
41
42
43
44
45
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe 'Login' do
include_context 'in site'
before { Factory(:user, :name => 'test') }
after { User.destroy }
shared_examples_for 'login failed' do
it 'should not redirect' do
last_response.should_not be_redirect
end
it 'should render login screen again' do
last_response.body.should match('<body class="admin_login">')
end
it 'should not render dashboard side bar' do
last_response.body.should_not match('<div id="aside">')
end
end
context 'when valid username and password' do
it 'should redirect to /admin/' do
post '/admin/login', {:name => 'test', :password => 'test'}
last_response.should be_redirect
follow_redirect!
last_request.env['PATH_INFO'].should == '/admin/'
end
end
context 'when invalid username' do
before { post '/admin/login', {:name => 'wrong', :password => 'test'} }
it_behaves_like 'login failed'
end
context 'when invalid password' do
before { post '/admin/login', {:name => 'test', :password => 'wrong'} }
it_behaves_like 'login failed'
end
context 'when invalid username and password' do
before { post '/admin/login', {:name => 'wrong', :password => 'wrong'} }
it_behaves_like 'login failed'
end
end