summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/concerns/confirm_email_warning_spec.rb10
-rw-r--r--spec/controllers/projects/repositories_controller_spec.rb8
-rw-r--r--spec/features/projects/branches/user_deletes_branch_spec.rb4
-rw-r--r--spec/models/ci/build_spec.rb18
-rw-r--r--spec/serializers/build_artifact_entity_spec.rb2
-rw-r--r--spec/serializers/build_details_entity_spec.rb17
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb4
-rw-r--r--spec/services/projects/after_import_service_spec.rb12
8 files changed, 51 insertions, 24 deletions
diff --git a/spec/controllers/concerns/confirm_email_warning_spec.rb b/spec/controllers/concerns/confirm_email_warning_spec.rb
index 56a6efab8ed..93e3423261c 100644
--- a/spec/controllers/concerns/confirm_email_warning_spec.rb
+++ b/spec/controllers/concerns/confirm_email_warning_spec.rb
@@ -5,7 +5,6 @@ require 'spec_helper'
describe ConfirmEmailWarning do
before do
stub_feature_flags(soft_email_confirmation: true)
- allow(User).to receive(:allow_unconfirmed_access_for).and_return 2.days
end
controller(ApplicationController) do
@@ -52,15 +51,6 @@ describe ConfirmEmailWarning do
context 'with an unconfirmed user' do
let(:user) { create(:user, confirmed_at: nil) }
- context 'when executing a peek request' do
- before do
- request.path = '/-/peek'
- get :index
- end
-
- it { is_expected.not_to set_confirm_warning_for(user.email) }
- end
-
context 'when executing a json request' do
before do
get :index, format: :json
diff --git a/spec/controllers/projects/repositories_controller_spec.rb b/spec/controllers/projects/repositories_controller_spec.rb
index 42dfdd3115c..d4a81f24d9c 100644
--- a/spec/controllers/projects/repositories_controller_spec.rb
+++ b/spec/controllers/projects/repositories_controller_spec.rb
@@ -88,6 +88,14 @@ describe Projects::RepositoriesController do
end
end
+ context "when the request format is HTML" do
+ it "renders 404" do
+ get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: "html"
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
describe 'caching' do
it 'sets appropriate caching headers' do
get_archive
diff --git a/spec/features/projects/branches/user_deletes_branch_spec.rb b/spec/features/projects/branches/user_deletes_branch_spec.rb
index 1f053b69646..ad63a75a149 100644
--- a/spec/features/projects/branches/user_deletes_branch_spec.rb
+++ b/spec/features/projects/branches/user_deletes_branch_spec.rb
@@ -4,7 +4,7 @@ require "spec_helper"
describe "User deletes branch", :js do
set(:user) { create(:user) }
- set(:project) { create(:project, :repository) }
+ let(:project) { create(:project, :repository) }
before do
project.add_developer(user)
@@ -20,6 +20,8 @@ describe "User deletes branch", :js do
accept_alert { find(".btn-remove").click }
end
+ wait_for_requests
+
expect(page).to have_css(".js-branch-improve\\/awesome", visible: :hidden)
end
end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 4f729f2546c..f0f6556deec 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -2338,14 +2338,24 @@ describe Ci::Build do
end
end
- describe '#has_expiring_artifacts?' do
+ describe '#has_expiring_archive_artifacts?' do
context 'when artifacts have expiration date set' do
before do
build.update(artifacts_expire_at: 1.day.from_now)
end
- it 'has expiring artifacts' do
- expect(build).to have_expiring_artifacts
+ context 'and job artifacts archive record exists' do
+ let!(:archive) { create(:ci_job_artifact, :archive, job: build) }
+
+ it 'has expiring artifacts' do
+ expect(build).to have_expiring_archive_artifacts
+ end
+ end
+
+ context 'and job artifacts archive record does not exist' do
+ it 'does not have expiring artifacts' do
+ expect(build).not_to have_expiring_archive_artifacts
+ end
end
end
@@ -2355,7 +2365,7 @@ describe Ci::Build do
end
it 'does not have expiring artifacts' do
- expect(build).not_to have_expiring_artifacts
+ expect(build).not_to have_expiring_archive_artifacts
end
end
end
diff --git a/spec/serializers/build_artifact_entity_spec.rb b/spec/serializers/build_artifact_entity_spec.rb
index 09fe094fff1..c8995cbc5a2 100644
--- a/spec/serializers/build_artifact_entity_spec.rb
+++ b/spec/serializers/build_artifact_entity_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe BuildArtifactEntity do
- let(:job) { create(:ci_build, name: 'test:job', artifacts_expire_at: 1.hour.from_now) }
+ let(:job) { create(:ci_build, :artifacts, name: 'test:job', artifacts_expire_at: 1.hour.from_now) }
let(:entity) do
described_class.new(job, request: double)
diff --git a/spec/serializers/build_details_entity_spec.rb b/spec/serializers/build_details_entity_spec.rb
index 91c5fd6bf2c..fc05989df16 100644
--- a/spec/serializers/build_details_entity_spec.rb
+++ b/spec/serializers/build_details_entity_spec.rb
@@ -176,5 +176,22 @@ describe BuildDetailsEntity do
expect(subject[:reports].first[:file_type]).to eq('codequality')
end
end
+
+ context 'when the build has no archive type artifacts' do
+ let!(:report) { create(:ci_job_artifact, :codequality, job: build) }
+
+ it 'does not expose any artifact actions path' do
+ expect(subject[:artifact].keys).not_to include(:download_path, :browse_path, :keep_path)
+ end
+ end
+
+ context 'when the build has archive type artifacts' do
+ let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: 7.days.from_now) }
+ let!(:report) { create(:ci_job_artifact, :codequality, job: build) }
+
+ it 'exposes artifact details' do
+ expect(subject[:artifact].keys).to include(:download_path, :browse_path, :keep_path, :expire_at, :expired)
+ end
+ end
end
end
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index 8158277ffbc..84b0e487ee7 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -159,7 +159,7 @@ describe PipelineSerializer do
it 'verifies number of queries', :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject }
- expected_queries = Gitlab.ee? ? 42 : 39
+ expected_queries = Gitlab.ee? ? 43 : 40
expect(recorded.count).to be_within(2).of(expected_queries)
expect(recorded.cached_count).to eq(0)
@@ -180,7 +180,7 @@ describe PipelineSerializer do
# pipeline. With the same ref this check is cached but if refs are
# different then there is an extra query per ref
# https://gitlab.com/gitlab-org/gitlab-foss/issues/46368
- expected_queries = Gitlab.ee? ? 45 : 42
+ expected_queries = Gitlab.ee? ? 46 : 43
expect(recorded.count).to be_within(2).of(expected_queries)
expect(recorded.cached_count).to eq(0)
diff --git a/spec/services/projects/after_import_service_spec.rb b/spec/services/projects/after_import_service_spec.rb
index 4f74a779cd5..82f654cea10 100644
--- a/spec/services/projects/after_import_service_spec.rb
+++ b/spec/services/projects/after_import_service_spec.rb
@@ -76,12 +76,12 @@ describe Projects::AfterImportService do
let(:exception) { GRPC::DeadlineExceeded.new }
before do
- call_count = 0
-
- allow(repository).to receive(:delete_all_refs_except).and_wrap_original do |original_method, *args|
- call_count += 1
- call_count > 1 ? original_method.call(*args) : raise(exception)
- end
+ expect(repository)
+ .to receive(:delete_all_refs_except)
+ .and_raise(exception)
+ expect(repository)
+ .to receive(:delete_all_refs_except)
+ .and_call_original
subject.execute
end