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/site_test.rb
DELETED
@@ -1,190 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class CmsSiteTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_fixtures_validity
|
10
|
-
Comfy::Cms::Site.all.each do |site|
|
11
|
-
assert site.valid?, site.errors.inspect
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_validation
|
16
|
-
site = Comfy::Cms::Site.new
|
17
|
-
assert site.invalid?
|
18
|
-
assert_has_errors_on site, :identifier, :label, :hostname
|
19
|
-
|
20
|
-
site = Comfy::Cms::Site.new(identifier: "test", hostname: "http://site.host")
|
21
|
-
assert site.invalid?
|
22
|
-
assert_has_errors_on site, :hostname
|
23
|
-
|
24
|
-
site = Comfy::Cms::Site.new(identifier: @site.identifier, hostname: "site.host")
|
25
|
-
assert site.invalid?
|
26
|
-
assert_has_errors_on site, :identifier
|
27
|
-
|
28
|
-
site = Comfy::Cms::Site.new(identifier: "test", hostname: "site.host")
|
29
|
-
assert site.valid?, site.errors.inspect
|
30
|
-
|
31
|
-
site = Comfy::Cms::Site.new(identifier: "test", hostname: "localhost:3000")
|
32
|
-
assert site.valid?, site.errors.inspect
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_validation_path_uniqueness
|
36
|
-
s1 = @site
|
37
|
-
s2 = Comfy::Cms::Site.new(
|
38
|
-
identifier: "test",
|
39
|
-
hostname: s1.hostname,
|
40
|
-
path: s1.path
|
41
|
-
)
|
42
|
-
assert s2.invalid?
|
43
|
-
assert_has_errors_on s2, :hostname
|
44
|
-
|
45
|
-
s2 = Comfy::Cms::Site.new(
|
46
|
-
identifier: "test",
|
47
|
-
hostname: s1.hostname,
|
48
|
-
path: "/en"
|
49
|
-
)
|
50
|
-
assert s2.valid?
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_identifier_assignment
|
54
|
-
site = Comfy::Cms::Site.new(hostname: "my-site.host")
|
55
|
-
assert site.valid?
|
56
|
-
assert_equal "my-site-host", site.identifier
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_hostname_assignment
|
60
|
-
site = Comfy::Cms::Site.new(identifier: "test-site")
|
61
|
-
assert site.valid?
|
62
|
-
assert_equal "test-site", site.hostname
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_label_assignment
|
66
|
-
site = Comfy::Cms::Site.new(identifier: "test", hostname: "my-site.host")
|
67
|
-
assert site.valid?
|
68
|
-
assert_equal "Test", site.label
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_clean_path
|
72
|
-
site = Comfy::Cms::Site.create!(
|
73
|
-
identifier: "test_a",
|
74
|
-
hostname: "test.host",
|
75
|
-
path: "/en///test//"
|
76
|
-
)
|
77
|
-
assert_equal "/en/test", site.path
|
78
|
-
|
79
|
-
site = Comfy::Cms::Site.create!(
|
80
|
-
identifier: "test_b",
|
81
|
-
hostname: "my-site.host",
|
82
|
-
path: "/"
|
83
|
-
)
|
84
|
-
assert_nil site.path
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_creation
|
88
|
-
assert_difference "Comfy::Cms::Site.count" do
|
89
|
-
Comfy::Cms::Site.create!(
|
90
|
-
identifier: "test",
|
91
|
-
label: "Test Site",
|
92
|
-
hostname: "test.test"
|
93
|
-
)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_cascading_destroy
|
98
|
-
assert_difference "Comfy::Cms::Site.count", -1 do
|
99
|
-
assert_difference "Comfy::Cms::Layout.count", -3 do
|
100
|
-
assert_difference "Comfy::Cms::Page.count", -2 do
|
101
|
-
assert_difference "Comfy::Cms::Snippet.count", -1 do
|
102
|
-
assert_difference "Comfy::Cms::Category.count", -1 do
|
103
|
-
@site.destroy
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_find_site
|
112
|
-
site_a = @site
|
113
|
-
assert_equal "www.example.com", site_a.hostname
|
114
|
-
assert_nil site_a.path
|
115
|
-
|
116
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("www.example.com")
|
117
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("www.example.com", "/some/path")
|
118
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("test99.host", "/some/path")
|
119
|
-
|
120
|
-
site_b = Comfy::Cms::Site.create!(identifier: "test_a", hostname: "test2.host", path: "en")
|
121
|
-
site_c = Comfy::Cms::Site.create!(identifier: "test_b", hostname: "test2.host", path: "fr")
|
122
|
-
|
123
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("www.example.com")
|
124
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("www.example.com", "/some/path")
|
125
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("www.example.com", "/some/path")
|
126
|
-
assert_nil Comfy::Cms::Site.find_site("test99.host", "/some/path")
|
127
|
-
|
128
|
-
assert_nil Comfy::Cms::Site.find_site("test2.host")
|
129
|
-
assert_nil Comfy::Cms::Site.find_site("test2.host", "/some/path")
|
130
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/en")
|
131
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/en?a=b")
|
132
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/en/some/path?a=b")
|
133
|
-
|
134
|
-
assert_nil Comfy::Cms::Site.find_site("test2.host", "/english/some/path")
|
135
|
-
|
136
|
-
assert_equal site_c, Comfy::Cms::Site.find_site("test2.host", "/fr")
|
137
|
-
assert_equal site_c, Comfy::Cms::Site.find_site("test2.host", "/fr?a=b")
|
138
|
-
assert_equal site_c, Comfy::Cms::Site.find_site("test2.host", "/fr/some/path")
|
139
|
-
assert_equal site_c, Comfy::Cms::Site.find_site("test2.host", "/fr/some/path?a=b")
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_find_site_with_public_cms_path
|
143
|
-
ComfortableMexicanSofa.config.public_cms_path = "/custom"
|
144
|
-
assert_equal "//www.example.com/custom", @site.url
|
145
|
-
|
146
|
-
site_a = Comfy::Cms::Site.create!(identifier: "test_a", hostname: "test2.host", path: "en")
|
147
|
-
site_b = Comfy::Cms::Site.create!(identifier: "test_b", hostname: "test2.host", path: "fr")
|
148
|
-
|
149
|
-
assert_nil Comfy::Cms::Site.find_site("test2.host")
|
150
|
-
assert_nil Comfy::Cms::Site.find_site("test2.host", "/custom/some/path")
|
151
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("test2.host", "/custom/en")
|
152
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("test2.host", "/custom/en?a=b")
|
153
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("test2.host", "/custom/en/some/path?a=b")
|
154
|
-
|
155
|
-
assert_nil Comfy::Cms::Site.find_site("test2.host", "/custom/english/some/path")
|
156
|
-
|
157
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/custom/fr")
|
158
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/custom/fr?a=b")
|
159
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/custom/fr/some/path")
|
160
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("test2.host", "/custom/fr/some/path?a=b")
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_find_site_with_site_alias
|
164
|
-
site_a = @site
|
165
|
-
site_b = Comfy::Cms::Site.create!(identifier: "site_b", hostname: "test2.host")
|
166
|
-
|
167
|
-
ComfortableMexicanSofa.config.hostname_aliases = {
|
168
|
-
"www.example.com" => "alias_a.host",
|
169
|
-
"test2.host" => %w[alias_b.host alias_c.host]
|
170
|
-
}
|
171
|
-
|
172
|
-
assert_equal site_a, Comfy::Cms::Site.find_site("alias_a.host")
|
173
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("alias_b.host")
|
174
|
-
assert_equal site_b, Comfy::Cms::Site.find_site("alias_c.host")
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_url
|
178
|
-
assert_equal "//www.example.com", @site.url
|
179
|
-
assert_nil @site.url(relative: true)
|
180
|
-
|
181
|
-
@site.update_column(:path, "/site-path")
|
182
|
-
assert_equal "//www.example.com/site-path", @site.url
|
183
|
-
|
184
|
-
ComfortableMexicanSofa.config.public_cms_path = "cms"
|
185
|
-
assert_equal "//www.example.com/cms/site-path", @site.url
|
186
|
-
|
187
|
-
assert_equal "/cms/site-path", @site.url(relative: true)
|
188
|
-
end
|
189
|
-
|
190
|
-
end
|
data/test/models/snippet_test.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class CmsSnippetTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_fixtures_validity
|
10
|
-
Comfy::Cms::Snippet.all.each do |snippet|
|
11
|
-
assert snippet.valid?, snippet.errors.full_messages.to_s
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_validations
|
16
|
-
snippet = Comfy::Cms::Snippet.new
|
17
|
-
snippet.save
|
18
|
-
assert snippet.invalid?
|
19
|
-
assert_has_errors_on snippet, :site, :label, :identifier
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_label_assignment
|
23
|
-
snippet = @site.snippets.new(
|
24
|
-
identifier: "test"
|
25
|
-
)
|
26
|
-
assert snippet.valid?
|
27
|
-
assert_equal "Test", snippet.label
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_create
|
31
|
-
assert_difference "Comfy::Cms::Snippet.count" do
|
32
|
-
snippet = @site.snippets.create(
|
33
|
-
label: "Test Snippet",
|
34
|
-
identifier: "test",
|
35
|
-
content: "Test Content"
|
36
|
-
)
|
37
|
-
assert_equal "Test Snippet", snippet.label
|
38
|
-
assert_equal "test", snippet.identifier
|
39
|
-
assert_equal "Test Content", snippet.content
|
40
|
-
assert_equal 1, snippet.position
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_update_forces_page_content_reload
|
45
|
-
snippet = comfy_cms_snippets(:default)
|
46
|
-
page = comfy_cms_pages(:default)
|
47
|
-
comfy_cms_fragments(:default).update_column(:content, "{{cms:snippet default}}")
|
48
|
-
page.clear_content_cache!
|
49
|
-
|
50
|
-
assert_equal "snippet content", page.content_cache
|
51
|
-
snippet.update_attributes(content: "new snippet content")
|
52
|
-
page.reload
|
53
|
-
assert_equal "new snippet content", page.content_cache
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class CmsPageTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@page = comfy_cms_pages(:default)
|
8
|
-
@translation = comfy_cms_translations(:default)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_fixtures_validity
|
12
|
-
Comfy::Cms::Translation.all.each do |translation|
|
13
|
-
assert translation.valid?, translation.errors.full_messages.to_s
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_validations
|
18
|
-
translation = Comfy::Cms::Translation.new
|
19
|
-
translation.save
|
20
|
-
assert translation.invalid?
|
21
|
-
assert_has_errors_on translation, :page, :layout, :locale, :label
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_validation_on_locale_uniqueness
|
25
|
-
translation = @page.translations.new(
|
26
|
-
label: "Test",
|
27
|
-
locale: @translation.locale
|
28
|
-
)
|
29
|
-
assert translation.invalid?
|
30
|
-
assert_has_errors_on translation, :locale
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_validation_on_locale_uniqueness_against_site
|
34
|
-
translation = @page.translations.new(
|
35
|
-
label: "Test",
|
36
|
-
locale: @site.locale
|
37
|
-
)
|
38
|
-
assert translation.invalid?
|
39
|
-
assert_has_errors_on translation, :locale
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_creation
|
43
|
-
assert_count_difference [Comfy::Cms::Translation, Comfy::Cms::Fragment] do
|
44
|
-
translation = @page.translations.create(
|
45
|
-
locale: "test",
|
46
|
-
label: "Test Translation",
|
47
|
-
fragments_attributes: [
|
48
|
-
{ identifier: "content",
|
49
|
-
tag: "text",
|
50
|
-
content: "test" }
|
51
|
-
]
|
52
|
-
)
|
53
|
-
assert_equal @page.layout, translation.layout
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_scope_published
|
58
|
-
assert_equal 1, Comfy::Cms::Translation.published.count
|
59
|
-
@translation.update_columns(is_published: false)
|
60
|
-
assert_equal 0, Comfy::Cms::Translation.published.count
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_site_delegation
|
64
|
-
assert_equal @site, @translation.site
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class LayoutsFrontendTest < ApplicationSystemTestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_new_identifier
|
10
|
-
visit_p new_comfy_admin_cms_site_layout_path(@site)
|
11
|
-
fill_in "Layout Name", with: "Test Layout"
|
12
|
-
assert_equal "test-layout", find_field("Identifier").value
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class PagesFrontendTest < ApplicationSystemTestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_new_identifier
|
10
|
-
visit_p new_comfy_admin_cms_site_page_path(@site)
|
11
|
-
fill_in "Label", with: "Test Page"
|
12
|
-
assert_equal "test-page", find_field("Slug").value
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class SitesFrontendTest < ApplicationSystemTestCase
|
4
|
-
|
5
|
-
def test_new_identifier
|
6
|
-
visit_p new_comfy_admin_cms_site_path
|
7
|
-
fill_in "Label", with: "Test Site"
|
8
|
-
assert_equal "test-site", find_field("Identifier").value
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class SnippetsFrontendTest < ApplicationSystemTestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_new_identifier
|
10
|
-
visit_p new_comfy_admin_cms_site_snippet_path(@site)
|
11
|
-
fill_in "Label", with: "Test Snippet"
|
12
|
-
assert_equal "test-snippet", find_field("Identifier").value
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
require "rake"
|
3
|
-
|
4
|
-
class CmsSeedsTaskTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@rake = Rake::Application.new
|
8
|
-
Rake.application = @rake
|
9
|
-
# We force rake file reload by passing empty array as the last parameter
|
10
|
-
Rake.application.rake_require("tasks/cms_seeds", $LOAD_PATH, [])
|
11
|
-
Rake::Task.define_task(:environment)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_import
|
15
|
-
importer = mock
|
16
|
-
ComfortableMexicanSofa::Seeds::Importer.expects(:new).with("from_folder", "to_site").returns(importer)
|
17
|
-
importer.expects(:import!)
|
18
|
-
|
19
|
-
with_captured_stout do
|
20
|
-
@rake["comfy:cms_seeds:import"].invoke("from_folder", "to_site")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_export
|
25
|
-
exporter = mock
|
26
|
-
ComfortableMexicanSofa::Seeds::Exporter.expects(:new).with("from_site", "to_folder").returns(exporter)
|
27
|
-
exporter.expects(:export!)
|
28
|
-
|
29
|
-
with_captured_stout do
|
30
|
-
@rake["comfy:cms_seeds:export"].invoke("from_site", "to_folder")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
3
|
-
# In CI envoronment I don't want to send coverage report for system tests that
|
4
|
-
# obviously don't cover everything 100%
|
5
|
-
unless ENV["SKIP_COV"]
|
6
|
-
require "simplecov"
|
7
|
-
require "coveralls"
|
8
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter "lib/generators"
|
11
|
-
add_filter "lib/comfortable_mexican_sofa/engine.rb "
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require_relative "../config/environment"
|
16
|
-
|
17
|
-
require "rails/test_help"
|
18
|
-
require "rails/generators"
|
19
|
-
require "mocha/setup"
|
20
|
-
|
21
|
-
Rails.backtrace_cleaner.remove_silencers!
|
22
|
-
|
23
|
-
class ActiveSupport::TestCase
|
24
|
-
|
25
|
-
include ActionDispatch::TestProcess
|
26
|
-
|
27
|
-
fixtures :all
|
28
|
-
|
29
|
-
setup :reset_config,
|
30
|
-
:reset_locale
|
31
|
-
|
32
|
-
# resetting default configuration
|
33
|
-
def reset_config
|
34
|
-
ComfortableMexicanSofa.configure do |config|
|
35
|
-
config.cms_title = "ComfortableMexicanSofa CMS Engine"
|
36
|
-
config.admin_auth = "ComfortableMexicanSofa::AccessControl::AdminAuthentication"
|
37
|
-
config.admin_authorization = "ComfortableMexicanSofa::AccessControl::AdminAuthorization"
|
38
|
-
config.public_auth = "ComfortableMexicanSofa::AccessControl::PublicAuthentication"
|
39
|
-
config.public_authorization = "ComfortableMexicanSofa::AccessControl::PublicAuthorization"
|
40
|
-
config.admin_route_redirect = ""
|
41
|
-
config.enable_seeds = false
|
42
|
-
config.seeds_path = File.expand_path("db/cms_seeds", Rails.root)
|
43
|
-
config.revisions_limit = 25
|
44
|
-
config.locales = {
|
45
|
-
"en" => "English",
|
46
|
-
"es" => "Español"
|
47
|
-
}
|
48
|
-
config.admin_locale = nil
|
49
|
-
config.admin_cache_sweeper = nil
|
50
|
-
config.allow_erb = false
|
51
|
-
config.allowed_helpers = nil
|
52
|
-
config.allowed_partials = nil
|
53
|
-
config.allowed_templates = nil
|
54
|
-
config.hostname_aliases = nil
|
55
|
-
config.public_cms_path = nil
|
56
|
-
end
|
57
|
-
ComfortableMexicanSofa::AccessControl::AdminAuthentication.username = "username"
|
58
|
-
ComfortableMexicanSofa::AccessControl::AdminAuthentication.password = "password"
|
59
|
-
end
|
60
|
-
|
61
|
-
def reset_locale
|
62
|
-
I18n.default_locale = :en
|
63
|
-
I18n.locale = :en
|
64
|
-
end
|
65
|
-
|
66
|
-
# Example usage:
|
67
|
-
# assert_has_errors_on @record, :field_1, :field_2
|
68
|
-
def assert_has_errors_on(record, *fields)
|
69
|
-
unmatched = record.errors.keys - fields.flatten
|
70
|
-
assert unmatched.blank?, "#{record.class} has errors on '#{unmatched.join(', ')}'"
|
71
|
-
unmatched = fields.flatten - record.errors.keys
|
72
|
-
assert unmatched.blank?, "#{record.class} doesn't have errors on '#{unmatched.join(', ')}'"
|
73
|
-
end
|
74
|
-
|
75
|
-
# Example usage:
|
76
|
-
# assert_exception_raised do ... end
|
77
|
-
# assert_exception_raised ActiveRecord::RecordInvalid do ... end
|
78
|
-
# assert_exception_raised Plugin::Error, 'error_message' do ... end
|
79
|
-
def assert_exception_raised(exception_class = nil, error_message = nil)
|
80
|
-
exception_raised = nil
|
81
|
-
yield
|
82
|
-
rescue StandardError => exception_raised
|
83
|
-
exception_raised
|
84
|
-
ensure
|
85
|
-
if exception_raised
|
86
|
-
if exception_class
|
87
|
-
assert_equal exception_class, exception_raised.class, exception_raised.to_s
|
88
|
-
else
|
89
|
-
assert true
|
90
|
-
end
|
91
|
-
assert_equal error_message, exception_raised.to_s if error_message
|
92
|
-
else
|
93
|
-
flunk "Exception was not raised"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def assert_no_select(selector, value = nil)
|
98
|
-
assert_select(selector, text: value, count: 0)
|
99
|
-
end
|
100
|
-
|
101
|
-
def assert_count_difference(models, number = 1)
|
102
|
-
counts = [models].flatten.map { |m| "#{m}.count" }
|
103
|
-
assert_difference counts, number do
|
104
|
-
yield
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def assert_count_no_difference(*models)
|
109
|
-
counts = [models].flatten.map { |m| "#{m}.count" }
|
110
|
-
assert_no_difference counts do
|
111
|
-
yield
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# Capturing STDOUT into a string
|
116
|
-
def with_captured_stout
|
117
|
-
old = $stdout
|
118
|
-
$stdout = StringIO.new
|
119
|
-
yield
|
120
|
-
$stdout.string
|
121
|
-
ensure
|
122
|
-
$stdout = old
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
class ActionDispatch::IntegrationTest
|
128
|
-
|
129
|
-
# Attaching http_auth stuff with request. Example use:
|
130
|
-
# r :get, '/cms-admin/pages'
|
131
|
-
def r(method, path, options = {})
|
132
|
-
headers = options[:headers] || {}
|
133
|
-
headers["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials(
|
134
|
-
ComfortableMexicanSofa::AccessControl::AdminAuthentication.username,
|
135
|
-
ComfortableMexicanSofa::AccessControl::AdminAuthentication.password
|
136
|
-
)
|
137
|
-
options[:headers] = headers
|
138
|
-
send(method, path, options)
|
139
|
-
end
|
140
|
-
|
141
|
-
def with_routing
|
142
|
-
yield ComfortableMexicanSofa::Application.routes
|
143
|
-
ensure
|
144
|
-
ComfortableMexicanSofa::Application.routes_reloader.reload!
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
class Rails::Generators::TestCase
|
150
|
-
|
151
|
-
setup :prepare_destination,
|
152
|
-
:prepare_files
|
153
|
-
|
154
|
-
destination File.expand_path("../tmp", File.dirname(__FILE__))
|
155
|
-
|
156
|
-
def prepare_files
|
157
|
-
config_path = File.join(destination_root, "config")
|
158
|
-
routes_path = File.join(config_path, "routes.rb")
|
159
|
-
app_path = File.join(config_path, "application.rb")
|
160
|
-
FileUtils.mkdir_p(config_path)
|
161
|
-
FileUtils.touch(routes_path)
|
162
|
-
File.open(routes_path, "w") do |f|
|
163
|
-
f.write <<-RUBY.strip_heredoc
|
164
|
-
Test::Application.routes.draw do
|
165
|
-
end
|
166
|
-
RUBY
|
167
|
-
end
|
168
|
-
File.open(app_path, "w") do |f|
|
169
|
-
f.write <<-RUBY.strip_heredoc
|
170
|
-
module TestApp
|
171
|
-
class Application < Rails::Application
|
172
|
-
end
|
173
|
-
end
|
174
|
-
RUBY
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def read_file(filename)
|
179
|
-
File.read(
|
180
|
-
File.join(
|
181
|
-
File.expand_path("fixtures/generators", File.dirname(__FILE__)),
|
182
|
-
filename
|
183
|
-
)
|
184
|
-
)
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
190
|
-
|
191
|
-
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
|
192
|
-
|
193
|
-
# Visiting path and passing in BasicAuth credentials at the same time
|
194
|
-
# I have no idea how to set headers here.
|
195
|
-
def visit_p(path)
|
196
|
-
username = ComfortableMexicanSofa::AccessControl::AdminAuthentication.username
|
197
|
-
password = ComfortableMexicanSofa::AccessControl::AdminAuthentication.password
|
198
|
-
visit("http://#{username}:#{password}@#{Capybara.server_host}:#{Capybara.server_port}#{path}")
|
199
|
-
end
|
200
|
-
|
201
|
-
end
|