Permalink
Browse files

Fixed error when user without roles is logged in

  • Loading branch information...
1 parent 3c5c13b commit 2e4db6b520834b5c1d68d762598da100d6026952 @stffn committed Nov 18, 2009
@@ -10,14 +10,14 @@
</head>
<body style="margin:0; padding: 0;">
-<div id="topnav" class="<%= logged_in? and current_user.roles.map(&:to_s) * " " %>">
+<div id="topnav" class="<%= logged_in? and current_user.role_symbols.map(&:to_s) * " " %>">
<%# link_to ... if permitted_to? ... is used to only show the links if the
current user has the stated privileges. %>
<%= link_to "Conferences", conferences_path if permitted_to? :read, :conferences %>
<%= link_to "Users", users_path if permitted_to? :read, :users %>
<%#= link_to "Authorization Rules", :controller => 'authorization_rules' if permitted_to? :read, :authorization_rules %> |
<% if logged_in? %>
- Logged in as <b><%= h current_user.login %> (<%= current_user.roles * ',' %>)</b>.
+ Logged in as <b><%= h current_user.login %> (<%= current_user.role_symbols.map(&:to_s) * ',' %>)</b>.
<%= link_to "Logout", '/logout' %>
<% else %>
Not logged in <b>(guest)</b> |
View
@@ -60,3 +60,11 @@ user:
crypted_password: 38b84d2bfb34030ee5601bdd3af794b8a52d0917 # 'monkey'
created_at: <%= 1.days.ago.to_s :db %>
roles: [:user]
+
+without_roles:
+ id: 7
+ login: without_roles
+ email: without_roles@example.com
+ salt: da4b9237bacccdf19c0760cab7aec4a8359010b0 # SHA1('1')
+ crypted_password: 38b84d2bfb34030ee5601bdd3af794b8a52d0917 # 'monkey'
+ created_at: <%= 1.days.ago.to_s :db %>
@@ -7,6 +7,11 @@ def test_should_get_index
assert_not_nil assigns(:conferences)
end
+ def test_should_get_index_for_user_without_roles
+ get_with users(:without_roles), :index
+ assert_response :success
+ end
+
def test_should_get_new
# check that an admin may view the new page
get_with admin, :new
@@ -4,7 +4,7 @@ class ConferenceAttendeesTest < ActiveSupport::TestCase
def test_should_create
assert_difference "ConferenceAttendee.count" do
with_user users(:user) do
- conferences(:public).conference_attendees.create(:user => users(:user))
+ conferences(:public).conference_attendees.create!(:user => users(:user))
end
end
end
View
@@ -13,6 +13,11 @@ def test_should_create_user
end
end
+ def test_empty_role_symbols
+ user = create_user
+ assert_equal [], user.role_symbols
+ end
+
# def test_should_require_login
# assert_no_difference 'User.count' do
# u = create_user(:login => nil)

0 comments on commit 2e4db6b

Please sign in to comment.