Skip to content

Commit c5601ef

Browse files
wjwb-uscielf
andauthored
5102 - Added Failing Test to storage_locations_requests_spec.rb (#5111)
Fix implimented in storage_locations_controller.rb Co-authored-by: CL Fisher <[email protected]>
1 parent 00eb697 commit c5601ef

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

app/controllers/storage_locations_controller.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,19 @@ def edit
5757
# TODO: Move these queries to Query Object
5858
def show
5959
@storage_location = current_organization.storage_locations.find(params[:id])
60+
version_date = params[:version_date].presence&.to_date
6061
# TODO: Find a way to do these with less hard SQL. These queries have to be manually updated because they're not in-sync with the Model
6162
@items_out = ItemsOutQuery.new(organization: current_organization, storage_location: @storage_location).call
6263
@items_out_total = ItemsOutTotalQuery.new(organization: current_organization, storage_location: @storage_location).call
6364
@items_in = ItemsInQuery.new(organization: current_organization, storage_location: @storage_location).call
6465
@items_in_total = ItemsInTotalQuery.new(organization: current_organization, storage_location: @storage_location).call
65-
if View::Inventory.within_snapshot?(current_organization.id, params[:version_date])
66-
@inventory = View::Inventory.new(current_organization.id, event_time: params[:version_date])
66+
if View::Inventory.within_snapshot?(current_organization.id, version_date)
67+
@inventory = View::Inventory.new(current_organization.id, event_time: version_date)
6768
else
6869
@legacy_inventory = View::Inventory.legacy_inventory_for_storage_location(
6970
current_organization.id,
7071
@storage_location.id,
71-
params[:version_date]
72+
version_date
7273
)
7374
end
7475

spec/requests/storage_locations_requests_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@
324324
expect(response.body).to include("200")
325325
end
326326

327+
it "should return a correct response with empty version date param" do
328+
get storage_location_path(storage_location, format: response_format,
329+
version_date: '')
330+
expect(response).to be_successful
331+
expect(response.body).to include("Smithsonian")
332+
expect(response.body).to include("Test Item")
333+
expect(response.body).to include("Test Item2")
334+
expect(response.body).not_to include("Test Item3")
335+
expect(response.body).to include("200")
336+
end
337+
327338
context "with version date set" do
328339
let!(:inventory_item) {
329340
InventoryItem.create!(storage_location_id: storage_location.id,

0 commit comments

Comments
 (0)