Skip to content

Commit 74c989d

Browse files
committed
Refs #38856 - halt manual composite publish if children are publishing
1 parent a630802 commit 74c989d

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/ruby.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: theforeman/actions/.github/workflows/rubocop.yml@v0
1919
with:
2020
command: bundle exec rubocop --parallel --format github
21-
ruby-version: '3.0'
21+
ruby: '3.0'
2222

2323
test:
2424
name: Ruby
@@ -27,7 +27,6 @@ jobs:
2727
with:
2828
plugin: katello
2929
foreman_version: develop # set to the Foreman release branch after branching :)
30-
ruby-version: '3.0'
3130

3231
angular:
3332
name: Angular ${{ matrix.engine }} - NodeJS ${{ matrix.node }}

app/models/katello/content_view.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ def check_ready_to_publish!(importing: false, syncable: false)
663663
check_docker_repository_names!([organization.library])
664664
check_orphaned_content_facets!(environments: self.environments)
665665
check_scheduled_publish!
666+
check_component_publishes!
666667
end
667668

668669
true
@@ -686,6 +687,14 @@ def check_scheduled_publish!
686687
end
687688
end
688689

690+
def check_component_publishes!
691+
return unless composite?
692+
693+
if ::Katello::ContentViewManager.running_component_publish_tasks(self).any?
694+
fail ::Katello::Errors::ConflictException, _("Cannot publish composite content view while its content views are being published. Please wait for component publishes to complete.")
695+
end
696+
end
697+
689698
def check_docker_repository_names!(environments)
690699
environments.each do |environment|
691700
repositories = []

test/models/content_view_test.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,5 +865,26 @@ def test_check_scheduled_publish_raises_when_scheduled_publish_exists
865865

866866
assert_match(/publish is already scheduled/, error.message)
867867
end
868+
869+
def test_check_component_publishes_raises_when_component_publishes_running
870+
composite_cv = katello_content_views(:composite_view)
871+
running_task = mock('task')
872+
873+
Katello::ContentViewManager.stubs(:running_component_publish_tasks).with(composite_cv).returns([running_task])
874+
875+
error = assert_raises(Katello::Errors::ConflictException) do
876+
composite_cv.check_component_publishes!
877+
end
878+
879+
assert_match(/component content views are being published/, error.message)
880+
end
881+
882+
def test_check_component_publishes_passes_when_no_component_publishes
883+
composite_cv = katello_content_views(:composite_view)
884+
885+
Katello::ContentViewManager.stubs(:running_component_publish_tasks).with(composite_cv).returns([])
886+
887+
composite_cv.check_component_publishes!
888+
end
868889
end
869890
end

0 commit comments

Comments
 (0)