You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.4 KiB
82 lines
2.4 KiB
13 years ago
|
require 'spec_helper'
|
||
|
|
||
|
# needs "rake db:test:clone" for the "hosts" part
|
||
|
|
||
12 years ago
|
describe UserAbility do
|
||
13 years ago
|
include_context "data"
|
||
12 years ago
|
let(:crud){UserAbility::CRUD}
|
||
13 years ago
|
|
||
13 years ago
|
context "basic" do
|
||
|
it "allows me to manage my domains and their records, and my hosts" do
|
||
13 years ago
|
user.should be_able_to(crud, domain)
|
||
|
user.should be_able_to(crud, a_record)
|
||
|
user.should be_able_to(crud, soa_record)
|
||
13 years ago
|
user.should_not be_able_to(:delete, soa_record) # SOA deleted only via parent
|
||
13 years ago
|
user.should be_able_to(crud, host_a_record)
|
||
13 years ago
|
end
|
||
|
|
||
|
it "denies other user to manage my domains and their records, and my hosts" do
|
||
13 years ago
|
user2.should_not be_able_to(crud, domain)
|
||
|
user2.should_not be_able_to(crud, a_record)
|
||
|
user2.should_not be_able_to(crud, soa_record)
|
||
|
user2.should_not be_able_to(crud, host_a_record)
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
13 years ago
|
it "allows admin to manage other user's hosts" do
|
||
13 years ago
|
admin.should be_able_to(crud, host_a_record)
|
||
13 years ago
|
end
|
||
13 years ago
|
end
|
||
|
|
||
13 years ago
|
context "permitted" do
|
||
|
before do
|
||
13 years ago
|
User.do_as(user) do
|
||
|
domain
|
||
|
subdomain
|
||
|
subsubdomain
|
||
|
permission # ensure permission to domain
|
||
|
end
|
||
13 years ago
|
end
|
||
|
|
||
13 years ago
|
it "allows other user to manage user's domains and records, if permitted" do
|
||
13 years ago
|
User.do_as(user2) do
|
||
|
user2.should be_able_to(crud, domain)
|
||
|
user2.should be_able_to(crud, a_record)
|
||
|
user2.should be_able_to(crud, soa_record)
|
||
|
end
|
||
13 years ago
|
end
|
||
|
|
||
13 years ago
|
it "denies third user to manage user's permitted domains and records" do
|
||
13 years ago
|
User.do_as(user3) do
|
||
|
user3.should_not be_able_to(crud, domain)
|
||
|
user3.should_not be_able_to(crud, a_record)
|
||
|
user3.should_not be_able_to(crud, soa_record)
|
||
|
end
|
||
13 years ago
|
end
|
||
|
|
||
13 years ago
|
it "allows other user to manage user's permitted subdomains" do
|
||
13 years ago
|
User.do_as(user2) do
|
||
|
user2.should be_able_to(crud, subdomain)
|
||
|
user2.should be_able_to(crud, subsubdomain)
|
||
|
end
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
|
it "denies third user to manage other user's permitted subdomains" do
|
||
13 years ago
|
User.do_as(user3) do
|
||
|
user3.should_not be_able_to(crud, subdomain)
|
||
|
user3.should_not be_able_to(crud, subsubdomain)
|
||
|
end
|
||
13 years ago
|
end
|
||
13 years ago
|
end
|
||
|
|
||
|
context "permission" do
|
||
13 years ago
|
it "allows me to manage my domain's permissions" do
|
||
13 years ago
|
user.should be_able_to(crud, permission)
|
||
13 years ago
|
end
|
||
|
|
||
|
it "denies other user to manage my domain's permissions" do
|
||
13 years ago
|
user2.should_not be_able_to(crud, permission)
|
||
13 years ago
|
end
|
||
13 years ago
|
end
|
||
|
|
||
|
end
|