+ def test_import_creates_tracepoints
+ trace = create(:trace, :fixture => "a")
+ assert_equal 0, Tracepoint.where(:gpx_id => trace.id).count
+
+ trace.import
+
+ trace.reload
+ assert_equal 1, Tracepoint.where(:gpx_id => trace.id).count
+
+ # Check that the tile has been set prior to the bulk import
+ # i.e. that the callbacks have been run correctly
+ assert_equal 3221331576, Tracepoint.where(:gpx_id => trace.id).first.tile
+ end
+
+ def test_import_creates_icon
+ trace = create(:trace, :fixture => "a")
+ icon_path = File.join(Settings.gpx_image_dir, "#{trace.id}_icon.gif")
+ FileUtils.rm(icon_path)
+ assert_not File.exist?(icon_path)
+
+ trace.import
+
+ 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_not File.exist?(large_picture_path)
+
+ trace.import
+
+ assert_path_exists(large_picture_path)
+ end
+
+ def test_import_handles_bz2
+ trace = create(:trace, :fixture => "c")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_plain
+ trace = create(:trace, :fixture => "a")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_plain_with_bom
+ trace = create(:trace, :fixture => "b")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_gz
+ trace = create(:trace, :fixture => "d")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_zip
+ trace = create(:trace, :fixture => "f")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ def test_import_handles_tar
+ trace = create(:trace, :fixture => "g")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ def test_import_handles_tar_gz
+ trace = create(:trace, :fixture => "h")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ def test_import_handles_tar_bz2
+ trace = create(:trace, :fixture => "i")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ private