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
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
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
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
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
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
text = "Test #{link} is <b>made</b> into a link"
html = linkify(text)
- assert html.html_safe?
+ assert_predicate html, :html_safe?
assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> 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 <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
end
text = "Test #{link} is not <b>made</b> 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 <b>made</b> into a link", html
end
end
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
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
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
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
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|
tag.changeset_id = changeset.id
tag.k = key * i
tag.v = "v"
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag.changeset_id = changeset.id
tag.k = "k"
tag.v = val * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
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
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|
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|
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|
def test_assigned_role
issue = create(:issue)
- assert issue.valid?
+ assert_predicate issue, :valid?
issue.assigned_role = "bogus"
assert_not issue.valid?
end
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
tag = create(:node_tag)
[0, 255].each do |i|
tag.k = "k" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag = create(:node_tag)
[0, 255].each do |i|
tag.v = "v" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
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|
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|
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|
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
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
##
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
tag = create(:old_node_tag)
[0, 255].each do |i|
tag.k = "k" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag = create(:old_node_tag)
[0, 255].each do |i|
tag.v = "v" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
tag = create(:old_relation_tag)
[0, 255].each do |i|
tag.k = "k" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag = create(:old_relation_tag)
[0, 255].each do |i|
tag.v = "v" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
tag = create(:old_way_tag)
[0, 255].each do |i|
tag.k = "k" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag = create(:old_way_tag)
[0, 255].each do |i|
tag.v = "v" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
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
tag = create(:relation_tag)
[0, 255].each do |i|
tag.k = "k" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag = create(:relation_tag)
[0, 255].each do |i|
tag.v = "v" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
##
def test_issue_required
report = create(:report)
- assert report.valid?
+ assert_predicate report, :valid?
report.issue = nil
assert_not report.valid?
end
def test_user_required
report = create(:report)
- assert report.valid?
+ assert_predicate report, :valid?
report.user = nil
assert_not report.valid?
end
def test_details_required
report = create(:report)
- assert report.valid?
+ assert_predicate report, :valid?
report.details = ""
assert_not report.valid?
end
def test_category_required
report = create(:report)
- assert report.valid?
+ assert_predicate report, :valid?
report.category = ""
assert_not report.valid?
end
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
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
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
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
trace.import
- assert trace.icon.attached?
+ assert_predicate trace.icon, :attached?
end
def test_import_creates_large_picture
trace.import
- assert trace.image.attached?
+ assert_predicate trace.image, :attached?
end
def test_import_handles_bz2
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
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"
: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
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 = ""
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|
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?
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?
tag = create(:way_tag)
[0, 255].each do |i|
tag.k = "k" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
tag = create(:way_tag)
[0, 255].each do |i|
tag.v = "v" * i
- assert tag.valid?
+ assert_predicate tag, :valid?
end
end
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
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
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)
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
issue.reload
assert_not issue.resolved?
- assert issue.open?
+ assert_predicate issue, :open?
end
def test_missing_report_params
valid.each do |v|
c.chars = v
- assert c.valid?, "'#{v}' should be valid"
+ assert_predicate c, :valid?, "'#{v}' should be valid"
end
end
valid.each do |v|
c.chars = v
- assert c.valid?, "'#{v}' should be valid"
+ assert_predicate c, :valid?, "'#{v}' should be valid"
end
end
strings.each do |v|
validator.string = v
- assert validator.valid?, "'#{v}' should be valid"
+ assert_predicate validator, :valid?, "'#{v}' should be valid"
end
end
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