From 3a1a12b3833e28323347b1021a845a4d85beb563 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Mon, 1 Apr 2019 11:55:08 +1300 Subject: Fix cert_manager_spec to not modify String Also break up long string to be readable --- .../clusters/applications/cert_manager_spec.rb | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb index fefeb8fd75f..af7eadfc74c 100644 --- a/spec/models/clusters/applications/cert_manager_spec.rb +++ b/spec/models/clusters/applications/cert_manager_spec.rb @@ -11,7 +11,27 @@ describe Clusters::Applications::CertManager do include_examples 'cluster application initial status specs' describe '#install_command' do - let(:cluster_issuer_file) { { "cluster_issuer.yaml": "---\napiVersion: certmanager.k8s.io/v1alpha1\nkind: ClusterIssuer\nmetadata:\n name: letsencrypt-prod\nspec:\n acme:\n server: https://acme-v02.api.letsencrypt.org/directory\n email: admin@example.com\n privateKeySecretRef:\n name: letsencrypt-prod\n http01: {}\n" } } + let(:cert_email) { 'admin@example.com' } + + let(:cluster_issuer_file) do + file_contents = <<~EOF + --- + apiVersion: certmanager.k8s.io/v1alpha1 + kind: ClusterIssuer + metadata: + name: letsencrypt-prod + spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: #{cert_email} + privateKeySecretRef: + name: letsencrypt-prod + http01: {} + EOF + + { "cluster_issuer.yaml": file_contents } + end + subject { cert_manager.install_command } it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) } @@ -26,9 +46,10 @@ describe Clusters::Applications::CertManager do end context 'for a specific user' do + let(:cert_email) { 'abc@xyz.com' } + before do - cert_manager.email = 'abc@xyz.com' - cluster_issuer_file[:'cluster_issuer.yaml'].gsub! 'admin@example.com', 'abc@xyz.com' + cert_manager.email = cert_email end it 'should use his/her email to register issuer with certificate provider' do -- cgit v1.2.3