diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-01-11 07:14:08 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-01-11 07:14:08 +0100 |
commit | cf95756aacdce842a5a2375bdb56c75a1b6abba3 (patch) | |
tree | eaaeb35bcbd18f14057af7c09a9ded774c66aa20 /spec/services/check_gcp_project_billing_service_spec.rb | |
parent | 0b294fc2bb336dbf564ca7508f4a6b8e0e17682a (diff) | |
download | gitlab-ce-cf95756aacdce842a5a2375bdb56c75a1b6abba3.tar.gz |
Refactor GCP redirect test suite
Diffstat (limited to 'spec/services/check_gcp_project_billing_service_spec.rb')
-rw-r--r-- | spec/services/check_gcp_project_billing_service_spec.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/spec/services/check_gcp_project_billing_service_spec.rb b/spec/services/check_gcp_project_billing_service_spec.rb index 02cfe0a96d8..3e68d906e71 100644 --- a/spec/services/check_gcp_project_billing_service_spec.rb +++ b/spec/services/check_gcp_project_billing_service_spec.rb @@ -1,29 +1,30 @@ require 'spec_helper' describe CheckGcpProjectBillingService do + include GoogleApi::CloudPlatformHelpers + let(:service) { described_class.new } - let(:projects) { [double(name: 'first_project', project_id: 'first_project-1234'), double(name: 'second_project', project_id: 'second_project-1234')] } + let(:project_id) { 'test-project-1234' } describe '#execute' do before do - expect_any_instance_of(GoogleApi::CloudPlatform::Client) - .to receive(:projects_list).and_return(projects) - - allow_any_instance_of(GoogleApi::CloudPlatform::Client) - .to receive_message_chain(:projects_get_billing_info, :billing_enabled) - .and_return(project_billing_enabled) + stub_cloud_platform_projects_list(project_id: project_id) end subject { service.execute('bogustoken') } context 'google account has a billing enabled gcp project' do - let(:project_billing_enabled) { true } + before do + stub_cloud_platform_projects_get_billing_info(project_id, true) + end - it { is_expected.to eq(projects) } + it { is_expected.to all(satisfy { |project| project.project_id == project_id }) } end context 'google account does not have a billing enabled gcp project' do - let(:project_billing_enabled) { false } + before do + stub_cloud_platform_projects_get_billing_info(project_id, false) + end it { is_expected.to eq([]) } end |