Rearrange permissions_spec.rb

This commit is contained in:
2012-10-29 10:09:53 +01:00
parent 4a723f26fb
commit 6541b97997

View File

@@ -8,8 +8,8 @@ describe "Permissions" do
purge_all_buckets purge_all_buckets
end end
describe "public data" do
describe "GET" do describe "GET" do
context "public data" do
before do before do
object = data_bucket.new("jimmy:public:foo") object = data_bucket.new("jimmy:public:foo")
object.content_type = "text/plain" object.content_type = "text/plain"
@@ -38,10 +38,8 @@ describe "Permissions" do
last_response.body.must_equal "some text data" last_response.body.must_equal "some text data"
end end
end end
end
describe "private data" do context "private data" do
describe "GET" do
before do before do
object = data_bucket.new("jimmy:documents:foo") object = data_bucket.new("jimmy:documents:foo")
object.content_type = "text/plain" object.content_type = "text/plain"
@@ -65,7 +63,7 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
describe "when authorized" do context "when authorized" do
it "returns the value for a key in a top-level directory" do it "returns the value for a key in a top-level directory" do
get "/jimmy/documents/foo" get "/jimmy/documents/foo"
@@ -81,7 +79,7 @@ describe "Permissions" do
end end
end end
describe "when not authorized" do context "when not authorized" do
it "returns a 403 for a key in a top-level directory" do it "returns a 403 for a key in a top-level directory" do
get "/jimmy/confidential/bar" get "/jimmy/confidential/bar"
@@ -89,6 +87,7 @@ describe "Permissions" do
end end
end end
end end
end
describe "PUT" do describe "PUT" do
before do before do
@@ -99,7 +98,7 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
describe "to a top-level directory" do context "to a top-level directory" do
it "saves the value when there are write permissions" do it "saves the value when there are write permissions" do
put "/jimmy/contacts/1", "John Doe" put "/jimmy/contacts/1", "John Doe"
@@ -114,7 +113,7 @@ describe "Permissions" do
end end
end end
describe "to a sub-directory" do context "to a sub-directory" do
it "saves the value when there are direct write permissions" do it "saves the value when there are direct write permissions" do
put "/jimmy/tasks/home/1", "take out the trash" put "/jimmy/tasks/home/1", "take out the trash"
@@ -146,7 +145,7 @@ describe "Permissions" do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
end end
describe "when authorized" do context "when authorized" do
before do before do
object = data_bucket.new("jimmy:tasks:1") object = data_bucket.new("jimmy:tasks:1")
object.content_type = "text/plain" object.content_type = "text/plain"
@@ -178,7 +177,7 @@ describe "Permissions" do
end end
end end
describe "when not authorized" do context "when not authorized" do
before do before do
object = data_bucket.new("jimmy:documents:private") object = data_bucket.new("jimmy:documents:private")
object.content_type = "text/plain" object.content_type = "text/plain"
@@ -204,7 +203,6 @@ describe "Permissions" do
end end
end end
end end
end
describe "global permissions" do describe "global permissions" do
before do before do
@@ -214,7 +212,7 @@ describe "Permissions" do
object.store object.store
end end
describe "write all" do context "write all" do
before do before do
auth = auth_bucket.new("jimmy:123") auth = auth_bucket.new("jimmy:123")
auth.data = [":rw", "documents:r"] auth.data = [":rw", "documents:r"]
@@ -279,7 +277,7 @@ describe "Permissions" do
end end
end end
describe "read all" do context "read all" do
before do before do
auth = auth_bucket.new("jimmy:123") auth = auth_bucket.new("jimmy:123")
auth.data = [":r", "contacts:rw"] auth.data = [":r", "contacts:rw"]