summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-03-12 16:51:38 +0100
committerAndreas Brandl <abrandl@gitlab.com>2018-03-16 13:35:25 +0100
commit3fa2eb4e10885c9b3a01f0f9f244c9fbb26cf6a1 (patch)
tree3cda29db8773fdc2c818b42523f4808d9336ac2c /spec
parent0360b0928aada1db7635e6c6bc40f0f571b72c30 (diff)
downloadgitlab-ce-3fa2eb4e10885c9b3a01f0f9f244c9fbb26cf6a1.tar.gz
Refactor, extract class and improve comments.
Diffstat (limited to 'spec')
-rw-r--r--spec/models/concerns/issuable_spec.rb2
-rw-r--r--spec/models/internal_id_spec.rb9
2 files changed, 5 insertions, 6 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 4b217df2e8f..f8874d14e3f 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -34,7 +34,7 @@ describe Issuable do
subject { build(:issue) }
before do
- allow(subject).to receive(:set_iid).and_return(false)
+ allow(InternalId).to receive(:generate_next).and_return(nil)
end
it { is_expected.to validate_presence_of(:project) }
diff --git a/spec/models/internal_id_spec.rb b/spec/models/internal_id_spec.rb
index 5971d8f47a6..6d5a12c9d06 100644
--- a/spec/models/internal_id_spec.rb
+++ b/spec/models/internal_id_spec.rb
@@ -4,12 +4,11 @@ describe InternalId do
let(:project) { create(:project) }
let(:usage) { :issues }
let(:issue) { build(:issue, project: project) }
- let(:scope) { :project }
- let(:init) { ->(s) { project.issues.size } }
+ let(:scope) { { project: project } }
+ let(:init) { ->(s) { s.project.issues.size } }
context 'validations' do
it { is_expected.to validate_presence_of(:usage) }
- it { is_expected.to validate_presence_of(:project_id) }
end
describe '.generate_next' do
@@ -31,8 +30,8 @@ describe InternalId do
context 'with existing issues' do
before do
- rand(10).times { create(:issue, project: project) }
- InternalId.delete_all
+ rand(1..10).times { create(:issue, project: project) }
+ described_class.delete_all
end
it 'calculates last_value values automatically' do