Skip to content

Commit

Permalink
adding link to add games
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenyxu committed Jan 29, 2012
1 parent 4485001 commit 3fcb639
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/ability.rb
Expand Up @@ -31,6 +31,7 @@ def initialize(user)

if user.admin?
can :read, :all
can :manage, Game
else
if user.persisted?
can :manage, user
Expand Down
5 changes: 4 additions & 1 deletion app/views/games/index.html.haml
@@ -1,4 +1,7 @@
%div#games.container
.fluid-sidebar
%h1 Games
.fluid-content
- @games.each do |game|
= link_to game.name, game
- if can? :manage, Game
= link_to 'Add game', new_game_path
33 changes: 33 additions & 0 deletions spec/requests/games/creating_games_spec.rb
@@ -0,0 +1,33 @@
require 'spec_helper'

describe 'Creating games' do
describe 'a logged in admin user' do
before { @admin = log_in! Factory(:admin) }

describe 'visiting the games page' do
before do
visit '/'
click_on 'Games'
end

it 'should see a link to add a game' do
page.should have_content('Add game')
end
end
end

describe 'a logged in normal user' do
before { @user = log_in! Factory(:user) }

describe 'visiting the games page' do
before do
visit '/'
click_on 'Games'
end

it 'should not see a link to add a game' do
page.should_not have_content('Add game')
end
end
end
end

0 comments on commit 3fcb639

Please sign in to comment.