Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure change note input field is visible for all pre-publication documents #8382

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/edition/publishing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def published_version
def change_note_required?
return false if new_record?

draft? && previous_edition.present?
pre_publication? && previous_edition.present?
end

def change_note_present!
Expand Down
12 changes: 12 additions & 0 deletions test/unit/app/models/edition/publishing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ class Edition::PublishingChangeNoteTest < ActiveSupport::TestCase
assert_not edition.valid?
end

test "a submitted edition is invalid without change note once saved if a published edition already exists" do
published_edition = create(:published_edition)
edition = create(:submitted_edition, change_note: nil, minor_change: false, document: published_edition.document)
assert_not edition.valid?
end

test "a rejected edition is invalid without change note once saved if a published edition already exists" do
published_edition = create(:published_edition)
edition = create(:rejected_edition, change_note: nil, minor_change: false, document: published_edition.document)
assert_not edition.valid?
end

test "a draft is invalid without change note once saved if an unpublished edition already exists" do
unpublished_edition = create(:unpublished_edition)
edition = create(:draft_edition, change_note: nil, minor_change: false, document: unpublished_edition.document)
Expand Down