Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (41 sloc) 1.181 kB
afe2b3d @jnunemaker Tests for ables.
authored
1 require 'helper'
2
3 class AblesTest < Test::Unit::TestCase
4 context "Class with Canable::Ables included" do
5 setup do
6 klass = Doc do
7 include Canable::Ables
8 end
9
10 @resource = klass.new
11 @user = mock('user')
12 end
13
14 should "default viewable_by? to true" do
15 assert @resource.viewable_by?(@user)
16 end
17
18 should "default creatable_by? to true" do
19 assert @resource.creatable_by?(@user)
20 end
21
22 should "default updatable_by? to true" do
23 assert @resource.updatable_by?(@user)
24 end
25
26 should "default destroyable_by? to true" do
27 assert @resource.destroyable_by?(@user)
28 end
29 end
30
31 context "Class that overrides an able method" do
32 setup do
33 klass = Doc do
34 include Canable::Ables
35
36 def viewable_by?(user)
37 user.name == 'John'
38 end
39 end
40
41 @resource = klass.new
42 @john = mock('user', :name => 'John')
43 @steve = mock('user', :name => 'Steve')
44 end
45
46 should "use the overriden method and not default to true" do
47 assert @resource.viewable_by?(@john)
48 assert ! @resource.viewable_by?(@steve)
49 end
50 end
51 end
Something went wrong with that request. Please try again.