diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-11-20 14:48:18 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-11-27 15:41:46 +0300 |
commit | fff7754186202cfcdeaa0962c28e5d43ddd705b7 (patch) | |
tree | bba449dc8386ce9a6ebd951d6a1291b1671cb7b5 /spec/models/pool_repository_spec.rb | |
parent | 397fd09ac4ba7353580f4d3a88c80105d51ff47a (diff) |
Rename the Repository table to PoolRepository
To separate the different kinds of repositories we have at GitLab this
table will be renamed to pool_repositories. A project can, for now at
least, be member of none, or one of these. The table will get additional
columns in a later merge request where more logic is implemented for the
model.
Further included is a small refactor of logic around hashing ids for the
disk_path, mainly to ensure a previous implementation is reusable.
The disk_path for the pool_repositories table no longer has a NOT NULL
constraint, but given the hashing of the ID requires the DB to assign
the record an ID, an after_create hook is used to update the value.
A related MR is:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23143, adding
tables for 'normal' repositories and wiki_repositories.
Diffstat (limited to 'spec/models/pool_repository_spec.rb')
-rw-r--r-- | spec/models/pool_repository_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/pool_repository_spec.rb b/spec/models/pool_repository_spec.rb new file mode 100644 index 00000000000..6c904710fb5 --- /dev/null +++ b/spec/models/pool_repository_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe PoolRepository do + describe 'associations' do + it { is_expected.to belong_to(:shard) } + it { is_expected.to have_many(:member_projects) } + end + + describe 'validations' do + let!(:pool_repository) { create(:pool_repository) } + + it { is_expected.to validate_presence_of(:shard) } + end + + describe '#disk_path' do + it 'sets the hashed disk_path' do + pool = create(:pool_repository) + + elements = File.split(pool.disk_path) + + expect(elements).to all( match(/\d{2,}/) ) + end + end +end |