# This is similar to above, just some validations don't apply
def check_create_consistency(new, user)
- if new.changeset.nil?
- raise OSM::APIChangesetMissingError
- elsif new.changeset.user_id != user.id
- raise OSM::APIUserChangesetMismatchError
- elsif !new.changeset.open?
- raise OSM::APIChangesetAlreadyClosedError, new.changeset
- end
+ check_changeset_consistency(new.changeset, user)
end
##
assert_equal relation_member2.relation.id, cr.second.id
assert_equal relation_member3.relation.id, cr.third.id
end
+
+ test "raises missing changeset exception when creating" do
+ user = create(:user)
+ node = Node.new
+ assert_raises OSM::APIChangesetMissingError do
+ node.create_with_history(user)
+ end
+ end
+
+ test "raises user-changeset mismatch exception when creating" do
+ user = create(:user)
+ changeset = create(:changeset)
+ node = Node.new(:changeset => changeset)
+ assert_raises OSM::APIUserChangesetMismatchError do
+ node.create_with_history(user)
+ end
+ end
+
+ test "raises already closed changeset exception when creating" do
+ user = create(:user)
+ changeset = create(:changeset, :closed, :user => user)
+ node = Node.new(:changeset => changeset)
+ assert_raises OSM::APIChangesetAlreadyClosedError do
+ node.create_with_history(user)
+ end
+ end
end
end
end
end
+
+ test "raises missing changeset exception when creating" do
+ user = create(:user)
+ relation = Relation.new
+ assert_raises OSM::APIChangesetMissingError do
+ relation.create_with_history(user)
+ end
+ end
+
+ test "raises user-changeset mismatch exception when creating" do
+ user = create(:user)
+ changeset = create(:changeset)
+ relation = Relation.new(:changeset => changeset)
+ assert_raises OSM::APIUserChangesetMismatchError do
+ relation.create_with_history(user)
+ end
+ end
+
+ test "raises already closed changeset exception when creating" do
+ user = create(:user)
+ changeset = create(:changeset, :closed, :user => user)
+ relation = Relation.new(:changeset => changeset)
+ assert_raises OSM::APIChangesetAlreadyClosedError do
+ relation.create_with_history(user)
+ end
+ end
end
assert_equal 1, cr.size
assert_equal relation.id, cr.first.id
end
+
+ test "raises missing changeset exception when creating" do
+ user = create(:user)
+ way = Way.new
+ assert_raises OSM::APIChangesetMissingError do
+ way.create_with_history(user)
+ end
+ end
+
+ test "raises user-changeset mismatch exception when creating" do
+ user = create(:user)
+ changeset = create(:changeset)
+ way = Way.new(:changeset => changeset)
+ assert_raises OSM::APIUserChangesetMismatchError do
+ way.create_with_history(user)
+ end
+ end
+
+ test "raises already closed changeset exception when creating" do
+ user = create(:user)
+ changeset = create(:changeset, :closed, :user => user)
+ way = Way.new(:changeset => changeset)
+ assert_raises OSM::APIChangesetAlreadyClosedError do
+ way.create_with_history(user)
+ end
+ end
end