diff options
| author | Xinhui | 2016-09-27 17:16:05 +0200 |
|---|---|---|
| committer | Xinhui | 2016-09-27 17:53:51 +0200 |
| commit | a2ac534ec3e9bbb34a392dff5ed1a11b7e270461 (patch) | |
| tree | ca584d03ce72ee15dad4c5bbefd3709212738042 /spec | |
| parent | 2d6fa24975ac5a3d28e657a96a781db1cb17d56c (diff) | |
| download | chouette-core-a2ac534ec3e9bbb34a392dff5ed1a11b7e270461.tar.bz2 | |
LineReferentialSync status aasm
Refs #1707
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/line_referential_sync_spec.rb | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/spec/models/line_referential_sync_spec.rb b/spec/models/line_referential_sync_spec.rb index bcd58f0c9..dd68b099d 100644 --- a/spec/models/line_referential_sync_spec.rb +++ b/spec/models/line_referential_sync_spec.rb @@ -8,12 +8,38 @@ RSpec.describe LineReferentialSync, :type => :model do 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 + pending = create(:line_referential_sync) + multiple = build(:line_referential_sync, line_referential: pending.line_referential) + expect(multiple).to be_invalid end it 'should call LineReferentialSyncWorker on create' do expect(LineReferentialSyncWorker).to receive(:perform_async) create(:line_referential_sync).run_callbacks(:commit) end + + describe 'states' do + let(:line_referential_sync) { create(:line_referential_sync) } + + it 'should initialize with new state' do + expect(line_referential_sync.new?).to be_truthy + end + + it 'should pending state change' do + expect(line_referential_sync).to receive(:log_pending) + line_referential_sync.run + end + + it 'should successful state change' do + expect(line_referential_sync).to receive(:log_successful) + line_referential_sync.run + line_referential_sync.successful + end + + it 'should failed state change' do + expect(line_referential_sync).to receive(:log_failed) + line_referential_sync.run + line_referential_sync.failed + end + end end |
