Metrics/PerceivedComplexity:
Max: 25
-# Offense count: 2
-# Cop supports --auto-correct.
-Minitest/AssertEmpty:
- Exclude:
- - 'test/controllers/api/amf_controller_test.rb'
-
-# Offense count: 6
-# Cop supports --auto-correct.
-Minitest/AssertEqual:
- Exclude:
- - 'test/controllers/api/amf_controller_test.rb'
-
-# Offense count: 27
-# Cop supports --auto-correct.
-Minitest/AssertIncludes:
- Exclude:
- - 'test/controllers/api/amf_controller_test.rb'
- - 'test/controllers/api/nodes_controller_test.rb'
- - 'test/helpers/browse_helper_test.rb'
- - 'test/lib/i18n_test.rb'
- - 'test/models/node_test.rb'
- - 'test/models/old_node_test.rb'
- - 'test/models/user_test.rb'
-
-# Offense count: 104
-# Cop supports --auto-correct.
-Minitest/AssertTruthy:
- Enabled: false
-
-# Offense count: 110
-# Cop supports --auto-correct.
-Minitest/RefuteFalse:
- Enabled: false
-
# Offense count: 6
Naming/AccessorMethodName:
Exclude:
assert_equal Array, map[4].class, 'map "relations" element should be an array'
map[2].each do |w|
assert_equal 2, w.length, "way should be (id, version) pair"
- assert w[0] == w[0].floor, "way ID should be an integer"
- assert w[1] == w[1].floor, "way version should be an integer"
+ assert_equal w[0], w[0].floor, "way ID should be an integer"
+ assert_equal w[1], w[1].floor, "way version should be an integer"
end
map[3].each do |n|
assert_equal 5, w.length, "node should be (id, lat, lon, [tags], version) tuple"
- assert n[0] == n[0].floor, "node ID should be an integer"
+ assert_equal n[0], n[0].floor, "node ID should be an integer"
assert n[1] >= minlat - 0.01, "node lat should be greater than min"
assert n[1] <= maxlat - 0.01, "node lat should be less than max"
assert n[2] >= minlon - 0.01, "node lon should be greater than min"
assert n[2] <= maxlon - 0.01, "node lon should be less than max"
assert_equal Array, a[3].class, "node tags should be array"
- assert n[4] == n[4].floor, "node version should be an integer"
+ assert_equal n[4], n[4].floor, "node version should be an integer"
end
map[4].each do |r|
assert_equal 2, r.length, "relation should be (id, version) pair"
- assert r[0] == r[0].floor, "relation ID should be an integer"
- assert r[1] == r[1].floor, "relation version should be an integer"
+ assert_equal r[0], r[0].floor, "relation ID should be an integer"
+ assert_equal r[1], r[1].floor, "relation version should be an integer"
end
# TODO: looks like amf_controller changed since this test was written
# so someone who knows what they're doing should check this!
ways = map[2].collect { |x| x[0] }
- assert ways.include?(way.id),
- "map should include used way"
+ assert_includes ways, way.id,
+ "map should include used way"
assert_not ways.include?(deleted_way.id),
"map should not include deleted way"
end
# so someone who knows what they're doing should check this!
assert_not map[2].include?(way.id),
"map should not include visible way"
- assert map[2].include?(deleted_way.id),
- "map should include deleted way"
+ assert_includes map[2], deleted_way.id,
+ "map should include deleted way"
end
def test_whichways_deleted_toobig
# ['way',wayid,history]
assert_equal history[0], "way"
assert_equal history[1], 0
- assert history[2].empty?
+ assert_empty history[2]
end
def test_getnode_history
# ['node',nodeid,history]
assert_equal history[0], "node"
assert_equal history[1], 0
- assert history[2].empty?
+ assert_empty history[2]
end
def test_findgpx_bad_user
assert_equal nd.version + 1, result[4]
current_node = Node.find(result[3].to_i)
- assert_equal false, current_node.visible
+ assert_not current_node.visible
end
# try deleting a node that is already deleted
new_node = Node.find(new_node_id)
assert_equal 1, new_node.version
- assert_equal true, new_node.visible
+ assert new_node.visible
assert_equal 4.56, new_node.lon
assert_equal 12.34, new_node.lat
assert_equal({ "test" => "new" }, new_node.tags)
changed_node = Node.find(d)
assert_equal 2, changed_node.version
- assert_equal true, changed_node.visible
+ assert changed_node.visible
assert_equal 12.34, changed_node.lon
assert_equal 4.56, changed_node.lat
assert_equal({ "test" => "ok" }, changed_node.tags)
# node is not deleted because our other ways are using it
deleted_node = Node.find(a)
assert_equal 1, deleted_node.version
- assert_equal true, deleted_node.visible
+ assert deleted_node.visible
end
# check that we can update a way
new_node = Node.find(new_node_id)
assert_equal 1, new_node.version
- assert_equal true, new_node.visible
+ assert new_node.visible
assert_equal 4.56, new_node.lon
assert_equal 12.34, new_node.lat
assert_equal({ "test" => "new" }, new_node.tags)
changed_node = Node.find(b)
assert_equal 2, changed_node.version
- assert_equal true, changed_node.visible
+ assert changed_node.visible
assert_equal 12.34, changed_node.lon
assert_equal 4.56, changed_node.lat
assert_equal({ "test" => "ok" }, changed_node.tags)
deleted_node = Node.find(d)
assert_equal 2, deleted_node.version
- assert_equal false, deleted_node.visible
+ assert_not deleted_node.visible
end
# check that we can delete a way
new_way = Way.find(way.id)
assert_equal way.version + 1, new_way.version
- assert_equal false, new_way.visible
+ assert_not new_way.visible
way.nds.each do |node_id|
assert_equal result[4][node_id.to_s].nil?, Node.find(node_id).visible
new_way = Way.find(way.id)
assert_equal way.version, new_way.version
- assert_equal true, new_way.visible
+ assert new_way.visible
way.nds.each do |node_id|
- assert_equal true, Node.find(node_id).visible
+ assert Node.find(node_id).visible
end
end
assert_equal 1, new_relation.version
assert_equal [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], new_relation.members
assert_equal({ "test" => "new" }, new_relation.tags)
- assert_equal true, new_relation.visible
+ assert new_relation.visible
end
# check that we can update a relation
assert_equal relation.version + 1, new_relation.version
assert_equal relation.members, new_relation.members
assert_equal({ "test" => "ok" }, new_relation.tags)
- assert_equal true, new_relation.visible
+ assert new_relation.visible
end
# check that we can delete a relation
assert_equal relation.version + 1, new_relation.version
assert_equal [], new_relation.members
assert_equal({}, new_relation.tags)
- assert_equal false, new_relation.visible
+ assert_not new_relation.visible
end
# check that we can't delete a relation that is in use
assert_equal relation.version, new_relation.version
assert_equal relation.members, new_relation.members
assert_equal relation.tags, new_relation.tags
- assert_equal true, new_relation.visible
+ assert new_relation.visible
end
# check that we can open a changeset
assert_equal "", result[1]
cs = Changeset.find(new_cs_id)
- assert_equal true, cs.is_open?
+ assert cs.is_open?
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
old_cs_id = new_cs_id
assert_equal "", result[1]
cs = Changeset.find(old_cs_id)
- assert_equal false, cs.is_open?
+ assert_not cs.is_open?
assert_equal({ "comment" => "newer", "source" => "new" }, cs.tags)
cs = Changeset.find(new_cs_id)
- assert_equal true, cs.is_open?
+ assert cs.is_open?
assert_equal({ "comment" => "newer", "source" => "newer" }, cs.tags)
old_cs_id = new_cs_id
assert_nil result[2]
cs = Changeset.find(old_cs_id)
- assert_equal false, cs.is_open?
+ assert_not cs.is_open?
assert_equal({ "comment" => "newer", "source" => "newer" }, cs.tags)
end
assert_equal "", result[1]
cs = Changeset.find(cs_id)
- assert_equal true, cs.is_open?
+ assert cs.is_open?
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0])
assert_equal "The user doesn't own that changeset", result[1]
cs = Changeset.find(cs_id)
- assert_equal true, cs.is_open?
+ assert cs.is_open?
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
end
assert_equal "", result[1]
cs = Changeset.find(new_cs_id)
- assert_equal true, cs.is_open?
+ assert cs.is_open?
assert_equal({ "comment" => "foobar" }, cs.tags)
end
def test_destroy_comment_fail
# unauthorized
comment = create(:changeset_comment)
- assert_equal true, comment.visible
+ assert comment.visible
post :destroy, :params => { :id => comment.id }
assert_response :unauthorized
- assert_equal true, comment.reload.visible
+ assert comment.reload.visible
basic_authorization create(:user).email, "test"
# not a moderator
post :destroy, :params => { :id => comment.id }
assert_response :forbidden
- assert_equal true, comment.reload.visible
+ assert comment.reload.visible
basic_authorization create(:moderator_user).email, "test"
# bad comment id
post :destroy, :params => { :id => 999111 }
assert_response :not_found
- assert_equal true, comment.reload.visible
+ assert comment.reload.visible
end
##
# test hide comment succes
def test_hide_comment_success
comment = create(:changeset_comment)
- assert_equal true, comment.visible
+ assert comment.visible
basic_authorization create(:moderator_user).email, "test"
post :destroy, :params => { :id => comment.id }
assert_response :success
- assert_equal false, comment.reload.visible
+ assert_not comment.reload.visible
end
##
def test_restore_comment_fail
# unauthorized
comment = create(:changeset_comment, :visible => false)
- assert_equal false, comment.visible
+ assert_not comment.visible
post :restore, :params => { :id => comment.id }
assert_response :unauthorized
- assert_equal false, comment.reload.visible
+ assert_not comment.reload.visible
basic_authorization create(:user).email, "test"
# not a moderator
post :restore, :params => { :id => comment.id }
assert_response :forbidden
- assert_equal false, comment.reload.visible
+ assert_not comment.reload.visible
basic_authorization create(:moderator_user).email, "test"
# bad comment id
post :restore, :params => { :id => 999111 }
assert_response :not_found
- assert_equal false, comment.reload.visible
+ assert_not comment.reload.visible
end
##
# test unhide comment succes
def test_unhide_comment_success
comment = create(:changeset_comment, :visible => false)
- assert_equal false, comment.visible
+ assert_not comment.visible
basic_authorization create(:moderator_user).email, "test"
post :restore, :params => { :id => comment.id }
assert_response :success
- assert_equal true, comment.reload.visible
+ assert comment.reload.visible
end
# This test ensures that token capabilities behave correctly for a method that
assert_select "diffResult>relation", 2
# check that everything was deleted
- assert_equal false, Node.find(used_node.id).visible
- assert_equal false, Way.find(used_way.id).visible
- assert_equal false, Relation.find(super_relation.id).visible
- assert_equal false, Relation.find(used_relation.id).visible
+ assert_not Node.find(used_node.id).visible
+ assert_not Way.find(used_way.id).visible
+ assert_not Relation.find(super_relation.id).visible
+ assert_not Relation.find(used_relation.id).visible
end
##
assert_select "diffResult>node", 1
# check that everything was deleted
- assert_equal false, Node.find(node.id).visible
+ assert_not Node.find(node.id).visible
end
def test_repeated_changeset_create
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
# check that nothing was, in fact, deleted
- assert_equal true, Node.find(used_node.id).visible
- assert_equal true, Way.find(used_way.id).visible
- assert_equal true, Relation.find(relation.id).visible
- assert_equal true, Relation.find(other_relation.id).visible
+ assert Node.find(used_node.id).visible
+ assert Way.find(used_way.id).visible
+ assert Relation.find(relation.id).visible
+ assert Relation.find(other_relation.id).visible
end
##
assert_equal used_relation.version, doc.find("//diffResult/relation").first["new_version"].to_i
# check that nothing was, in fact, deleted
- assert_equal true, Node.find(used_node.id).visible
- assert_equal true, Way.find(used_way.id).visible
- assert_equal true, Relation.find(used_relation.id).visible
+ assert Node.find(used_node.id).visible
+ assert Way.find(used_way.id).visible
+ assert Relation.find(used_relation.id).visible
end
##
assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude"
assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude"
assert_equal changeset.id, checknode.changeset_id, "saved node does not belong to changeset that it was created in"
- assert_equal true, checknode.visible, "saved node is not visible"
+ assert checknode.visible, "saved node is not visible"
end
def test_create_invalid_xml
# test adding tags to a node
def test_duplicate_tags
existing_tag = create(:node_tag)
- assert_equal true, existing_tag.node.changeset.user.data_public
+ assert existing_tag.node.changeset.user.data_public
# setup auth
basic_authorization existing_tag.node.changeset.user.email, "test"
# check the tags are not corrupted
assert_equal checknode.tags, apinode.tags
- assert apinode.tags.include?("\#{@user.inspect}")
+ assert_includes apinode.tags, "\#{@user.inspect}"
end
##
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
"saved relation does not belong to user that created it"
- assert_equal true, checkrelation.visible,
- "saved relation is not visible"
+ assert checkrelation.visible,
+ "saved relation is not visible"
# ok the relation is there but can we also retrieve it?
get :show, :params => { :id => relationid }
assert_response :success
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
"saved relation does not belong to user that created it"
- assert_equal true, checkrelation.visible,
- "saved relation is not visible"
+ assert checkrelation.visible,
+ "saved relation is not visible"
# ok the relation is there but can we also retrieve it?
get :show, :params => { :id => relationid }
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
"saved relation does not belong to user that created it"
- assert_equal true, checkrelation.visible,
- "saved relation is not visible"
+ assert checkrelation.visible,
+ "saved relation is not visible"
# ok the relation is there but can we also retrieve it?
get :show, :params => { :id => relationid }
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
"saved relation does not belong to user that created it"
- assert_equal true, checkrelation.visible,
- "saved relation is not visible"
+ assert checkrelation.visible,
+ "saved relation is not visible"
# ok the relation is there but can we also retrieve it?
get :show, :params => { :id => relationid }
assert_response :success
assert_equal "New Trace", trace.description
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "trackable", trace.visibility
- assert_equal false, trace.inserted
+ assert_not trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace.destroy
assert_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
assert_equal "New Trace", trace.description
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "public", trace.visibility
- assert_equal false, trace.inserted
+ assert_not trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace.destroy
assert_equal "public", user.preferences.where(:k => "gps.trace.visibility").first.v
assert_equal "New Trace", trace.description
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "private", trace.visibility
- assert_equal false, trace.inserted
+ assert_not trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace.destroy
assert_equal "private", second_user.preferences.where(:k => "gps.trace.visibility").first.v
"saved way does not belong to the correct changeset"
assert_equal user.id, checkway.changeset.user_id,
"saved way does not belong to user that created it"
- assert_equal true, checkway.visible,
- "saved way is not visible"
+ assert checkway.visible,
+ "saved way is not visible"
end
# -------------------------------------
post :hide,
:params => { :display_name => user.display_name, :id => diary_entry.id }
assert_response :forbidden
- assert_equal true, DiaryEntry.find(diary_entry.id).visible
+ assert DiaryEntry.find(diary_entry.id).visible
# Now try as a normal user
post :hide,
:session => { :user => user }
assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
- assert_equal true, DiaryEntry.find(diary_entry.id).visible
+ assert DiaryEntry.find(diary_entry.id).visible
# Now try as a moderator
post :hide,
:session => { :user => create(:moderator_user) }
assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
- assert_equal false, DiaryEntry.find(diary_entry.id).visible
+ assert_not DiaryEntry.find(diary_entry.id).visible
# Reset
diary_entry.reload.update(:visible => true)
:session => { :user => create(:administrator_user) }
assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
- assert_equal false, DiaryEntry.find(diary_entry.id).visible
+ assert_not DiaryEntry.find(diary_entry.id).visible
end
def test_unhide
post :unhide,
:params => { :display_name => user.display_name, :id => diary_entry.id }
assert_response :forbidden
- assert_equal false, DiaryEntry.find(diary_entry.id).visible
+ assert_not DiaryEntry.find(diary_entry.id).visible
# Now try as a normal user
post :unhide,
:session => { :user => user }
assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
- assert_equal false, DiaryEntry.find(diary_entry.id).visible
+ assert_not DiaryEntry.find(diary_entry.id).visible
# Finally try as an administrator
post :unhide,
:session => { :user => create(:administrator_user) }
assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
- assert_equal true, DiaryEntry.find(diary_entry.id).visible
+ assert DiaryEntry.find(diary_entry.id).visible
end
def test_hidecomment
post :hidecomment,
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
assert_response :forbidden
- assert_equal true, DiaryComment.find(diary_comment.id).visible
+ assert DiaryComment.find(diary_comment.id).visible
# Now try as a normal user
post :hidecomment,
:session => { :user => user }
assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
- assert_equal true, DiaryComment.find(diary_comment.id).visible
+ assert DiaryComment.find(diary_comment.id).visible
# Try as a moderator
post :hidecomment,
:session => { :user => create(:moderator_user) }
assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
- assert_equal false, DiaryComment.find(diary_comment.id).visible
+ assert_not DiaryComment.find(diary_comment.id).visible
# Reset
diary_comment.reload.update(:visible => true)
:session => { :user => create(:administrator_user) }
assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
- assert_equal false, DiaryComment.find(diary_comment.id).visible
+ assert_not DiaryComment.find(diary_comment.id).visible
end
def test_unhidecomment
post :unhidecomment,
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
assert_response :forbidden
- assert_equal false, DiaryComment.find(diary_comment.id).visible
+ assert_not DiaryComment.find(diary_comment.id).visible
# Now try as a normal user
post :unhidecomment,
:session => { :user => user }
assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
- assert_equal false, DiaryComment.find(diary_comment.id).visible
+ assert_not DiaryComment.find(diary_comment.id).visible
# Finally try as an administrator
post :unhidecomment,
:session => { :user => administrator_user }
assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
- assert_equal true, DiaryComment.find(diary_comment.id).visible
+ assert DiaryComment.find(diary_comment.id).visible
end
def test_comments
session[:user] = create(:administrator_user).id
get :resolve, :params => { :id => issue.id }
assert_response :not_found
- assert_equal false, issue.reload.resolved?
+ assert_not issue.reload.resolved?
# Resolve issue as moderator
session[:user] = create(:moderator_user).id
get :resolve, :params => { :id => issue.id }
assert_response :redirect
- assert_equal true, issue.reload.resolved?
+ assert issue.reload.resolved?
end
def test_resolve_administrator
session[:user] = create(:moderator_user).id
get :resolve, :params => { :id => issue.id }
assert_response :not_found
- assert_equal false, issue.reload.resolved?
+ assert_not issue.reload.resolved?
# Resolve issue as administrator
session[:user] = create(:administrator_user).id
get :resolve, :params => { :id => issue.id }
assert_response :redirect
- assert_equal true, issue.reload.resolved?
+ assert issue.reload.resolved?
end
def test_ignore_moderator
session[:user] = create(:administrator_user).id
get :ignore, :params => { :id => issue.id }
assert_response :not_found
- assert_equal false, issue.reload.ignored?
+ assert_not issue.reload.ignored?
# Ignore issue as moderator
session[:user] = create(:moderator_user).id
get :ignore, :params => { :id => issue.id }
assert_response :redirect
- assert_equal true, issue.reload.ignored?
+ assert issue.reload.ignored?
end
def test_ignore_administrator
session[:user] = create(:moderator_user).id
get :ignore, :params => { :id => issue.id }
assert_response :not_found
- assert_equal false, issue.reload.ignored?
+ assert_not issue.reload.ignored?
# Ignore issue as administrator
session[:user] = create(:administrator_user).id
get :ignore, :params => { :id => issue.id }
assert_response :redirect
- assert_equal true, issue.reload.ignored?
+ assert issue.reload.ignored?
end
def test_reopen_moderator
session[:user] = create(:administrator_user).id
get :reopen, :params => { :id => issue.id }
assert_response :not_found
- assert_equal false, issue.reload.open?
+ assert_not issue.reload.open?
# Reopen issue as moderator
session[:user] = create(:moderator_user).id
get :reopen, :params => { :id => issue.id }
assert_response :redirect
- assert_equal true, issue.reload.open?
+ assert issue.reload.open?
end
def test_reopen_administrator
session[:user] = create(:moderator_user).id
get :reopen, :params => { :id => issue.id }
assert_response :not_found
- assert_equal false, issue.reload.open?
+ assert_not issue.reload.open?
# Reopen issue as administrator
session[:user] = create(:administrator_user).id
get :reopen, :params => { :id => issue.id }
assert_response :redirect
- assert_equal true, issue.reload.open?
+ assert issue.reload.open?
end
end
assert_select "textarea#message_body", :count => 1
assert_select "input[type='submit'][value='Send']", :count => 1
end
- assert_equal true, Message.find(unread_message.id).message_read
+ assert Message.find(unread_message.id).message_read
# Asking to reply to a message with no ID should fail
assert_raise ActionController::UrlGenerationError do
get :show, :params => { :id => unread_message.id }
assert_response :success
assert_template "show"
- assert_equal false, Message.find(unread_message.id).message_read
+ assert_not Message.find(unread_message.id).message_read
# Login as the message recipient
session[:user] = recipient_user.id
get :show, :params => { :id => unread_message.id }
assert_response :success
assert_template "show"
- assert_equal true, Message.find(unread_message.id).message_read
+ assert Message.find(unread_message.id).message_read
# Asking to read a message with no ID should fail
assert_raise ActionController::UrlGenerationError do
# Check that the marking a message read works
post :mark, :params => { :message_id => unread_message.id, :mark => "read" }
assert_redirected_to inbox_messages_path
- assert_equal true, Message.find(unread_message.id).message_read
+ assert Message.find(unread_message.id).message_read
# Check that the marking a message unread works
post :mark, :params => { :message_id => unread_message.id, :mark => "unread" }
assert_redirected_to inbox_messages_path
- assert_equal false, Message.find(unread_message.id).message_read
+ assert_not Message.find(unread_message.id).message_read
# Check that the marking a message read via XHR works
post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "read" }
assert_response :success
assert_template "mark"
- assert_equal true, Message.find(unread_message.id).message_read
+ assert Message.find(unread_message.id).message_read
# Check that the marking a message unread via XHR works
post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "unread" }
assert_response :success
assert_template "mark"
- assert_equal false, Message.find(unread_message.id).message_read
+ assert_not Message.find(unread_message.id).message_read
# Asking to mark a message with no ID should fail
assert_raise ActionController::UrlGenerationError do
assert_redirected_to inbox_messages_path
assert_equal "Message deleted", flash[:notice]
m = Message.find(read_message.id)
- assert_equal true, m.from_user_visible
- assert_equal false, m.to_user_visible
+ assert m.from_user_visible
+ assert_not m.to_user_visible
# Check that the destroying a sent message works
delete :destroy, :params => { :id => sent_message.id, :referer => outbox_messages_path }
assert_redirected_to outbox_messages_path
assert_equal "Message deleted", flash[:notice]
m = Message.find(sent_message.id)
- assert_equal false, m.from_user_visible
- assert_equal true, m.to_user_visible
+ assert_not m.from_user_visible
+ assert m.to_user_visible
# Asking to destroy a message with no ID should fail
assert_raise ActionController::UrlGenerationError do
assert_equal "New Trace", trace.description
assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "trackable", trace.visibility
- assert_equal false, trace.inserted
+ assert_not trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace.destroy
assert_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
assert_response :redirect
assert_redirected_to :action => :index, :display_name => public_trace_file.user.display_name
trace = Trace.find(public_trace_file.id)
- assert_equal false, trace.visible
+ assert_not trace.visible
# Finally with a trace that is destroyed by an admin
public_trace_file = create(:trace, :visibility => "public")
assert_response :redirect
assert_redirected_to :action => :index, :display_name => public_trace_file.user.display_name
trace = Trace.find(public_trace_file.id)
- assert_equal false, trace.visible
+ assert_not trace.visible
end
private
# Viewing an active block should work, but shouldn't mark it as seen
get :show, :params => { :id => active_block.id }
assert_response :success
- assert_equal true, UserBlock.find(active_block.id).needs_view
+ assert UserBlock.find(active_block.id).needs_view
# Login as the blocked user
session[:user] = active_block.user.id
# Now viewing it should mark it as seen
get :show, :params => { :id => active_block.id }
assert_response :success
- assert_equal false, UserBlock.find(active_block.id).needs_view
+ assert_not UserBlock.find(active_block.id).needs_view
end
##
assert_in_delta Time.now, b.created_at, 1
assert_in_delta Time.now, b.updated_at, 1
assert_in_delta Time.now + 12.hours, b.ends_at, 1
- assert_equal false, b.needs_view
+ assert_not b.needs_view
assert_equal "Vandalism", b.reason
assert_equal "markdown", b.reason_format
assert_equal moderator_user.id, b.creator_id
assert_equal "Block updated.", flash[:notice]
b = UserBlock.find(active_block.id)
assert_in_delta Time.now, b.updated_at, 1
- assert_equal true, b.needs_view
+ assert b.needs_view
assert_equal "Vandalism", b.reason
# We should get an error if no block ID is specified
user.reload
- assert_equal true, user.consider_pd
+ assert user.consider_pd
assert_not_nil user.terms_agreed
- assert_equal true, user.terms_seen
+ assert user.terms_seen
end
def test_terms_not_seen_with_referer
user.reload
- assert_equal true, user.consider_pd
+ assert user.consider_pd
assert_not_nil user.terms_agreed
- assert_equal true, user.terms_seen
+ assert user.terms_seen
end
# Check that if you haven't seen the terms, and make a request that requires authentication,
post :go_public, :session => { :user => user }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
- assert_equal true, User.find(user.id).data_public
+ assert User.find(user.id).data_public
end
def test_lost_password
assert_equal user.id, session[:user]
user.reload
assert_equal "active", user.status
- assert_equal true, user.email_valid
+ assert user.email_valid
assert_equal user, User.authenticate(:username => user.email, :password => "new_password")
end
assert_equal "", user.description
assert_nil user.home_lat
assert_nil user.home_lon
- assert_equal false, user.avatar.attached?
- assert_equal false, user.email_valid
+ assert_not user.avatar.attached?
+ assert_not user.email_valid
assert_nil user.new_email
assert_nil user.auth_provider
assert_nil user.auth_uid
text = "Test #{link} is <b>made</b> into a link"
html = linkify(text)
- assert_equal true, html.html_safe?
+ assert 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_equal true, html.html_safe?
+ assert 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_equal true, html.html_safe?
+ assert html.html_safe?
assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
html = linkify(text.html_safe)
- assert_equal true, html.html_safe?
+ assert html.html_safe?
assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
end
end
tags = icon_tags(node)
assert_equal 3, tags.count
- assert tags.include?(%w[building yes])
- assert tags.include?(%w[tourism museum])
- assert tags.include?(%w[shop gift])
+ assert_includes tags, %w[building yes]
+ assert_includes tags, %w[tourism museum]
+ assert_includes tags, %w[shop gift]
add_old_tags_selection(node_v2)
add_old_tags_selection(node_v1)
tags = icon_tags(node_v2)
assert_equal 3, tags.count
- assert tags.include?(%w[building yes])
- assert tags.include?(%w[tourism museum])
- assert tags.include?(%w[shop gift])
+ assert_includes tags, %w[building yes]
+ assert_includes tags, %w[tourism museum]
+ assert_includes tags, %w[shop gift]
tags = icon_tags(node_v1)
assert_equal 3, tags.count
- assert tags.include?(%w[building yes])
- assert tags.include?(%w[tourism museum])
- assert tags.include?(%w[shop gift])
+ assert_includes tags, %w[building yes]
+ assert_includes tags, %w[tourism museum]
+ assert_includes tags, %w[shop gift]
end
def add_old_tags_selection(old_node)
next if subvalue.nil?
subvalue.scan(/%\{(\w+)\}/) do
- assert variables.include?(Regexp.last_match(1)), "#{key}.#{subkey} uses unknown interpolation variable #{Regexp.last_match(1)}"
+ assert_includes variables, Regexp.last_match(1), "#{key}.#{subkey} uses unknown interpolation variable #{Regexp.last_match(1)}"
end
end
else
assert value.is_a?(String), "#{key} is not a string"
value.scan(/%\{(\w+)\}/) do
- assert variables.include?(Regexp.last_match(1)), "#{key} uses unknown interpolation variable #{Regexp.last_match(1)}"
+ assert_includes variables, Regexp.last_match(1), "#{key} uses unknown interpolation variable #{Regexp.last_match(1)}"
end
end
end
- assert %w[ltr rtl].include?(I18n.t("html.dir", :locale => locale)), "html.dir must be ltr or rtl"
+ assert_includes %w[ltr rtl], I18n.t("html.dir", :locale => locale), "html.dir must be ltr or rtl"
end
end
end
class PasswordHashTest < ActiveSupport::TestCase
def test_md5_without_salt
- assert_equal true, PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "password")
- assert_equal false, PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "wrong")
- assert_equal true, PasswordHash.upgrade?("5f4dcc3b5aa765d61d8327deb882cf99", nil)
+ assert PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "password")
+ assert_not PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "wrong")
+ assert PasswordHash.upgrade?("5f4dcc3b5aa765d61d8327deb882cf99", nil)
end
def test_md5_with_salt
- assert_equal true, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "password")
- assert_equal false, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "wrong")
- assert_equal false, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "wrong", "password")
- assert_equal true, PasswordHash.upgrade?("67a1e09bb1f83f5007dc119c14d663aa", "salt")
+ assert PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "password")
+ assert_not PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "wrong")
+ assert_not PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "wrong", "password")
+ assert PasswordHash.upgrade?("67a1e09bb1f83f5007dc119c14d663aa", "salt")
end
def test_pbkdf2_1000_32_sha512
- assert_equal true, PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "password")
- assert_equal false, PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "wrong")
- assert_equal false, PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gwrongtoNzm/CNKe4cf7bPKwdUNrk=", "password")
- assert_equal true, PasswordHash.upgrade?("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=")
+ assert PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "password")
+ assert_not PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=", "wrong")
+ assert_not PasswordHash.check("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gwrongtoNzm/CNKe4cf7bPKwdUNrk=", "password")
+ assert PasswordHash.upgrade?("ApT/28+FsTBLa/J8paWfgU84SoRiTfeY8HjKWhgHy08=", "sha512!1000!HR4z+hAvKV2ra1gpbRybtoNzm/CNKe4cf7bPKwdUNrk=")
end
def test_pbkdf2_10000_32_sha512
- assert_equal true, PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
- assert_equal false, PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "wrong")
- assert_equal false, PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtMwronguvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
- assert_equal false, PasswordHash.upgrade?("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=")
+ assert PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
+ assert_not PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "wrong")
+ assert_not PasswordHash.check("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtMwronguvanFT5/WtWaCwdOdrir8QOtFwxhO0A=", "password")
+ assert_not PasswordHash.upgrade?("3wYbPiOxk/tU0eeIDjUhdvi8aDP3AbFtwYKKxF1IhGg=", "sha512!10000!OUQLgtM7eD8huvanFT5/WtWaCwdOdrir8QOtFwxhO0A=")
end
def test_default
hash2, salt2 = PasswordHash.create("password")
assert_not_equal hash1, hash2
assert_not_equal salt1, salt2
- assert_equal true, PasswordHash.check(hash1, salt1, "password")
- assert_equal false, PasswordHash.check(hash1, salt1, "wrong")
- assert_equal true, PasswordHash.check(hash2, salt2, "password")
- assert_equal false, PasswordHash.check(hash2, salt2, "wrong")
- assert_equal false, PasswordHash.upgrade?(hash1, salt1)
- assert_equal false, PasswordHash.upgrade?(hash2, salt2)
+ assert PasswordHash.check(hash1, salt1, "password")
+ assert_not PasswordHash.check(hash1, salt1, "wrong")
+ assert PasswordHash.check(hash2, salt2, "password")
+ assert_not PasswordHash.check(hash2, salt2, "wrong")
+ assert_not PasswordHash.upgrade?(hash1, salt1)
+ assert_not PasswordHash.upgrade?(hash2, salt2)
end
end
class UTF8Test < ActiveSupport::TestCase
def test_valid?
- assert_equal true, UTF8.valid?("test")
- assert_equal true, UTF8.valid?("vergrößern")
- assert_equal true, UTF8.valid?("ルシステムにも対応します")
- assert_equal true, UTF8.valid?("輕觸搖晃的遊戲")
+ assert UTF8.valid?("test")
+ assert UTF8.valid?("vergrößern")
+ assert UTF8.valid?("ルシステムにも対応します")
+ assert UTF8.valid?("輕觸搖晃的遊戲")
- assert_equal false, UTF8.valid?("\xC0") # always invalid utf8
- assert_equal false, UTF8.valid?("\xC2\x4a") # 2-byte multibyte identifier, followed by plain ASCII
- assert_equal false, UTF8.valid?("\xC2\xC2") # 2-byte multibyte identifier, followed by another one
- assert_equal false, UTF8.valid?("\x4a\x82") # plain ASCII, followed by multibyte continuation
- assert_equal false, UTF8.valid?("\x82\x82") # multibyte continuations without multibyte identifier
- assert_equal false, UTF8.valid?("\xe1\x82\x4a") # three-byte identifier, contination and (incorrectly) plain ASCII
+ assert_not UTF8.valid?("\xC0") # always invalid utf8
+ assert_not UTF8.valid?("\xC2\x4a") # 2-byte multibyte identifier, followed by plain ASCII
+ assert_not UTF8.valid?("\xC2\xC2") # 2-byte multibyte identifier, followed by another one
+ assert_not UTF8.valid?("\x4a\x82") # plain ASCII, followed by multibyte continuation
+ assert_not UTF8.valid?("\x82\x82") # multibyte continuations without multibyte identifier
+ assert_not UTF8.valid?("\xe1\x82\x4a") # three-byte identifier, contination and (incorrectly) plain ASCII
end
end
def test_node_too_far_north
node = build(:node, :latitude => 90.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_north_limit
node = build(:node, :latitude => 90 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_too_far_south
node = build(:node, :latitude => -90.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_south_limit
node = build(:node, :latitude => -90 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_too_far_west
node = build(:node, :longitude => -180.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_west_limit
node = build(:node, :longitude => -180 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_too_far_east
node = build(:node, :longitude => 180.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_east_limit
node = build(:node, :longitude => 180 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_totally_wrong
node = build(:node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_lat_lon
assert_equal node_template.latitude, node.latitude
assert_equal node_template.longitude, node.longitude
assert_equal node_template.changeset_id, node.changeset_id
- assert_equal false, node.visible
+ assert_not node.visible
# assert_equal node_template.tags, node.tags
assert_equal OldNode.where(:node_id => node_template.id).count, 2
assert_equal node_template.latitude, old_node.latitude
assert_equal node_template.longitude, old_node.longitude
assert_equal node_template.changeset_id, old_node.changeset_id
- assert_equal false, old_node.visible
+ assert_not old_node.visible
# assert_equal node_template.tags, old_node.tags
end
end
def test_visible?
- assert_equal true, create(:note, :status => "open").visible?
- assert_equal true, create(:note, :status => "closed").visible?
- assert_equal false, create(:note, :status => "hidden").visible?
+ assert create(:note, :status => "open").visible?
+ assert create(:note, :status => "closed").visible?
+ assert_not create(:note, :status => "hidden").visible?
end
def test_closed?
- assert_equal true, create(:note, :status => "closed", :closed_at => Time.now).closed?
- assert_equal false, create(:note, :status => "open", :closed_at => nil).closed?
+ assert create(:note, :status => "closed", :closed_at => Time.now).closed?
+ assert_not create(:note, :status => "open", :closed_at => nil).closed?
end
def test_author
assert_not_equal false, nonce1, "First nonce should be unique. Check your test database is empty."
nonce2 = OauthNonce.remember(string, timestamp)
- assert_equal false, nonce2, "Shouldn't be able to remember the same nonce twice."
+ assert_not nonce2, "Shouldn't be able to remember the same nonce twice."
end
##
string = "0123456789ABCDEF"
nonce1 = OauthNonce.remember(string, Time.now.to_i - 86430)
- assert_equal false, nonce1, "Nonces over a day in the past should be rejected"
+ assert_not nonce1, "Nonces over a day in the past should be rejected"
nonce2 = OauthNonce.remember(string, Time.now.to_i - 86370)
assert_not_equal false, nonce2, "Nonces under a day in the past should be rejected"
# check that after calling invalidate! on a token, it is invalid.
def test_token_invalidation
tok = OauthToken.new
- assert_equal false, tok.invalidated?, "Token should be created valid."
+ assert_not tok.invalidated?, "Token should be created valid."
tok.invalidate!
- assert_equal true, tok.invalidated?, "Token should now be invalid."
+ assert tok.invalidated?, "Token should now be invalid."
end
##
# check that an authorized token is authorised and can be invalidated
def test_token_authorisation
tok = RequestToken.create(:client_application => create(:client_application))
- assert_equal false, tok.authorized?, "Token should be created unauthorised."
+ assert_not tok.authorized?, "Token should be created unauthorised."
tok.authorize!(create(:user))
- assert_equal true, tok.authorized?, "Token should now be authorised."
+ assert tok.authorized?, "Token should now be authorised."
tok.invalidate!
- assert_equal false, tok.authorized?, "Token should now be invalid."
+ assert_not tok.authorized?, "Token should now be invalid."
end
end
def test_node_too_far_north
node = build(:old_node, :latitude => 90.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_north_limit
node = build(:old_node, :latitude => 90 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_too_far_south
node = build(:old_node, :latitude => -90.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_south_limit
node = build(:old_node, :latitude => -90 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_too_far_west
node = build(:old_node, :longitude => -180.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_west_limit
node = build(:old_node, :longitude => -180 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_too_far_east
node = build(:old_node, :longitude => 180.01 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_node_east_limit
node = build(:old_node, :longitude => 180 * OldNode::SCALE)
node.validate
- assert_equal false, node.errors.full_messages.include?("Node is not in the world")
+ assert_not_includes node.errors.full_messages, "Node is not in the world"
end
def test_totally_wrong
node = build(:old_node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
node.validate
- assert node.errors.full_messages.include?("Node is not in the world")
+ assert_includes node.errors.full_messages, "Node is not in the world"
end
def test_lat_lon
def test_cannot_redact_current
n = create(:node)
r = create(:redaction)
- assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
+ assert_not(n.redacted?, "Expected node to not be redacted already.")
assert_raise(OSM::APICannotRedactError) do
n.redact!(r)
end
node = create(:node, :with_history)
node_v1 = node.old_nodes.find_by(:version => 1)
r = create(:redaction)
- assert_equal(false, node_v1.redacted?, "Expected node to not be redacted already.")
+ assert_not(node_v1.redacted?, "Expected node to not be redacted already.")
assert_raise(OSM::APICannotRedactError) do
node_v1.redact!(r)
end
node_v2 = node.old_nodes.find_by(:version => 2)
r = create(:redaction)
- assert_equal(false, node_v1.redacted?, "Expected node to not be redacted already.")
+ assert_not(node_v1.redacted?, "Expected node to not be redacted already.")
assert_nothing_raised do
node_v1.redact!(r)
end
- assert_equal(true, node_v1.redacted?, "Expected node version 1 to be redacted after redact! call.")
- assert_equal(false, node_v2.redacted?, "Expected node version 2 to not be redacted after redact! call.")
+ assert(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
class RequestTokenTest < ActiveSupport::TestCase
def test_oob
- assert_equal true, RequestToken.new.oob?
- assert_equal true, RequestToken.new(:callback_url => "oob").oob?
- assert_equal true, RequestToken.new(:callback_url => "OOB").oob?
- assert_equal false, RequestToken.new(:callback_url => "http://test.host/").oob?
+ assert RequestToken.new.oob?
+ assert RequestToken.new(:callback_url => "oob").oob?
+ assert RequestToken.new(:callback_url => "OOB").oob?
+ assert_not RequestToken.new(:callback_url => "http://test.host/").oob?
end
end
end
def test_public?
- assert_equal true, build(:trace, :visibility => "public").public?
- assert_equal false, build(:trace, :visibility => "private").public?
- assert_equal false, build(:trace, :visibility => "trackable").public?
- assert_equal true, build(:trace, :visibility => "identifiable").public?
- assert_equal true, build(:trace, :deleted, :visibility => "public").public?
+ assert 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?
end
def test_trackable?
- assert_equal false, build(:trace, :visibility => "public").trackable?
- assert_equal false, build(:trace, :visibility => "private").trackable?
- assert_equal true, build(:trace, :visibility => "trackable").trackable?
- assert_equal true, build(:trace, :visibility => "identifiable").trackable?
- assert_equal false, build(:trace, :deleted, :visibility => "public").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_not build(:trace, :deleted, :visibility => "public").trackable?
end
def test_identifiable?
- assert_equal false, build(:trace, :visibility => "public").identifiable?
- assert_equal false, build(:trace, :visibility => "private").identifiable?
- assert_equal false, build(:trace, :visibility => "trackable").identifiable?
- assert_equal true, build(:trace, :visibility => "identifiable").identifiable?
- assert_equal false, build(:trace, :deleted, :visibility => "public").identifiable?
+ 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_not build(:trace, :deleted, :visibility => "public").identifiable?
end
def test_mime_type
trace = create(:trace, :fixture => "a")
icon_path = File.join(Settings.gpx_image_dir, "#{trace.id}_icon.gif")
FileUtils.rm(icon_path)
- assert_equal false, File.exist?(icon_path)
+ assert_not File.exist?(icon_path)
trace.import
- assert_equal true, File.exist?(icon_path)
+ assert File.exist?(icon_path)
end
def test_import_creates_large_picture
trace = create(:trace, :fixture => "a")
large_picture_path = File.join(Settings.gpx_image_dir, "#{trace.id}.gif")
FileUtils.rm(large_picture_path)
- assert_equal false, File.exist?(large_picture_path)
+ assert_not File.exist?(large_picture_path)
trace.import
- assert_equal true, File.exist?(large_picture_path)
+ assert File.exist?(large_picture_path)
end
def test_import_handles_bz2
up.user = create(:user)
up.k = key * i
up.v = val * i
- assert_equal false, up.valid?
+ assert_not up.valid?
assert_raise(ActiveRecord::RecordInvalid) { up.save! }
end
end
:description => "desc"
)
assert_not new_user.save
- assert new_user.errors[:email].include?("has already been taken")
+ assert_includes new_user.errors[:email], "has already been taken"
end
def test_unique_display_name
:description => "desc"
)
assert_not new_user.save
- assert new_user.errors[:display_name].include?("has already been taken")
+ assert_includes new_user.errors[:display_name], "has already been taken"
end
def test_email_valid
end
def test_visible?
- assert_equal true, build(:user, :pending).visible?
- assert_equal true, build(:user, :active).visible?
- assert_equal true, build(:user, :confirmed).visible?
- assert_equal false, build(:user, :suspended).visible?
- assert_equal false, build(:user, :deleted).visible?
+ assert build(:user, :pending).visible?
+ assert build(:user, :active).visible?
+ assert build(:user, :confirmed).visible?
+ assert_not build(:user, :suspended).visible?
+ assert_not build(:user, :deleted).visible?
end
def test_active?
- assert_equal false, build(:user, :pending).active?
- assert_equal true, build(:user, :active).active?
- assert_equal true, build(:user, :confirmed).active?
- assert_equal false, build(:user, :suspended).active?
- assert_equal false, build(:user, :deleted).active?
+ assert_not build(:user, :pending).active?
+ assert build(:user, :active).active?
+ assert build(:user, :confirmed).active?
+ assert_not build(:user, :suspended).active?
+ assert_not build(:user, :deleted).active?
end
def test_moderator?
- assert_equal false, create(:user).moderator?
- assert_equal true, create(:moderator_user).moderator?
+ assert_not create(:user).moderator?
+ assert create(:moderator_user).moderator?
end
def test_administrator?
- assert_equal false, create(:user).administrator?
- assert_equal true, create(:administrator_user).administrator?
+ assert_not create(:user).administrator?
+ assert create(:administrator_user).administrator?
end
def test_has_role?
- assert_equal false, create(:user).has_role?("administrator")
- assert_equal false, create(:user).has_role?("moderator")
- assert_equal true, create(:administrator_user).has_role?("administrator")
- assert_equal true, create(:moderator_user).has_role?("moderator")
+ assert_not create(:user).has_role?("administrator")
+ assert_not create(:user).has_role?("moderator")
+ assert create(:administrator_user).has_role?("administrator")
+ assert create(:moderator_user).has_role?("moderator")
end
def test_delete
assert user.description.blank?
assert_nil user.home_lat
assert_nil user.home_lon
- assert_equal false, user.avatar.attached?
+ assert_not user.avatar.attached?
assert_equal "deleted", user.status
- assert_equal false, user.visible?
- assert_equal false, user.active?
+ assert_not user.visible?
+ assert_not user.active?
end
def test_to_xml