Skip to content

Commit

Permalink
Merge pull request lokka#183 from morygonzalez/fix-admin-login-layout…
Browse files Browse the repository at this point in the history
…-rendering-bug

Fix admin login layout rendering bug / ログイン失敗時レンダリングのバグを修正しました
  • Loading branch information
komagata committed Nov 19, 2012
2 parents fd2cc99 + 0a7db6a commit 6a55220
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/lokka/app/admin.rb
Expand Up @@ -22,7 +22,7 @@ class App
end
else
@login_failed = true
haml :'admin/login', :layout => :'admin/layout'
haml :'admin/login', :layout => false
end
end

Expand Down
33 changes: 21 additions & 12 deletions spec/integration/login_spec.rb
Expand Up @@ -4,6 +4,21 @@
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'}
Expand All @@ -14,23 +29,17 @@
end

context 'when invalid username' do
it 'should not redirect' do
post '/admin/login', {:name => 'wrong', :password => 'test'}
last_response.should_not be_redirect
end
before { post '/admin/login', {:name => 'wrong', :password => 'test'} }
it_behaves_like 'login failed'
end

context 'when invalid password' do
it 'should not redirect' do
post '/admin/login', {:name => 'test', :password => 'wrong'}
last_response.should_not be_redirect
end
before { post '/admin/login', {:name => 'test', :password => 'wrong'} }
it_behaves_like 'login failed'
end

context 'when invalid username and password' do
it 'should not redirect' do
post '/admin/login', {:name => 'wrong', :password => 'wrong'}
last_response.should_not be_redirect
end
before { post '/admin/login', {:name => 'wrong', :password => 'wrong'} }
it_behaves_like 'login failed'
end
end

0 comments on commit 6a55220

Please sign in to comment.