Commit 04dc80db authored by Shinya Maeda's avatar Shinya Maeda

Fix spec

parent 0af2ab18
...@@ -14,7 +14,7 @@ module Ci ...@@ -14,7 +14,7 @@ module Ci
belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline' belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline'
belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule' belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule'
has_internal_id :iid, scope: :project, presence: false, init: -> do |s| has_internal_id :iid, scope: :project, presence: false, init: ->(s) do
s&.project&.pipelines&.maximum(:iid) || s&.project&.pipelines.count s&.project&.pipelines&.maximum(:iid) || s&.project&.pipelines.count
end end
......
...@@ -63,7 +63,7 @@ future GitLab releases.** ...@@ -63,7 +63,7 @@ future GitLab releases.**
| **CI_RUNNER_REVISION** | all | 10.6 | GitLab Runner revision that is executing the current job | | **CI_RUNNER_REVISION** | all | 10.6 | GitLab Runner revision that is executing the current job |
| **CI_RUNNER_EXECUTABLE_ARCH** | all | 10.6 | The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor) | | **CI_RUNNER_EXECUTABLE_ARCH** | all | 10.6 | The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor) |
| **CI_PIPELINE_ID** | 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally | | **CI_PIPELINE_ID** | 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally |
| **CI_PIPELINE_IID** | 10.8 | all | The unique id of the current pipeline scoped to project | | **CI_PIPELINE_IID** | 11.0 | all | The unique id of the current pipeline scoped to project |
| **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] | | **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] |
| **CI_PIPELINE_SOURCE** | 10.0 | all | Indicates how the pipeline was triggered. Possible options are: `push`, `web`, `trigger`, `schedule`, `api`, and `pipeline`. For pipelines created before GitLab 9.5, this will show as `unknown` | | **CI_PIPELINE_SOURCE** | 10.0 | all | Indicates how the pipeline was triggered. Possible options are: `push`, `web`, `trigger`, `schedule`, `api`, and `pipeline`. For pipelines created before GitLab 9.5, this will show as `unknown` |
| **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run | | **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run |
......
...@@ -41,6 +41,7 @@ describe Ci::Pipeline, :mailer do ...@@ -41,6 +41,7 @@ describe Ci::Pipeline, :mailer do
let(:instance) { build(:ci_pipeline) } let(:instance) { build(:ci_pipeline) }
let(:scope_attrs) { { project: instance.project } } let(:scope_attrs) { { project: instance.project } }
let(:usage) { :ci_pipelines } let(:usage) { :ci_pipelines }
let(:validate_presence) { false }
end end
end end
......
require 'spec_helper' require 'spec_helper'
shared_examples_for 'AtomicInternalId' do shared_examples_for 'AtomicInternalId' do
let(:validate_presence) { true }
describe '.has_internal_id' do describe '.has_internal_id' do
describe 'Module inclusion' do describe 'Module inclusion' do
subject { described_class } subject { described_class }
...@@ -15,7 +17,14 @@ shared_examples_for 'AtomicInternalId' do ...@@ -15,7 +17,14 @@ shared_examples_for 'AtomicInternalId' do
allow(InternalId).to receive(:generate_next).and_return(nil) allow(InternalId).to receive(:generate_next).and_return(nil)
end end
it { is_expected.to validate_presence_of(internal_id_attribute) } it 'checks presence' do
if validate_presence
is_expected.to validate_presence_of(internal_id_attribute)
else
is_expected.not_to validate_presence_of(internal_id_attribute)
end
end
it { is_expected.to validate_numericality_of(internal_id_attribute) } it { is_expected.to validate_numericality_of(internal_id_attribute) }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment