+ end
+
+ def test_import_removes_previous_tracepoints
+ trace = create(:trace, :fixture => "a")
+ # Tracepoints don't have a primary key, so we use a specific latitude to
+ # check for successful deletion
+ create(:tracepoint, :latitude => 54321, :trace => trace)
+ assert_equal 1, Tracepoint.where(:latitude => 54321).count
+
+ trace.import
+
+ assert_equal 0, Tracepoint.where(:latitude => 54321).count
+ end
+
+ def test_import_creates_tracepoints
+ trace = create(:trace, :fixture => "a")
+ assert_equal 0, Tracepoint.where(:trace => trace).count
+
+ trace.import
+
+ trace.reload
+ assert_equal 1, Tracepoint.where(:trace => trace).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.find_by(:trace => trace).tile
+ end
+
+ def test_import_creates_icon
+ trace = create(:trace, :inserted => false, :fixture => "a")
+
+ assert_not trace.icon.attached?
+
+ trace.import
+
+ assert_predicate trace.icon, :attached?
+ end
+
+ def test_import_creates_large_picture
+ trace = create(:trace, :inserted => false, :fixture => "a")
+
+ assert_not trace.image.attached?
+
+ trace.import
+
+ assert_predicate trace.image, :attached?
+ end
+
+ def test_import_handles_bz2
+ trace = create(:trace, :inserted => false, :fixture => "c")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_plain
+ trace = create(:trace, :inserted => false, :fixture => "a")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_plain_with_bom
+ trace = create(:trace, :inserted => false, :fixture => "b")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_gz
+ trace = create(:trace, :inserted => false, :fixture => "d")
+
+ trace.import
+
+ assert_equal 1, trace.size
+ end
+
+ def test_import_handles_zip
+ trace = create(:trace, :inserted => false, :fixture => "f")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ def test_import_handles_tar
+ trace = create(:trace, :inserted => false, :fixture => "g")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ def test_import_handles_tar_gz
+ trace = create(:trace, :inserted => false, :fixture => "h")
+
+ trace.import
+
+ assert_equal 2, trace.size
+ end
+
+ def test_import_handles_tar_bz2
+ trace = create(:trace, :inserted => false, :fixture => "i")
+
+ trace.import