diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories/line_referential_syncs.rb | 1 | ||||
| -rw-r--r-- | spec/factories/line_referentials.rb | 1 | ||||
| -rw-r--r-- | spec/models/line_referential_sync_spec.rb | 11 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 5 | ||||
| -rw-r--r-- | spec/workers/line_referential_sync_worker_spec.rb | 17 |
5 files changed, 33 insertions, 2 deletions
diff --git a/spec/factories/line_referential_syncs.rb b/spec/factories/line_referential_syncs.rb index 8f0d1e6fb..27b7a9fb9 100644 --- a/spec/factories/line_referential_syncs.rb +++ b/spec/factories/line_referential_syncs.rb @@ -1,4 +1,5 @@ FactoryGirl.define do factory :line_referential_sync do + association :line_referential, :factory => :line_referential end end diff --git a/spec/factories/line_referentials.rb b/spec/factories/line_referentials.rb index 47d0727c5..cfce1399f 100644 --- a/spec/factories/line_referentials.rb +++ b/spec/factories/line_referentials.rb @@ -1,6 +1,5 @@ FactoryGirl.define do factory :line_referential do sequence(:name) { |n| "Line Referential #{n}" } - association :line_referential_sync, :factory => :line_referential_sync end end diff --git a/spec/models/line_referential_sync_spec.rb b/spec/models/line_referential_sync_spec.rb index 0cab0389c..f5c738792 100644 --- a/spec/models/line_referential_sync_spec.rb +++ b/spec/models/line_referential_sync_spec.rb @@ -4,5 +4,16 @@ RSpec.describe LineReferentialSync, :type => :model do it 'should have a valid factory' do expect(FactoryGirl.build(:line_referential_sync)).to be_valid end + it { is_expected.to belong_to(:line_referential) } + + it 'should validate multiple sync instance' do + lref_sync = build(:line_referential_sync, line_referential: create(:line_referential_sync).line_referential) + expect(lref_sync).to be_invalid + end + + it 'should call LineReferentialSyncWorker on create' do + expect(LineReferentialSyncWorker).to receive(:perform_async) + create :line_referential_sync + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 93b148496..dd062bc84 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ require 'will_paginate/array' require 'fakeweb' require 'webmock/rspec' require 'simplecov' +require 'sidekiq/testing' +Sidekiq::Testing.fake! if ENV['JOB_NAME'] require 'simplecov-rcov' @@ -43,6 +45,9 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} ActiveRecord::Migration.maintain_test_schema! RSpec.configure do |config| + config.before(:each) do + Sidekiq::Worker.clear_all + end #Capybara.exact = true Capybara.javascript_driver = :poltergeist diff --git a/spec/workers/line_referential_sync_worker_spec.rb b/spec/workers/line_referential_sync_worker_spec.rb index 0a1172e41..f1a63c9db 100644 --- a/spec/workers/line_referential_sync_worker_spec.rb +++ b/spec/workers/line_referential_sync_worker_spec.rb @@ -1,4 +1,19 @@ require 'rails_helper' RSpec.describe LineReferentialSyncWorker, type: :worker do - pending "add some examples to (or delete) #{__FILE__}" + let!(:line_referential_sync) { create :line_referential_sync } + + it 'should call codifline synchronize on worker perform' do + expect(Stif::CodifLineSynchronization).to receive(:synchronize) + LineReferentialSyncWorker.new.perform(line_referential_sync.id) + end + + it 'should update line_referential_sync started_at on worker perform' do + LineReferentialSyncWorker.new.perform(line_referential_sync.id) + expect(line_referential_sync.reload.started_at).not_to be_nil + end + + it 'should update line_referential_sync ended_at on worker perform success' do + LineReferentialSyncWorker.new.perform(line_referential_sync.id) + expect(line_referential_sync.reload.started_at).not_to be_nil + end end |
