Skip to content

Commit 5a46a4c

Browse files
committed
Fix rubocop offenses
1 parent 79b8780 commit 5a46a4c

File tree

1 file changed

+67
-67
lines changed

1 file changed

+67
-67
lines changed

spec/requests/volumes/file_tree_spec.rb

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -62,71 +62,71 @@ def parsed
6262
end
6363
end
6464

65-
describe "GET /volumes/:id/file_tree_assets" do
66-
it "returns assets for a given parent_folder_id" do
67-
get "/volumes/#{volume.id}/file_tree_assets.json", params: { parent_folder_id: folder_c.id }
68-
expect(response).to have_http_status(:ok)
69-
70-
body = parsed
71-
expect(body).to be_a(Array)
72-
expect(body).to all(be_a(Hash))
73-
expect(body).to all(include("folder", "parent_folder_id", "path", "key"))
74-
expect(body).to all(satisfy { |h| h["folder"] == false })
75-
expect(body).to all(satisfy { |h| h["parent_folder_id"] == folder_c.id })
76-
77-
keys = body.map { |h| h["key"] }
78-
expect(keys).to include("a-#{asset.id}")
79-
match = body.find { |h| h["key"] == "a-#{asset.id}" }
80-
expect(match["path"]).to eq([root.id, folder_a.id, folder_b.id, folder_c.id])
81-
end
82-
end
83-
84-
describe "GET /volumes/:id/file_tree_folders_search" do
85-
it "finds a nested folder and includes its ancestor path" do
86-
get "/volumes/#{volume.id}/file_tree_folders_search.json", params: { q: "tul_ohist" }
87-
expect(response).to have_http_status(:ok)
88-
89-
body = parsed
90-
expect(body).to be_a(Array)
91-
92-
match = body.find { |h| h["id"] == folder_b.id }
93-
94-
expect(match).to be_present
95-
expect(match["folder"]).to eq(true)
96-
expect(match["id"]).to eq(folder_b.id)
97-
expect(match["path"]).to be_a(Array)
98-
expect(match["path"]).to eq([ root.id, folder_a.id ])
99-
end
100-
101-
it "returns empty array for no matches" do
102-
get "/volumes/#{volume.id}/file_tree_folders_search.json", params: { q: "nope-nope" }
103-
expect(response).to have_http_status(:ok)
104-
expect(parsed).to eq([])
105-
end
106-
end
107-
108-
describe "GET /volumes/:id/file_tree_assets_search" do
109-
it "finds a deep asset and returns path to its parent folder" do
110-
get "/volumes/#{volume.id}/file_tree_assets_search.json", params: { q: "beta" }
111-
expect(response).to have_http_status(:ok)
112-
113-
body = parsed
114-
expect(body).to be_a(Array)
115-
116-
match = body.find { |h| h["id"] == asset.id }
117-
118-
expect(match).to be_present
119-
expect(match["folder"]).to eq(false)
120-
expect(match["parent_folder_id"]).to eq(folder_c.id)
121-
expect(match["path"]).to start_with([ root.id, folder_a.id, folder_b.id ])
122-
expect(match["path"].last).to eq(folder_c.id)
123-
expect(match["path"].length).to eq(4)
124-
end
125-
126-
it "returns empty array when no assets match" do
127-
get "/volumes/#{volume.id}/file_tree_assets_search.json", params: { q: "zzz-not-found" }
128-
expect(response).to have_http_status(:ok)
129-
expect(parsed).to eq([])
130-
end
131-
end
65+
describe "GET /volumes/:id/file_tree_assets" do
66+
it "returns assets for a given parent_folder_id" do
67+
get "/volumes/#{volume.id}/file_tree_assets.json", params: { parent_folder_id: folder_c.id }
68+
expect(response).to have_http_status(:ok)
69+
70+
body = parsed
71+
expect(body).to be_a(Array)
72+
expect(body).to all(be_a(Hash))
73+
expect(body).to all(include("folder", "parent_folder_id", "path", "key"))
74+
expect(body).to all(satisfy { |h| h["folder"] == false })
75+
expect(body).to all(satisfy { |h| h["parent_folder_id"] == folder_c.id })
76+
77+
keys = body.map { |h| h["key"] }
78+
expect(keys).to include("a-#{asset.id}")
79+
match = body.find { |h| h["key"] == "a-#{asset.id}" }
80+
expect(match["path"]).to eq([ root.id, folder_a.id, folder_b.id, folder_c.id ])
81+
end
82+
end
83+
84+
describe "GET /volumes/:id/file_tree_folders_search" do
85+
it "finds a nested folder and includes its ancestor path" do
86+
get "/volumes/#{volume.id}/file_tree_folders_search.json", params: { q: "tul_ohist" }
87+
expect(response).to have_http_status(:ok)
88+
89+
body = parsed
90+
expect(body).to be_a(Array)
91+
92+
match = body.find { |h| h["id"] == folder_b.id }
93+
94+
expect(match).to be_present
95+
expect(match["folder"]).to eq(true)
96+
expect(match["id"]).to eq(folder_b.id)
97+
expect(match["path"]).to be_a(Array)
98+
expect(match["path"]).to eq([ root.id, folder_a.id ])
99+
end
100+
101+
it "returns empty array for no matches" do
102+
get "/volumes/#{volume.id}/file_tree_folders_search.json", params: { q: "nope-nope" }
103+
expect(response).to have_http_status(:ok)
104+
expect(parsed).to eq([])
105+
end
106+
end
107+
108+
describe "GET /volumes/:id/file_tree_assets_search" do
109+
it "finds a deep asset and returns path to its parent folder" do
110+
get "/volumes/#{volume.id}/file_tree_assets_search.json", params: { q: "beta" }
111+
expect(response).to have_http_status(:ok)
112+
113+
body = parsed
114+
expect(body).to be_a(Array)
115+
116+
match = body.find { |h| h["id"] == asset.id }
117+
118+
expect(match).to be_present
119+
expect(match["folder"]).to eq(false)
120+
expect(match["parent_folder_id"]).to eq(folder_c.id)
121+
expect(match["path"]).to start_with([ root.id, folder_a.id, folder_b.id ])
122+
expect(match["path"].last).to eq(folder_c.id)
123+
expect(match["path"].length).to eq(4)
124+
end
125+
126+
it "returns empty array when no assets match" do
127+
get "/volumes/#{volume.id}/file_tree_assets_search.json", params: { q: "zzz-not-found" }
128+
expect(response).to have_http_status(:ok)
129+
expect(parsed).to eq([])
130+
end
131+
end
132132
end

0 commit comments

Comments
 (0)