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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-17 06:10:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-17 06:10:45 +0300
commit158548078665a076f33ed161967f030653586f24 (patch)
tree15f969bc601269d1ff183a70a14998eaad9b8a9e /spec
parent541b6cf72fe31f266b1dac57c0da76967fecf38e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/channels/issues_channel_spec.rb36
-rw-r--r--spec/migrations/backfill_nuget_temporary_packages_to_processing_status_spec.rb34
-rw-r--r--spec/services/issues/update_service_spec.rb2
-rw-r--r--spec/services/projects/update_statistics_service_spec.rb46
4 files changed, 75 insertions, 43 deletions
diff --git a/spec/channels/issues_channel_spec.rb b/spec/channels/issues_channel_spec.rb
deleted file mode 100644
index 4c860402f03..00000000000
--- a/spec/channels/issues_channel_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe IssuesChannel do
- let_it_be(:issue) { create(:issue) }
-
- it 'rejects when project path is invalid' do
- subscribe(project_path: 'invalid_project_path', iid: issue.iid)
-
- expect(subscription).to be_rejected
- end
-
- it 'rejects when iid is invalid' do
- subscribe(project_path: issue.project.full_path, iid: non_existing_record_iid)
-
- expect(subscription).to be_rejected
- end
-
- it 'rejects when the user does not have access' do
- stub_action_cable_connection current_user: nil
-
- subscribe(project_path: issue.project.full_path, iid: issue.iid)
-
- expect(subscription).to be_rejected
- end
-
- it 'subscribes to a stream when the user has access' do
- stub_action_cable_connection current_user: issue.author
-
- subscribe(project_path: issue.project.full_path, iid: issue.iid)
-
- expect(subscription).to be_confirmed
- expect(subscription).to have_stream_for(issue)
- end
-end
diff --git a/spec/migrations/backfill_nuget_temporary_packages_to_processing_status_spec.rb b/spec/migrations/backfill_nuget_temporary_packages_to_processing_status_spec.rb
new file mode 100644
index 00000000000..574020e52d5
--- /dev/null
+++ b/spec/migrations/backfill_nuget_temporary_packages_to_processing_status_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require_migration!
+
+RSpec.describe BackfillNugetTemporaryPackagesToProcessingStatus, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:packages) { table(:packages_packages) }
+
+ before do
+ namespace = namespaces.create!(id: 123, name: 'test_namespace', path: 'test_namespace')
+ project = projects.create!(id: 111, name: 'sample_project', path: 'sample_project', namespace_id: namespace.id)
+
+ packages.create!(name: 'NuGet.Temporary.Package', version: '0.1.1', package_type: 4, status: 0, project_id: project.id)
+ packages.create!(name: 'foo', version: '0.1.1', package_type: 4, status: 0, project_id: project.id)
+ packages.create!(name: 'NuGet.Temporary.Package', version: '0.1.1', package_type: 4, status: 2, project_id: project.id)
+ packages.create!(name: 'NuGet.Temporary.Package', version: '0.1.1', package_type: 1, status: 2, project_id: project.id)
+ packages.create!(name: 'NuGet.Temporary.Package', version: '0.1.1', package_type: 1, status: 0, project_id: project.id)
+ end
+
+ it 'updates the applicable packages to processing status', :aggregate_failures do
+ expect(packages.where(status: 0).count).to eq(3)
+ expect(packages.where(status: 2).count).to eq(2)
+ expect(packages.where(name: 'NuGet.Temporary.Package', package_type: 4, status: 0).count).to eq(1)
+
+ migrate!
+
+ expect(packages.where(status: 0).count).to eq(2)
+ expect(packages.where(status: 2).count).to eq(3)
+ expect(packages.where(name: 'NuGet.Temporary.Package', package_type: 4, status: 0).count).to eq(0)
+ end
+end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 2bb62f49bd0..7490ad5b2b3 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -1024,10 +1024,8 @@ RSpec.describe Issues::UpdateService, :mailer do
stub_feature_flags(broadcast_issue_updates: feature_flag_enabled)
if should_broadcast
- expect(IssuesChannel).to receive(:broadcast_to).with(issue, event: 'updated')
expect(GraphqlTriggers).to receive(:issuable_assignees_updated).with(issue)
else
- expect(IssuesChannel).not_to receive(:broadcast_to)
expect(GraphqlTriggers).not_to receive(:issuable_assignees_updated).with(issue)
end
diff --git a/spec/services/projects/update_statistics_service_spec.rb b/spec/services/projects/update_statistics_service_spec.rb
index 92e97186be3..6987185b549 100644
--- a/spec/services/projects/update_statistics_service_spec.rb
+++ b/spec/services/projects/update_statistics_service_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe Projects::UpdateStatisticsService do
+ using RSpec::Parameterized::TableSyntax
+
let(:service) { described_class.new(project, nil, statistics: statistics)}
let(:statistics) { %w(repository_size) }
@@ -18,12 +20,46 @@ RSpec.describe Projects::UpdateStatisticsService do
end
context 'with an existing project' do
- let(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
+
+ where(:statistics, :method_caches) do
+ [] | %i(size commit_count)
+ ['repository_size'] | [:size]
+ [:repository_size] | [:size]
+ [:lfs_objects_size] | nil
+ [:commit_count] | [:commit_count] # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
+ [:repository_size, :commit_count] | %i(size commit_count)
+ [:repository_size, :commit_count, :lfs_objects_size] | %i(size commit_count)
+ end
+
+ with_them do
+ it 'refreshes the project statistics' do
+ expect(project.statistics).to receive(:refresh!).with(only: statistics.map(&:to_sym)).and_call_original
+
+ service.execute
+ end
+
+ it 'invalidates the method caches after a refresh' do
+ expect(project.wiki.repository).not_to receive(:expire_method_caches)
+
+ if method_caches.present?
+ expect(project.repository).to receive(:expire_method_caches).with(method_caches).and_call_original
+ else
+ expect(project.repository).not_to receive(:expire_method_caches)
+ end
+
+ service.execute
+ end
+ end
+ end
+
+ context 'with an existing project with a Wiki' do
+ let(:project) { create(:project, :repository, :wiki_enabled) }
+ let(:statistics) { [:wiki_size] }
- it 'refreshes the project statistics' do
- expect_any_instance_of(ProjectStatistics).to receive(:refresh!)
- .with(only: statistics.map(&:to_sym))
- .and_call_original
+ it 'invalidates and refreshes Wiki size' do
+ expect(project.statistics).to receive(:refresh!).with(only: statistics).and_call_original
+ expect(project.wiki.repository).to receive(:expire_method_caches).with(%i(size)).and_call_original
service.execute
end