Skip to content

Commit

Permalink
Merge pull request #9131 from alphagov/ww-org-summary
Browse files Browse the repository at this point in the history
Make summary required for Editionable Worldwide Organisations and their pages
  • Loading branch information
brucebolt authored Jun 11, 2024
2 parents 68cdbcb + 297a71e commit 7af0244
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
4 changes: 0 additions & 4 deletions app/models/editionable_worldwide_organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ def skip_world_location_validation?
false
end

def summary_required?
false
end

def translatable?
true
end
Expand Down
1 change: 1 addition & 0 deletions app/models/worldwide_organisation_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class WorldwideOrganisationPage < ApplicationRecord
validates :corporate_information_page_type_id,
presence: true,
exclusion: { in: [CorporateInformationPageType::AboutUs.id], message: "Type cannot be `About us`" }
validates :summary, presence: true
validate :unique_worldwide_organisation_and_page_type, on: :create, if: :edition
validate :parent_edition_has_locales, if: :edition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
textarea: {
label: {
heading_size: "l",
text: "Translated summary",
text: "Translated summary (required)",
},
name: "page[summary]",
id: "page_summary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<%= render "govuk_publishing_components/components/character_count", {
textarea: {
label: {
text: "Summary",
text: "Summary (required)",
heading_size: "l",
},
name: "worldwide_organisation_page[summary]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,10 @@ class EditionableWorldwideOrganisationTest < ActiveSupport::TestCase
organisation = build(:editionable_worldwide_organisation)
organisation.attachments << build(:file_attachment)
end

%w[body summary title].each do |param|
test "should not be valid without a #{param}" do
assert_not build(:editionable_worldwide_organisation, param.to_sym => nil).valid?
end
end
end
2 changes: 1 addition & 1 deletion test/unit/app/models/worldwide_organisation_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WorldwideOrganisationPageTest < ActiveSupport::TestCase
page.destroy!
end

%w[body corporate_information_page_type_id].each do |param|
%w[body corporate_information_page_type_id summary].each do |param|
test "should not be valid without a #{param}" do
assert_not build(:worldwide_organisation_page, param.to_sym => nil).valid?
end
Expand Down

0 comments on commit 7af0244

Please sign in to comment.