diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-05-17 02:07:49 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-05-17 02:07:49 +0300 |
commit | 04933fd572f60909e8dbd14bd9366e96dc40806e (patch) | |
tree | 12339989cb98d87172accb24b7c10b2d9dde39d5 | |
parent | 8572a6b2d469009f01533b1003e73952bd2b6850 (diff) |
Use container registry config stub
-rw-r--r-- | spec/features/container_registry_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 16 | ||||
-rw-r--r-- | spec/services/auth/container_registry_authentication_service_spec.rb | 9 | ||||
-rw-r--r-- | spec/services/projects/destroy_service_spec.rb | 8 |
4 files changed, 6 insertions, 34 deletions
diff --git a/spec/features/container_registry_spec.rb b/spec/features/container_registry_spec.rb index 271ef883d13..53b4f027117 100644 --- a/spec/features/container_registry_spec.rb +++ b/spec/features/container_registry_spec.rb @@ -5,17 +5,12 @@ describe "Container Registry" do let(:repository) { project.container_registry_repository } let(:tag_name) { 'latest' } let(:tags) { [tag_name] } - let(:registry_settings) do - { - enabled: true - } - end before do login_as(:user) project.team << [@user, :developer] stub_container_registry_tags(*tags) - allow(Gitlab.config.registry).to receive_messages(registry_settings) + stub_container_registry_config(enabled: true) allow(Auth::ContainerRegistryAuthenticationService).to receive(:full_access_token).and_return('token') end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 262f4122220..e434d267896 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -797,7 +797,7 @@ describe Project, models: true do subject { project.container_registry_repository_url } - before { allow(Gitlab.config.registry).to receive_messages(registry_settings) } + before { stub_container_registry_config(**registry_settings) } context 'for enabled registry' do let(:registry_settings) do @@ -826,14 +826,8 @@ describe Project, models: true do subject { project.has_container_registry_tags? } - before { allow(Gitlab.config.registry).to receive_messages(registry_settings) } - context 'for enabled registry' do - let(:registry_settings) do - { - enabled: true - } - end + before { stub_container_registry_config(enabled: true) } context 'with tags' do before { stub_container_registry_tags('test', 'test2') } @@ -849,11 +843,7 @@ describe Project, models: true do end context 'for disabled registry' do - let(:registry_settings) do - { - enabled: false - } - end + before { stub_container_registry_config(enabled: false) } it { is_expected.to be_falsey } end diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb index 143d992b6e4..d90e2982c4f 100644 --- a/spec/services/auth/container_registry_authentication_service_spec.rb +++ b/spec/services/auth/container_registry_authentication_service_spec.rb @@ -5,19 +5,12 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do let(:current_user) { nil } let(:current_params) { {} } let(:rsa_key) { OpenSSL::PKey::RSA.generate(512) } - let(:registry_settings) do - { - enabled: true, - issuer: 'rspec', - key: nil - } - end let(:payload) { JWT.decode(subject[:token], rsa_key).first } subject { described_class.new(current_project, current_user, current_params).execute } before do - allow(Gitlab.config.registry).to receive_messages(registry_settings) + stub_container_registry_config(enabled: true, issuer: 'rspec', key: nil) allow_any_instance_of(JSONWebToken::RSAToken).to receive(:key).and_return(rsa_key) end diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 45b78ccf136..29341c5e57e 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -29,14 +29,8 @@ describe Projects::DestroyService, services: true do end context 'container registry' do - let(:registry_settings) do - { - enabled: true - } - end - before do - allow(Gitlab.config.registry).to receive_messages(registry_settings) + stub_container_registry_config(enabled: true) stub_container_registry_tags('tag') end |