Fix specs

This commit is contained in:
Kamil Trzcinski 2016-05-16 23:40:40 -05:00
parent 0a6c3494b0
commit ac6992ba68
3 changed files with 10 additions and 2 deletions

View File

@ -787,6 +787,8 @@ describe Project, models: true do
describe '#container_registry_repository' do
let(:project) { create(:empty_project) }
before { stub_container_registry_config(enabled: true) }
subject { project.container_registry_repository }
it { is_expected.to_not be_nil }

View File

@ -50,6 +50,11 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
end
shared_examples 'an unauthorized' do
it { is_expected.to include(http_status: 401) }
it { is_expected.to_not include(:token) }
end
shared_examples 'a forbidden' do
it { is_expected.to include(http_status: 403) }
it { is_expected.to_not include(:token) }
@ -116,7 +121,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{ offline_token: true }
end
it_behaves_like 'a forbidden'
it_behaves_like 'an unauthorized'
end
context 'allow to pull and push images' do
@ -179,7 +184,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{ offline_token: true }
end
it_behaves_like 'a forbidden'
it_behaves_like 'an unauthorized'
end
context 'for invalid scope' do

View File

@ -27,6 +27,7 @@ module StubGitlabCalls
def stub_container_registry_config(registry_settings)
allow(Gitlab.config.registry).to receive_messages(registry_settings)
allow(Auth::ContainerRegistryAuthenticationService).to receive(:full_access_token).and_return('token')
end
def stub_container_registry_tags(*tags)