|
4 | 4 | it { should respond_to(:with_role).with(1).argument }
|
5 | 5 | it { should respond_to(:with_role).with(2).arguments }
|
6 | 6 |
|
7 |
| - context "with a global role" do |
8 |
| - it { subject.with_role("admin".send(param_method)).should eq([ root ]) } |
9 |
| - it { subject.with_role("moderator".send(param_method)).should be_empty } |
10 |
| - it { subject.with_role("visitor".send(param_method)).should be_empty } |
11 |
| - end |
12 |
| - |
13 |
| - context "with a class scoped role" do |
14 |
| - context "on Forum class" do |
15 |
| - it { subject.with_role("admin".send(param_method), Forum).should eq([ root ]) } |
16 |
| - it { subject.with_role("moderator".send(param_method), Forum).should eq([ modo ]) } |
17 |
| - it { subject.with_role("visitor".send(param_method), Forum).should be_empty } |
| 7 | + context "when resource setting: strict is set to false" do |
| 8 | + context "with a global role" do |
| 9 | + it { subject.with_role("admin".send(param_method)).should eq([ root ]) } |
| 10 | + it { subject.with_role("moderator".send(param_method)).should be_empty } |
| 11 | + it { subject.with_role("visitor".send(param_method)).should be_empty } |
18 | 12 | end
|
19 | 13 |
|
20 |
| - context "on Group class" do |
21 |
| - it { subject.with_role("admin".send(param_method), Group).should eq([ root ]) } |
22 |
| - it { subject.with_role("moderator".send(param_method), Group).should eq([ root ]) } |
23 |
| - it { subject.with_role("visitor".send(param_method), Group).should be_empty } |
| 14 | + context "with a class scoped role" do |
| 15 | + context "on Forum class" do |
| 16 | + it { subject.with_role("admin".send(param_method), Forum).should eq([ root ]) } |
| 17 | + it { subject.with_role("moderator".send(param_method), Forum).should eq([ modo ]) } |
| 18 | + it { subject.with_role("visitor".send(param_method), Forum).should be_empty } |
| 19 | + end |
| 20 | + |
| 21 | + context "on Group class" do |
| 22 | + it { subject.with_role("admin".send(param_method), Group).should eq([ root ]) } |
| 23 | + it { subject.with_role("moderator".send(param_method), Group).should eq([ root ]) } |
| 24 | + it { subject.with_role("visitor".send(param_method), Group).should be_empty } |
| 25 | + end |
24 | 26 | end
|
25 |
| - end |
26 | 27 |
|
27 |
| - context "with an instance scoped role" do |
28 |
| - context "on Forum.first instance" do |
29 |
| - it { subject.with_role("admin".send(param_method), Forum.first).should eq([ root ]) } |
30 |
| - it { subject.with_role("moderator".send(param_method), Forum.first).should eq([ modo ]) } |
31 |
| - it { subject.with_role("visitor".send(param_method), Forum.first).should be_empty } |
| 28 | + context "with an instance scoped role" do |
| 29 | + context "on Forum.first instance" do |
| 30 | + it { subject.with_role("admin".send(param_method), Forum.first).should eq([ root ]) } |
| 31 | + it { subject.with_role("moderator".send(param_method), Forum.first).should eq([ modo ]) } |
| 32 | + it { subject.with_role("visitor".send(param_method), Forum.first).should be_empty } |
| 33 | + end |
| 34 | + |
| 35 | + context "on Forum.last instance" do |
| 36 | + it { subject.with_role("admin".send(param_method), Forum.last).should eq([ root ]) } |
| 37 | + it { subject.with_role("moderator".send(param_method), Forum.last).should eq([ modo ]) } |
| 38 | + it { subject.with_role("visitor".send(param_method), Forum.last).should include(root, visitor) } # =~ doesn't pass using mongoid, don't know why... |
| 39 | + end |
| 40 | + |
| 41 | + context "on Group.first instance" do |
| 42 | + it { subject.with_role("admin".send(param_method), Group.first).should eq([ root ]) } |
| 43 | + it { subject.with_role("moderator".send(param_method), Group.first).should eq([ root ]) } |
| 44 | + it { subject.with_role("visitor".send(param_method), Group.first).should eq([ modo ]) } |
| 45 | + end |
| 46 | + |
| 47 | + context "on Company.first_instance" do |
| 48 | + it { subject.with_role("owner".send(param_method), Company.first).should eq([ owner ]) } |
| 49 | + end |
32 | 50 | end
|
| 51 | + end |
33 | 52 |
|
34 |
| - context "on Forum.last instance" do |
35 |
| - it { subject.with_role("admin".send(param_method), Forum.last).should eq([ root ]) } |
36 |
| - it { subject.with_role("moderator".send(param_method), Forum.last).should eq([ modo ]) } |
37 |
| - it { subject.with_role("visitor".send(param_method), Forum.last).should include(root, visitor) } # =~ doesn't pass using mongoid, don't know why... |
| 53 | + context "when resource setting: strict is set to true" do |
| 54 | + before(:context) do |
| 55 | + user_class.strict_rolify = true |
38 | 56 | end
|
39 |
| - |
40 |
| - context "on Group.first instance" do |
41 |
| - it { subject.with_role("admin".send(param_method), Group.first).should eq([ root ]) } |
42 |
| - it { subject.with_role("moderator".send(param_method), Group.first).should eq([ root ]) } |
43 |
| - it { subject.with_role("visitor".send(param_method), Group.first).should eq([ modo ]) } |
| 57 | + after(:context) do |
| 58 | + user_class.strict_rolify = false |
44 | 59 | end
|
45 | 60 |
|
46 |
| - context "on Company.first_instance" do |
47 |
| - it { subject.with_role("owner".send(param_method), Company.first).should eq([ owner ]) } |
| 61 | + context "with an instance scoped role" do |
| 62 | + context "on Forum.first instance" do |
| 63 | + it { subject.with_role("admin".send(param_method), Forum.first).should be_empty } |
| 64 | + it { subject.with_role("moderator".send(param_method), Forum.first).should be_empty } |
| 65 | + end |
48 | 66 | end
|
49 | 67 | end
|
50 | 68 | end
|
|
0 commit comments