|
11 | 11 | # DELETE /models/:model_id/model_files/:id(.:format) model_files#destroy
|
12 | 12 |
|
13 | 13 | RSpec.describe "Model Files" do
|
14 |
| - context "when signed out" do |
15 |
| - context "when downloading via a signed ID", :multiuser do |
16 |
| - before { create(:admin) } |
| 14 | + [:multiuser, :singleuser].each do |mode| |
| 15 | + context "when signed out in #{mode} mode", mode do |
| 16 | + context "when downloading via a signed ID" do |
| 17 | + before { create(:admin) } |
17 | 18 |
|
18 |
| - let!(:file) { create(:model_file, filename: "test.jpg") } |
| 19 | + let!(:file) { create(:model_file, filename: "test.jpg") } |
19 | 20 |
|
20 |
| - it "succeeds with a valid ID" do |
21 |
| - id = file.signed_id(expires_in: 1.minute, purpose: "download") |
22 |
| - get "/models/#{file.model.to_param}/model_files/#{id}.jpg?download=true" |
23 |
| - expect(response).to have_http_status(:success) |
24 |
| - end |
| 21 | + it "succeeds with a valid ID" do |
| 22 | + id = file.signed_id(expires_in: 1.minute, purpose: "download") |
| 23 | + get "/models/#{file.model.to_param}/model_files/#{id}.jpg?download=true" |
| 24 | + expect(response).to have_http_status(:success) |
| 25 | + end |
25 | 26 |
|
26 |
| - it "fails if expired" do |
27 |
| - id = file.signed_id(expires_at: 1.minute.ago, purpose: "download") |
28 |
| - get "/models/#{file.model.to_param}/model_files/#{id}.jpg?download=true" |
29 |
| - expect(response).to have_http_status(:not_found) |
30 |
| - end |
| 27 | + it "fails if expired" do |
| 28 | + id = file.signed_id(expires_at: 1.minute.ago, purpose: "download") |
| 29 | + get "/models/#{file.model.to_param}/model_files/#{id}.jpg?download=true" |
| 30 | + expect(response).to have_http_status(:not_found) |
| 31 | + end |
31 | 32 |
|
32 |
| - it "fails if purpose doesn't match" do |
33 |
| - id = file.signed_id(expires_in: 1.minute, purpose: "shenanigans") |
34 |
| - get "/models/#{file.model.to_param}/model_files/#{id}.jpg?download=true" |
35 |
| - expect(response).to have_http_status(:not_found) |
| 33 | + it "fails if purpose doesn't match" do |
| 34 | + id = file.signed_id(expires_in: 1.minute, purpose: "shenanigans") |
| 35 | + get "/models/#{file.model.to_param}/model_files/#{id}.jpg?download=true" |
| 36 | + expect(response).to have_http_status(:not_found) |
| 37 | + end |
36 | 38 | end
|
37 | 39 | end
|
38 | 40 | end
|
|
0 commit comments