[OSM-dev] Rails_port unit tests 3 errors, functional tests 39 failures -- found fix

Steve steveh1966 at msn.com
Sun Jan 17 16:50:02 GMT 2010

Hi everyone,


Ubuntu server 8.04.3 install


Whenever I ran 'rake test', I would get 3 unit errors and 39 functional
failures ie:


  1) Error:


OSM::APIChangesetAlreadyClosedError: The changeset 1 was closed at Tue Jan
12 18:46:10 UTC 2010

    lib/consistency_validations.rb:29:in `check_create_consistency'

    app/models/node.rb:180:in `create_with_history'

    /test/unit/node_test.rb:85:in `test_create'


with the 2nd and 3rd errors always complaining about changeset closed also,
and functional test errors like:


 36) Failure:


    [/test/functional/relation_controller_test.rb:835:in `with_update_diff'

     /test/functional/../test_helper.rb:86:in `with_controller'

     /test/functional/relation_controller_test.rb:825:in `with_update_diff'


     /test/functional/relation_controller_test.rb:792:in `with_relation'


can't upload diff relation: The changeset 2 was closed at Wed Jan 13
06:27:56 UTC 2010.

Expected response to be a <:success>, but was <409> 


Again, complaining about closed changesets.


Finally, after five (possibly more) OS, Ruby, Rails and Rails_port
reinstalls, decided to look at the code even though previous posts
concerning this error were always thought to be ruby/rails, or outdated svn
rails_port problems.


Found that in /app/models/changeset.rb open changesets are determined by, 


  def is_open?

    return ((closed_at > Time.now.getutc) and (num_changes <= MAX_ELEMENTS))



Here the Ruby 'Time' function is called referencing UTC, but in
/tests/fixtures/changsets.yml the 'Open" changesets were polulated with:


  closed_at: <%= DateTime.now + Rational(1,24) %>


Ruby 'Time' and "DateTime' are not interchangeable:


They are 2 defferent classes.


I modified my local changesets.yml to use Time.now.utc only, ie:


# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html


  id: 1

  user_id: 1

  created_at: "2007-01-01 00:00:00"

  closed_at: <%= Time.now.utc + 86400 %>

  min_lon: <%= 1 * SCALE %>

  min_lat: <%= 1 * SCALE %>

  max_lon: <%= 5 * SCALE %>

  max_lat: <%= 5 * SCALE %>

  num_changes: 11



  id: 2

  user_id: 2

  created_at: <%= Time.now.utc %>

  closed_at: <%= Time.now.utc + 86400 %>

  num_changes: 0


Where the 86400 is 24 hours in seconds, and all 3 errors and 39 failures
disappeared, and 100% 'rake test's' now pass!


Haven't looked into why DateTime would work on some installs and not others,
(timezone, local date format??) but just fixing the changesets.yml to be
consistent with how the open changeset is being determined seems to work
like it should.


Would someone with svn write capability want to update changesets.yml?  I
can post the code as the file is not too long.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20100117/d34faaab/attachment.html>

More information about the dev mailing list