X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eec9e29c963bc20e4e968d5aefd7cc22ca1cbeba..a8e8ba1a64d4f82c74003b5fc05c6fc89a10cc65:/test/models/trace_test.rb diff --git a/test/models/trace_test.rb b/test/models/trace_test.rb index 2955be3ad..9682d6b28 100644 --- a/test/models/trace_test.rb +++ b/test/models/trace_test.rb @@ -76,17 +76,17 @@ class TraceTest < ActiveSupport::TestCase def test_validations trace_valid({}) - trace_valid({ :user_id => nil }, false) - trace_valid(:name => "a" * 255) - trace_valid({ :name => "a" * 256 }, false) - trace_valid({ :description => nil }, false) - trace_valid(:description => "a" * 255) - trace_valid({ :description => "a" * 256 }, false) - trace_valid(:visibility => "private") - trace_valid(:visibility => "public") - trace_valid(:visibility => "trackable") - trace_valid(:visibility => "identifiable") - trace_valid({ :visibility => "foo" }, false) + trace_valid({ :user_id => nil }, :valid => false) + trace_valid({ :name => "a" * 255 }) + trace_valid({ :name => "a" * 256 }, :valid => false) + trace_valid({ :description => nil }, :valid => false) + trace_valid({ :description => "a" * 255 }) + trace_valid({ :description => "a" * 256 }, :valid => false) + trace_valid({ :visibility => "private" }) + trace_valid({ :visibility => "public" }) + trace_valid({ :visibility => "trackable" }) + trace_valid({ :visibility => "identifiable" }) + trace_valid({ :visibility => "foo" }, :valid => false) end def test_tagstring @@ -108,27 +108,27 @@ class TraceTest < ActiveSupport::TestCase 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 @@ -218,22 +218,22 @@ class TraceTest < ActiveSupport::TestCase 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_path_exists(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_path_exists(large_picture_path) end def test_import_handles_bz2 @@ -319,9 +319,9 @@ class TraceTest < ActiveSupport::TestCase assert_equal md5sum, md5sum(create(:trace, :fixture => id).xml_file) end - def trace_valid(attrs, result = true) + def trace_valid(attrs, valid: true) entry = build(:trace, attrs) - assert_equal result, entry.valid?, "Expected #{attrs.inspect} to be #{result}" + assert_equal valid, entry.valid?, "Expected #{attrs.inspect} to be #{valid}" end def md5sum(io)