[opensuse-buildservice] [Patch] API Test Suite - Remove hardcoded timezone from assert
Hi,
I was running the API test suite and found 2 failures:
1) Failure:
test_latest_added(StatisticsControllerTest) [/test/functional/statistics_controller_test.rb:28]:
expected tag, but no tag found matching {:tag=>"project", :attributes=>{:created=>"2008-04-28T05:05:05+02:00", :name=>"kde4"}} in:
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
Applied, thanks. bye adrian On Sunday 27 June 2010 21:00:38 Srinidhi B wrote:
Hi,
I was running the API test suite and found 2 failures:
1) Failure: test_latest_added(StatisticsControllerTest) [/test/functional/statistics_controller_test.rb:28]: expected tag, but no tag found matching {:tag=>"project", :attributes=>{:created=>"2008-04-28T05:05:05+02:00", :name=>"kde4"}} in: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
\n \n". <nil> is not true.\n \n \n \n \n \n \n \n \n \n 2) Failure: test_latest_updated(StatisticsControllerTest) [/test/functional/statistics_controller_test.rb:40]: expected tag, but no tag found matching {:tag=>"project", :attributes=>{:updated=>"2008-04-28T06:06:06+02:00", :name=>"kde4"}} in: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
\n \n". <nil> is not true.\n \n \n \n \n \n \n \n \n \n The failure was due to the timezone being hardcoded to "+02:00". Attached is a trivial patch that uses Ruby's Time class to use local timezone in assert statement.
Srinidhi.
----
diff --git a/src/api/test/functional/statistics_controller_test.rb b/src/api/test/functional/statistics_controller_test.rb index 32fee23..157ea14 100644 --- a/src/api/test/functional/statistics_controller_test.rb +++ b/src/api/test/functional/statistics_controller_test.rb @@ -1,5 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' require 'statistics_controller' +require 'time'
# Re-raise errors caught by the controller. class StatisticsController; def rescue_action(e) raise e end; end @@ -24,7 +25,7 @@ class StatisticsControllerTest < ActionController::IntegrationTest assert_tag :tag => 'latest_added', :child => { :tag => 'project' } assert_tag :tag => 'project', :attributes => { :name => "kde4", - :created => "2008-04-28T05:05:05+02:00", + :created => Time.local(2008, 04, 28, 05, 05, 05).xmlschema } end
@@ -36,7 +37,7 @@ class StatisticsControllerTest < ActionController::IntegrationTest assert_tag :tag => 'latest_updated', :child => { :tag => 'project' } assert_tag :tag => 'project', :attributes => { :name => "kde4", - :updated => "2008-04-28T06:06:06+02:00", + :updated => Time.local(2008, 04, 28, 06, 06, 06).xmlschema, } end
-- Adrian Schroeter SUSE Linux Products GmbH email: adrian@suse.de -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (2)
-
Adrian Schröter
-
Srinidhi B