diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-04-20 14:00:15 +0000 |
---|---|---|
committer | Yorick Peterse - OOO until May 4th <yorickpeterse@gmail.com> | 2018-04-20 14:00:15 +0000 |
commit | 9ea2fc85a3387e7bbb10558b3f2302f05abe5b64 (patch) | |
tree | 3a56fa83b93423314915c65d6ae549c98d78cacc /spec/models | |
parent | 87e592dc0a81d94efac157dfd7382df4e5b2a223 (diff) | |
download | gitlab-ce-9ea2fc85a3387e7bbb10558b3f2302f05abe5b64.tar.gz |
Atomic internal ids for all models
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/deployment_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/milestone_spec.rb | 20 |
3 files changed, 36 insertions, 1 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index ac30cd27e0c..aee70bcfb29 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -16,6 +16,15 @@ describe Deployment do it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } + describe 'modules' do + it_behaves_like 'AtomicInternalId' do + let(:internal_id_attribute) { :iid } + let(:instance) { build(:deployment) } + let(:scope_attrs) { { project: instance.project } } + let(:usage) { :deployments } + end + end + describe 'after_create callbacks' do let(:environment) { create(:environment) } let(:store) { Gitlab::EtagCaching::Store.new } diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index f73f44ca0ad..becb146422e 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -17,11 +17,17 @@ describe MergeRequest do describe 'modules' do subject { described_class } - it { is_expected.to include_module(NonatomicInternalId) } it { is_expected.to include_module(Issuable) } it { is_expected.to include_module(Referable) } it { is_expected.to include_module(Sortable) } it { is_expected.to include_module(Taskable) } + + it_behaves_like 'AtomicInternalId' do + let(:internal_id_attribute) { :iid } + let(:instance) { build(:merge_request) } + let(:scope_attrs) { { project: instance.target_project } } + let(:usage) { :merge_requests } + end end describe 'validation' do diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index c7460981a32..4bb9717d33e 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -1,6 +1,26 @@ require 'spec_helper' describe Milestone do + describe 'modules' do + context 'with a project' do + it_behaves_like 'AtomicInternalId' do + let(:internal_id_attribute) { :iid } + let(:instance) { build(:milestone, project: build(:project), group: nil) } + let(:scope_attrs) { { project: instance.project } } + let(:usage) { :milestones } + end + end + + context 'with a group' do + it_behaves_like 'AtomicInternalId' do + let(:internal_id_attribute) { :iid } + let(:instance) { build(:milestone, project: nil, group: build(:group)) } + let(:scope_attrs) { { namespace: instance.group } } + let(:usage) { :milestones } + end + end + end + describe "Validation" do before do allow(subject).to receive(:set_iid).and_return(false) |