Defect #38797
closedFix incorrect argument format for assert_select
0%
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
Updated by Go MAEDA about 1 year ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch.
Updated by Vincent Robert about 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.