comfortable_mexican_sofa 2.0.9 → 2.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/comfy/vendor/bootstrap.min.js +3 -3
- data/app/assets/stylesheets/comfy/admin/cms/application.sass +1 -2
- data/app/assets/stylesheets/comfy/admin/cms/base.sass +12 -13
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_alert.scss +3 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_button-group.scss +31 -72
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_buttons.scss +26 -19
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_card.scss +23 -12
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_carousel.scss +2 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_close.scss +6 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_code.scss +4 -12
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_custom-forms.scss +124 -84
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_dropdown.scss +30 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_forms.scss +46 -71
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_functions.scss +4 -4
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_images.scss +0 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_input-group.scss +99 -126
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_list-group.scss +2 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_modal.scss +24 -9
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_nav.scss +2 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_navbar.scss +8 -3
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_pagination.scss +32 -19
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_popover.scss +106 -117
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_print.scss +17 -3
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_progress.scss +4 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_reboot.scss +3 -25
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_tables.scss +1 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_tooltip.scss +65 -57
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_type.scss +2 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_variables.scss +174 -108
- data/app/assets/stylesheets/comfy/vendor/bootstrap/bootstrap-grid.scss +32 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/bootstrap-reboot.scss +12 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/bootstrap.scss +42 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_background-variant.scss +2 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_breakpoints.scss +11 -7
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_buttons.scss +37 -22
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_caret.scss +30 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_forms.scss +48 -19
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_grid-framework.scss +5 -7
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_hover.scss +24 -46
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_list-group.scss +10 -13
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_screen-reader.scss +1 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_text-hide.scss +1 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/utilities/_borders.scss +6 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/utilities/_display.scss +10 -28
- data/app/controllers/comfy/admin/cms/files_controller.rb +6 -7
- data/app/helpers/comfy/admin/cms_helper.rb +5 -4
- data/app/models/concerns/comfy/cms/with_categories.rb +20 -9
- data/app/views/comfy/admin/cms/categories/_edit.html.haml +3 -3
- data/app/views/comfy/admin/cms/categories/_form.html.haml +3 -9
- data/app/views/comfy/admin/cms/categories/_index.html.haml +2 -2
- data/app/views/comfy/admin/cms/categories/_show.html.haml +4 -3
- data/app/views/comfy/admin/cms/categories/create.js.erb +1 -1
- data/app/views/comfy/admin/cms/files/_form.html.haml +11 -12
- data/app/views/comfy/admin/cms/files/edit.html.haml +2 -2
- data/app/views/comfy/admin/cms/files/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/fragments/_form_fragment_attachments.html.haml +7 -5
- data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +1 -1
- data/app/views/comfy/admin/cms/layouts/_form.html.haml +3 -2
- data/app/views/comfy/admin/cms/layouts/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/layouts/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/pages/_form.html.haml +3 -5
- data/app/views/comfy/admin/cms/pages/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/pages/new.html.haml +1 -1
- data/app/views/comfy/admin/cms/revisions/show.html.haml +2 -2
- data/app/views/comfy/admin/cms/sites/_form.html.haml +4 -4
- data/app/views/comfy/admin/cms/sites/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/sites/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/snippets/_form.html.haml +2 -2
- data/app/views/comfy/admin/cms/snippets/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/snippets/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/translations/_form.html.haml +5 -7
- data/app/views/comfy/admin/cms/translations/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/translations/new.html.haml +2 -2
- data/comfortable_mexican_sofa.gemspec +6 -3
- data/config/locales/fr.yml +33 -33
- data/lib/comfortable_mexican_sofa/content/tags/file.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/files.rb +1 -1
- data/lib/comfortable_mexican_sofa/form_builder.rb +10 -15
- data/lib/comfortable_mexican_sofa/seeds.rb +2 -5
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- metadata +9 -116
- data/app/assets/stylesheets/comfy/vendor/_bootstrap.scss +0 -42
- data/doc/preview.jpg +0 -0
- data/test/controllers/comfy/admin/cms/base_controller_test.rb +0 -18
- data/test/controllers/comfy/admin/cms/categories_controller_test.rb +0 -74
- data/test/controllers/comfy/admin/cms/files_controller_test.rb +0 -242
- data/test/controllers/comfy/admin/cms/layouts_controller_test.rb +0 -137
- data/test/controllers/comfy/admin/cms/pages_controller_test.rb +0 -580
- data/test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb +0 -62
- data/test/controllers/comfy/admin/cms/revisions/page_controller_test.rb +0 -87
- data/test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb +0 -60
- data/test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb +0 -68
- data/test/controllers/comfy/admin/cms/sites_controller_test.rb +0 -106
- data/test/controllers/comfy/admin/cms/snippets_controller_test.rb +0 -156
- data/test/controllers/comfy/admin/cms/translations_controller_test.rb +0 -182
- data/test/controllers/comfy/cms/assets_controller_test.rb +0 -61
- data/test/controllers/comfy/cms/content_controller_test.rb +0 -249
- data/test/fixtures/active_storage/attachments.yml +0 -9
- data/test/fixtures/active_storage/blobs.yml +0 -13
- data/test/fixtures/comfy/cms/categories.yml +0 -4
- data/test/fixtures/comfy/cms/categorizations.yml +0 -3
- data/test/fixtures/comfy/cms/files.yml +0 -5
- data/test/fixtures/comfy/cms/fragments.yml +0 -25
- data/test/fixtures/comfy/cms/layouts.yml +0 -34
- data/test/fixtures/comfy/cms/pages.yml +0 -24
- data/test/fixtures/comfy/cms/revisions.yml +0 -29
- data/test/fixtures/comfy/cms/sites.yml +0 -5
- data/test/fixtures/comfy/cms/snippets.yml +0 -6
- data/test/fixtures/comfy/cms/translations.yml +0 -7
- data/test/fixtures/files/data.zip +0 -0
- data/test/fixtures/files/document.pdf +0 -0
- data/test/fixtures/files/image.gif +0 -0
- data/test/fixtures/files/image.jpg +0 -0
- data/test/fixtures/generators/cms/application.rb +0 -7
- data/test/fixtures/generators/cms/routes.rb +0 -5
- data/test/fixtures/generators/scaffold/controller.rb +0 -62
- data/test/fixtures/generators/scaffold/migration.rb +0 -9
- data/test/fixtures/generators/scaffold/model.rb +0 -21
- data/test/fixtures/generators/scaffold/routes.rb +0 -6
- data/test/fixtures/generators/scaffold/tests/controller.rb +0 -111
- data/test/fixtures/generators/scaffold/tests/fixture +0 -2
- data/test/fixtures/generators/scaffold/tests/model.rb +0 -24
- data/test/fixtures/generators/scaffold/views/_form.haml +0 -5
- data/test/fixtures/generators/scaffold/views/edit.haml +0 -5
- data/test/fixtures/generators/scaffold/views/index.haml +0 -21
- data/test/fixtures/generators/scaffold/views/new.haml +0 -5
- data/test/fixtures/generators/scaffold/views/show.haml +0 -4
- data/test/fixtures/views/_nav_hook.html.erb +0 -1
- data/test/fixtures/views/_nav_hook_2.html.erb +0 -1
- data/test/fixtures/views/render_test/_test.html.erb +0 -1
- data/test/fixtures/views/render_test/new.html.erb +0 -1
- data/test/fixtures/views/render_test/render_layout.html.erb +0 -1
- data/test/gemfiles/5.2.gemfile +0 -19
- data/test/generators/cms_assets_generator_test.rb +0 -14
- data/test/generators/cms_controllers_generator_test.rb +0 -14
- data/test/generators/cms_generator_test.rb +0 -26
- data/test/generators/cms_models_generator_test.rb +0 -14
- data/test/generators/cms_views_generator_test.rb +0 -14
- data/test/generators/scaffold_generator_test.rb +0 -32
- data/test/helpers/cms_helper_test.rb +0 -106
- data/test/integration/access_control_test.rb +0 -179
- data/test/integration/i18n_test.rb +0 -38
- data/test/integration/meta_variables_test.rb +0 -27
- data/test/integration/render_cms_test.rb +0 -255
- data/test/integration/routing_test.rb +0 -19
- data/test/integration/seeds_test.rb +0 -75
- data/test/integration/sites_test.rb +0 -107
- data/test/integration/view_hooks_test.rb +0 -47
- data/test/lib/configuration_test.rb +0 -38
- data/test/lib/content/block_test.rb +0 -26
- data/test/lib/content/params_parser_test.rb +0 -126
- data/test/lib/content/renderer_test.rb +0 -276
- data/test/lib/content/tag_test.rb +0 -58
- data/test/lib/content/tags/asset_test.rb +0 -104
- data/test/lib/content/tags/checkbox_test.rb +0 -21
- data/test/lib/content/tags/date_test.rb +0 -21
- data/test/lib/content/tags/datetime_test.rb +0 -21
- data/test/lib/content/tags/file_link_test.rb +0 -91
- data/test/lib/content/tags/file_test.rb +0 -69
- data/test/lib/content/tags/files_test.rb +0 -52
- data/test/lib/content/tags/fragment_test.rb +0 -68
- data/test/lib/content/tags/helper_test.rb +0 -62
- data/test/lib/content/tags/markdown_test.rb +0 -37
- data/test/lib/content/tags/number_test.rb +0 -14
- data/test/lib/content/tags/partial_test.rb +0 -65
- data/test/lib/content/tags/snippet_test.rb +0 -37
- data/test/lib/content/tags/template_test.rb +0 -51
- data/test/lib/content/tags/text_test.rb +0 -14
- data/test/lib/content/tags/textarea_test.rb +0 -14
- data/test/lib/content/tags/wysiwyg_test.rb +0 -14
- data/test/lib/revisions_test.rb +0 -222
- data/test/lib/seeds/files_test.rb +0 -97
- data/test/lib/seeds/layouts_test.rb +0 -156
- data/test/lib/seeds/pages_test.rb +0 -230
- data/test/lib/seeds/snippets_test.rb +0 -99
- data/test/lib/seeds_test.rb +0 -51
- data/test/models/categorization_test.rb +0 -76
- data/test/models/category_test.rb +0 -39
- data/test/models/file_test.rb +0 -43
- data/test/models/fragment_test.rb +0 -132
- data/test/models/layout_test.rb +0 -194
- data/test/models/page_test.rb +0 -575
- data/test/models/site_test.rb +0 -190
- data/test/models/snippet_test.rb +0 -56
- data/test/models/translation_test.rb +0 -67
- data/test/system/layouts_frontend_test.rb +0 -15
- data/test/system/pages_frontend_test.rb +0 -15
- data/test/system/sites_frontend_test.rb +0 -11
- data/test/system/snippets_frontend_test.rb +0 -15
- data/test/tasks/cms_seeds_test.rb +0 -34
- data/test/test_helper.rb +0 -201
data/test/models/page_test.rb
DELETED
@@ -1,575 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class CmsPageTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@page = comfy_cms_pages(:default)
|
9
|
-
end
|
10
|
-
|
11
|
-
def new_params(options = {})
|
12
|
-
{ label: "Test Page",
|
13
|
-
slug: "test-page",
|
14
|
-
layout: @layout
|
15
|
-
}.merge(options)
|
16
|
-
end
|
17
|
-
|
18
|
-
# -- Tests -------------------------------------------------------------------
|
19
|
-
|
20
|
-
def test_fixtures_validity
|
21
|
-
Comfy::Cms::Page.all.each do |page|
|
22
|
-
assert page.valid?, page.errors.full_messages.to_s
|
23
|
-
assert_equal page.content_cache, page.render
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_validations
|
28
|
-
page = Comfy::Cms::Page.new
|
29
|
-
page.save
|
30
|
-
assert page.invalid?
|
31
|
-
assert_has_errors_on page, :site, :layout, :slug, :label
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_validation_of_parent_presence
|
35
|
-
page = @site.pages.new(new_params)
|
36
|
-
assert !page.parent
|
37
|
-
assert page.valid?, page.errors.full_messages.to_s
|
38
|
-
assert_equal @page, page.parent
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_validation_of_parent_relationship
|
42
|
-
assert !@page.parent
|
43
|
-
@page.parent = @page
|
44
|
-
assert @page.invalid?
|
45
|
-
assert_has_errors_on @page, :parent_id
|
46
|
-
|
47
|
-
@page.parent = comfy_cms_pages(:child)
|
48
|
-
assert @page.invalid?
|
49
|
-
assert_has_errors_on @page, :parent_id
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_validation_of_target_page
|
53
|
-
page = comfy_cms_pages(:child)
|
54
|
-
page.target_page = @page
|
55
|
-
page.save!
|
56
|
-
assert_equal @page, page.target_page
|
57
|
-
page.target_page = page
|
58
|
-
assert page.invalid?
|
59
|
-
assert_has_errors_on page, :target_page_id
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_validation_of_slug
|
63
|
-
page = comfy_cms_pages(:child)
|
64
|
-
page.slug = "slug.with.d0ts-and_things"
|
65
|
-
assert page.valid?
|
66
|
-
|
67
|
-
page.slug = "inva lid"
|
68
|
-
assert page.invalid?
|
69
|
-
|
70
|
-
page.slug = "acción"
|
71
|
-
assert page.valid?
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_validation_of_slug_allows_unicode_accent_characters
|
75
|
-
page = comfy_cms_pages(:child)
|
76
|
-
thai_character_ko_kai = "\u0e01"
|
77
|
-
thai_character_mai_tho = "\u0E49"
|
78
|
-
page.slug = thai_character_ko_kai + thai_character_mai_tho
|
79
|
-
assert page.valid?
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_label_assignment
|
83
|
-
page = @site.pages.new(
|
84
|
-
slug: "test",
|
85
|
-
parent: @page,
|
86
|
-
layout: @layout
|
87
|
-
)
|
88
|
-
assert page.valid?
|
89
|
-
assert_equal "Test", page.label
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_create
|
93
|
-
assert_count_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
94
|
-
page = @site.pages.create!(
|
95
|
-
new_params(
|
96
|
-
parent: @page,
|
97
|
-
fragments_attributes: [
|
98
|
-
{ identifier: "content",
|
99
|
-
tag: "text",
|
100
|
-
content: "test" }
|
101
|
-
]
|
102
|
-
)
|
103
|
-
)
|
104
|
-
assert page.is_published?
|
105
|
-
assert_equal 1, page.position
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_create_with_file
|
110
|
-
assert_count_difference [Comfy::Cms::Page, Comfy::Cms::Fragment, ActiveStorage::Attachment] do
|
111
|
-
page = @site.pages.create!(
|
112
|
-
new_params(
|
113
|
-
parent: @page,
|
114
|
-
fragments_attributes: [{
|
115
|
-
identifier: "test",
|
116
|
-
tag: "file",
|
117
|
-
files: [fixture_file_upload("files/image.jpg", "image/jpeg")]
|
118
|
-
}]
|
119
|
-
)
|
120
|
-
)
|
121
|
-
assert_equal 1, page.fragments.count
|
122
|
-
assert page.fragments.first.attachments.attached?
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_create_with_files
|
127
|
-
assert_count_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
128
|
-
assert_count_difference [ActiveStorage::Attachment], 2 do
|
129
|
-
page = @site.pages.create!(
|
130
|
-
new_params(
|
131
|
-
parent: @page,
|
132
|
-
fragments_attributes: [{
|
133
|
-
identifier: "test",
|
134
|
-
tag: "files",
|
135
|
-
files: [
|
136
|
-
fixture_file_upload("files/image.jpg", "image/jpeg"),
|
137
|
-
fixture_file_upload("files/document.pdf", "application/pdf")
|
138
|
-
]
|
139
|
-
}]
|
140
|
-
)
|
141
|
-
)
|
142
|
-
assert_equal 1, page.fragments.count
|
143
|
-
assert page.fragments.first.attachments.attached?
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_create_with_date
|
149
|
-
string = "1981-10-04 12:34:56"
|
150
|
-
datetime = DateTime.parse(string)
|
151
|
-
assert_count_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
152
|
-
page = @site.pages.create!(
|
153
|
-
new_params(
|
154
|
-
parent: @page,
|
155
|
-
fragments_attributes: [{
|
156
|
-
identifier: "test",
|
157
|
-
tag: "date_time",
|
158
|
-
datetime: string
|
159
|
-
}]
|
160
|
-
)
|
161
|
-
)
|
162
|
-
frag = page.fragments.first
|
163
|
-
assert_equal datetime, frag.datetime
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_create_with_boolean
|
168
|
-
assert_count_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
169
|
-
page = @site.pages.create!(
|
170
|
-
new_params(
|
171
|
-
parent: @page,
|
172
|
-
fragments_attributes: [{
|
173
|
-
identifier: "test",
|
174
|
-
tag: "checkbox",
|
175
|
-
boolean: "1"
|
176
|
-
}]
|
177
|
-
)
|
178
|
-
)
|
179
|
-
frag = page.fragments.first
|
180
|
-
assert frag.boolean
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_update
|
185
|
-
frag = comfy_cms_fragments(:default)
|
186
|
-
assert_count_no_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
187
|
-
@page.update_attributes!(fragments_attributes: [
|
188
|
-
{ identifier: frag.identifier,
|
189
|
-
content: "updated content" }
|
190
|
-
])
|
191
|
-
end
|
192
|
-
frag.reload
|
193
|
-
assert_equal "updated content", frag.content
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_update_with_file
|
197
|
-
assert_count_no_difference [ActiveStorage::Attachment] do
|
198
|
-
@page.update_attributes!(
|
199
|
-
fragments_attributes: [{
|
200
|
-
identifier: "file",
|
201
|
-
tag: "file",
|
202
|
-
files: fixture_file_upload("files/document.pdf", "application/pdf")
|
203
|
-
}]
|
204
|
-
)
|
205
|
-
assert_equal "document.pdf", comfy_cms_fragments(:file).attachments.first.filename.to_s
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_update_with_file_removal
|
210
|
-
id = comfy_cms_fragments(:file).attachments.first.id
|
211
|
-
assert_count_difference [ActiveStorage::Attachment], -1 do
|
212
|
-
@page.update_attributes!(
|
213
|
-
fragments_attributes: [{
|
214
|
-
identifier: "file",
|
215
|
-
file_ids_destroy: [id]
|
216
|
-
}]
|
217
|
-
)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_update_with_date
|
222
|
-
frag = comfy_cms_fragments(:datetime)
|
223
|
-
string = "2020-01-01"
|
224
|
-
date = DateTime.parse(string)
|
225
|
-
assert_count_no_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
226
|
-
@page.update_attributes!(fragments_attributes: [
|
227
|
-
{ identifier: frag.identifier,
|
228
|
-
datetime: string }
|
229
|
-
])
|
230
|
-
end
|
231
|
-
frag.reload
|
232
|
-
assert_equal date, frag.datetime
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_update_with_boolean
|
236
|
-
frag = comfy_cms_fragments(:boolean)
|
237
|
-
assert frag.boolean
|
238
|
-
assert_count_no_difference [Comfy::Cms::Page, Comfy::Cms::Fragment] do
|
239
|
-
@page.update_attributes!(fragments_attributes: [
|
240
|
-
{ identifier: frag.identifier,
|
241
|
-
boolean: "0" }
|
242
|
-
])
|
243
|
-
end
|
244
|
-
frag.reload
|
245
|
-
refute frag.boolean
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_update_with_parent_id_change
|
249
|
-
page_a = @page
|
250
|
-
page_b = comfy_cms_pages(:child)
|
251
|
-
page_c = @site.pages.create!(
|
252
|
-
label: "Test Page",
|
253
|
-
slug: "test-page",
|
254
|
-
layout: @layout,
|
255
|
-
parent: page_a
|
256
|
-
)
|
257
|
-
|
258
|
-
assert_equal 2, page_a.children_count
|
259
|
-
assert_equal 0, page_b.children_count
|
260
|
-
assert_equal 0, page_c.children_count
|
261
|
-
|
262
|
-
page_c.update_attributes!(parent_id: page_b)
|
263
|
-
|
264
|
-
[page_a, page_b, page_c].each(&:reload)
|
265
|
-
assert_equal 1, page_a.children_count
|
266
|
-
assert_equal 1, page_b.children_count
|
267
|
-
assert_equal 0, page_c.children_count
|
268
|
-
end
|
269
|
-
|
270
|
-
def test_initialization_of_full_path
|
271
|
-
page = Comfy::Cms::Page.new
|
272
|
-
assert_equal "/", page.full_path
|
273
|
-
|
274
|
-
page = Comfy::Cms::Page.new(new_params)
|
275
|
-
assert page.invalid?
|
276
|
-
assert_has_errors_on page, :site
|
277
|
-
|
278
|
-
page = @site.pages.new(new_params(parent: @page))
|
279
|
-
assert page.valid?
|
280
|
-
assert_equal "/test-page", page.full_path
|
281
|
-
|
282
|
-
page = @site.pages.new(new_params(parent: comfy_cms_pages(:child)))
|
283
|
-
assert page.valid?
|
284
|
-
assert_equal "/child-page/test-page", page.full_path
|
285
|
-
|
286
|
-
Comfy::Cms::Page.destroy_all
|
287
|
-
page = @site.pages.new(new_params)
|
288
|
-
assert page.valid?
|
289
|
-
assert_equal "/", page.full_path
|
290
|
-
end
|
291
|
-
|
292
|
-
def test_sync_child_pages
|
293
|
-
page = comfy_cms_pages(:child)
|
294
|
-
page_a = @site.pages.create!(new_params(parent: page, slug: "test-page-1"))
|
295
|
-
page_b = @site.pages.create!(new_params(parent: page, slug: "test-page-2"))
|
296
|
-
page_c = @site.pages.create!(new_params(parent: page_b, slug: "test-page-3"))
|
297
|
-
page_d = @site.pages.create!(new_params(parent: page_a, slug: "test-page-4"))
|
298
|
-
|
299
|
-
assert_equal "/child-page/test-page-1", page_a.full_path
|
300
|
-
assert_equal "/child-page/test-page-2", page_b.full_path
|
301
|
-
assert_equal "/child-page/test-page-2/test-page-3", page_c.full_path
|
302
|
-
assert_equal "/child-page/test-page-1/test-page-4", page_d.full_path
|
303
|
-
|
304
|
-
page.update_attributes!(slug: "updated-page")
|
305
|
-
assert_equal "/updated-page", page.full_path
|
306
|
-
[page_a, page_b, page_c, page_d].each(&:reload)
|
307
|
-
assert_equal "/updated-page/test-page-1", page_a.full_path
|
308
|
-
assert_equal "/updated-page/test-page-2", page_b.full_path
|
309
|
-
assert_equal "/updated-page/test-page-2/test-page-3", page_c.full_path
|
310
|
-
assert_equal "/updated-page/test-page-1/test-page-4", page_d.full_path
|
311
|
-
|
312
|
-
page_b.update_attributes!(parent: page_a)
|
313
|
-
[page_a, page_b, page_c, page_d].each(&:reload)
|
314
|
-
assert_equal "/updated-page/test-page-1", page_a.full_path
|
315
|
-
assert_equal "/updated-page/test-page-1/test-page-2", page_b.full_path
|
316
|
-
assert_equal "/updated-page/test-page-1/test-page-2/test-page-3", page_c.full_path
|
317
|
-
assert_equal "/updated-page/test-page-1/test-page-4", page_d.full_path
|
318
|
-
end
|
319
|
-
|
320
|
-
def test_children_count_updating
|
321
|
-
page_a = @page
|
322
|
-
page_b = comfy_cms_pages(:child)
|
323
|
-
assert_equal 1, page_a.children_count
|
324
|
-
assert_equal 0, page_b.children_count
|
325
|
-
|
326
|
-
page_c = @site.pages.create!(new_params(parent: page_b))
|
327
|
-
[page_a, page_b].each(&:reload)
|
328
|
-
assert_equal 1, page_a.children_count
|
329
|
-
assert_equal 1, page_b.children_count
|
330
|
-
assert_equal 0, page_c.children_count
|
331
|
-
|
332
|
-
page_c.update_attributes!(parent: page_a)
|
333
|
-
[page_a, page_b].each(&:reload)
|
334
|
-
assert_equal 2, page_a.children_count
|
335
|
-
assert_equal 0, page_b.children_count
|
336
|
-
|
337
|
-
page_c.destroy
|
338
|
-
[page_a, page_b].each(&:reload)
|
339
|
-
assert_equal 1, page_a.children_count
|
340
|
-
assert_equal 0, page_b.children_count
|
341
|
-
end
|
342
|
-
|
343
|
-
def test_cascading_destroy
|
344
|
-
assert_count_difference [Comfy::Cms::Page], -2 do
|
345
|
-
assert_count_difference [Comfy::Cms::Fragment], -4 do
|
346
|
-
assert_count_difference [Comfy::Cms::Translation], -1 do
|
347
|
-
@page.destroy
|
348
|
-
end
|
349
|
-
end
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
def test_options_for_select
|
354
|
-
assert_equal ["Default Page", ". . Child Page"],
|
355
|
-
Comfy::Cms::Page.options_for_select(site: @site).collect(&:first)
|
356
|
-
assert_equal ["Default Page"],
|
357
|
-
Comfy::Cms::Page.options_for_select(site: @site, page: comfy_cms_pages(:child)).collect(&:first)
|
358
|
-
assert_equal [],
|
359
|
-
Comfy::Cms::Page.options_for_select(site: @site, page: @page)
|
360
|
-
|
361
|
-
page = Comfy::Cms::Page.new(new_params(parent: @page))
|
362
|
-
assert_equal ["Default Page", ". . Child Page"],
|
363
|
-
Comfy::Cms::Page.options_for_select(site: @site, page: page).collect(&:first)
|
364
|
-
end
|
365
|
-
|
366
|
-
def test_fragments_attributes
|
367
|
-
assert_equal @page.fragments.count, @page.fragments_attributes.size
|
368
|
-
|
369
|
-
@page.fragments_attributes = [
|
370
|
-
{ identifier: "content",
|
371
|
-
content: "updated content"
|
372
|
-
}
|
373
|
-
]
|
374
|
-
|
375
|
-
assert_equal [
|
376
|
-
{ identifier: "boolean",
|
377
|
-
tag: "checkbox",
|
378
|
-
content: nil,
|
379
|
-
datetime: nil,
|
380
|
-
boolean: true },
|
381
|
-
{ identifier: "file",
|
382
|
-
tag: "file",
|
383
|
-
content: nil,
|
384
|
-
datetime: nil,
|
385
|
-
boolean: false },
|
386
|
-
{ identifier: "datetime",
|
387
|
-
tag: "datetime",
|
388
|
-
content: nil,
|
389
|
-
datetime: comfy_cms_fragments(:datetime).datetime,
|
390
|
-
boolean: false },
|
391
|
-
{ identifier: "content",
|
392
|
-
tag: "text",
|
393
|
-
content: "updated content",
|
394
|
-
datetime: nil,
|
395
|
-
boolean: false }
|
396
|
-
], @page.fragments_attributes
|
397
|
-
|
398
|
-
assert_equal [
|
399
|
-
{ identifier: "boolean",
|
400
|
-
tag: "checkbox",
|
401
|
-
content: nil,
|
402
|
-
datetime: nil,
|
403
|
-
boolean: true },
|
404
|
-
{ identifier: "file",
|
405
|
-
tag: "file",
|
406
|
-
content: nil,
|
407
|
-
datetime: nil,
|
408
|
-
boolean: false },
|
409
|
-
{ identifier: "datetime",
|
410
|
-
tag: "datetime",
|
411
|
-
content: nil,
|
412
|
-
datetime: comfy_cms_fragments(:datetime).datetime,
|
413
|
-
boolean: false },
|
414
|
-
{ identifier: "content",
|
415
|
-
tag: "text",
|
416
|
-
content: "content",
|
417
|
-
datetime: nil,
|
418
|
-
boolean: false }
|
419
|
-
], @page.fragments_attributes_was
|
420
|
-
end
|
421
|
-
|
422
|
-
def test_render
|
423
|
-
expected = @page.render
|
424
|
-
assert_equal "content", expected
|
425
|
-
end
|
426
|
-
|
427
|
-
def test_fragment_nodes
|
428
|
-
content = "a {{cms:text a}} b {{cms:snippet b}} c {{cms:text c}}"
|
429
|
-
@page.layout.update_column(:content, content)
|
430
|
-
nodes = @page.fragment_nodes
|
431
|
-
assert_equal 2, nodes.count
|
432
|
-
assert_equal "a", nodes[0].identifier
|
433
|
-
assert_equal "c", nodes[1].identifier
|
434
|
-
end
|
435
|
-
|
436
|
-
def test_fragment_nodes_with_duplicates
|
437
|
-
content = "{{cms:wysiwyg test}} {{cms:markdown test}}"
|
438
|
-
@page.layout.update_column(:content, content)
|
439
|
-
nodes = @page.fragment_nodes
|
440
|
-
assert_equal 1, nodes.count
|
441
|
-
assert_equal ComfortableMexicanSofa::Content::Tag::Wysiwyg, nodes[0].class
|
442
|
-
assert_equal "test", nodes[0].identifier
|
443
|
-
end
|
444
|
-
|
445
|
-
def test_fragment_nodes_with_no_layout
|
446
|
-
@page.update_column(:layout_id, nil)
|
447
|
-
assert_equal [], @page.fragment_nodes
|
448
|
-
end
|
449
|
-
|
450
|
-
def test_content_caching
|
451
|
-
assert_equal @page.content_cache, @page.render
|
452
|
-
|
453
|
-
@page.update_columns(content_cache: "Old Content")
|
454
|
-
refute_equal @page.content_cache, @page.render
|
455
|
-
|
456
|
-
@page.clear_content_cache!
|
457
|
-
assert_equal @page.content_cache, @page.render
|
458
|
-
end
|
459
|
-
|
460
|
-
def test_content_cache_clear_on_save
|
461
|
-
old_content = "Old Content"
|
462
|
-
@page.update_columns(content_cache: old_content)
|
463
|
-
|
464
|
-
@page.save!
|
465
|
-
refute_equal old_content, @page.content_cache
|
466
|
-
end
|
467
|
-
|
468
|
-
def test_scope_published
|
469
|
-
assert_equal 2, Comfy::Cms::Page.published.count
|
470
|
-
comfy_cms_pages(:child).update_columns(is_published: false)
|
471
|
-
assert_equal 1, Comfy::Cms::Page.published.count
|
472
|
-
end
|
473
|
-
|
474
|
-
def test_root?
|
475
|
-
assert @page.root?
|
476
|
-
refute comfy_cms_pages(:child).root?
|
477
|
-
end
|
478
|
-
|
479
|
-
def test_url
|
480
|
-
assert_equal "//www.example.com/", @page.url
|
481
|
-
assert_equal "//www.example.com/child-page", comfy_cms_pages(:child).url
|
482
|
-
|
483
|
-
assert_equal "/", @page.url(relative: true)
|
484
|
-
assert_equal "/child-page", comfy_cms_pages(:child).url(relative: true)
|
485
|
-
|
486
|
-
@site.update_columns(path: "/en/site")
|
487
|
-
@page.reload
|
488
|
-
comfy_cms_pages(:child).reload
|
489
|
-
|
490
|
-
assert_equal "//www.example.com/en/site/", @page.url
|
491
|
-
assert_equal "//www.example.com/en/site/child-page", comfy_cms_pages(:child).url
|
492
|
-
|
493
|
-
assert_equal "/en/site/", @page.url(relative: true)
|
494
|
-
assert_equal "/en/site/child-page", comfy_cms_pages(:child).url(relative: true)
|
495
|
-
end
|
496
|
-
|
497
|
-
def test_url_with_public_cms_path
|
498
|
-
ComfortableMexicanSofa.config.public_cms_path = "/custom"
|
499
|
-
assert_equal "//www.example.com/custom/", @page.url
|
500
|
-
assert_equal "//www.example.com/custom/child-page", comfy_cms_pages(:child).url
|
501
|
-
|
502
|
-
assert_equal "/custom/", @page.url(relative: true)
|
503
|
-
assert_equal "/custom/child-page", comfy_cms_pages(:child).url(relative: true)
|
504
|
-
end
|
505
|
-
|
506
|
-
def test_unicode_slug_escaping
|
507
|
-
page = comfy_cms_pages(:child)
|
508
|
-
page_a = @site.pages.create!(new_params(parent: page, slug: "tést-ünicode-slug"))
|
509
|
-
assert_equal CGI.escape("tést-ünicode-slug"), page_a.slug
|
510
|
-
assert_equal CGI.escape("/child-page/tést-ünicode-slug").gsub("%2F", "/"), page_a.full_path
|
511
|
-
end
|
512
|
-
|
513
|
-
def test_unicode_slug_unescaping
|
514
|
-
page = comfy_cms_pages(:child)
|
515
|
-
@site.pages.create!(new_params(parent: page, slug: "tést-ünicode-slug"))
|
516
|
-
found_page = @site.pages.where(slug: CGI.escape("tést-ünicode-slug")).first
|
517
|
-
assert_equal "tést-ünicode-slug", found_page.slug
|
518
|
-
assert_equal "/child-page/tést-ünicode-slug", found_page.full_path
|
519
|
-
end
|
520
|
-
|
521
|
-
def test_identifier
|
522
|
-
assert_equal "index", @page.identifier
|
523
|
-
assert_equal "child-page", comfy_cms_pages(:child).identifier
|
524
|
-
|
525
|
-
@page.update_column(:slug, "index")
|
526
|
-
assert_equal "index", comfy_cms_pages(:default).identifier
|
527
|
-
end
|
528
|
-
|
529
|
-
def test_children_count_updating_on_move
|
530
|
-
page_a = @page
|
531
|
-
page_b = comfy_cms_pages(:child)
|
532
|
-
page_c = @site.pages.create!(new_params(parent: page_b))
|
533
|
-
|
534
|
-
page_b.reload
|
535
|
-
|
536
|
-
assert_equal 1, page_a.children_count
|
537
|
-
assert_equal 1, page_b.children_count
|
538
|
-
assert_equal 0, page_c.children_count
|
539
|
-
|
540
|
-
page_c.parent_id = page_a.id
|
541
|
-
page_c.save!
|
542
|
-
|
543
|
-
[page_a, page_b, page_c].each(&:reload)
|
544
|
-
|
545
|
-
assert_equal 2, page_a.children_count
|
546
|
-
assert_equal 0, page_b.children_count
|
547
|
-
assert_equal 0, page_c.children_count
|
548
|
-
end
|
549
|
-
|
550
|
-
def test_translate
|
551
|
-
translation = comfy_cms_translations(:default)
|
552
|
-
translation.update_columns(layout_id: comfy_cms_layouts(:nested).id)
|
553
|
-
|
554
|
-
@page.translate!(:fr)
|
555
|
-
assert @page.readonly?
|
556
|
-
|
557
|
-
assert_equal comfy_cms_layouts(:nested), @page.layout
|
558
|
-
assert_equal "Default Translation", @page.label
|
559
|
-
assert_equal "Translation Content", @page.content_cache
|
560
|
-
end
|
561
|
-
|
562
|
-
def test_translate_with_unpublished
|
563
|
-
comfy_cms_translations(:default).update_column(:is_published, false)
|
564
|
-
assert_exception_raised ActiveRecord::RecordNotFound do
|
565
|
-
@page.translate!(:fr)
|
566
|
-
end
|
567
|
-
end
|
568
|
-
|
569
|
-
def test_translate_with_invalid_locale
|
570
|
-
assert_exception_raised ActiveRecord::RecordNotFound do
|
571
|
-
@page.translate!(:es)
|
572
|
-
end
|
573
|
-
end
|
574
|
-
|
575
|
-
end
|