Skip to content

Commit a0ad807

Browse files
committed
Merge pull request riseuplabs#83 from azul/bugfix/login_required_flow
redirect to page with login fields on login required
2 parents 15fd249 + 7eadc75 commit a0ad807

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

app/controllers/common/application/rescue_errors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def render_auth_error_html(exception)
259259
# fyi, this template will eat the alert_message
260260
render template: 'error/permission_denied', layout: 'notice'
261261
else
262-
redirect_to login_path(redirect: request.path)
262+
redirect_to root_path(redirect: request.path)
263263
end
264264
end
265265

test/helpers/functional_test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def assert_permission_denied(failure_message='missing "permission denied" messag
1414

1515
def assert_login_required
1616
assert_response :redirect
17-
assert_redirected_to login_path(redirect: @request.path)
17+
assert_redirected_to root_path(redirect: @request.path)
1818
end
1919

2020
# can pass either a regexp of the flash error string,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# There's a bunch of error scenarios. This test tries to make sure crabgrass
3+
# responds in a meaningful way:
4+
#
5+
# login required -> offer a login form
6+
# permission denied -> display message
7+
# not found -> display not found
8+
# hidden from user -> display not found
9+
#
10+
11+
require 'integration_test'
12+
13+
class ErrorFlowTest < IntegrationTest
14+
15+
def test_login_required
16+
visit '/me/pages'
17+
assert_content 'Login Required'
18+
fill_in 'login', with: 'blue'
19+
fill_in 'password', with: 'blue'
20+
click_button 'Login'
21+
assert_equal '/me/pages', current_path
22+
end
23+
24+
end

test/integration/people_directory_test.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class PeopleDirectoryTest < JavascriptIntegrationTest
55
def setup
66
super
77
@user = users(:blue)
8-
login
98
end
109

1110
def test_contacts
11+
login
1212
click_on 'People'
1313
autocomplete 'q', with: 'orange'
1414
within '#user_list' do
@@ -19,6 +19,7 @@ def test_contacts
1919
end
2020

2121
def test_peers
22+
login
2223
click_on 'People'
2324
click_on 'Peers'
2425
autocomplete 'q', with: 'red'
@@ -30,6 +31,7 @@ def test_peers
3031
end
3132

3233
def test_search
34+
login
3335
click_on 'People'
3436
find('#column_left').click_on 'Search'
3537
within '#user_list' do
@@ -42,4 +44,12 @@ def test_search
4244
end
4345
end
4446

47+
def test_logged_out
48+
visit '/'
49+
click_on 'People'
50+
assert_content 'Search'
51+
assert_no_content 'Peers'
52+
assert_no_content 'Contacts'
53+
end
54+
4555
end

0 commit comments

Comments
 (0)