Add tests for visible admin links and fix bug

This commit is contained in:
kikito
2015-08-21 19:09:26 +02:00
parent 01eb89f5f4
commit 5328355c3e
2 changed files with 13 additions and 4 deletions

View File

@@ -6,10 +6,10 @@
</li>
<% end %>
<% if current_user.moderator? %>
<% if current_user.moderator? || current_user.administrator? %>
<li>
<%= link_to t("layouts.header.moderation"), moderation_root_path %>
</li>
<% end %>
<% end %>
</ul>
</ul>

View File

@@ -5,6 +5,9 @@ feature 'Admin' do
scenario 'Access as regular user is not authorized' do
login_as(user)
visit root_path
expect(page).to_not have_link("Moderation")
visit moderation_root_path
expect(current_path).to eq(root_path)
@@ -15,7 +18,10 @@ feature 'Admin' do
create(:moderator, user: user)
login_as(user)
visit moderation_root_path
visit root_path
expect(page).to have_link("Moderation")
click_on "Moderation"
expect(current_path).to eq(moderation_root_path)
expect(page).to_not have_content "not authorized"
@@ -25,7 +31,10 @@ feature 'Admin' do
create(:administrator, user: user)
login_as(user)
visit moderation_root_path
visit root_path
expect(page).to have_link("Moderation")
click_on "Moderation"
expect(current_path).to eq(moderation_root_path)
expect(page).to_not have_content "not authorized"