Skip to content

Commit

Permalink
Fixes #37254 - Unpublishable content views should always return false…
Browse files Browse the repository at this point in the history
… for needs_publish? (Katello#10933)
  • Loading branch information
sjha4 authored Mar 21, 2024
1 parent 9c6aff6 commit ec68d4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,10 @@ def cv_repo_indexed_after_last_published?
repositories.any? { |repo| repo.last_indexed && repo.last_indexed > latest_version_object.created_at }
end

def unpublishable?
default? || import_only? || generated?
end

def needs_publish?
#Returns
# True:
Expand All @@ -819,7 +823,9 @@ def needs_publish?
# a) No changes were detected via audits *and*
# Audit for CV publish exists (Audits haven't been cleaned up)
# *and* applied_filters field is set(Published after upgrade)
# b) Default, import only and generated CVs can not be published, hence these will always return false.
#
return false if unpublishable?
return true unless latest_version_object
return nil unless last_publish_task_success?
return composite_cv_components_changed? if composite?
Expand Down
12 changes: 12 additions & 0 deletions test/models/content_view_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,18 @@ def test_update_host_statuses
end
end

def test_unpublishable?
default_content_view = ContentView.default.first
import_only_content_view = FactoryBot.create(:katello_content_view, :import_only)
generated_content_view = FactoryBot.create(:katello_content_view, generated_for: "repository_export")
normal_content_view = FactoryBot.create(:katello_content_view, generated_for: "none")

assert default_content_view.unpublishable?
assert import_only_content_view.unpublishable?
assert generated_content_view.unpublishable?
refute normal_content_view.unpublishable?
end

def test_new_cv_needs_publish
content_view = FactoryBot.build(:katello_content_view, :name => "New CV")
content_view.save!
Expand Down

0 comments on commit ec68d4c

Please sign in to comment.