summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb40
-rw-r--r--spec/helpers/time_helper_spec.rb38
-rw-r--r--spec/javascripts/datetime_utility_spec.js25
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb65
-rw-r--r--spec/lib/gitlab/ci/status/build/factory_spec.rb49
-rw-r--r--spec/lib/gitlab/ci/status/build/scheduled_spec.rb58
-rw-r--r--spec/lib/gitlab/ci/status/pipeline/factory_spec.rb48
-rw-r--r--spec/lib/gitlab/ci/status/scheduled_spec.rb27
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb17
-rw-r--r--spec/lib/gitlab/favicon_spec.rb1
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml1
12 files changed, 46 insertions, 324 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index 5b09e4a082c..fd11cb31a2a 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -632,46 +632,6 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- describe 'POST unschedule' do
- before do
- project.add_developer(user)
-
- create(:protected_branch, :developers_can_merge,
- name: 'master', project: project)
-
- sign_in(user)
-
- post_unschedule
- end
-
- context 'when job is scheduled' do
- let(:job) { create(:ci_build, :scheduled, pipeline: pipeline) }
-
- it 'redirects to the unscheduled job page' do
- expect(response).to have_gitlab_http_status(:found)
- expect(response).to redirect_to(namespace_project_job_path(id: job.id))
- end
-
- it 'transits to manual' do
- expect(job.reload).to be_manual
- end
- end
-
- context 'when job is not scheduled' do
- let(:job) { create(:ci_build, pipeline: pipeline) }
-
- it 'renders unprocessable_entity' do
- expect(response).to have_gitlab_http_status(:unprocessable_entity)
- end
- end
-
- def post_unschedule
- post :unschedule, namespace_id: project.namespace,
- project_id: project,
- id: job.id
- end
- end
-
describe 'POST cancel_all' do
before do
project.add_developer(user)
diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb
index cc310766433..0b371d69ecf 100644
--- a/spec/helpers/time_helper_spec.rb
+++ b/spec/helpers/time_helper_spec.rb
@@ -20,35 +20,17 @@ describe TimeHelper do
end
describe "#duration_in_numbers" do
- using RSpec::Parameterized::TableSyntax
-
- context "without passing allow_overflow" do
- where(:duration, :formatted_string) do
- 0 | "00:00"
- 1.second | "00:01"
- 42.seconds | "00:42"
- 2.minutes + 1.second | "02:01"
- 3.hours + 2.minutes + 1.second | "03:02:01"
- 30.hours | "06:00:00"
- end
-
- with_them do
- it { expect(duration_in_numbers(duration)).to eq formatted_string }
- end
- end
-
- context "with allow_overflow = true" do
- where(:duration, :formatted_string) do
- 0 | "00:00:00"
- 1.second | "00:00:01"
- 42.seconds | "00:00:42"
- 2.minutes + 1.second | "00:02:01"
- 3.hours + 2.minutes + 1.second | "03:02:01"
- 30.hours | "30:00:00"
- end
+ it "returns minutes and seconds" do
+ durations_and_expectations = {
+ 100 => "01:40",
+ 121 => "02:01",
+ 3721 => "01:02:01",
+ 0 => "00:00",
+ 42 => "00:42"
+ }
- with_them do
- it { expect(duration_in_numbers(duration, true)).to eq formatted_string }
+ durations_and_expectations.each do |duration, expectation|
+ expect(duration_in_numbers(duration)).to eq(expectation)
end
end
end
diff --git a/spec/javascripts/datetime_utility_spec.js b/spec/javascripts/datetime_utility_spec.js
index 6c3e73f134e..492171684dc 100644
--- a/spec/javascripts/datetime_utility_spec.js
+++ b/spec/javascripts/datetime_utility_spec.js
@@ -6,7 +6,9 @@ describe('Date time utils', () => {
const date = new Date();
date.setFullYear(date.getFullYear() - 1);
- expect(datetimeUtility.timeFor(date)).toBe('Past due');
+ expect(
+ datetimeUtility.timeFor(date),
+ ).toBe('Past due');
});
it('returns remaining time when in the future', () => {
@@ -17,7 +19,9 @@ describe('Date time utils', () => {
// short of a full year, timeFor will return '11 months remaining'
date.setDate(date.getDate() + 1);
- expect(datetimeUtility.timeFor(date)).toBe('1 year remaining');
+ expect(
+ datetimeUtility.timeFor(date),
+ ).toBe('1 year remaining');
});
});
@@ -164,20 +168,3 @@ describe('getTimeframeWindowFrom', () => {
});
});
});
-
-describe('formatTime', () => {
- const expectedTimestamps = [
- [0, '00:00:00'],
- [1000, '00:00:01'],
- [42000, '00:00:42'],
- [121000, '00:02:01'],
- [10921000, '03:02:01'],
- [108000000, '30:00:00'],
- ];
-
- expectedTimestamps.forEach(([milliseconds, expectedTimestamp]) => {
- it(`formats ${milliseconds}ms as ${expectedTimestamp}`, () => {
- expect(datetimeUtility.formatTime(milliseconds)).toBe(expectedTimestamp);
- });
- });
-});
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index d745c4ca2ad..2c9758401b7 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -39,16 +39,6 @@ describe Gitlab::Ci::Config::Entry::Job do
expect(entry.errors).to include "job name can't be blank"
end
end
-
- context 'when delayed job' do
- context 'when start_in is specified' do
- let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } }
-
- it 'returns error about invalid type' do
- expect(entry).to be_valid
- end
- end
- end
end
context 'when entry value is not correct' do
@@ -139,43 +129,6 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
end
-
- context 'when delayed job' do
- context 'when start_in is specified' do
- let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } }
-
- it 'returns error about invalid type' do
- expect(entry).to be_valid
- end
- end
-
- context 'when start_in is empty' do
- let(:config) { { when: 'delayed', start_in: nil } }
-
- it 'returns error about invalid type' do
- expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in should be a duration'
- end
- end
-
- context 'when start_in is not formateed ad a duration' do
- let(:config) { { when: 'delayed', start_in: 'test' } }
-
- it 'returns error about invalid type' do
- expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in should be a duration'
- end
- end
- end
-
- context 'when start_in specified without delayed specification' do
- let(:config) { { start_in: '1 day' } }
-
- it 'returns error about invalid type' do
- expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in must be blank'
- end
- end
end
end
@@ -285,24 +238,6 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
- describe '#delayed?' do
- context 'when job is a delayed' do
- let(:config) { { script: 'deploy', when: 'delayed' } }
-
- it 'is a delayed' do
- expect(entry).to be_delayed
- end
- end
-
- context 'when job is not a delayed' do
- let(:config) { { script: 'deploy' } }
-
- it 'is not a delayed' do
- expect(entry).not_to be_delayed
- end
- end
- end
-
describe '#ignored?' do
context 'when job is a manual action' do
context 'when it is not specified if job is allowed to fail' do
diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb
index aa53ecd5967..8b92088902b 100644
--- a/spec/lib/gitlab/ci/status/build/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb
@@ -319,53 +319,4 @@ describe Gitlab::Ci::Status::Build::Factory do
end
end
end
-
- context 'when build is a delayed action' do
- let(:build) { create(:ci_build, :scheduled) }
-
- it 'matches correct core status' do
- expect(factory.core_status).to be_a Gitlab::Ci::Status::Scheduled
- end
-
- it 'matches correct extended statuses' do
- expect(factory.extended_statuses)
- .to eq [Gitlab::Ci::Status::Build::Scheduled,
- Gitlab::Ci::Status::Build::Unschedule,
- Gitlab::Ci::Status::Build::Action]
- end
-
- it 'fabricates action detailed status' do
- expect(status).to be_a Gitlab::Ci::Status::Build::Action
- end
-
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'scheduled'
- expect(status.group).to eq 'scheduled'
- expect(status.icon).to eq 'status_scheduled'
- expect(status.favicon).to eq 'favicon_status_scheduled'
- expect(status.illustration).to include(:image, :size, :title, :content)
- expect(status.label).to include 'unschedule action'
- expect(status).to have_details
- expect(status.action_path).to include 'unschedule'
- end
-
- context 'when user has ability to play action' do
- it 'fabricates status that has action' do
- expect(status).to have_action
- end
- end
-
- context 'when user does not have ability to play action' do
- before do
- allow(build.project).to receive(:empty_repo?).and_return(false)
-
- create(:protected_branch, :no_one_can_push,
- name: build.ref, project: build.project)
- end
-
- it 'fabricates status that has no action' do
- expect(status).not_to have_action
- end
- end
- end
end
diff --git a/spec/lib/gitlab/ci/status/build/scheduled_spec.rb b/spec/lib/gitlab/ci/status/build/scheduled_spec.rb
deleted file mode 100644
index 3098a17c50d..00000000000
--- a/spec/lib/gitlab/ci/status/build/scheduled_spec.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::Ci::Status::Build::Scheduled do
- let(:user) { create(:user) }
- let(:project) { create(:project, :stubbed_repository) }
- let(:build) { create(:ci_build, :scheduled, project: project) }
- let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
-
- subject { described_class.new(status) }
-
- describe '#illustration' do
- it { expect(subject.illustration).to include(:image, :size, :title) }
- end
-
- describe '#status_tooltip' do
- context 'when scheduled_at is not expired' do
- let(:build) { create(:ci_build, scheduled_at: 1.minute.since, project: project) }
-
- it 'shows execute_in of the scheduled job' do
- Timecop.freeze do
- expect(subject.status_tooltip).to include('00:01:00')
- end
- end
- end
-
- context 'when scheduled_at is expired' do
- let(:build) { create(:ci_build, :expired_scheduled, project: project) }
-
- it 'shows 00:00:00' do
- Timecop.freeze do
- expect(subject.status_tooltip).to include('00:00:00')
- end
- end
- end
- end
-
- describe '.matches?' do
- subject { described_class.matches?(build, user) }
-
- context 'when build is scheduled and scheduled_at is present' do
- let(:build) { create(:ci_build, :expired_scheduled, project: project) }
-
- it { is_expected.to be_truthy }
- end
-
- context 'when build is scheduled' do
- let(:build) { create(:ci_build, status: :scheduled, project: project) }
-
- it { is_expected.to be_falsy }
- end
-
- context 'when scheduled_at is present' do
- let(:build) { create(:ci_build, scheduled_at: 1.minute.since, project: project) }
-
- it { is_expected.to be_falsy }
- end
- end
-end
diff --git a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
index 694d4ce160a..defb3fdc0df 100644
--- a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
@@ -11,7 +11,8 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end
context 'when pipeline has a core status' do
- HasStatus::AVAILABLE_STATUSES.each do |simple_status|
+ (HasStatus::AVAILABLE_STATUSES - [HasStatus::BLOCKED_STATUS])
+ .each do |simple_status|
context "when core status is #{simple_status}" do
let(:pipeline) { create(:ci_pipeline, status: simple_status) }
@@ -23,24 +24,12 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(factory.core_status).to be_a expected_status
end
- if simple_status == 'manual'
- it 'matches a correct extended statuses' do
- expect(factory.extended_statuses)
- .to eq [Gitlab::Ci::Status::Pipeline::Blocked]
- end
- elsif simple_status == 'scheduled'
- it 'matches a correct extended statuses' do
- expect(factory.extended_statuses)
- .to eq [Gitlab::Ci::Status::Pipeline::Scheduled]
- end
- else
- it 'does not match extended statuses' do
- expect(factory.extended_statuses).to be_empty
- end
-
- it "fabricates a core status #{simple_status}" do
- expect(status).to be_a expected_status
- end
+ it 'does not match extended statuses' do
+ expect(factory.extended_statuses).to be_empty
+ end
+
+ it "fabricates a core status #{simple_status}" do
+ expect(status).to be_a expected_status
end
it 'extends core status with common pipeline methods' do
@@ -51,6 +40,27 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end
end
end
+
+ context "when core status is manual" do
+ let(:pipeline) { create(:ci_pipeline, status: :manual) }
+
+ it "matches manual core status" do
+ expect(factory.core_status)
+ .to be_a Gitlab::Ci::Status::Manual
+ end
+
+ it 'matches a correct extended statuses' do
+ expect(factory.extended_statuses)
+ .to eq [Gitlab::Ci::Status::Pipeline::Blocked]
+ end
+
+ it 'extends core status with common pipeline methods' do
+ expect(status).to have_details
+ expect(status).not_to have_action
+ expect(status.details_path)
+ .to include "pipelines/#{pipeline.id}"
+ end
+ end
end
context 'when pipeline has warnings' do
diff --git a/spec/lib/gitlab/ci/status/scheduled_spec.rb b/spec/lib/gitlab/ci/status/scheduled_spec.rb
deleted file mode 100644
index c35a6f43d5d..00000000000
--- a/spec/lib/gitlab/ci/status/scheduled_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::Ci::Status::Scheduled do
- subject do
- described_class.new(double('subject'), double('user'))
- end
-
- describe '#text' do
- it { expect(subject.text).to eq 'scheduled' }
- end
-
- describe '#label' do
- it { expect(subject.label).to eq 'scheduled' }
- end
-
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_scheduled' }
- end
-
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_scheduled' }
- end
-
- describe '#group' do
- it { expect(subject.group).to eq 'scheduled' }
- end
-end
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index d75c473eb66..a2d429fa859 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -121,21 +121,6 @@ module Gitlab
end
end
end
-
- describe 'delayed job entry' do
- context 'when delayed is defined' do
- let(:config) do
- YAML.dump(rspec: { script: 'rollout 10%',
- when: 'delayed',
- start_in: '1 day' })
- end
-
- it 'has the attributes' do
- expect(subject[:when]).to eq 'delayed'
- expect(subject[:options][:start_in]).to eq '1 day'
- end
- end
- end
end
describe '#stages_attributes' do
@@ -1275,7 +1260,7 @@ module Gitlab
config = YAML.dump({ rspec: { script: "test", when: 1 } })
expect do
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec when should be on_success, on_failure, always, manual or delayed")
+ end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec when should be on_success, on_failure, always or manual")
end
it "returns errors if job artifacts:name is not an a string" do
diff --git a/spec/lib/gitlab/favicon_spec.rb b/spec/lib/gitlab/favicon_spec.rb
index 49a423191bb..68abcb3520a 100644
--- a/spec/lib/gitlab/favicon_spec.rb
+++ b/spec/lib/gitlab/favicon_spec.rb
@@ -58,7 +58,6 @@ RSpec.describe Gitlab::Favicon, :request_store do
favicon_status_not_found
favicon_status_pending
favicon_status_running
- favicon_status_scheduled
favicon_status_skipped
favicon_status_success
favicon_status_warning
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index fe167033941..ec2bdbe22e1 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -117,7 +117,6 @@ pipelines:
- retryable_builds
- cancelable_statuses
- manual_actions
-- scheduled_actions
- artifacts
- pipeline_schedule
- merge_requests
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index 1d59cff7ba8..e9f1be172b0 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -300,7 +300,6 @@ CommitStatus:
- retried
- protected
- failure_reason
-- scheduled_at
Ci::Variable:
- id
- project_id