Project

General

Profile

Actions

Defect #38797

closed

Fix incorrect argument format for assert_select

Added by Go MAEDA over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Some `assert_select` in the tests have wrong argument format. For example, the code at source:trunk/test/functional/timelog_report_test.rb@22254#L113 should be fixed as follows.

current wrong code:

assert_select 'td.name a.user.active[href=?]', '/users/1', 1, :text => 'Redmine Admin'

fixed code:

assert_select 'td.name a.user.active[href=?]', '/users/1', :text => 'Redmine Admin', :count => 1

The current code probably be intended to check if there is one matching td.name a.user.active[href=/users/1] with text "Redmine Admin", but assert_select recognizes the last argument :text => 'Redmine Admin' as a assertion message. As a result, the link text never been checked.

In Rails::Dom::Testing version 2.1.0 and later checks this kind of mistakes and raises ArgumentError.
Raise an error if the last arg is the wrong format by ghiculescu · Pull Request #96 · rails/rails-dom-testing · GitHub

Error:
TimelogReportTest#test_report_should_show_locked_users:
ArgumentError: Last argument was a Hash, which would be used for the assertion message. You probably want this to be a String, or you have the wrong type of arguments.
    test/functional/timelog_report_test.rb:113:in `test_report_should_show_locked_users'

rails test test/functional/timelog_report_test.rb:103

The attached patch fixes wrong usages of assert_select.


Files

Actions #1

Updated by Go MAEDA over 1 year ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch.

Actions #2

Updated by Vincent Robert over 1 year ago

I was wondering what caused all the automated tests to suddenly turn red on Redmine 4.2.10.
Thank you for addressing this problem and resolving it in the upcoming release.

Actions

Also available in: Atom PDF