@@ -71,6 +71,91 @@ def test_alias_recursion(self):
71
71
self .assertEqual (response .status_code , 200 )
72
72
self .assertContains (response , '<div class="info">' , html = True )
73
73
74
+ def test_alias_ref_plugin_on_unpublished_page (self ):
75
+ superuser = self .get_superuser ()
76
+ source_page = api .create_page (
77
+ "Alias plugin" ,
78
+ "col_two.html" ,
79
+ "en" ,
80
+ published = False ,
81
+ )
82
+ source_plugin = api .add_plugin (
83
+ source_page .placeholders .get (slot = "col_left" ),
84
+ 'LinkPlugin' ,
85
+ language = 'en' ,
86
+ name = 'A Link' ,
87
+ external_link = 'https://www.django-cms.org' ,
88
+ )
89
+ target_page = api .create_page (
90
+ "Alias plugin" ,
91
+ "col_two.html" ,
92
+ "en" ,
93
+ published = False ,
94
+ )
95
+ api .add_plugin (
96
+ target_page .placeholders .get (slot = "col_left" ),
97
+ 'AliasPlugin' ,
98
+ language = 'en' ,
99
+ plugin = source_plugin ,
100
+ )
101
+
102
+ with self .login_user_context (superuser ):
103
+ # Source page is unpublished. Alias plugin should not render anything.
104
+ response = self .client .get (target_page .get_absolute_url () + '?edit' )
105
+ self .assertEqual (response .status_code , 200 )
106
+ self .assertNotContains (response , '<a href="https://www.django-cms.org" >A Link</a>' , html = True )
107
+
108
+ source_page .publish ('en' )
109
+
110
+ with self .login_user_context (superuser ):
111
+ # Source page is published. Alias plugin should render normally.
112
+ response = self .client .get (target_page .get_absolute_url () + '?edit' )
113
+ self .assertEqual (response .status_code , 200 )
114
+ self .assertContains (response , '<a href="https://www.django-cms.org" >A Link</a>' , html = True )
115
+
116
+ def test_alias_ref_placeholder_on_unpublished_page (self ):
117
+ superuser = self .get_superuser ()
118
+ source_page = api .create_page (
119
+ "Alias plugin" ,
120
+ "col_two.html" ,
121
+ "en" ,
122
+ published = False ,
123
+ )
124
+ source_placeholder = source_page .placeholders .get (slot = "col_left" )
125
+ api .add_plugin (
126
+ source_placeholder ,
127
+ 'LinkPlugin' ,
128
+ language = 'en' ,
129
+ name = 'A Link' ,
130
+ external_link = 'https://www.django-cms.org' ,
131
+ )
132
+ target_page = api .create_page (
133
+ "Alias plugin" ,
134
+ "col_two.html" ,
135
+ "en" ,
136
+ published = False ,
137
+ )
138
+ api .add_plugin (
139
+ target_page .placeholders .get (slot = "col_left" ),
140
+ 'AliasPlugin' ,
141
+ language = 'en' ,
142
+ alias_placeholder = source_placeholder ,
143
+ )
144
+
145
+ with self .login_user_context (superuser ):
146
+ # Source page is unpublished. Alias plugin should not render anything.
147
+ response = self .client .get (target_page .get_absolute_url () + '?edit' )
148
+ self .assertEqual (response .status_code , 200 )
149
+ self .assertNotContains (response , '<a href="https://www.django-cms.org" >A Link</a>' , html = True )
150
+
151
+ source_page .publish ('en' )
152
+
153
+ with self .login_user_context (superuser ):
154
+ # Source page is published. Alias plugin should render normally.
155
+ response = self .client .get (target_page .get_absolute_url () + '?edit' )
156
+ self .assertEqual (response .status_code , 200 )
157
+ self .assertContains (response , '<a href="https://www.django-cms.org" >A Link</a>' , html = True )
158
+
74
159
def test_alias_placeholder_is_not_editable (self ):
75
160
"""
76
161
When a placeholder is aliased, it shouldn't render as editable
0 commit comments