Skip to content

Commit 6db146d

Browse files
committed
Fix up test for etag updates
1 parent fda6599 commit 6db146d

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

Diff for: api_spec.rb

+14-16
Original file line numberDiff line numberDiff line change
@@ -81,35 +81,34 @@ def check_dir_listing_content_type(content_type)
8181
end
8282
end
8383

84-
describe "PUT another JSON object" do
84+
describe "updating that JSON object" do
8585
before do
8686
@old_outer_listing_res = do_get_request("#{CONFIG[:category]}/")
87-
@old_listing_res = do_get_request("#{CONFIG[:category]}/some-other-subdir/")
88-
@res = do_put_request("#{CONFIG[:category]}/some-other-subdir/test-object-simple.json",
89-
'{"new": "object"}',
87+
@old_listing_res = do_get_request("#{CONFIG[:category]}/some-subdir/")
88+
@res = do_put_request("#{CONFIG[:category]}/some-subdir/nested-folder-object.json",
89+
'{"foo": "bam"}',
9090
{ content_type: "application/json" })
9191
@outer_listing_res = do_get_request("#{CONFIG[:category]}/")
92-
@listing_res = do_get_request("#{CONFIG[:category]}/some-other-subdir/")
92+
@listing_res = do_get_request("#{CONFIG[:category]}/some-subdir/")
9393

9494
@item_etag = @res.headers[:etag]
9595
@old_listing = JSON.parse @old_listing_res.body
9696
@listing = JSON.parse @listing_res.body
97-
@item_info = @listing["items"]["test-object-simple.json"]
98-
@old_item_info = @old_listing["items"]["test-object-simple.json"]
97+
@item_info = @listing["items"]["nested-folder-object.json"]
98+
@old_item_info = @old_listing["items"]["nested-folder-object.json"]
9999
end
100100

101101
it "works" do
102+
# before runs for each block once, so we have to put all blocks into one
102103
[200, 201].must_include @res.code
103104
@item_etag.wont_be_nil
104105
@item_etag.must_be_etag
105-
end
106106

107-
it "updates the file etag in the listing" do
107+
# updates the file etags in the folder listing
108108
@item_info["ETag"].must_equal @item_etag.delete('"')
109109
@item_info["ETag"].wont_equal @old_item_info["ETag"]
110-
end
111110

112-
it "updates the folder etag" do
111+
# updates the folder etag
113112
@listing_res.headers[:etag].wont_equal @old_outer_listing_res.headers[:etag]
114113
@outer_listing_res.headers[:etag].wont_equal @old_outer_listing_res.headers[:etag]
115114
end
@@ -348,8 +347,8 @@ def check_dir_listing_content_type(content_type)
348347
end
349348

350349
it "contains the correct items" do
351-
@listing["items"].length.must_equal 6
352-
["Capture d'écran.jpg", "my-list", "some-subdir/", "some-other-subdir/",
350+
@listing["items"].length.must_equal 5
351+
["Capture d'écran.jpg", "my-list", "some-subdir/",
353352
"test-object-simple.json", "test-object-simple2.json"].each do |key|
354353
@listing["items"].keys.must_include key
355354
end
@@ -624,9 +623,8 @@ def check_dir_listing_content_type(content_type)
624623

625624
describe "DELETE objects" do
626625
it "works" do
627-
[ "test-object-simple.json", "some-other-subdir/test-object-simple.json",
628-
"Capture d'écran.jpg", "some-subdir/nested-folder-object.json",
629-
"my-list" ].each do |key|
626+
[ "test-object-simple.json", "Capture d'écran.jpg",
627+
"some-subdir/nested-folder-object.json", "my-list" ].each do |key|
630628
res = do_delete_request("#{CONFIG[:category]}/#{key}")
631629

632630
res.code.must_equal 200

0 commit comments

Comments
 (0)