2019-09-30 05:06:31 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-02 16:53:14 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ContainerRepositoryEntity do
|
|
|
|
let(:entity) do
|
|
|
|
described_class.new(repository, request: request)
|
|
|
|
end
|
|
|
|
|
|
|
|
set(:project) { create(:project) }
|
|
|
|
set(:user) { create(:user) }
|
|
|
|
set(:repository) { create(:container_repository, project: project) }
|
|
|
|
|
|
|
|
let(:request) { double('request') }
|
|
|
|
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_container_registry_config(enabled: true)
|
|
|
|
allow(request).to receive(:project).and_return(project)
|
|
|
|
allow(request).to receive(:current_user).and_return(user)
|
|
|
|
end
|
|
|
|
|
2019-01-16 07:09:29 -05:00
|
|
|
it 'exposes required informations' do
|
2017-10-02 16:53:14 -04:00
|
|
|
expect(subject).to include(:id, :path, :location, :tags_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user can manage repositories' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'exposes destroy_path' do
|
|
|
|
expect(subject).to include(:destroy_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user cannot manage repositories' do
|
|
|
|
it 'does not expose destroy_path' do
|
|
|
|
expect(subject).not_to include(:destroy_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|