Skip to content

Commit 682c7e2

Browse files
committed
Rename can_be_published? to parent_allows_publishing?
As per #11431 (review) This is more descriptive.
1 parent 2e107cc commit 682c7e2

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

app/components/admin/editions/show/sidebar_actions_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def actions
2323
add_create_action
2424
add_edit_action
2525
add_submit_action
26-
unless @edition.is_child_document? && !@edition.can_be_published?
26+
unless @edition.is_child_document? && !@edition.parent_allows_publishing?
2727
add_unschedule_action
2828
add_schedule_action
2929
add_publish_action

app/models/concerns/standard_edition/child_document.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def is_child_document?
2121
parent_edition.present?
2222
end
2323

24-
def can_be_published?
24+
def parent_allows_publishing?
2525
return true unless is_child_document?
2626

2727
parent_edition.document.live_edition&.state == "published" && !parent_edition.pre_publication?
@@ -34,7 +34,7 @@ def publishing?
3434
end
3535

3636
def ensure_publishing_is_allowed!
37-
return if can_be_published?
37+
return if parent_allows_publishing?
3838

3939
raise IncompatibleParentState, "Unable to publish child document"
4040
end

app/views/admin/editions/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
if @edition.is_child_document?
2222
parent = @edition.parent_edition
2323
inset_text = "This is a child document of <a href='/government/admin/editions/#{parent.id}'>#{parent.title}</a>."
24-
if !@edition.can_be_published?
24+
if !@edition.parent_allows_publishing?
2525
if @edition.parent_edition.document.live_edition&.state == "published" && @edition.document.live_edition.nil?
2626
inset_text += " As this is a new document, you will need to publish the parent again first before you can publish the child."
2727
else

test/unit/app/models/concerns/standard_edition/child_document_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class StandardEdition::ChildDocumentTest < ActiveSupport::TestCase
8686
assert_equal "#{parent_edition.base_path}/foo", child_edition.base_path
8787
end
8888

89-
test "can_be_published? returns true if parent edition is not in a pre-publication state AND parent document is 'published'" do
89+
test "parent_allows_publishing? returns true if parent edition is not in a pre-publication state AND parent document is 'published'" do
9090
parent_document = create(:document)
9191
parent_edition = create(:superseded_standard_edition, document: parent_document)
9292
create(:published_standard_edition, document: parent_document) # Live Parent
@@ -100,10 +100,10 @@ class StandardEdition::ChildDocumentTest < ActiveSupport::TestCase
100100
)
101101
relationship.save!(validate: false)
102102

103-
assert child_edition.can_be_published?
103+
assert child_edition.parent_allows_publishing?
104104
end
105105

106-
test "can_be_published? returns false if parent edition is in a pre-publication state, despite the parent document being published" do
106+
test "parent_allows_publishing? returns false if parent edition is in a pre-publication state, despite the parent document being published" do
107107
Edition::PRE_PUBLICATION_STATES.each do |state|
108108
parent_document = create(:document)
109109
create(:published_standard_edition, document: parent_document) # Live Parent...
@@ -117,11 +117,11 @@ class StandardEdition::ChildDocumentTest < ActiveSupport::TestCase
117117
child_document:,
118118
)
119119

120-
assert_not child_edition.can_be_published?
120+
assert_not child_edition.parent_allows_publishing?
121121
end
122122
end
123123

124-
test "can_be_published? returns false if parent edition is not in a pre-publication state and parent document is not 'published'" do
124+
test "parent_allows_publishing? returns false if parent edition is not in a pre-publication state and parent document is not 'published'" do
125125
parent_document = create(:document)
126126
parent_edition = create(:withdrawn_standard_edition, document: parent_document)
127127
create(:draft_standard_edition, document: parent_document)
@@ -135,6 +135,6 @@ class StandardEdition::ChildDocumentTest < ActiveSupport::TestCase
135135
)
136136
relationship.save!(validate: false)
137137

138-
assert_not child_edition.can_be_published?
138+
assert_not child_edition.parent_allows_publishing?
139139
end
140140
end

0 commit comments

Comments
 (0)