From 3b98ce7a73f94fcf0ccc24bb4b3eac576744cebb Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 11 Aug 2014 16:36:12 -0400 Subject: [PATCH] 3531: Make test case less confusing. --- .../functional/projects_controller_test.rb | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/workbench/test/functional/projects_controller_test.rb b/apps/workbench/test/functional/projects_controller_test.rb index e8a696bb12..b3e67bc4b2 100644 --- a/apps/workbench/test/functional/projects_controller_test.rb +++ b/apps/workbench/test/functional/projects_controller_test.rb @@ -103,16 +103,23 @@ class ProjectsControllerTest < ActionController::TestCase last_kind = nil found_kind = {} json_response['content'].scan /]+>/ do |tr_tag| - assert_equal(1, - (tr_tag.scan(/\ data-object-created-at=\"(.*?)\"/).each do |t,| - if last_timestamp - assert_operator(last_timestamp, :>=, t, - "Rows are not sorted by timestamp desc") - end - last_timestamp = t - end).count, + found_timestamps = 0 + tr_tag.scan(/\ data-object-created-at=\"(.*?)\"/).each do |t,| + if last_timestamp + assert_operator(last_timestamp, :>=, t, + "Rows are not sorted by timestamp desc") + end + last_timestamp = t + found_timestamps += 1 + end + assert_equal(1, found_timestamps, "Content row did not have exactly one timestamp") + # Confirm that the test for timestamp ordering couldn't have + # passed merely because the test fixtures have convenient + # timestamps (e.g., there is only one pipeline and one job in + # the project being tested, or there are no pipelines at all in + # the project being tested): tr_tag.scan /\ data-kind=\"(.*?)\"/ do |kind| if last_kind and last_kind != kind and found_kind[kind] # We saw this kind before, then a different kind, then -- 2.30.2