From 03cad948e30d8f82d0c1c5e249cd6c92bb44dd3d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 15 Mar 2022 18:24:32 +0000 Subject: [PATCH] Fix new rubocop warnings --- test/controllers/issues_controller_test.rb | 12 ++++---- test/helpers/application_helper_test.rb | 8 ++--- test/integration/oauth_test.rb | 2 +- test/lib/bounding_box_test.rb | 2 +- test/lib/rich_text_test.rb | 2 +- test/models/acl_test.rb | 2 +- test/models/changeset_comment_test.rb | 2 +- test/models/changeset_tag_test.rb | 14 ++++----- test/models/client_application_test.rb | 6 ++-- test/models/issue_test.rb | 2 +- test/models/message_test.rb | 10 +++--- test/models/node_tag_test.rb | 14 ++++----- test/models/note_comment_test.rb | 4 +-- test/models/note_test.rb | 8 ++--- test/models/oauth_token_test.rb | 4 +-- test/models/old_node_tag_test.rb | 14 ++++----- test/models/old_relation_tag_test.rb | 14 ++++----- test/models/old_way_tag_test.rb | 14 ++++----- test/models/redaction_test.rb | 2 +- test/models/relation_tag_test.rb | 14 ++++----- test/models/report_test.rb | 8 ++--- test/models/request_token_test.rb | 6 ++-- test/models/trace_test.rb | 20 ++++++------ test/models/tracepoint_test.rb | 2 +- test/models/user_preference_test.rb | 2 +- test/models/user_test.rb | 32 ++++++++++---------- test/models/way_tag_test.rb | 14 ++++----- test/models/way_test.rb | 6 ++-- test/system/report_diary_entry_test.rb | 2 +- test/validators/characters_validator_test.rb | 4 +-- test/validators/whitespace_validator_test.rb | 4 +-- 31 files changed, 125 insertions(+), 125 deletions(-) diff --git a/test/controllers/issues_controller_test.rb b/test/controllers/issues_controller_test.rb index 5e980e0b8..f9f29afbb 100644 --- a/test/controllers/issues_controller_test.rb +++ b/test/controllers/issues_controller_test.rb @@ -100,7 +100,7 @@ class IssuesControllerTest < ActionDispatch::IntegrationTest session_for(create(:moderator_user)) post resolve_issue_path(:id => issue) assert_response :redirect - assert issue.reload.resolved? + assert_predicate issue.reload, :resolved? end def test_resolve_administrator @@ -127,7 +127,7 @@ class IssuesControllerTest < ActionDispatch::IntegrationTest session_for(create(:administrator_user)) post resolve_issue_path(:id => issue) assert_response :redirect - assert issue.reload.resolved? + assert_predicate issue.reload, :resolved? end def test_ignore_moderator @@ -154,7 +154,7 @@ class IssuesControllerTest < ActionDispatch::IntegrationTest session_for(create(:moderator_user)) post ignore_issue_path(:id => issue) assert_response :redirect - assert issue.reload.ignored? + assert_predicate issue.reload, :ignored? end def test_ignore_administrator @@ -181,7 +181,7 @@ class IssuesControllerTest < ActionDispatch::IntegrationTest session_for(create(:administrator_user)) post ignore_issue_path(:id => issue) assert_response :redirect - assert issue.reload.ignored? + assert_predicate issue.reload, :ignored? end def test_reopen_moderator @@ -210,7 +210,7 @@ class IssuesControllerTest < ActionDispatch::IntegrationTest session_for(create(:moderator_user)) post reopen_issue_path(:id => issue) assert_response :redirect - assert issue.reload.open? + assert_predicate issue.reload, :open? end def test_reopen_administrator @@ -239,6 +239,6 @@ class IssuesControllerTest < ActionDispatch::IntegrationTest session_for(create(:administrator_user)) post reopen_issue_path(:id => issue) assert_response :redirect - assert issue.reload.open? + assert_predicate issue.reload, :open? end end diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index d3e4d4f07..06c1c09f8 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -8,11 +8,11 @@ class ApplicationHelperTest < ActionView::TestCase text = "Test #{link} is made into a link" html = linkify(text) - assert html.html_safe? + assert_predicate html, :html_safe? assert_dom_equal "Test #{link} is <b>made</b> into a link", html html = linkify(text.html_safe) - assert html.html_safe? + assert_predicate html, :html_safe? assert_dom_equal "Test #{link} is made into a link", html end @@ -20,11 +20,11 @@ class ApplicationHelperTest < ActionView::TestCase text = "Test #{link} is not made into a link" html = linkify(text) - assert html.html_safe? + assert_predicate html, :html_safe? assert_dom_equal "Test #{link} is not <b>made</b> into a link", html html = linkify(text.html_safe) - assert html.html_safe? + assert_predicate html, :html_safe? assert_dom_equal "Test #{link} is not made into a link", html end end diff --git a/test/integration/oauth_test.rb b/test/integration/oauth_test.rb index 579941774..2c473aac5 100644 --- a/test/integration/oauth_test.rb +++ b/test/integration/oauth_test.rb @@ -358,7 +358,7 @@ class OAuthTest < ActionDispatch::IntegrationTest params = CGI.parse(URI.parse(response.location).query) assert_not_nil params["oauth_verifier"] - assert params["oauth_verifier"].first.present? + assert_predicate params["oauth_verifier"].first, :present? params["oauth_verifier"].first end diff --git a/test/lib/bounding_box_test.rb b/test/lib/bounding_box_test.rb index 866820a6e..d82e2c9ae 100644 --- a/test/lib/bounding_box_test.rb +++ b/test/lib/bounding_box_test.rb @@ -223,7 +223,7 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_complete assert_not @bbox_from_nils.complete?, "should contain a nil" - assert @bbox_from_string.complete?, "should not contain a nil" + assert_predicate @bbox_from_string, :complete?, "should not contain a nil" end def test_centre_lon diff --git a/test/lib/rich_text_test.rb b/test/lib/rich_text_test.rb index fc9355717..9d00d658d 100644 --- a/test/lib/rich_text_test.rb +++ b/test/lib/rich_text_test.rb @@ -224,7 +224,7 @@ class RichTextTest < ActiveSupport::TestCase def assert_html(richtext, &block) html = richtext.to_html - assert html.html_safe? + assert_predicate html, :html_safe? root = Nokogiri::HTML::DocumentFragment.parse(html) assert_select root, "*" do yield block diff --git a/test/models/acl_test.rb b/test/models/acl_test.rb index 49f065612..88d1c0e7d 100644 --- a/test/models/acl_test.rb +++ b/test/models/acl_test.rb @@ -3,7 +3,7 @@ require "test_helper" class AclTest < ActiveSupport::TestCase def test_k_required acl = create(:acl) - assert acl.valid? + assert_predicate acl, :valid? acl.k = nil assert_not acl.valid? end diff --git a/test/models/changeset_comment_test.rb b/test/models/changeset_comment_test.rb index b620dc8e7..2139c8d39 100644 --- a/test/models/changeset_comment_test.rb +++ b/test/models/changeset_comment_test.rb @@ -44,7 +44,7 @@ class ChangesetCommentTest < ActiveSupport::TestCase ok.each do |body| changeset_comment = create(:changeset_comment) changeset_comment.body = body - assert changeset_comment.valid?, "#{body} is invalid, when it should be" + assert_predicate changeset_comment, :valid?, "#{body} is invalid, when it should be" end bad.each do |body| diff --git a/test/models/changeset_tag_test.rb b/test/models/changeset_tag_test.rb index 90674fbbe..0c5ffb151 100644 --- a/test/models/changeset_tag_test.rb +++ b/test/models/changeset_tag_test.rb @@ -10,7 +10,7 @@ class ChangesetTagTest < ActiveSupport::TestCase tag.changeset_id = changeset.id tag.k = key * i tag.v = "v" - assert tag.valid? + assert_predicate tag, :valid? end end @@ -23,7 +23,7 @@ class ChangesetTagTest < ActiveSupport::TestCase tag.changeset_id = changeset.id tag.k = "k" tag.v = val * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -34,7 +34,7 @@ class ChangesetTagTest < ActiveSupport::TestCase tag.k = k tag.v = "v" assert_not tag.valid?, "Key #{k} should be too long" - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end end @@ -45,14 +45,14 @@ class ChangesetTagTest < ActiveSupport::TestCase tag.k = "k" tag.v = v assert_not tag.valid?, "Value #{v} should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end end def test_empty_tag_invalid tag = ChangesetTag.new assert_not tag.valid?, "Empty tag should be invalid" - assert tag.errors[:changeset].any? + assert_predicate tag.errors[:changeset], :any? end def test_uniqueness @@ -61,9 +61,9 @@ class ChangesetTagTest < ActiveSupport::TestCase tag.changeset_id = existing.changeset_id tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end end diff --git a/test/models/client_application_test.rb b/test/models/client_application_test.rb index c0b7b7977..c3f1df23c 100644 --- a/test/models/client_application_test.rb +++ b/test/models/client_application_test.rb @@ -8,7 +8,7 @@ class ClientApplicationTest < ActiveSupport::TestCase ok.each do |url| app = build(:client_application) app.url = url - assert app.valid?, "#{url} is invalid, when it should be" + assert_predicate app, :valid?, "#{url} is invalid, when it should be" end bad.each do |url| @@ -25,7 +25,7 @@ class ClientApplicationTest < ActiveSupport::TestCase ok.each do |url| app = build(:client_application) app.support_url = url - assert app.valid?, "#{url} is invalid, when it should be" + assert_predicate app, :valid?, "#{url} is invalid, when it should be" end bad.each do |url| @@ -42,7 +42,7 @@ class ClientApplicationTest < ActiveSupport::TestCase ok.each do |url| app = build(:client_application) app.callback_url = url - assert app.valid?, "#{url} is invalid, when it should be" + assert_predicate app, :valid?, "#{url} is invalid, when it should be" end bad.each do |url| diff --git a/test/models/issue_test.rb b/test/models/issue_test.rb index 02e2580b8..f166282c1 100644 --- a/test/models/issue_test.rb +++ b/test/models/issue_test.rb @@ -4,7 +4,7 @@ class IssueTest < ActiveSupport::TestCase def test_assigned_role issue = create(:issue) - assert issue.valid? + assert_predicate issue, :valid? issue.assigned_role = "bogus" assert_not issue.valid? end diff --git a/test/models/message_test.rb b/test/models/message_test.rb index 1a1241091..97afad56e 100644 --- a/test/models/message_test.rb +++ b/test/models/message_test.rb @@ -6,17 +6,17 @@ class MessageTest < ActiveSupport::TestCase def test_check_empty_message_fails message = build(:message, :title => nil, :body => nil, :sent_on => nil) assert_not message.valid? - assert message.errors[:title].any? - assert message.errors[:body].any? - assert message.errors[:sent_on].any? + assert_predicate message.errors[:title], :any? + assert_predicate message.errors[:body], :any? + assert_predicate message.errors[:sent_on], :any? assert_not message.message_read end def test_validating_msgs message = create(:message, :unread) - assert message.valid? + assert_predicate message, :valid? message = create(:message, :read) - assert message.valid? + assert_predicate message, :valid? end def test_invalid_send_recipient diff --git a/test/models/node_tag_test.rb b/test/models/node_tag_test.rb index 47295770f..ffc8fb422 100644 --- a/test/models/node_tag_test.rb +++ b/test/models/node_tag_test.rb @@ -5,7 +5,7 @@ class NodeTagTest < ActiveSupport::TestCase tag = create(:node_tag) [0, 255].each do |i| tag.k = "k" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -13,7 +13,7 @@ class NodeTagTest < ActiveSupport::TestCase tag = create(:node_tag) [0, 255].each do |i| tag.v = "v" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -21,20 +21,20 @@ class NodeTagTest < ActiveSupport::TestCase tag = create(:node_tag) tag.k = "k" * 256 assert_not tag.valid?, "Key should be too long" - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end def test_length_value_invalid tag = create(:node_tag) tag.v = "v" * 256 assert_not tag.valid?, "Value should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end def test_empty_node_tag_invalid tag = NodeTag.new assert_not tag.valid?, "Empty tag should be invalid" - assert tag.errors[:node].any? + assert_predicate tag.errors[:node], :any? end def test_uniqueness @@ -43,9 +43,9 @@ class NodeTagTest < ActiveSupport::TestCase tag.node_id = existing.node_id tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end end diff --git a/test/models/note_comment_test.rb b/test/models/note_comment_test.rb index bfedcf125..f4dd645ee 100644 --- a/test/models/note_comment_test.rb +++ b/test/models/note_comment_test.rb @@ -8,7 +8,7 @@ class NoteCommentTest < ActiveSupport::TestCase ok.each do |event| note_comment = create(:note_comment) note_comment.event = event - assert note_comment.valid?, "#{event} is invalid, when it should be" + assert_predicate note_comment, :valid?, "#{event} is invalid, when it should be" end bad.each do |event| @@ -27,7 +27,7 @@ class NoteCommentTest < ActiveSupport::TestCase ok.each do |body| note_comment = create(:note_comment) note_comment.body = body - assert note_comment.valid?, "#{body} is invalid, when it should be" + assert_predicate note_comment, :valid?, "#{body} is invalid, when it should be" end bad.each do |body| diff --git a/test/models/note_test.rb b/test/models/note_test.rb index b74cebcc4..8d5a557cd 100644 --- a/test/models/note_test.rb +++ b/test/models/note_test.rb @@ -8,7 +8,7 @@ class NoteTest < ActiveSupport::TestCase ok.each do |status| note = create(:note) note.status = status - assert note.valid?, "#{status} is invalid, when it should be" + assert_predicate note, :valid?, "#{status} is invalid, when it should be" end bad.each do |status| @@ -37,13 +37,13 @@ class NoteTest < ActiveSupport::TestCase end def test_visible? - assert create(:note, :status => "open").visible? - assert create(:note, :status => "closed").visible? + assert_predicate create(:note, :status => "open"), :visible? + assert_predicate create(:note, :status => "closed"), :visible? assert_not create(:note, :status => "hidden").visible? end def test_closed? - assert create(:note, :status => "closed", :closed_at => Time.now.utc).closed? + assert_predicate create(:note, :status => "closed", :closed_at => Time.now.utc), :closed? assert_not create(:note, :status => "open", :closed_at => nil).closed? end diff --git a/test/models/oauth_token_test.rb b/test/models/oauth_token_test.rb index 3e3aaae7c..28f2c34a1 100644 --- a/test/models/oauth_token_test.rb +++ b/test/models/oauth_token_test.rb @@ -7,7 +7,7 @@ class OauthTokenTest < ActiveSupport::TestCase tok = OauthToken.new assert_not tok.invalidated?, "Token should be created valid." tok.invalidate! - assert tok.invalidated?, "Token should now be invalid." + assert_predicate tok, :invalidated?, "Token should now be invalid." end ## @@ -16,7 +16,7 @@ class OauthTokenTest < ActiveSupport::TestCase tok = RequestToken.create(:client_application => create(:client_application)) assert_not tok.authorized?, "Token should be created unauthorised." tok.authorize!(create(:user)) - assert tok.authorized?, "Token should now be authorised." + assert_predicate tok, :authorized?, "Token should now be authorised." tok.invalidate! assert_not tok.authorized?, "Token should now be invalid." end diff --git a/test/models/old_node_tag_test.rb b/test/models/old_node_tag_test.rb index 62869c6ad..ddcda2203 100644 --- a/test/models/old_node_tag_test.rb +++ b/test/models/old_node_tag_test.rb @@ -5,7 +5,7 @@ class OldNodeTagTest < ActiveSupport::TestCase tag = create(:old_node_tag) [0, 255].each do |i| tag.k = "k" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -13,7 +13,7 @@ class OldNodeTagTest < ActiveSupport::TestCase tag = create(:old_node_tag) [0, 255].each do |i| tag.v = "v" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -21,20 +21,20 @@ class OldNodeTagTest < ActiveSupport::TestCase tag = create(:old_node_tag) tag.k = "k" * 256 assert_not tag.valid? - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end def test_length_value_invalid tag = create(:old_node_tag) tag.v = "v" * 256 assert_not tag.valid?, "Value should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end def test_empty_tag_invalid tag = OldNodeTag.new assert_not tag.valid?, "Empty tag should be invalid" - assert tag.errors[:old_node].any? + assert_predicate tag.errors[:old_node], :any? end def test_uniqueness @@ -44,9 +44,9 @@ class OldNodeTagTest < ActiveSupport::TestCase tag.version = existing.version tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end end diff --git a/test/models/old_relation_tag_test.rb b/test/models/old_relation_tag_test.rb index dbdbf54c5..a373e386d 100644 --- a/test/models/old_relation_tag_test.rb +++ b/test/models/old_relation_tag_test.rb @@ -5,7 +5,7 @@ class OldRelationTagTest < ActiveSupport::TestCase tag = create(:old_relation_tag) [0, 255].each do |i| tag.k = "k" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -13,7 +13,7 @@ class OldRelationTagTest < ActiveSupport::TestCase tag = create(:old_relation_tag) [0, 255].each do |i| tag.v = "v" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -21,20 +21,20 @@ class OldRelationTagTest < ActiveSupport::TestCase tag = create(:old_relation_tag) tag.k = "k" * 256 assert_not tag.valid?, "Key should be too long" - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end def test_length_value_invalid tag = create(:old_relation_tag) tag.v = "v" * 256 assert_not tag.valid?, "Value should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end def test_empty_tag_invalid tag = OldRelationTag.new assert_not tag.valid?, "Empty tag should be invalid" - assert tag.errors[:old_relation].any? + assert_predicate tag.errors[:old_relation], :any? end def test_uniqueness @@ -44,9 +44,9 @@ class OldRelationTagTest < ActiveSupport::TestCase tag.version = existing.version tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end end diff --git a/test/models/old_way_tag_test.rb b/test/models/old_way_tag_test.rb index d794cc275..51c644c18 100644 --- a/test/models/old_way_tag_test.rb +++ b/test/models/old_way_tag_test.rb @@ -5,7 +5,7 @@ class OldWayTagTest < ActiveSupport::TestCase tag = create(:old_way_tag) [0, 255].each do |i| tag.k = "k" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -13,7 +13,7 @@ class OldWayTagTest < ActiveSupport::TestCase tag = create(:old_way_tag) [0, 255].each do |i| tag.v = "v" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -21,20 +21,20 @@ class OldWayTagTest < ActiveSupport::TestCase tag = create(:old_way_tag) tag.k = "k" * 256 assert_not tag.valid?, "Key should be too long" - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end def test_length_value_invalid tag = create(:old_way_tag) tag.v = "v" * 256 assert_not tag.valid?, "Value should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end def test_empty_tag_invalid tag = OldWayTag.new assert_not tag.valid?, "Empty tag should be invalid" - assert tag.errors[:old_way].any? + assert_predicate tag.errors[:old_way], :any? end def test_uniqueness @@ -44,9 +44,9 @@ class OldWayTagTest < ActiveSupport::TestCase tag.version = existing.version tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end end diff --git a/test/models/redaction_test.rb b/test/models/redaction_test.rb index d74a91179..06159cb5d 100644 --- a/test/models/redaction_test.rb +++ b/test/models/redaction_test.rb @@ -30,7 +30,7 @@ class RedactionTest < ActiveSupport::TestCase assert_nothing_raised do node_v1.redact!(r) end - assert(node_v1.redacted?, "Expected node version 1 to be redacted after redact! call.") + assert_predicate(node_v1, :redacted?, "Expected node version 1 to be redacted after redact! call.") assert_not(node_v2.redacted?, "Expected node version 2 to not be redacted after redact! call.") end end diff --git a/test/models/relation_tag_test.rb b/test/models/relation_tag_test.rb index 02d6d95c7..4e9108a63 100644 --- a/test/models/relation_tag_test.rb +++ b/test/models/relation_tag_test.rb @@ -5,7 +5,7 @@ class RelationTagTest < ActiveSupport::TestCase tag = create(:relation_tag) [0, 255].each do |i| tag.k = "k" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -13,7 +13,7 @@ class RelationTagTest < ActiveSupport::TestCase tag = create(:relation_tag) [0, 255].each do |i| tag.v = "v" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -21,20 +21,20 @@ class RelationTagTest < ActiveSupport::TestCase tag = create(:relation_tag) tag.k = "k" * 256 assert_not tag.valid?, "Key should be too long" - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end def test_length_value_invalid tag = create(:relation_tag) tag.v = "v" * 256 assert_not tag.valid?, "Value should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end def test_empty_tag_invalid tag = RelationTag.new assert_not tag.valid?, "Empty relation tag should be invalid" - assert tag.errors[:relation].any? + assert_predicate tag.errors[:relation], :any? end def test_uniqueness @@ -43,10 +43,10 @@ class RelationTagTest < ActiveSupport::TestCase tag.relation_id = existing.relation_id tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end ## diff --git a/test/models/report_test.rb b/test/models/report_test.rb index b65753b82..d172ff7db 100644 --- a/test/models/report_test.rb +++ b/test/models/report_test.rb @@ -4,7 +4,7 @@ class ReportTest < ActiveSupport::TestCase def test_issue_required report = create(:report) - assert report.valid? + assert_predicate report, :valid? report.issue = nil assert_not report.valid? end @@ -12,7 +12,7 @@ class ReportTest < ActiveSupport::TestCase def test_user_required report = create(:report) - assert report.valid? + assert_predicate report, :valid? report.user = nil assert_not report.valid? end @@ -20,7 +20,7 @@ class ReportTest < ActiveSupport::TestCase def test_details_required report = create(:report) - assert report.valid? + assert_predicate report, :valid? report.details = "" assert_not report.valid? end @@ -28,7 +28,7 @@ class ReportTest < ActiveSupport::TestCase def test_category_required report = create(:report) - assert report.valid? + assert_predicate report, :valid? report.category = "" assert_not report.valid? end diff --git a/test/models/request_token_test.rb b/test/models/request_token_test.rb index c231371ce..4f17b7256 100644 --- a/test/models/request_token_test.rb +++ b/test/models/request_token_test.rb @@ -2,9 +2,9 @@ require "test_helper" class RequestTokenTest < ActiveSupport::TestCase def test_oob - assert RequestToken.new.oob? - assert RequestToken.new(:callback_url => "oob").oob? - assert RequestToken.new(:callback_url => "OOB").oob? + assert_predicate RequestToken.new, :oob? + assert_predicate RequestToken.new(:callback_url => "oob"), :oob? + assert_predicate RequestToken.new(:callback_url => "OOB"), :oob? assert_not RequestToken.new(:callback_url => "http://test.host/").oob? end end diff --git a/test/models/trace_test.rb b/test/models/trace_test.rb index 99aac41d8..2dcae58d0 100644 --- a/test/models/trace_test.rb +++ b/test/models/trace_test.rb @@ -76,14 +76,14 @@ class TraceTest < ActiveSupport::TestCase def test_tagstring trace = build(:trace) trace.tagstring = "foo bar baz" - assert trace.valid? + assert_predicate trace, :valid? assert_equal 3, trace.tags.length assert_equal "foo", trace.tags[0].tag assert_equal "bar", trace.tags[1].tag assert_equal "baz", trace.tags[2].tag assert_equal "foo, bar, baz", trace.tagstring trace.tagstring = "foo, bar baz ,qux" - assert trace.valid? + assert_predicate trace, :valid? assert_equal 3, trace.tags.length assert_equal "foo", trace.tags[0].tag assert_equal "bar baz", trace.tags[1].tag @@ -92,18 +92,18 @@ class TraceTest < ActiveSupport::TestCase end def test_public? - assert build(:trace, :visibility => "public").public? + assert_predicate build(:trace, :visibility => "public"), :public? assert_not build(:trace, :visibility => "private").public? assert_not build(:trace, :visibility => "trackable").public? - assert build(:trace, :visibility => "identifiable").public? - assert build(:trace, :deleted, :visibility => "public").public? + assert_predicate build(:trace, :visibility => "identifiable"), :public? + assert_predicate build(:trace, :deleted, :visibility => "public"), :public? end def test_trackable? assert_not build(:trace, :visibility => "public").trackable? assert_not build(:trace, :visibility => "private").trackable? - assert build(:trace, :visibility => "trackable").trackable? - assert build(:trace, :visibility => "identifiable").trackable? + assert_predicate build(:trace, :visibility => "trackable"), :trackable? + assert_predicate build(:trace, :visibility => "identifiable"), :trackable? assert_not build(:trace, :deleted, :visibility => "public").trackable? end @@ -111,7 +111,7 @@ class TraceTest < ActiveSupport::TestCase assert_not build(:trace, :visibility => "public").identifiable? assert_not build(:trace, :visibility => "private").identifiable? assert_not build(:trace, :visibility => "trackable").identifiable? - assert build(:trace, :visibility => "identifiable").identifiable? + assert_predicate build(:trace, :visibility => "identifiable"), :identifiable? assert_not build(:trace, :deleted, :visibility => "public").identifiable? end @@ -197,7 +197,7 @@ class TraceTest < ActiveSupport::TestCase trace.import - assert trace.icon.attached? + assert_predicate trace.icon, :attached? end def test_import_creates_large_picture @@ -207,7 +207,7 @@ class TraceTest < ActiveSupport::TestCase trace.import - assert trace.image.attached? + assert_predicate trace.image, :attached? end def test_import_handles_bz2 diff --git a/test/models/tracepoint_test.rb b/test/models/tracepoint_test.rb index 2ffbef09f..115b8ec9b 100644 --- a/test/models/tracepoint_test.rb +++ b/test/models/tracepoint_test.rb @@ -3,7 +3,7 @@ require "test_helper" class TracepointTest < ActiveSupport::TestCase def test_timestamp_required tracepoint = create(:tracepoint) - assert tracepoint.valid? + assert_predicate tracepoint, :valid? tracepoint.timestamp = nil assert_not tracepoint.valid? end diff --git a/test/models/user_preference_test.rb b/test/models/user_preference_test.rb index 2f5e16b18..3df38aa6f 100644 --- a/test/models/user_preference_test.rb +++ b/test/models/user_preference_test.rb @@ -20,7 +20,7 @@ class UserPreferenceTest < ActiveSupport::TestCase up.user = create(:user) up.k = key * i up.v = val * i - assert up.valid? + assert_predicate up, :valid? assert up.save! resp = UserPreference.find(up.id) assert_equal key * i, resp.k, "User preference with #{i} #{key} chars (i.e. #{key.length * i} bytes) fails" diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 644283e84..72e1ca5d9 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -11,12 +11,12 @@ class UserTest < ActiveSupport::TestCase :home_lon => nil, :home_zoom => nil) assert_not user.valid? - assert user.errors[:email].any? - assert user.errors[:pass_crypt].any? - assert user.errors[:display_name].any? - assert user.errors[:home_lat].none? - assert user.errors[:home_lon].none? - assert user.errors[:home_zoom].none? + assert_predicate user.errors[:email], :any? + assert_predicate user.errors[:pass_crypt], :any? + assert_predicate user.errors[:display_name], :any? + assert_predicate user.errors[:home_lat], :none? + assert_predicate user.errors[:home_lon], :none? + assert_predicate user.errors[:home_zoom], :none? end def test_unique_email @@ -55,7 +55,7 @@ class UserTest < ActiveSupport::TestCase def test_display_name_length user = build(:user) user.display_name = "123" - assert user.valid?, "should allow 3 char name name" + assert_predicate user, :valid?, "should allow 3 char name name" user.display_name = "12" assert_not user.valid?, "should not allow 2 char name" user.display_name = "" @@ -81,7 +81,7 @@ class UserTest < ActiveSupport::TestCase ok.each do |display_name| user = build(:user) user.display_name = display_name - assert user.valid?, "#{display_name} is invalid, when it should be" + assert_predicate user, :valid?, "#{display_name} is invalid, when it should be" end bad.each do |display_name| @@ -214,29 +214,29 @@ class UserTest < ActiveSupport::TestCase end def test_visible? - assert build(:user, :pending).visible? - assert build(:user, :active).visible? - assert build(:user, :confirmed).visible? + assert_predicate build(:user, :pending), :visible? + assert_predicate build(:user, :active), :visible? + assert_predicate build(:user, :confirmed), :visible? assert_not build(:user, :suspended).visible? assert_not build(:user, :deleted).visible? end def test_active? assert_not build(:user, :pending).active? - assert build(:user, :active).active? - assert build(:user, :confirmed).active? + assert_predicate build(:user, :active), :active? + assert_predicate build(:user, :confirmed), :active? assert_not build(:user, :suspended).active? assert_not build(:user, :deleted).active? end def test_moderator? assert_not create(:user).moderator? - assert create(:moderator_user).moderator? + assert_predicate create(:moderator_user), :moderator? end def test_administrator? assert_not create(:user).administrator? - assert create(:administrator_user).administrator? + assert_predicate create(:administrator_user), :administrator? end def test_has_role? @@ -250,7 +250,7 @@ class UserTest < ActiveSupport::TestCase user = create(:user, :with_home_location, :description => "foo") user.soft_destroy assert_equal "user_#{user.id}", user.display_name - assert user.description.blank? + assert_predicate user.description, :blank? assert_nil user.home_lat assert_nil user.home_lon assert_not user.avatar.attached? diff --git a/test/models/way_tag_test.rb b/test/models/way_tag_test.rb index 5860786c6..cb225947c 100644 --- a/test/models/way_tag_test.rb +++ b/test/models/way_tag_test.rb @@ -5,7 +5,7 @@ class WayTagTest < ActiveSupport::TestCase tag = create(:way_tag) [0, 255].each do |i| tag.k = "k" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -13,7 +13,7 @@ class WayTagTest < ActiveSupport::TestCase tag = create(:way_tag) [0, 255].each do |i| tag.v = "v" * i - assert tag.valid? + assert_predicate tag, :valid? end end @@ -21,20 +21,20 @@ class WayTagTest < ActiveSupport::TestCase tag = create(:way_tag) tag.k = "k" * 256 assert_not tag.valid?, "Key should be too long" - assert tag.errors[:k].any? + assert_predicate tag.errors[:k], :any? end def test_length_value_invalid tag = create(:way_tag) tag.v = "v" * 256 assert_not tag.valid?, "Value should be too long" - assert tag.errors[:v].any? + assert_predicate tag.errors[:v], :any? end def test_empty_tag_invalid tag = WayTag.new assert_not tag.valid?, "Empty way tag should be invalid" - assert tag.errors[:way].any? + assert_predicate tag.errors[:way], :any? end def test_uniqueness @@ -43,9 +43,9 @@ class WayTagTest < ActiveSupport::TestCase tag.way_id = existing.way_id tag.k = existing.k tag.v = existing.v - assert tag.new_record? + assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! } - assert tag.new_record? + assert_predicate tag, :new_record? end end diff --git a/test/models/way_test.rb b/test/models/way_test.rb index 6b166ec7e..420eb42a8 100644 --- a/test/models/way_test.rb +++ b/test/models/way_test.rb @@ -27,7 +27,7 @@ class WayTest < ActiveSupport::TestCase node_c = create(:node) way = create(:way_with_nodes, :nodes_count => 1) # Take one of the current ways and add nodes to it until we are near the limit - assert way.valid? + assert_predicate way, :valid? # it already has 1 node 1.upto(Settings.max_number_of_way_nodes / 2) do way.add_nd_num(node_a.id) @@ -35,9 +35,9 @@ class WayTest < ActiveSupport::TestCase end way.save # print way.nds.size - assert way.valid? + assert_predicate way, :valid? way.add_nd_num(node_c.id) - assert way.valid? + assert_predicate way, :valid? end def test_from_xml_no_id diff --git a/test/system/report_diary_entry_test.rb b/test/system/report_diary_entry_test.rb index 0800e1541..efb107065 100644 --- a/test/system/report_diary_entry_test.rb +++ b/test/system/report_diary_entry_test.rb @@ -54,7 +54,7 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase issue.reload assert_not issue.resolved? - assert issue.open? + assert_predicate issue, :open? end def test_missing_report_params diff --git a/test/validators/characters_validator_test.rb b/test/validators/characters_validator_test.rb index e1409a5dc..341ca4d77 100644 --- a/test/validators/characters_validator_test.rb +++ b/test/validators/characters_validator_test.rb @@ -23,7 +23,7 @@ class CharactersValidatorTest < ActiveSupport::TestCase valid.each do |v| c.chars = v - assert c.valid?, "'#{v}' should be valid" + assert_predicate c, :valid?, "'#{v}' should be valid" end end @@ -48,7 +48,7 @@ class CharactersValidatorTest < ActiveSupport::TestCase valid.each do |v| c.chars = v - assert c.valid?, "'#{v}' should be valid" + assert_predicate c, :valid?, "'#{v}' should be valid" end end diff --git a/test/validators/whitespace_validator_test.rb b/test/validators/whitespace_validator_test.rb index c908538d1..2607d9f23 100644 --- a/test/validators/whitespace_validator_test.rb +++ b/test/validators/whitespace_validator_test.rb @@ -33,7 +33,7 @@ class WhitespaceValidatorTest < ActiveSupport::TestCase strings.each do |v| validator.string = v - assert validator.valid?, "'#{v}' should be valid" + assert_predicate validator, :valid?, "'#{v}' should be valid" end end @@ -55,7 +55,7 @@ class WhitespaceValidatorTest < ActiveSupport::TestCase strings.each do |v| validator.string = v - assert validator.valid?, "'#{v}' should be valid" + assert_predicate validator, :valid?, "'#{v}' should be valid" end end end -- 2.39.5