id_please 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -5
- data/VERSION +1 -1
- data/id_please.gemspec +1 -1
- data/lib/id_please/model_extensions/for_group.rb +34 -6
- data/test/debug.log +41920 -0
- data/test/roles_test.rb +20 -0
- metadata +1 -1
data/test/roles_test.rb
CHANGED
@@ -285,6 +285,26 @@ class RolesTest < ActiveSupport::TestCase
|
|
285
285
|
assert_false @group4.accepts_role?(:member, @user1, :check_groups => false)
|
286
286
|
end
|
287
287
|
|
288
|
+
should "be able to filter children based on roles" do
|
289
|
+
assert_same_elements @group4.children(:roles => :any), [@group2, @group1, @user1, @user2]
|
290
|
+
assert_same_elements @group4.children(:roles => [:member]), [@group2, @group1, @user1, @user2]
|
291
|
+
assert_same_elements @group4.children(:roles => [:owner]), []
|
292
|
+
|
293
|
+
|
294
|
+
@user3.has_role!(:owner, @group4)
|
295
|
+
|
296
|
+
assert_same_elements @group4.children(), [@group2, @group1, @user1, @user2]
|
297
|
+
assert_same_elements @group4.children(:roles => :any), [@group2, @group1, @user1, @user2, @user3]
|
298
|
+
assert_same_elements @group4.children(:roles => [:member]), [@group2, @group1, @user1, @user2]
|
299
|
+
assert_same_elements @group4.children(:roles => [:owner]), [@user3]
|
300
|
+
|
301
|
+
end
|
302
|
+
|
303
|
+
should "be able to display hashes of subject permissions" do
|
304
|
+
@user3.has_role!(:owner, @group4)
|
305
|
+
assert_equal @group4.children(:roles => :any, :view => :subject_hash), {@group2 => [:member], @group1 => [:member], @user1 => [:member], @user2 => [:member], @user3 => [:owner]}
|
306
|
+
end
|
307
|
+
|
288
308
|
should "check roles based on groups" do
|
289
309
|
|
290
310
|
assert @user2.has_role?(:member, @group2)
|