diff options
Diffstat (limited to 'spec/support/shared_examples/analytics/cycle_analytics')
-rw-r--r-- | spec/support/shared_examples/analytics/cycle_analytics/parentable_examples.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/support/shared_examples/analytics/cycle_analytics/parentable_examples.rb b/spec/support/shared_examples/analytics/cycle_analytics/parentable_examples.rb new file mode 100644 index 00000000000..5fd0e685c67 --- /dev/null +++ b/spec/support/shared_examples/analytics/cycle_analytics/parentable_examples.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'value stream analytics namespace models' do + let(:factory_name) { nil } + + context 'when ProjectNamespace is given' do + it 'is valid' do + project_namespace = create(:project_namespace) + model = build(factory_name, namespace: project_namespace) + + expect(model).to be_valid + expect(model.save).to be(true) + expect(model.namespace).to eq(project_namespace) + end + end + + context 'when Namespace is given' do + it 'fails' do + namespace = create(:namespace) + model = build(factory_name, namespace: namespace) + + expect(model).to be_invalid + + error_message = s_('CycleAnalytics|the assigned object is not supported') + expect(model.errors.messages_for(:namespace)).to eq([error_message]) + end + end +end |