spec/guard_spec.rb in ixtlan-guard-0.6.1 vs spec/guard_spec.rb in ixtlan-guard-0.7.0
- old
+ new
@@ -27,49 +27,61 @@
it 'should pass with user being root' do
subject.allowed?(:users, :show, [:root]).should be_true
end
it 'should pass "allow all groups" with user with any groups' do
- subject.allowed?(:users, :index, [:any]).should be_true
+ subject.allowed?(:users, :index, [:any_possible_group]).should be_true
+ subject.allowed?(:only_defaults, :index, [:any_possible_group]).should be_true
end
it 'should pass' do
subject.allowed?(:users, :update, [:users]).should be_true
+ subject.allowed?(:only_defaults, :update, [:users]).should be_true
+ subject.allowed?(:allow_all_defaults, :update, [:users]).should be_true
end
it 'should not pass with user when in blocked group' do
subject.block_groups([:users])
begin
subject.allowed?(:users, :update, [:users]).should be_false
+ subject.allowed?(:only_defaults, :update, [:users]).should be_false
+ subject.allowed?(:allow_all_defaults, :update, [:users]).should be_false
ensure
subject.block_groups([])
end
end
it 'should pass with user when not in blocked group' do
subject.block_groups([:accounts])
begin
subject.allowed?(:users, :update, [:users]).should be_true
+ subject.allowed?(:only_defaults, :update, [:users]).should be_true
+ subject.allowed?(:allow_all_defaults, :update, [:users]).should be_true
ensure
subject.block_groups([])
end
end
it 'should not block root group' do
subject.block_groups([:root])
begin
subject.allowed?(:users, :update, [:root]).should be_true
+ subject.allowed?(:only_defaults, :update, [:root]).should be_true
+ subject.allowed?(:allow_all_defaults, :update, [:root]).should be_true
ensure
subject.block_groups([])
end
end
it 'should not pass' do
subject.allowed?(:users, :update, [:accounts]).should be_false
+ subject.allowed?(:allow_all_defaults, :index, [:users]).should be_false
end
it 'should should use defaults on unknown action' do
subject.allowed?(:users, :unknow, [:users]).should be_true
+ subject.allowed?(:only_defaults, :unknow, [:users]).should be_true
+ subject.allowed?(:allow_all_defaults, :update, [:users]).should be_true
end
it 'should pass with right group and allowed flavor' do
subject.allowed?(:users, :update, [:users], :example){ |g| [:example]}.should be_true
end