test/discard_test.rb in artemis_api-0.3.0 vs test/discard_test.rb in artemis_api-0.4.0
- old
+ new
@@ -58,10 +58,13 @@
}
}.to_json)
stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/discards")
.to_return(body: {data: [{id: '1', type: 'discards', attributes: {id: 1, reason_type: 'disease', quantity: 20}}, {id: '2', type: 'discards', attributes: {id: 2, reason_type: 'pests', quantity: 5}}]}.to_json)
+
+ stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/discards?filter[crop_batch_ids][]=2&filter[crop_batch_ids][]=3")
+ .to_return(body: {data: [{id: '1', type: 'discards', attributes: {id: 1, quantity: 4, reason_type: 'pests'}}]}.to_json)
end
def test_finding_a_specific_discard
discard = ArtemisApi::Discard.find(id: 2, facility_id: @facility.id, client: @client)
assert_equal 20, discard.quantity
@@ -79,7 +82,12 @@
end
def test_finding_all_discards
discards = ArtemisApi::Discard.find_all(facility_id: @facility.id, client: @client)
assert_equal 2, discards.count
+ end
+
+ def test_filtering_discard_by_crop_batch_ids
+ discards = ArtemisApi::Discard.find_all(facility_id: @facility.id, client: @client, filters: {crop_batch_ids: [2, 3]})
+ assert_equal 1, discards.count
end
end