diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-02-06 14:05:21 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-02-06 14:25:33 +0300 |
commit | d204ec3d37f9fa422876072402f57028231ee2f4 (patch) | |
tree | 1beb6c6d4a6df2f59ad98924cb0a7c69e0cfeeea /spec/support | |
parent | e72f24d27be911ffce943929b7ca2f6df7051083 (diff) |
Refactor specs to run shared parts only when used
All applications except for Jupyter have the same #set_initial_status,
so create a new shared example which we include in all application specs
except for juptyer_spec. Juptyer specs already have specs for it's
version of #set_initial_status
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/models/cluster_application_initial_status.rb | 29 | ||||
-rw-r--r-- | spec/support/shared_examples/models/cluster_application_status_shared_examples.rb | 24 |
2 files changed, 29 insertions, 24 deletions
diff --git a/spec/support/shared_examples/models/cluster_application_initial_status.rb b/spec/support/shared_examples/models/cluster_application_initial_status.rb new file mode 100644 index 00000000000..9775d87953c --- /dev/null +++ b/spec/support/shared_examples/models/cluster_application_initial_status.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +shared_examples 'cluster application initial status specs' do + describe '#status' do + let(:cluster) { create(:cluster, :provided_by_gcp) } + + subject { described_class.new(cluster: cluster) } + + context 'when application helm is scheduled' do + before do + create(:clusters_applications_helm, :scheduled, cluster: cluster) + end + + it 'defaults to :not_installable' do + expect(subject.status_name).to be(:not_installable) + end + end + + context 'when application is scheduled' do + before do + create(:clusters_applications_helm, :installed, cluster: cluster) + end + + it 'sets a default status' do + expect(subject.status_name).to be(:installable) + end + end + end +end diff --git a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb index af6147bed39..554f2e747bc 100644 --- a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb +++ b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb @@ -7,30 +7,6 @@ shared_examples 'cluster application status specs' do |application_name| it 'sets a default status' do expect(subject.status_name).to be(:not_installable) end - - context 'when application helm is scheduled' do - before do - create(:clusters_applications_helm, :scheduled, cluster: cluster) - end - - it 'defaults to :not_installable' do - expect(subject.status_name).to be(:not_installable) - end - end - - context 'when application is scheduled' do - before do - create(:clusters_applications_helm, :installed, cluster: cluster) - - if described_class == Clusters::Applications::Jupyter - create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1', cluster: cluster) - end - end - - it 'sets a default status' do - expect(subject.status_name).to be(:installable) - end - end end describe 'status state machine' do |