diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /spec/models/integrations/google_play_spec.rb | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'spec/models/integrations/google_play_spec.rb')
-rw-r--r-- | spec/models/integrations/google_play_spec.rb | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/spec/models/integrations/google_play_spec.rb b/spec/models/integrations/google_play_spec.rb index 8349ac71bc9..a0bc73378d3 100644 --- a/spec/models/integrations/google_play_spec.rb +++ b/spec/models/integrations/google_play_spec.rb @@ -20,6 +20,8 @@ RSpec.describe Integrations::GooglePlay, feature_category: :mobile_devops do it { is_expected.to allow_value('a.a.a').for(:package_name) } it { is_expected.to allow_value('com.example').for(:package_name) } it { is_expected.not_to allow_value('com').for(:package_name) } + it { is_expected.to allow_value(true, false).for(:google_play_protected_refs) } + it { is_expected.not_to allow_value(nil).for(:google_play_protected_refs) } it { is_expected.not_to allow_value('com.example.my app').for(:package_name) } it { is_expected.not_to allow_value('1com.example.myapp').for(:package_name) } it { is_expected.not_to allow_value('com.1example.myapp').for(:package_name) } @@ -33,7 +35,7 @@ RSpec.describe Integrations::GooglePlay, feature_category: :mobile_devops do describe '#fields' do it 'returns custom fields' do expect(google_play_integration.fields.pluck(:name)).to match_array(%w[package_name service_account_key - service_account_key_file_name]) + service_account_key_file_name google_play_protected_refs]) end end @@ -67,9 +69,8 @@ RSpec.describe Integrations::GooglePlay, feature_category: :mobile_devops do describe '#ci_variables' do let(:google_play_integration) { build_stubbed(:google_play_integration) } - - it 'returns vars when the integration is activated' do - ci_vars = [ + let(:ci_vars) do + [ { key: 'SUPPLY_PACKAGE_NAME', value: google_play_integration.package_name, @@ -83,8 +84,36 @@ RSpec.describe Integrations::GooglePlay, feature_category: :mobile_devops do public: false } ] + end + + it 'returns the vars for protected branch' do + expect(google_play_integration.ci_variables(protected_ref: true)).to match_array(ci_vars) + end + + it "doesn't return vars for unproteced branch" do + expect(google_play_integration.ci_variables(protected_ref: false)).to be_empty + end + end + + describe '#initialize_properties' do + context 'when google_play_protected_refs is nil' do + let(:google_play_integration) { described_class.new(google_play_protected_refs: nil) } - expect(google_play_integration.ci_variables).to match_array(ci_vars) + it 'sets google_play_protected_refs to true' do + expect(google_play_integration.google_play_protected_refs).to be(true) + end + end + + context 'when google_play_protected_refs is false' do + let(:google_play_integration) { build(:google_play_integration, google_play_protected_refs: false) } + + it 'sets google_play_protected_refs to false' do + expect(google_play_integration.google_play_protected_refs).to be(false) + end + + it "returns vars for unprotected ref when google_play_protected_refs is false" do + expect(google_play_integration.ci_variables(protected_ref: false)).not_to be_empty + end end end end @@ -94,7 +123,7 @@ RSpec.describe Integrations::GooglePlay, feature_category: :mobile_devops do describe '#ci_variables' do it 'returns an empty array' do - expect(google_play_integration.ci_variables).to match_array([]) + expect(google_play_integration.ci_variables(protected_ref: true)).to be_empty end end end |