From 8275b56d541d8201762d9ae978f5f193203712e4 Mon Sep 17 00:00:00 2001 From: Ryan Lue Date: Mon, 28 Jan 2019 14:08:33 +0800 Subject: [PATCH] Wrap ChecksImport spec examples in a single describe block (for clearer spec report output) --- .../checks_import_examples.rb | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/spec/models/application_model/checks_import_examples.rb b/spec/models/application_model/checks_import_examples.rb index b3ff67eb6..4ef072e07 100644 --- a/spec/models/application_model/checks_import_examples.rb +++ b/spec/models/application_model/checks_import_examples.rb @@ -1,42 +1,44 @@ RSpec.shared_examples 'ApplicationModel::ChecksImport' do - subject { build(described_class.name.underscore, id: unused_id) } - let(:unused_id) { (described_class.pluck(:id).max || 1) * 2 } + describe '#id (for referential integrity during OTRS/Zendesk import)' do + subject { build(described_class.name.underscore, id: unused_id) } + let(:unused_id) { (described_class.pluck(:id).max || 1) * 2 } - context 'when Setting.get("system_init_done") is false (regardless of import_mode)' do - before { Setting.set('system_init_done', false) } + context 'when Setting.get("system_init_done") is false (regardless of import_mode)' do + before { Setting.set('system_init_done', false) } - it 'allows explicit setting of #id attribute' do - expect { subject.save }.not_to change { subject.id } - end - end - - context 'when Setting.get("system_init_done") is true' do - before { Setting.set('system_init_done', true) } - - context 'and Setting.get("import_mode") is false' do - before { Setting.set('import_mode', false) } - - it 'prevents explicit setting of #id attribute' do - expect { subject.save }.to change { subject.id } + it 'allows explicit setting of #id attribute' do + expect { subject.save }.not_to change { subject.id } end end - context 'and Setting.get("import_mode") is true' do - before { Setting.set('import_mode', true) } + context 'when Setting.get("system_init_done") is true' do + before { Setting.set('system_init_done', true) } - shared_examples 'importable classes' do - it 'allows explicit setting of #id attribute' do - expect { subject.save }.not_to change { subject.id } - end - end + context 'and Setting.get("import_mode") is false' do + before { Setting.set('import_mode', false) } - shared_examples 'non-importable classes' do it 'prevents explicit setting of #id attribute' do expect { subject.save }.to change { subject.id } end end - include_examples described_class.importable? ? 'importable classes' : 'non-importable classes' + context 'and Setting.get("import_mode") is true' do + before { Setting.set('import_mode', true) } + + shared_examples 'importable classes' do + it 'allows explicit setting of #id attribute' do + expect { subject.save }.not_to change { subject.id } + end + end + + shared_examples 'non-importable classes' do + it 'prevents explicit setting of #id attribute' do + expect { subject.save }.to change { subject.id } + end + end + + include_examples described_class.importable? ? 'importable classes' : 'non-importable classes' + end end end end