Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/dot_gitlab_ci/rules_spec.rb26
-rw-r--r--spec/features/projects/branches/new_branch_ref_dropdown_spec.rb5
-rw-r--r--spec/lib/backup/manager_spec.rb23
-rw-r--r--spec/lib/gitlab/pagination/keyset/order_spec.rb28
-rw-r--r--spec/models/ci/catalog/resource_spec.rb4
-rw-r--r--spec/models/ci/catalog/resources/version_spec.rb48
-rw-r--r--spec/models/release_spec.rb63
-rw-r--r--spec/tooling/quality/test_level_spec.rb4
-rw-r--r--spec/views/devise/shared/_signup_box.html.haml_spec.rb1
9 files changed, 139 insertions, 63 deletions
diff --git a/spec/dot_gitlab_ci/rules_spec.rb b/spec/dot_gitlab_ci/rules_spec.rb
new file mode 100644
index 00000000000..88e98fe95ba
--- /dev/null
+++ b/spec/dot_gitlab_ci/rules_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+RSpec.describe '.gitlab/ci/rules.gitlab-ci.yml', feature_category: :tooling do
+ config = YAML.load_file(
+ File.expand_path('../../.gitlab/ci/rules.gitlab-ci.yml', __dir__),
+ aliases: true
+ ).freeze
+
+ context 'with changes' do
+ config.each do |name, definition|
+ next unless definition.is_a?(Hash) && definition['rules']
+
+ definition['rules'].each do |rule|
+ next unless rule.is_a?(Hash) && rule['changes']
+
+ # See this for why we want to always have if
+ # https://docs.gitlab.com/ee/development/pipelines/internals.html#avoid-force_gitlab_ci
+ it "#{name} has corresponding if" do
+ expect(rule).to include('if')
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb
index c1b468a3746..2559aedf0d2 100644
--- a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb
+++ b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb
@@ -69,6 +69,11 @@ RSpec.describe 'New Branch Ref Dropdown', :js, feature_category: :source_code_ma
expect(toggle).not_to have_content(non_existing_ref)
end
+ it 'passes accessibility tests' do
+ click_button 'master'
+ expect(page).to be_axe_clean.within('.ref-selector')
+ end
+
def item(ref_name)
find('li', text: ref_name, match: :prefer_exact)
end
diff --git a/spec/lib/backup/manager_spec.rb b/spec/lib/backup/manager_spec.rb
index 1aba245cab3..7a8cffe8529 100644
--- a/spec/lib/backup/manager_spec.rb
+++ b/spec/lib/backup/manager_spec.rb
@@ -608,6 +608,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
expect(Kernel).not_to have_received(:system).with(*pack_tar_cmdline)
expect(subject.send(:backup_information).to_h).to include(
+ backup_id: backup_id,
backup_created_at: backup_time.localtime,
db_version: be_a(String),
gitlab_version: Gitlab::VERSION,
@@ -1035,6 +1036,28 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
expect(FileUtils).to have_received(:rm_rf).with(File.join(Gitlab.config.backup.path, 'tmp'))
end
+ context 'backup information mismatches' do
+ let(:backup_id) { 'pineapple' }
+ let(:backup_information) do
+ {
+ backup_id: backup_id,
+ backup_created_at: Time.zone.parse('2019-01-01'),
+ gitlab_version: gitlab_version
+ }
+ end
+
+ it 'unpacks the BACKUP specified file but uses the backup information backup ID' do
+ expect(task1).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'lfs.tar.gz'), backup_id)
+ expect(task2).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'pages.tar.gz'), backup_id)
+
+ subject.restore
+
+ expect(Kernel).to have_received(:system).with(*tar_cmdline)
+ expect(FileUtils).to have_received(:rm_rf).with(File.join(Gitlab.config.backup.path, 'backup_information.yml'))
+ expect(FileUtils).to have_received(:rm_rf).with(File.join(Gitlab.config.backup.path, 'tmp'))
+ end
+ end
+
context 'tar fails' do
before do
expect(Kernel).to receive(:system).with(*tar_cmdline).and_return(false)
diff --git a/spec/lib/gitlab/pagination/keyset/order_spec.rb b/spec/lib/gitlab/pagination/keyset/order_spec.rb
index 52d2688c06e..0d7de1596e6 100644
--- a/spec/lib/gitlab/pagination/keyset/order_spec.rb
+++ b/spec/lib/gitlab/pagination/keyset/order_spec.rb
@@ -635,6 +635,34 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do
end
end
end
+
+ context 'when the cursor attribute is an array' do
+ let(:model) { Group.new(traversal_ids: [1, 2]) }
+ let(:scope) { Group.order(traversal_ids: :asc) }
+ let(:order) do
+ described_class.build(
+ [
+ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new(
+ attribute_name: 'traversal_ids',
+ order_expression: Group.arel_table['traversal_ids'].asc,
+ nullable: :not_nullable,
+ distinct: true
+ )
+ ])
+ end
+
+ describe '#cursor_attributes_for_node' do
+ subject { order.cursor_attributes_for_node(model) }
+
+ it { is_expected.to eq({ traversal_ids: [1, 2] }.with_indifferent_access) }
+ end
+
+ describe '#apply_cursor_conditions' do
+ subject(:sql) { order.apply_cursor_conditions(scope, { 'traversal_ids' => [1, 2] }).to_sql }
+
+ it { is_expected.to include('"namespaces"."traversal_ids" > \'{1,2}\')') }
+ end
+ end
end
end
diff --git a/spec/models/ci/catalog/resource_spec.rb b/spec/models/ci/catalog/resource_spec.rb
index 0faf43e9ee3..70adfddec15 100644
--- a/spec/models/ci/catalog/resource_spec.rb
+++ b/spec/models/ci/catalog/resource_spec.rb
@@ -227,7 +227,7 @@ RSpec.describe Ci::Catalog::Resource, feature_category: :pipeline_composition do
end
end
- describe 'synchronizing denormalized columns with `projects` table', :sidekiq_inline do
+ describe 'synchronizing denormalized columns with `projects` table using SyncEvents processing', :sidekiq_inline do
let_it_be_with_reload(:project) { create(:project, name: 'Test project', description: 'Test description') }
context 'when the catalog resource is created' do
@@ -272,7 +272,7 @@ RSpec.describe Ci::Catalog::Resource, feature_category: :pipeline_composition do
end
end
- describe '#update_latest_released_at! triggered in model callbacks' do
+ describe 'updating latest_released_at using model callbacks' do
let_it_be(:project) { create(:project) }
let_it_be(:resource) { create(:ci_catalog_resource, project: project) }
diff --git a/spec/models/ci/catalog/resources/version_spec.rb b/spec/models/ci/catalog/resources/version_spec.rb
index bacaa6355fe..c91b2c71241 100644
--- a/spec/models/ci/catalog/resources/version_spec.rb
+++ b/spec/models/ci/catalog/resources/version_spec.rb
@@ -119,29 +119,6 @@ RSpec.describe Ci::Catalog::Resources::Version, type: :model, feature_category:
end
end
- describe '#update_catalog_resource' do
- let_it_be(:release) { create(:release, project: project1, tag: 'v1') }
- let(:version) { build(:ci_catalog_resource_version, catalog_resource: resource1, release: release) }
-
- context 'when a version is created' do
- it 'calls update_catalog_resource' do
- expect(version).to receive(:update_catalog_resource).once
-
- version.save!
- end
- end
-
- context 'when a version is destroyed' do
- it 'calls update_catalog_resource' do
- version.save!
-
- expect(version).to receive(:update_catalog_resource).once
-
- version.destroy!
- end
- end
- end
-
describe '#name' do
it 'is equivalent to release.tag' do
v1_0.release.update!(name: 'Release v1.0')
@@ -172,4 +149,29 @@ RSpec.describe Ci::Catalog::Resources::Version, type: :model, feature_category:
expect(v1_1.readme.data).to include('Readme v1.1')
end
end
+
+ describe 'synchronizing released_at with `releases` table using model callbacks' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:resource) { create(:ci_catalog_resource, project: project) }
+
+ let_it_be_with_reload(:release) do
+ create(:release, :with_catalog_resource_version, project: project, tag: 'v1', released_at: '2023-01-01T00:00:00Z')
+ end
+
+ let(:version) { release.catalog_resource_version }
+
+ context 'when the version is created' do
+ it 'updates released_at to match the release' do
+ expect(version.read_attribute(:released_at)).to eq(release.released_at)
+ end
+ end
+
+ context 'when release.released_at is updated' do
+ it 'updates released_at to match the release' do
+ release.update!(released_at: '2023-02-02T00:00:00Z')
+
+ expect(version.read_attribute(:released_at)).to eq(release.released_at)
+ end
+ end
+ end
end
diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb
index 4a4cb1ae46a..1f3af7d46bc 100644
--- a/spec/models/release_spec.rb
+++ b/spec/models/release_spec.rb
@@ -104,42 +104,6 @@ RSpec.describe Release, feature_category: :release_orchestration do
end
end
- describe '#update_catalog_resource' do
- let_it_be(:project) { create(:project) }
- let_it_be_with_refind(:release) { create(:release, project: project, author: user) }
-
- context 'when the project is a catalog resource' do
- before_all do
- create(:ci_catalog_resource, project: project)
- end
-
- context 'when released_at is updated' do
- it 'calls update_catalog_resource' do
- expect(release).to receive(:update_catalog_resource).once
-
- release.update!(released_at: release.released_at + 1.day)
- end
- end
-
- context 'when the release is destroyed' do
- it 'calls update_catalog_resource' do
- expect(release).to receive(:update_catalog_resource).once
-
- release.destroy!
- end
- end
- end
-
- context 'when the project is not a catalog resource' do
- it 'does not call update_catalog_resource' do
- expect(release).not_to receive(:update_catalog_resource)
-
- release.update!(released_at: release.released_at + 1.day)
- release.destroy!
- end
- end
- end
-
describe 'tagged' do
# We only test for empty string since there's a not null constraint at the database level
it 'does not return the tagless release' do
@@ -402,4 +366,31 @@ RSpec.describe Release, feature_category: :release_orchestration do
it { expect(release.milestone_titles).to eq("#{milestone_1.title}, #{milestone_2.title}") }
end
+
+ describe 'updating catalog resource version' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:resource) { create(:ci_catalog_resource, project: project) }
+
+ let_it_be_with_reload(:release) do
+ create(:release, :with_catalog_resource_version, project: project, tag: 'v1', released_at: '2023-01-01T00:00:00Z')
+ end
+
+ let(:version) { release.catalog_resource_version }
+
+ context 'when released_at has changed' do
+ it 'calls sync_with_release! on the catalog resource version' do
+ expect(version).to receive(:sync_with_release!).once
+
+ release.update!(released_at: '2023-02-02T00:00:00Z')
+ end
+ end
+
+ context 'when released_at has not changed' do
+ it 'does not call sync_with_release! on the catalog resource version' do
+ expect(version).not_to receive(:sync_with_release!)
+
+ release.update!(released_at: '2023-01-01T00:00:00Z')
+ end
+ end
+ end
end
diff --git a/spec/tooling/quality/test_level_spec.rb b/spec/tooling/quality/test_level_spec.rb
index b6c469929ea..dfbe5ce283b 100644
--- a/spec/tooling/quality/test_level_spec.rb
+++ b/spec/tooling/quality/test_level_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe Quality::TestLevel, feature_category: :tooling do
context 'when level is unit' do
it 'returns a pattern' do
expect(subject.pattern(:unit))
- .to eq("spec/{bin,channels,components,config,contracts,db,dependencies,elastic,elastic_integration,experiments,factories,finders,frontend,graphql,haml_lint,helpers,initializers,keeps,lib,metrics_server,models,policies,presenters,rack_servers,replicators,routing,rubocop,scripts,serializers,services,sidekiq,sidekiq_cluster,spam,support_specs,tasks,uploaders,validators,views,workers,tooling}{,/**/}*_spec.rb")
+ .to eq("spec/{bin,channels,components,config,contracts,db,dependencies,elastic,elastic_integration,experiments,factories,finders,frontend,graphql,haml_lint,helpers,initializers,keeps,lib,metrics_server,models,policies,presenters,rack_servers,replicators,routing,rubocop,scripts,serializers,services,sidekiq,sidekiq_cluster,spam,support_specs,tasks,uploaders,validators,views,workers,tooling,dot_gitlab_ci}{,/**/}*_spec.rb")
end
end
@@ -121,7 +121,7 @@ RSpec.describe Quality::TestLevel, feature_category: :tooling do
context 'when level is unit' do
it 'returns a regexp' do
expect(subject.regexp(:unit))
- .to eq(%r{spec/(bin|channels|components|config|contracts|db|dependencies|elastic|elastic_integration|experiments|factories|finders|frontend|graphql|haml_lint|helpers|initializers|keeps|lib|metrics_server|models|policies|presenters|rack_servers|replicators|routing|rubocop|scripts|serializers|services|sidekiq|sidekiq_cluster|spam|support_specs|tasks|uploaders|validators|views|workers|tooling)/})
+ .to eq(%r{spec/(bin|channels|components|config|contracts|db|dependencies|elastic|elastic_integration|experiments|factories|finders|frontend|graphql|haml_lint|helpers|initializers|keeps|lib|metrics_server|models|policies|presenters|rack_servers|replicators|routing|rubocop|scripts|serializers|services|sidekiq|sidekiq_cluster|spam|support_specs|tasks|uploaders|validators|views|workers|tooling|dot_gitlab_ci)/})
end
end
diff --git a/spec/views/devise/shared/_signup_box.html.haml_spec.rb b/spec/views/devise/shared/_signup_box.html.haml_spec.rb
index 13beb87c383..1b2324c9893 100644
--- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb
+++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb
@@ -26,6 +26,7 @@ RSpec.describe 'devise/shared/_signup_box' do
allow(view).to receive(:terms_path).and_return(terms_path)
allow(view).to receive(:button_text).and_return(button_text)
allow(view).to receive(:signup_username_data_attributes).and_return({})
+ allow(view).to receive(:tracking_label).and_return('')
stub_template 'devise/shared/_error_messages.html.haml' => ''
end