-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Bug Description
Validation for interpolated collections should expect exactly 1 saved scenario and now it check for 1 or more.
Steps to Reproduce
- Make the following curl call (or equivalent with your test data):
curl -X POST "http://localhost:3000/api/v1/collections" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $ETM_API_TOKEN" \ -d '{"title":"Interpolated collection", "version":"latest", "saved_scenario_ids":[6,2], "interpolation":true}'
- Observe that there is no error
- Additionally you can observe the repercussion of this unexpected collection in the frontend by going to the listed collections in MyETM.
Expected interaction
It should raise an error
Proposed solutions
Change this code in app/models/collection.rb
def validate_interpolated # Ensure interpolated collections (AKA transition paths) have no saved scenarios active_saved_scenarios = collection_saved_scenarios.reject(&:marked_for_destruction?) if self.interpolated? && active_saved_scenarios.size > 1 errors.add(:scenarios, "interpolated collections cannot have more than 1 saved scenario") end endTo:
def validate_interpolated # Ensure interpolated collections (AKA transition paths) have one saved scenario active_saved_scenarios = collection_saved_scenarios.reject(&:marked_for_destruction?) if self.interpolated? && active_saved_scenarios.size != 1 errors.add(:scenarios, "interpolated collections must have exactly 1 saved scenario") end end
louispt1