aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/exporters/chouette/kml/exporter.rb7
-rw-r--r--app/models/export.rb2
-rw-r--r--app/models/kml_export.rb2
-rw-r--r--spec/exporters/chouette/kml/exporter_spec.rb7
4 files changed, 12 insertions, 6 deletions
diff --git a/app/exporters/chouette/kml/exporter.rb b/app/exporters/chouette/kml/exporter.rb
index 29fcac879..9a3cf5eef 100644
--- a/app/exporters/chouette/kml/exporter.rb
+++ b/app/exporters/chouette/kml/exporter.rb
@@ -1,7 +1,7 @@
class Chouette::Kml::Exporter
- def initialize()
-
+ def initialize(referential)
+ @referential = referential
end
def lines(object, ids)
@@ -17,8 +17,9 @@ class Chouette::Kml::Exporter
end
def export(zip_file_path, options = {})
-
begin
+ @referential.switch
+
FileUtils.rm(zip_file_path) if File.exists? zip_file_path
Dir.mktmpdir{ |temp_dir|
diff --git a/app/models/export.rb b/app/models/export.rb
index 566b0c435..eee7b1943 100644
--- a/app/models/export.rb
+++ b/app/models/export.rb
@@ -72,6 +72,8 @@ class Export < ActiveRecord::Base
FileUtils.mkdir_p root
begin
+ # delayed job may repeat call
+ ExportLogMessage.where(:export_id => self.id).delete_all
log_messages.create :key => :started
exporter.export file, export_options
diff --git a/app/models/kml_export.rb b/app/models/kml_export.rb
index 83218a09f..418c2ccc1 100644
--- a/app/models/kml_export.rb
+++ b/app/models/kml_export.rb
@@ -5,7 +5,7 @@ class KmlExport < Export
end
def exporter
- exporter ||= ::Chouette::Kml::Exporter.new()
+ exporter ||= ::Chouette::Kml::Exporter.new(referential)
end
end
diff --git a/spec/exporters/chouette/kml/exporter_spec.rb b/spec/exporters/chouette/kml/exporter_spec.rb
index e83cc1ad6..5f2b30b82 100644
--- a/spec/exporters/chouette/kml/exporter_spec.rb
+++ b/spec/exporters/chouette/kml/exporter_spec.rb
@@ -2,10 +2,13 @@ require 'spec_helper'
describe Chouette::Kml::Exporter do
- subject { Chouette::Kml::Exporter.new }
+ let(:referential) { Factory(:referential) }
+ subject { Chouette::Kml::Exporter.new(referential) }
let(:zip_file_path) { "#{Rails.root}/tmp/exports/test.zip" }
- let(:line) { Factory(:line_with_stop_areas_having_parent) }
+ let(:line) {
+ referential.switch
+ Factory(:line_with_stop_areas_having_parent) }
describe "#export" do