diff options
Diffstat (limited to 'spec/services/google_cloud/create_service_accounts_service_spec.rb')
-rw-r--r-- | spec/services/google_cloud/create_service_accounts_service_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/services/google_cloud/create_service_accounts_service_spec.rb b/spec/services/google_cloud/create_service_accounts_service_spec.rb index 53d21df713a..3f500e7c235 100644 --- a/spec/services/google_cloud/create_service_accounts_service_spec.rb +++ b/spec/services/google_cloud/create_service_accounts_service_spec.rb @@ -26,6 +26,8 @@ RSpec.describe GoogleCloud::CreateServiceAccountsService do end it 'creates unprotected vars', :aggregate_failures do + allow(ProtectedBranch).to receive(:protected?).and_return(false) + project = create(:project) service = described_class.new( @@ -45,5 +47,28 @@ RSpec.describe GoogleCloud::CreateServiceAccountsService do expect(project.variables.second.protected).to eq(false) expect(project.variables.third.protected).to eq(false) end + + it 'creates protected vars', :aggregate_failures do + allow(ProtectedBranch).to receive(:protected?).and_return(true) + + project = create(:project) + + service = described_class.new( + project, + nil, + google_oauth2_token: 'mock-token', + gcp_project_id: 'mock-gcp-project-id', + environment_name: '*' + ) + + response = service.execute + + expect(response.status).to eq(:success) + expect(response.message).to eq('Service account generated successfully') + expect(project.variables.count).to eq(3) + expect(project.variables.first.protected).to eq(true) + expect(project.variables.second.protected).to eq(true) + expect(project.variables.third.protected).to eq(true) + end end end |