Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Commit

Permalink
there was a minor glitch: non-admins could see links they shouldn't
Browse files Browse the repository at this point in the history
  • Loading branch information
mamhoff committed Dec 10, 2013
1 parent 2dc024f commit 5c16d21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/views/tours/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<% @tours.each do |tour| %>
<div class="well">
<p> <%= tour.name %>
<%= link_to "delete", tour, method: :delete,
data: {confirm: "Are you sure?"},
title: tour.name %>
<% if user_signed_in? && current_user.has_role?('admin') %>
<%= link_to "delete", tour, method: :delete,
data: {confirm: "Are you sure?"},
title: tour.name %>
<% end %>
</p>
</div>
<% end %>
Expand Down
7 changes: 5 additions & 2 deletions spec/views/tours/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'spec_helper'

describe "roles/index.html.erb" do
before { visit tours_path }
before do
FactoryGirl.create(:tour)
visit tours_path
end

it "should have the word tour index" do
expect(page).to have_content("Tour index")
end
Expand All @@ -13,7 +17,6 @@
describe "signed in as admin" do

before do
FactoryGirl.create(:tour)
admin = FactoryGirl.create(:user, :admin)
sign_in admin
visit tours_path
Expand Down

0 comments on commit 5c16d21

Please sign in to comment.