+ 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(: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, :inserted => false, :fixture => "a")
+
+ assert_not trace.icon.attached?
+
+ trace.import
+
+ assert 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 trace.image.attached?
+ end
+
+ def test_import_handles_bz2
+ trace = create(:trace, :inserted => false, :fixture => "c")
+
+ trace.import