Skip to content

Commit

Permalink
Preview a template follows the read permission.
Browse files Browse the repository at this point in the history
  • Loading branch information
bamnet committed May 31, 2012
1 parent ec4e580 commit e4d20f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def initialize(accessor)
## Templates
# Oddly enough, templates store a hidden flag instead of public
# like everything else.
can :read, Template, :is_hidden => false
can [:read, :preview], Template, :is_hidden => false
end

# Load abilities based on the type of object.
Expand Down
4 changes: 3 additions & 1 deletion test/unit/abilities/shared/template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ def setup
[@user, @screen].each do |thing|
ability = Ability.new(thing)
assert ability.can?(:read, @template)
assert ability.can?(:preview, @template)
end
end

test "noone can read public templates" do
test "noone can read hidden templates" do
template = templates(:hidden)
[@user, @screen].each do |thing|
ability = Ability.new(thing)
assert ability.cannot?(:read, template)
assert ability.cannot?(:preview, template)
end
end

Expand Down

0 comments on commit e4d20f3

Please sign in to comment.