X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b91b514cf22f04910c83b6dcc254908ed37d7413..0be6dd860f1843681e6380fbe69ca71a6eb01ab7:/lib/consistency_validations.rb diff --git a/lib/consistency_validations.rb b/lib/consistency_validations.rb index 4becce89c..6e214f902 100644 --- a/lib/consistency_validations.rb +++ b/lib/consistency_validations.rb @@ -7,7 +7,7 @@ module ConsistencyValidations # This will throw an exception if there is an inconsistency def check_consistency(old, new, user) if new.version != old.version - raise OSM::APIVersionMismatchError.new(new.version, old.version) + raise OSM::APIVersionMismatchError.new(new.id, new.class.to_s, new.version, old.version) elsif new.changeset.nil? raise OSM::APIChangesetMissingError.new elsif new.changeset.user_id != user.id @@ -16,4 +16,15 @@ module ConsistencyValidations raise OSM::APIChangesetAlreadyClosedError.new end end + + # This is similar to above, just some validations don't apply + def check_create_consistency(new, user) + if new.changeset.nil? + raise OSM::APIChangesetMissingError.new + elsif new.changeset.user_id != user.id + raise OSM::APIUserChangesetMismatchError.new + elsif not new.changeset.is_open? + raise OSM::APIChangesetAlreadyClosedError.new + end + end end