diff options
| author | Robert | 2017-07-31 14:57:30 +0200 |
|---|---|---|
| committer | Robert | 2017-07-31 14:57:30 +0200 |
| commit | 54856654f0e7c1802ab785f8dff689f35c92fe80 (patch) | |
| tree | 6b9e06f91f0b852eb3158aa0181483ed33d8f8b6 | |
| parent | 609b774388a7f57703ec14a224363c88f3564eaf (diff) | |
| download | chouette-core-54856654f0e7c1802ab785f8dff689f35c92fe80.tar.bz2 | |
Refs: #3507@2h CR 2nd leg
| -rw-r--r-- | app/workers/workbench_import_worker.rb | 2 | ||||
| -rw-r--r-- | config/application.rb | 1 | ||||
| -rw-r--r-- | config/initializers/workbench_import.rb | 2 | ||||
| -rw-r--r-- | spec/concerns/configurable_spec.rb | 4 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 3 | ||||
| -rw-r--r-- | spec/models/netex_import_spec.rb | 4 | ||||
| -rw-r--r-- | spec/services/retry_service_spec.rb | 5 | ||||
| -rw-r--r-- | spec/services/zip_service/zip_output_streams_spec.rb | 2 | ||||
| -rw-r--r-- | spec/support/fixtures_helper.rb | 3 | ||||
| -rw-r--r-- | spec/tasks/reflex_rake_spec.rb | 4 | ||||
| -rw-r--r-- | spec/workers/workbench_import_worker_spec.rb | 6 |
11 files changed, 21 insertions, 15 deletions
diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb index 982d3e0d6..488fbfc0b 100644 --- a/app/workers/workbench_import_worker.rb +++ b/app/workers/workbench_import_worker.rb @@ -106,7 +106,7 @@ class WorkbenchImportWorker Rails.application.config.front_end_host end def import_path - @__import_path__ ||= File.join(download_workbench_import_path(@import.workbench, @import)) + @__import_path__ ||= download_workbench_import_path(@import.workbench, @import) end def import_url @__import_url__ ||= File.join(import_host, import_path) diff --git a/config/application.rb b/config/application.rb index e2f6f8e7b..05a9752b6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,7 +15,6 @@ module ChouetteIhm # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. config.autoload_paths << config.root.join('lib') - config.autoload_paths << config.root.join('concerns') # custom exception pages config.exceptions_app = self.routes diff --git a/config/initializers/workbench_import.rb b/config/initializers/workbench_import.rb index 1e405c9ca..89ddd72ef 100644 --- a/config/initializers/workbench_import.rb +++ b/config/initializers/workbench_import.rb @@ -1,5 +1,5 @@ WorkbenchImportWorker.config do | config | config.dir = ENV.fetch('WORKBENCH_IMPORT_DIR'){ Rails.root.join 'tmp/workbench_import' } - FileUtils.mkdir_p config.dir rescue nil + FileUtils.mkdir_p config.dir end diff --git a/spec/concerns/configurable_spec.rb b/spec/concerns/configurable_spec.rb index 822f572c1..330241b72 100644 --- a/spec/concerns/configurable_spec.rb +++ b/spec/concerns/configurable_spec.rb @@ -14,7 +14,9 @@ RSpec.describe Configurable do subject.config.something = something expect( subject.config.something ).to eq(something) + # Instances delegate to the class expect( subject.new.send(:config).something ).to eq(something) + # **All** instances delegate to the class expect( subject.new.send(:config).something ).to eq(something) end @@ -25,7 +27,9 @@ RSpec.describe Configurable do end expect( subject.config.something ).to eq(something) + # Instances delegate to the class expect( subject.new.send(:config).something ).to eq(something) + # **All** instances delegate to the class expect( subject.new.send(:config).something ).to eq(something) end end diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index ee30ce8ba..6546b14ab 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -1,5 +1,6 @@ RSpec.describe Import, :type => :model do subject{ build_stubbed :import } + it { should belong_to(:referential) } it { should belong_to(:workbench) } it { should belong_to(:parent).class_name(described_class.to_s) } @@ -7,4 +8,6 @@ RSpec.describe Import, :type => :model do it { should enumerize(:status).in("aborted", "canceled", "failed", "new", "pending", "running", "successful") } it { should validate_presence_of(:file) } + it { should validate_presence_of(:referential) } + it { should validate_presence_of(:workbench) } end diff --git a/spec/models/netex_import_spec.rb b/spec/models/netex_import_spec.rb deleted file mode 100644 index 066595f06..000000000 --- a/spec/models/netex_import_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -RSpec.describe NetexImport, type: :model do - it { should validate_presence_of(:referential) } - it { should validate_presence_of(:workbench) } -end diff --git a/spec/services/retry_service_spec.rb b/spec/services/retry_service_spec.rb index ce150f808..bb3416373 100644 --- a/spec/services/retry_service_spec.rb +++ b/spec/services/retry_service_spec.rb @@ -42,7 +42,7 @@ RSpec.describe RetryService do expect( subject ).to receive(:sleep).with(2) end - it 'succeds the second time' do + it 'succeeds the second time' do expect( subject.execute{ succeed_later(ArgumentError){ 42 } } ).to eq(Result.ok(42)) end @@ -58,7 +58,8 @@ RSpec.describe RetryService do expect( subject ).to receive(:sleep).with(3) end it 'succeeds the third time with try again (automatically registered exception)' do - expect( subject.execute{ succeed_later(RetryService::Retry, count: 2){ 42 } } ).to eq(Result.ok(42)) + result = subject.execute{ succeed_later(RetryService::Retry, count: 2){ 42 } } + expect( result ).to eq( Result.ok(42) ) end end diff --git a/spec/services/zip_service/zip_output_streams_spec.rb b/spec/services/zip_service/zip_output_streams_spec.rb index b99e7bc2d..d2452bfd8 100644 --- a/spec/services/zip_service/zip_output_streams_spec.rb +++ b/spec/services/zip_service/zip_output_streams_spec.rb @@ -15,7 +15,7 @@ RSpec.describe ZipService do expect( ref2_lines ).to eq %w(multiref/ref2/ multiref/ref2/datum-1 multiref/ref2/datum-2) end - it "exposes it's size" do + it "exposes its size" do expect( subject.entry_group_streams.size ).to eq(2) end end diff --git a/spec/support/fixtures_helper.rb b/spec/support/fixtures_helper.rb index 81f6ce838..20963261b 100644 --- a/spec/support/fixtures_helper.rb +++ b/spec/support/fixtures_helper.rb @@ -4,6 +4,9 @@ module Support Rails.root.join( fixture_path, *segments ) end + def open_fixture *segments + File.open(fixtures_path(*segments)) + end def read_fixture *segments File.read(fixtures_path(*segments)) end diff --git a/spec/tasks/reflex_rake_spec.rb b/spec/tasks/reflex_rake_spec.rb index 04c5886aa..6ece223d2 100644 --- a/spec/tasks/reflex_rake_spec.rb +++ b/spec/tasks/reflex_rake_spec.rb @@ -5,7 +5,7 @@ describe 'reflex:sync' do before(:each) do ['getOP', 'getOR'].each do |method| stub_request(:get, "#{Rails.application.config.reflex_api_url}/?format=xml&idRefa=0&method=#{method}"). - to_return(body: File.open("#{fixture_path}/reflex.zip"), status: 200) + to_return(body: open_fixture('reflex.zip'), status: 200) end stop_area_ref = create(:stop_area_referential, name: 'Reflex') @@ -43,7 +43,7 @@ describe 'reflex:sync' do before(:each) do ['getOP', 'getOR'].each do |method| stub_request(:get, "#{Rails.application.config.reflex_api_url}/?format=xml&idRefa=0&method=#{method}"). - to_return(body: File.open("#{fixture_path}/reflex_updated.zip"), status: 200) + to_return(body: open_fixture('reflex_updated.zip'), status: 200) end Stif::ReflexSynchronization.synchronize end diff --git a/spec/workers/workbench_import_worker_spec.rb b/spec/workers/workbench_import_worker_spec.rb index 03206113c..3ed5833dc 100644 --- a/spec/workers/workbench_import_worker_spec.rb +++ b/spec/workers/workbench_import_worker_spec.rb @@ -1,7 +1,7 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do let( :worker ) { described_class.new } - let( :import ){ build_stubbed :import, token_download: download_token, file: File.open(zip_file) } + let( :import ){ build_stubbed :import, token_download: download_token, file: zip_file } let( :workbench ){ import.workbench } let( :referential ){ import.referential } @@ -21,7 +21,7 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do let( :download_token ){ SecureRandom.urlsafe_base64 } - let( :upload_path ) { '/api/v1/netex_imports.json' } + let( :upload_path ) { api_v1_netex_imports_path(format: :json) } let( :entry_group_streams ) do entry_count.times.map{ |i| double( "entry group stream #{i}" ) } @@ -33,7 +33,7 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do end let( :zip_service ){ double("zip service") } - let( :zip_file ){ File.join(fixture_path, 'multiref.zip') } + let( :zip_file ){ open_fixture('multiref.zip') } let( :post_response_ok ){ response(status: 201, boody: "{}") } |
