diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-31 13:27:05 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-31 13:27:05 +0300 |
commit | 60cdd2bcc894cf9cce4892570bf6a146dc45e536 (patch) | |
tree | f2564895a487658eed25f73bd67a53b7c96ea99d /spec/models/container_repository_spec.rb | |
parent | a7466af3a6f31311d64654631a2ea2740c42b88e (diff) |
Add specs for container repository factory method
Diffstat (limited to 'spec/models/container_repository_spec.rb')
-rw-r--r-- | spec/models/container_repository_spec.rb | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb index 92dccf76d71..884eac43719 100644 --- a/spec/models/container_repository_spec.rb +++ b/spec/models/container_repository_spec.rb @@ -85,28 +85,63 @@ describe ContainerRepository do end end - describe '#from_repository_path' do + describe '.create_from_path!' do + let(:repository) do + described_class.create_from_path!(ContainerRegistry::Path.new(path)) + end + + let(:repository_path) { ContainerRegistry::Path.new(path) } + context 'when received multi-level repository path' do - let(:repository) do - described_class.from_repository_path('group/test/some/image/name') - end + let(:path) { project.full_path + '/some/image' } - pending 'fabricates object within a correct project' do + it 'fabricates repository assigned to a correct project' do expect(repository.project).to eq project end - pending 'it fabricates project with a correct name' do - expect(repository.name).to eq 'some/image/name' + it 'fabricates repository with a correct name' do + expect(repository.name).to eq 'some/image' end end - context 'when path contains too many nodes' do + context 'when path is too long' do + let(:path) do + project.full_path + '/a/b/c/d/e/f/g/h/i/j/k/l/n/o/p/s/t/u/x/y/z' + end + + it 'does not create repository and raises error' do + expect { repository }.to raise_error( + ContainerRegistry::Path::InvalidRegistryPathError) + end end context 'when received multi-level repository with nested groups' do + let(:group) { create(:group, :nested, name: 'nested') } + let(:path) { project.full_path + '/some/image' } + + it 'fabricates repository assigned to a correct project' do + expect(repository.project).to eq project + end + + it 'fabricates repository with a correct name' do + expect(repository.name).to eq 'some/image' + end + + it 'has path including a nested group' do + expect(repository.path).to include 'nested/test/some/image' + end end context 'when received root repository path' do + let(:path) { project.full_path } + + it 'fabricates repository assigned to a correct project' do + expect(repository.project).to eq project + end + + it 'fabricates repository with an empty name' do + expect(repository.name).to be_empty + end end end end |