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
@@ -1,182 +0,0 @@
|
|
1
|
-
require_relative "../../../../test_helper"
|
2
|
-
|
3
|
-
class Comfy::Admin::Cms::TranslationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@page = comfy_cms_pages(:default)
|
9
|
-
@translation = comfy_cms_translations(:default)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_get_new
|
13
|
-
r :get, new_comfy_admin_cms_site_page_translation_path(@site, @page)
|
14
|
-
assert_response :success
|
15
|
-
assert assigns(:translation)
|
16
|
-
assert_template :new
|
17
|
-
assert_select "form[action='/admin/sites/#{@site.id}/pages/#{@page.id}/translations']"
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_get_new_with_field_wysiwyg
|
21
|
-
@layout.update_column(:content, "{{cms:wysiwyg test}}")
|
22
|
-
r :get, new_comfy_admin_cms_site_page_translation_path(@site, @page)
|
23
|
-
assert_response :success
|
24
|
-
assert_select "textarea[name='translation[fragments_attributes][0][content]'][data-cms-rich-text]"
|
25
|
-
assert_select "input[type='hidden'][name='translation[fragments_attributes][0][identifier]'][value='test']"
|
26
|
-
assert_select "input[type='hidden'][name='translation[fragments_attributes][0][tag]'][value='wysiwyg']"
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_get_edit
|
30
|
-
r :get, edit_comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
31
|
-
assert_response :success
|
32
|
-
assert assigns(:translation)
|
33
|
-
assert_template :edit
|
34
|
-
assert_select "form[action='/admin/sites/#{@site.id}/pages/#{@page.id}/translations/#{@translation.id}']"
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_get_edit_failure
|
38
|
-
r :get, edit_comfy_admin_cms_site_page_translation_path(@site, @page, "invalid")
|
39
|
-
assert_response :redirect
|
40
|
-
assert_redirected_to edit_comfy_admin_cms_site_page_path(@site, @page)
|
41
|
-
assert_equal "Translation not found", flash[:danger]
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create
|
45
|
-
assert_count_difference [Comfy::Cms::Translation] do
|
46
|
-
path = comfy_admin_cms_site_page_translations_path(@site, @page)
|
47
|
-
r :post, path, params: { translation: {
|
48
|
-
locale: "es",
|
49
|
-
label: "Test Translation"
|
50
|
-
} }
|
51
|
-
assert_response :redirect
|
52
|
-
translation = Comfy::Cms::Translation.last
|
53
|
-
assert_equal @page, translation.page
|
54
|
-
assert_redirected_to action: :edit, id: translation
|
55
|
-
assert_equal "Translation created", flash[:success]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_creation_failure
|
60
|
-
assert_count_no_difference [Comfy::Cms::Translation] do
|
61
|
-
path = comfy_admin_cms_site_page_translations_path(@site, @page)
|
62
|
-
r :post, path, params: { translation: {} }
|
63
|
-
assert_response :success
|
64
|
-
assert_template :new
|
65
|
-
assert_equal "Failed to create translation", flash[:danger]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_update
|
70
|
-
path = comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
71
|
-
r :put, path, params: { translation: {
|
72
|
-
label: "Updated Translation"
|
73
|
-
} }
|
74
|
-
assert_response :redirect
|
75
|
-
assert_redirected_to action: :edit, site_id: @site, page_id: @page, id: @translation
|
76
|
-
assert_equal "Translation updated", flash[:success]
|
77
|
-
@translation.reload
|
78
|
-
assert_equal "Updated Translation", @translation.label
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_update_failure
|
82
|
-
path = comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
83
|
-
r :put, path, params: { translation: {
|
84
|
-
locale: ""
|
85
|
-
} }
|
86
|
-
assert_response :success
|
87
|
-
assert_template :edit
|
88
|
-
@translation.reload
|
89
|
-
assert_not_equal "", @translation.locale
|
90
|
-
assert_equal "Failed to update translation", flash[:danger]
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_destroy
|
94
|
-
assert_count_difference [Comfy::Cms::Translation], -1 do
|
95
|
-
r :delete, comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
96
|
-
assert_response :redirect
|
97
|
-
assert_redirected_to edit_comfy_admin_cms_site_page_path(@site, @page)
|
98
|
-
assert_equal "Translation deleted", flash[:success]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_get_form_fragments
|
103
|
-
path = form_fragments_comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
104
|
-
r :get, path, xhr: true, params: {
|
105
|
-
layout_id: comfy_cms_layouts(:nested).id
|
106
|
-
}
|
107
|
-
assert_response :success
|
108
|
-
assert assigns(:translation)
|
109
|
-
assert_equal 2, assigns(:translation).fragment_nodes.size
|
110
|
-
assert_template :form_fragments
|
111
|
-
|
112
|
-
r :get, path, xhr: true, params: {
|
113
|
-
layout_id: @layout.id
|
114
|
-
}
|
115
|
-
assert_response :success
|
116
|
-
assert assigns(:translation)
|
117
|
-
assert_equal 1, assigns(:translation).fragment_nodes.size
|
118
|
-
assert_template :form_fragments
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_get_form_fragments_for_new_translation
|
122
|
-
path = form_fragments_comfy_admin_cms_site_page_translation_path(@site, @page, 0)
|
123
|
-
r :get, path, xhr: true, params: {
|
124
|
-
layout_id: @layout.id
|
125
|
-
}
|
126
|
-
assert_response :success
|
127
|
-
assert assigns(:translation)
|
128
|
-
assert_equal 1, assigns(:translation).fragment_nodes.size
|
129
|
-
assert_template :form_fragments
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_creation_preview
|
133
|
-
assert_count_no_difference [Comfy::Cms::Translation] do
|
134
|
-
r :post, comfy_admin_cms_site_page_translations_path(@site, @page), params: {
|
135
|
-
preview: "Preview",
|
136
|
-
translation: {
|
137
|
-
label: "Test Page",
|
138
|
-
layout_id: @layout.id,
|
139
|
-
locale: "fr",
|
140
|
-
fragments_attributes: [
|
141
|
-
{ identifier: "content",
|
142
|
-
content: "preview content" }
|
143
|
-
]
|
144
|
-
}
|
145
|
-
}
|
146
|
-
assert_response :success
|
147
|
-
assert_match %r{preview content}, response.body
|
148
|
-
assert_equal "text/html", response.content_type
|
149
|
-
|
150
|
-
assert_equal @site, assigns(:cms_site)
|
151
|
-
assert_equal @layout, assigns(:cms_layout)
|
152
|
-
assert assigns(:cms_page)
|
153
|
-
assert assigns(:translation).new_record?
|
154
|
-
|
155
|
-
assert_equal :fr, I18n.locale
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_update_preview
|
160
|
-
assert_count_no_difference [Comfy::Cms::Page] do
|
161
|
-
r :put, comfy_admin_cms_site_page_translation_path(@site, @page, @translation), params: {
|
162
|
-
preview: "Preview",
|
163
|
-
translation: {
|
164
|
-
label: "Updated Label",
|
165
|
-
fragments_attributes: [
|
166
|
-
{ identifier: "content",
|
167
|
-
content: "preview content" }
|
168
|
-
]
|
169
|
-
}
|
170
|
-
}
|
171
|
-
assert_response :success
|
172
|
-
assert_match %r{preview content}, response.body
|
173
|
-
@translation.reload
|
174
|
-
assert_not_equal "Updated Label", @page.label
|
175
|
-
|
176
|
-
assert_equal @page.site, assigns(:cms_site)
|
177
|
-
assert_equal @page.layout, assigns(:cms_layout)
|
178
|
-
assert_equal @page, assigns(:cms_page)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require_relative "../../../test_helper"
|
2
|
-
|
3
|
-
class Comfy::Cms::AssetsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_render_css_with_site_with_path
|
11
|
-
@site.update_column(:path, "some/path")
|
12
|
-
|
13
|
-
get comfy_cms_render_css_path(site_id: @site, identifier: @layout.identifier)
|
14
|
-
assert_response :success
|
15
|
-
assert_match "text/css", response.content_type
|
16
|
-
assert_equal @layout.css, response.body
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_render_css_without_cache_buster
|
20
|
-
get comfy_cms_render_css_path(site_id: @site, identifier: @layout.identifier)
|
21
|
-
assert_response :success
|
22
|
-
assert_match "text/css", response.content_type
|
23
|
-
assert_equal "max-age=0, private, must-revalidate", response.headers["Cache-Control"]
|
24
|
-
assert_equal @layout.css, response.body
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_render_css_with_cache_buster
|
28
|
-
get comfy_cms_render_css_path(site_id: @site, identifier: @layout.identifier, cache_buster: @layout.cache_buster)
|
29
|
-
assert_response :success
|
30
|
-
assert_match "text/css", response.content_type
|
31
|
-
assert_equal "max-age=31556952, public", response.headers["Cache-Control"]
|
32
|
-
assert_equal @layout.css, response.body
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_render_css_not_found
|
36
|
-
get comfy_cms_render_css_path(site_id: @site, identifier: "invalid")
|
37
|
-
assert_response 404
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_render_js_without_cache_buster
|
41
|
-
get comfy_cms_render_js_path(site_id: @site, identifier: @layout.identifier)
|
42
|
-
assert_response :success
|
43
|
-
assert_equal "application/javascript", response.content_type
|
44
|
-
assert_equal "max-age=0, private, must-revalidate", response.headers["Cache-Control"]
|
45
|
-
assert_equal @layout.js, response.body
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_render_js_with_cache_buster
|
49
|
-
get comfy_cms_render_js_path(site_id: @site, identifier: @layout.identifier, cache_buster: @layout.cache_buster)
|
50
|
-
assert_response :success
|
51
|
-
assert_equal "application/javascript", response.content_type
|
52
|
-
assert_equal "max-age=31556952, public", response.headers["Cache-Control"]
|
53
|
-
assert_equal @layout.js, response.body
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_render_js_not_found
|
57
|
-
get comfy_cms_render_js_path(site_id: @site, identifier: "bogus")
|
58
|
-
assert_response 404
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,249 +0,0 @@
|
|
1
|
-
require_relative "../../../test_helper"
|
2
|
-
|
3
|
-
class Comfy::Cms::ContentControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@page = comfy_cms_pages(:default)
|
9
|
-
@translation = comfy_cms_translations(:default)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_show
|
13
|
-
get comfy_cms_render_page_path(cms_path: "")
|
14
|
-
assert_equal @site, assigns(:cms_site)
|
15
|
-
assert_equal @layout, assigns(:cms_layout)
|
16
|
-
assert_equal @page, assigns(:cms_page)
|
17
|
-
|
18
|
-
assert_response :success
|
19
|
-
assert_equal "content", response.body
|
20
|
-
assert_equal "text/html", response.content_type
|
21
|
-
|
22
|
-
assert_equal :en, I18n.locale
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_show_default_html
|
26
|
-
get comfy_cms_render_page_path(cms_path: ""), headers: { "Accept" => "*/*" }
|
27
|
-
assert_response :success
|
28
|
-
assert_equal "text/html", response.content_type
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_show_as_json
|
32
|
-
get comfy_cms_render_page_path(cms_path: ""), as: :json
|
33
|
-
assert_response :success
|
34
|
-
assert_equal "application/json", response.content_type
|
35
|
-
|
36
|
-
json_response = JSON.parse(response.body)
|
37
|
-
assert_equal @page.id, json_response["id"]
|
38
|
-
assert_equal @page.site.id, json_response["site_id"]
|
39
|
-
assert_equal @page.layout.id, json_response["layout_id"]
|
40
|
-
assert_nil json_response["parent_id"]
|
41
|
-
assert_nil json_response["target_page_id"]
|
42
|
-
assert_equal "Default Page", json_response["label"]
|
43
|
-
assert_nil json_response["slug"]
|
44
|
-
assert_equal "/", json_response["full_path"]
|
45
|
-
assert_equal "content", json_response["content"]
|
46
|
-
assert_equal 0, json_response["position"]
|
47
|
-
assert_equal 1, json_response["children_count"]
|
48
|
-
assert_equal true, json_response["is_published"]
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_show_as_json_with_erb
|
52
|
-
@page.update_attributes(fragments_attributes: [
|
53
|
-
{ identifier: "content", content: "{{ cms:helper pluralize, 2, monkey }}" }
|
54
|
-
])
|
55
|
-
get comfy_cms_render_page_path(cms_path: ""), as: :json
|
56
|
-
assert_response :success
|
57
|
-
|
58
|
-
json_response = JSON.parse(response.body)
|
59
|
-
assert_equal "2 monkeys", json_response["content"]
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_show_with_custom_mimetype
|
63
|
-
layout = @site.layouts.create!(
|
64
|
-
label: "RSS Layout",
|
65
|
-
identifier: "rss-layout",
|
66
|
-
content: "{{cms:text mime_type, render: false}}{{cms:textarea content}}"
|
67
|
-
)
|
68
|
-
@site.pages.create!(
|
69
|
-
label: "rss",
|
70
|
-
slug: "rss",
|
71
|
-
parent_id: comfy_cms_pages(:default).id,
|
72
|
-
layout_id: layout.id,
|
73
|
-
is_published: true,
|
74
|
-
fragments_attributes: [
|
75
|
-
{ identifier: "content",
|
76
|
-
content: "content" },
|
77
|
-
{ identifier: "mime_type",
|
78
|
-
content: "application/rss+xml" }
|
79
|
-
]
|
80
|
-
)
|
81
|
-
get comfy_cms_render_page_path(cms_path: "rss")
|
82
|
-
assert_response :success
|
83
|
-
assert_equal "application/rss+xml", response.content_type
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_show_with_app_layout
|
87
|
-
@layout.update_columns(app_layout: "comfy/admin/cms")
|
88
|
-
get comfy_cms_render_page_path(cms_path: "")
|
89
|
-
assert_response :success
|
90
|
-
assert assigns(:cms_page)
|
91
|
-
assert_select "body.c-comfy-cms-content.a-show"
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_show_with_xhr
|
95
|
-
@layout.update_columns(app_layout: "cms_admin")
|
96
|
-
get comfy_cms_render_page_path(cms_path: ""), xhr: true
|
97
|
-
assert_response :success
|
98
|
-
assert assigns(:cms_page)
|
99
|
-
assert_no_select "body.c-comfy-cms-content.a-show"
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_show_not_found
|
103
|
-
assert_exception_raised ActionController::RoutingError, 'Page Not Found at: "doesnotexist"' do
|
104
|
-
get comfy_cms_render_page_path(cms_path: "doesnotexist")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_show_not_found_with_custom_404
|
109
|
-
page = @site.pages.create!(
|
110
|
-
label: "404",
|
111
|
-
slug: "404",
|
112
|
-
parent_id: @page.id,
|
113
|
-
layout_id: @layout.id,
|
114
|
-
is_published: "1",
|
115
|
-
fragments_attributes: [
|
116
|
-
{ identifier: "content",
|
117
|
-
content: "custom 404 page content" }
|
118
|
-
]
|
119
|
-
)
|
120
|
-
assert_equal "/404", page.full_path
|
121
|
-
assert page.is_published?
|
122
|
-
get comfy_cms_render_page_path(cms_path: "doesnotexist")
|
123
|
-
assert_response :not_found
|
124
|
-
assert assigns(:cms_page)
|
125
|
-
assert_match %r{custom 404 page content}, response.body
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_show_with_no_site
|
129
|
-
Comfy::Cms::Site.destroy_all
|
130
|
-
|
131
|
-
assert_exception_raised ActionController::RoutingError, "Site Not Found" do
|
132
|
-
get comfy_cms_render_page_path(cms_path: "")
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_show_with_no_layout
|
137
|
-
Comfy::Cms::Layout.destroy_all
|
138
|
-
|
139
|
-
get comfy_cms_render_page_path(cms_path: "")
|
140
|
-
assert_response :ok
|
141
|
-
assert_equal "", response.body
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_show_with_redirect
|
145
|
-
comfy_cms_pages(:child).update_columns(target_page_id: @page.id)
|
146
|
-
assert_equal @page, comfy_cms_pages(:child).target_page
|
147
|
-
get comfy_cms_render_page_path(cms_path: "child-page")
|
148
|
-
assert_response :redirect
|
149
|
-
assert_redirected_to @page.full_path
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_show_with_redirect_and_site_path
|
153
|
-
@site.update_column(:path, "test-site-path")
|
154
|
-
comfy_cms_pages(:child).update_columns(target_page_id: @page.id)
|
155
|
-
assert_equal @page, comfy_cms_pages(:child).target_page
|
156
|
-
get comfy_cms_render_page_path(cms_path: "/test-site-path/child-page")
|
157
|
-
assert_response :redirect
|
158
|
-
assert_redirected_to "/test-site-path#{@page.full_path}"
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_show_unpublished
|
162
|
-
@page.update_columns(is_published: false)
|
163
|
-
|
164
|
-
assert_exception_raised ActionController::RoutingError, 'Page Not Found at: ""' do
|
165
|
-
get comfy_cms_render_page_path(cms_path: "")
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_show_with_erb_disabled
|
170
|
-
assert_equal false, ComfortableMexicanSofa.config.allow_erb
|
171
|
-
|
172
|
-
@site.pages.create!(
|
173
|
-
label: "erb",
|
174
|
-
slug: "erb",
|
175
|
-
parent_id: @page.id,
|
176
|
-
layout_id: @layout.id,
|
177
|
-
is_published: "1",
|
178
|
-
fragments_attributes: [
|
179
|
-
{ identifier: "content",
|
180
|
-
content: "text <%= 2 + 2 %> text" }
|
181
|
-
]
|
182
|
-
)
|
183
|
-
get comfy_cms_render_page_path(cms_path: "erb")
|
184
|
-
assert_response :success
|
185
|
-
assert_match "text <%= 2 + 2 %> text", response.body
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_show_with_irb_enabled
|
189
|
-
ComfortableMexicanSofa.config.allow_erb = true
|
190
|
-
|
191
|
-
@site.pages.create!(
|
192
|
-
label: "erb",
|
193
|
-
slug: "erb",
|
194
|
-
parent_id: @page.id,
|
195
|
-
layout_id: @layout.id,
|
196
|
-
is_published: "1",
|
197
|
-
fragments_attributes: [
|
198
|
-
{ identifier: "content",
|
199
|
-
content: "text <%= 2 + 2 %> text" }
|
200
|
-
]
|
201
|
-
)
|
202
|
-
get comfy_cms_render_page_path(cms_path: "erb")
|
203
|
-
assert_response :success
|
204
|
-
assert_match "text 4 text", response.body
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_show_with_translation
|
208
|
-
@translation.update_column(:content_cache, "translation content")
|
209
|
-
I18n.locale = @translation.locale
|
210
|
-
|
211
|
-
assert_no_difference -> { @page.fragments.count } do
|
212
|
-
get comfy_cms_render_page_path(cms_path: "")
|
213
|
-
assert_equal "translation content", response.body
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_show_with_translation_not_found
|
218
|
-
I18n.locale = :ja
|
219
|
-
assert_exception_raised ActionController::RoutingError, 'Page Not Found at: ""' do
|
220
|
-
get comfy_cms_render_page_path(cms_path: "")
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_show_with_translation_unpublished
|
225
|
-
@translation.update_column(:is_published, false)
|
226
|
-
I18n.locale = @translation.locale
|
227
|
-
|
228
|
-
assert_exception_raised ActionController::RoutingError, 'Page Not Found at: ""' do
|
229
|
-
get comfy_cms_render_page_path(cms_path: "")
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_with_translation_with_snippet
|
234
|
-
translation = @page.translations.create!(
|
235
|
-
locale: "ja",
|
236
|
-
label: "Test Translation",
|
237
|
-
fragments_attributes: [
|
238
|
-
{ identifier: "content",
|
239
|
-
tag: "text",
|
240
|
-
content: "test {{cms:snippet default}} test" }
|
241
|
-
]
|
242
|
-
)
|
243
|
-
I18n.locale = translation.locale
|
244
|
-
|
245
|
-
get comfy_cms_render_page_path(cms_path: "")
|
246
|
-
assert_equal "test snippet content test", response.body
|
247
|
-
end
|
248
|
-
|
249
|
-
end
|