@@ -43,6 +43,31 @@ class Edition::OrganisationsTest < ActiveSupport::TestCase
43
43
end
44
44
end
45
45
46
+ test "should remain publishable when linked organisations are invalid" do
47
+ # Build and persist an organisation that will be invalid.
48
+ invalid_org = create ( :organisation )
49
+ invalid_org . update_column ( :homepage_type , "invalid" )
50
+ assert_not invalid_org . valid? , "Homepage type is not included in the list"
51
+
52
+ # Create an edition using the invalid organisation as the lead organisation and
53
+ # disable default organisation creation. Persisting the edition mirrors real usage.
54
+ edition = create (
55
+ :publication ,
56
+ create_default_organisation : false ,
57
+ lead_organisations : [ invalid_org ] ,
58
+ supporting_organisations : [ ] ,
59
+ )
60
+
61
+ # The edition should be valid for publishing before any side-effects.
62
+ assert edition . valid? ( :publish ) , "edition should be valid in publish context before touching organisations"
63
+
64
+ # Reading organisation names used to build unsaved translations and make the edition
65
+ # invalid via autosave validations:contentReference[oaicite:0]{index=0}. After overriding those validations,
66
+ # the edition should remain valid even after accessing organisation names.
67
+ edition . organisations . map ( &:name )
68
+ assert edition . valid? ( :publish ) , "edition should still be valid in publish context after reading organisation names"
69
+ end
70
+
46
71
test "#sorted_organisations returns organisations in alphabetical order" do
47
72
organisation1 = create ( :organisation , name : "Ministry of Jazz" )
48
73
organisation2 = create ( :organisation , name : "Free Jazz Foundation" )
0 commit comments