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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-22 15:14:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-22 15:14:34 +0300
commit26fa51816ab94df9c2f3db8c93da4d57f7bd6fc4 (patch)
tree3b29671cb4bc910500d8c7db4e2694b4c012387e /spec/workers
parent6b0293c14dce817f72310127dd38562313321b1b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/releases/publish_event_worker_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/workers/releases/publish_event_worker_spec.rb b/spec/workers/releases/publish_event_worker_spec.rb
new file mode 100644
index 00000000000..86dd09a756f
--- /dev/null
+++ b/spec/workers/releases/publish_event_worker_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Releases::PublishEventWorker, feature_category: :release_evidence do
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be_with_reload(:release) { create(:release, project: project, released_at: Time.current) }
+
+ before do
+ allow(Gitlab::EventStore).to receive(:publish).and_return(true)
+ end
+
+ describe 'when the releases feature is not disabled' do
+ before do
+ project.update!(releases_access_level: 'enabled')
+ described_class.new.perform
+ end
+
+ it 'broadcasts the published event' do
+ expect(Gitlab::EventStore).to have_received(:publish).with(Projects::ReleasePublishedEvent)
+ end
+
+ it 'sets the release as published' do
+ expect(release.release_published_at).not_to be_nil
+ end
+ end
+
+ describe 'when the releases feature is disabled' do
+ before do
+ project.update!(releases_access_level: 'disabled')
+ described_class.new.perform
+ end
+
+ it 'does not broadcasts the published event' do
+ expect(Gitlab::EventStore).not_to have_received(:publish).with(Projects::ReleasePublishedEvent)
+ end
+
+ # Having a release created with the releases feature disabled is a bogus state anyway.
+ # Setting it as published prevents having such releases piling up forever in the
+ # `unpublished` scope.
+ it 'sets the release as published' do
+ expect(release.release_published_at).not_to be_nil
+ end
+ end
+end