diff options
| author | Marc Florisson | 2013-07-08 17:12:18 +0200 |
|---|---|---|
| committer | Marc Florisson | 2013-07-08 17:12:18 +0200 |
| commit | 0cad1a2a6cc092b8bf4e2d479f247d87b1cd409d (patch) | |
| tree | 15a1cebe90e70c3f4906c82e2b9025556c47f30d | |
| parent | 267c336f437257f293c8d04d17d716df2885dae6 (diff) | |
| download | chouette-core-0cad1a2a6cc092b8bf4e2d479f247d87b1cd409d.tar.bz2 | |
fix Kml Export : correct use of Referential
| -rw-r--r-- | app/exporters/chouette/kml/exporter.rb | 7 | ||||
| -rw-r--r-- | app/models/export.rb | 2 | ||||
| -rw-r--r-- | app/models/kml_export.rb | 2 | ||||
| -rw-r--r-- | spec/exporters/chouette/kml/exporter_spec.rb | 7 |
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 |
