From 2347761266d8848dcdc42f9e5d9ef380fa04b89a Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Tue, 7 Oct 2008 23:49:53 +0000 Subject: [PATCH] some useful notes in code for ideas that require implementing. --- app/controllers/node_controller.rb | 5 +++++ app/models/changeset.rb | 10 ++++++++++ test/functional/node_controller_test.rb | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb index 03ae64f41..bfd1031f0 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -87,6 +87,11 @@ class NodeController < ApplicationController def delete begin node = Node.find(params[:id]) + # FIXME we no longer care about the user, (or maybe we want to check + # that the user of the changeset is the same user as is making this + # little change?) we really care about the + # changeset which must be open, and that the version that we have been + # given is the one that is currently stored in the database node.delete_with_history(@user) render :nothing => true diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 04023ae2b..7e2216f0e 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -11,6 +11,15 @@ class Changeset < ActiveRecord::Base has_many :old_nodes has_many :old_ways has_many :old_relations + + validates_presence_of :user_id, :created_at, :open + + # Use a method like this, so that we can easily change how we + # determine whether a changeset is open, without breaking code in at + # least 6 controllers + def is_open? + return open + end def self.from_xml(xml, create=false) begin @@ -83,6 +92,7 @@ class Changeset < ActiveRecord::Base doc.root << to_xml_node() return doc end + def to_xml_node(user_display_name_cache = nil) el1 = XML::Node.new 'changeset' el1['id'] = self.id.to_s diff --git a/test/functional/node_controller_test.rb b/test/functional/node_controller_test.rb index 3f316d012..59b28e114 100644 --- a/test/functional/node_controller_test.rb +++ b/test/functional/node_controller_test.rb @@ -15,7 +15,9 @@ class NodeControllerTest < Test::Unit::TestCase def test_create # cannot read password from fixture as it is stored as MD5 digest - basic_authorization("test@openstreetmap.org", "test"); + basic_authorization(users(:normal_user).email, "test"); + # FIXME we need to create a changeset first argh + # create a node with random lat/lon lat = rand(100)-50 + rand lon = rand(100)-50 + rand -- 2.43.2