aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorXinhui2016-09-27 17:16:05 +0200
committerXinhui2016-09-27 17:53:51 +0200
commita2ac534ec3e9bbb34a392dff5ed1a11b7e270461 (patch)
treeca584d03ce72ee15dad4c5bbefd3709212738042 /spec
parent2d6fa24975ac5a3d28e657a96a781db1cb17d56c (diff)
downloadchouette-core-a2ac534ec3e9bbb34a392dff5ed1a11b7e270461.tar.bz2
LineReferentialSync status aasm
Refs #1707
Diffstat (limited to 'spec')
-rw-r--r--spec/models/line_referential_sync_spec.rb30
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