comfortable_mexican_sofa 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +95 -4
  3. data/.travis.yml +2 -1
  4. data/CONTRIBUTING.md +8 -5
  5. data/Gemfile +9 -9
  6. data/Rakefile +1 -1
  7. data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +1 -0
  8. data/app/assets/stylesheets/comfy/admin/cms/base.sass +14 -4
  9. data/app/controllers/application_controller.rb +2 -2
  10. data/app/controllers/comfy/admin/base_controller.rb +1 -1
  11. data/app/controllers/comfy/admin/cms/base_controller.rb +7 -6
  12. data/app/controllers/comfy/admin/cms/categories_controller.rb +2 -1
  13. data/app/controllers/comfy/admin/cms/files_controller.rb +32 -29
  14. data/app/controllers/comfy/admin/cms/layouts_controller.rb +10 -9
  15. data/app/controllers/comfy/admin/cms/pages_controller.rb +31 -27
  16. data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +5 -4
  17. data/app/controllers/comfy/admin/cms/revisions/layout_controller.rb +2 -1
  18. data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +9 -3
  19. data/app/controllers/comfy/admin/cms/revisions/snippet_controller.rb +2 -1
  20. data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +9 -3
  21. data/app/controllers/comfy/admin/cms/sites_controller.rb +10 -9
  22. data/app/controllers/comfy/admin/cms/snippets_controller.rb +10 -9
  23. data/app/controllers/comfy/admin/cms/translations_controller.rb +15 -14
  24. data/app/controllers/comfy/cms/assets_controller.rb +4 -3
  25. data/app/controllers/comfy/cms/base_controller.rb +12 -11
  26. data/app/controllers/comfy/cms/content_controller.rb +8 -7
  27. data/app/controllers/concerns/comfy/paginate.rb +2 -1
  28. data/app/helpers/comfy/cms_helper.rb +6 -3
  29. data/app/models/comfy/cms/categorization.rb +2 -1
  30. data/app/models/comfy/cms/category.rb +3 -2
  31. data/app/models/comfy/cms/file.rb +9 -7
  32. data/app/models/comfy/cms/fragment.rb +8 -6
  33. data/app/models/comfy/cms/layout.rb +24 -24
  34. data/app/models/comfy/cms/page.rb +51 -32
  35. data/app/models/comfy/cms/revision.rb +2 -1
  36. data/app/models/comfy/cms/site.rb +27 -26
  37. data/app/models/comfy/cms/snippet.rb +7 -5
  38. data/app/models/comfy/cms/translation.rb +6 -4
  39. data/app/models/concerns/comfy/cms/with_categories.rb +9 -7
  40. data/app/models/concerns/comfy/cms/with_fragments.rb +15 -13
  41. data/app/views/comfy/admin/cms/categories/_categories.html.haml +1 -1
  42. data/app/views/comfy/admin/cms/files/_file.html.haml +3 -3
  43. data/app/views/comfy/admin/cms/files/_modal.html.haml +2 -2
  44. data/app/views/comfy/admin/cms/{pages/_fragment_attachments.html.haml → fragments/_form_fragment_attachments.html.haml} +0 -0
  45. data/app/views/comfy/admin/cms/{pages → fragments}/_form_fragments.html.haml +0 -0
  46. data/app/views/comfy/admin/cms/layouts/_index_branch.html.haml +2 -2
  47. data/app/views/comfy/admin/cms/pages/_form.html.haml +7 -7
  48. data/app/views/comfy/admin/cms/pages/_index_branch.html.haml +16 -15
  49. data/app/views/comfy/admin/cms/pages/form_fragments.js.erb +1 -1
  50. data/app/views/comfy/admin/cms/pages/toggle_branch.js.erb +1 -1
  51. data/app/views/comfy/admin/cms/snippets/index.html.haml +3 -3
  52. data/app/views/comfy/admin/cms/translations/_form.html.haml +1 -1
  53. data/app/views/comfy/admin/cms/translations/form_fragments.js.erb +1 -1
  54. data/app/views/layouts/comfy/admin/cms/_body.html.haml +1 -4
  55. data/app/views/layouts/comfy/admin/cms.html.haml +1 -1
  56. data/bin/bundle +3 -0
  57. data/bin/rails +4 -0
  58. data/bin/rake +4 -0
  59. data/bin/setup +36 -0
  60. data/bin/update +31 -0
  61. data/bin/yarn +11 -0
  62. data/comfortable_mexican_sofa.gemspec +14 -14
  63. data/config/application.rb +4 -3
  64. data/config/boot.rb +3 -3
  65. data/config/cms_routes.rb +1 -1
  66. data/config/environment.rb +1 -1
  67. data/config/environments/development.rb +2 -2
  68. data/config/environments/test.rb +1 -1
  69. data/config/initializers/comfortable_mexican_sofa.rb +2 -5
  70. data/config/locales/cs.yml +2 -1
  71. data/config/locales/da.yml +2 -1
  72. data/config/locales/de.yml +2 -1
  73. data/config/locales/en.yml +2 -1
  74. data/config/locales/es.yml +2 -1
  75. data/config/locales/fr.yml +2 -1
  76. data/config/locales/it.yml +2 -1
  77. data/config/locales/ja.yml +2 -1
  78. data/config/locales/nb.yml +2 -1
  79. data/config/locales/nl.yml +2 -1
  80. data/config/locales/pl.yml +2 -1
  81. data/config/locales/pt-BR.yml +2 -1
  82. data/config/locales/ru.yml +2 -1
  83. data/config/locales/sk.yml +2 -1
  84. data/config/locales/sv.yml +2 -1
  85. data/config/locales/tr.yml +2 -1
  86. data/config/locales/uk.yml +2 -1
  87. data/config/locales/zh-CN.yml +2 -1
  88. data/config/locales/zh-TW.yml +2 -1
  89. data/config.ru +1 -1
  90. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +2 -1
  91. data/lib/comfortable_mexican_sofa/access_control/admin_authorization.rb +2 -0
  92. data/lib/comfortable_mexican_sofa/access_control/public_authentication.rb +3 -1
  93. data/lib/comfortable_mexican_sofa/access_control/public_authorization.rb +2 -0
  94. data/lib/comfortable_mexican_sofa/configuration.rb +27 -29
  95. data/lib/comfortable_mexican_sofa/content/block.rb +2 -1
  96. data/lib/comfortable_mexican_sofa/content/params_parser.rb +22 -21
  97. data/lib/comfortable_mexican_sofa/content/renderer.rb +10 -8
  98. data/lib/comfortable_mexican_sofa/content/tag.rb +1 -0
  99. data/lib/comfortable_mexican_sofa/content/tags/asset.rb +4 -3
  100. data/lib/comfortable_mexican_sofa/content/tags/checkbox.rb +3 -2
  101. data/lib/comfortable_mexican_sofa/content/tags/date.rb +4 -3
  102. data/lib/comfortable_mexican_sofa/content/tags/datetime.rb +4 -3
  103. data/lib/comfortable_mexican_sofa/content/tags/file.rb +15 -13
  104. data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +8 -7
  105. data/lib/comfortable_mexican_sofa/content/tags/files.rb +15 -13
  106. data/lib/comfortable_mexican_sofa/content/tags/fragment.rb +7 -6
  107. data/lib/comfortable_mexican_sofa/content/tags/helper.rb +2 -1
  108. data/lib/comfortable_mexican_sofa/content/tags/markdown.rb +5 -4
  109. data/lib/comfortable_mexican_sofa/content/tags/number.rb +4 -3
  110. data/lib/comfortable_mexican_sofa/content/tags/partial.rb +1 -0
  111. data/lib/comfortable_mexican_sofa/content/tags/snippet.rb +3 -2
  112. data/lib/comfortable_mexican_sofa/content/tags/template.rb +1 -0
  113. data/lib/comfortable_mexican_sofa/content/tags/text.rb +4 -3
  114. data/lib/comfortable_mexican_sofa/content/tags/textarea.rb +4 -3
  115. data/lib/comfortable_mexican_sofa/content/tags/wysiwyg.rb +4 -3
  116. data/lib/comfortable_mexican_sofa/content.rb +21 -21
  117. data/lib/comfortable_mexican_sofa/engine.rb +17 -15
  118. data/lib/comfortable_mexican_sofa/error.rb +12 -6
  119. data/lib/comfortable_mexican_sofa/extensions/acts_as_tree.rb +17 -11
  120. data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +14 -13
  121. data/lib/comfortable_mexican_sofa/form_builder.rb +2 -2
  122. data/lib/comfortable_mexican_sofa/render_methods.rb +74 -76
  123. data/lib/comfortable_mexican_sofa/routes/cms.rb +4 -4
  124. data/lib/comfortable_mexican_sofa/routes/cms_admin.rb +2 -1
  125. data/lib/comfortable_mexican_sofa/routing.rb +4 -2
  126. data/lib/comfortable_mexican_sofa/seeds/file/exporter.rb +7 -6
  127. data/lib/comfortable_mexican_sofa/seeds/file/importer.rb +9 -9
  128. data/lib/comfortable_mexican_sofa/seeds/layout/exporter.rb +8 -7
  129. data/lib/comfortable_mexican_sofa/seeds/layout/importer.rb +11 -10
  130. data/lib/comfortable_mexican_sofa/seeds/page/exporter.rb +25 -23
  131. data/lib/comfortable_mexican_sofa/seeds/page/importer.rb +47 -43
  132. data/lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb +7 -6
  133. data/lib/comfortable_mexican_sofa/seeds/snippet/importer.rb +7 -6
  134. data/lib/comfortable_mexican_sofa/seeds.rb +16 -9
  135. data/lib/comfortable_mexican_sofa/version.rb +4 -2
  136. data/lib/comfortable_mexican_sofa/view_hooks.rb +10 -9
  137. data/lib/comfortable_mexican_sofa.rb +30 -30
  138. data/lib/generators/comfy/cms/assets_generator.rb +6 -4
  139. data/lib/generators/comfy/cms/cms_generator.rb +14 -14
  140. data/lib/generators/comfy/cms/controllers_generator.rb +5 -3
  141. data/lib/generators/comfy/cms/models_generator.rb +5 -3
  142. data/lib/generators/comfy/cms/views_generator.rb +5 -3
  143. data/lib/generators/comfy/scaffold/scaffold_generator.rb +19 -18
  144. data/lib/tasks/cms_seeds.rake +4 -5
  145. data/test/controllers/comfy/admin/cms/base_controller_test.rb +4 -3
  146. data/test/controllers/comfy/admin/cms/categories_controller_test.rb +19 -18
  147. data/test/controllers/comfy/admin/cms/files_controller_test.rb +19 -19
  148. data/test/controllers/comfy/admin/cms/layouts_controller_test.rb +33 -32
  149. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +99 -98
  150. data/test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb +9 -9
  151. data/test/controllers/comfy/admin/cms/revisions/page_controller_test.rb +6 -6
  152. data/test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb +9 -8
  153. data/test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb +6 -7
  154. data/test/controllers/comfy/admin/cms/sites_controller_test.rb +31 -30
  155. data/test/controllers/comfy/admin/cms/snippets_controller_test.rb +38 -37
  156. data/test/controllers/comfy/admin/cms/translations_controller_test.rb +21 -20
  157. data/test/controllers/comfy/cms/assets_controller_test.rb +14 -13
  158. data/test/controllers/comfy/cms/content_controller_test.rb +58 -57
  159. data/test/gemfiles/Gemfile.rails.5.2 +5 -4
  160. data/test/generators/cms_assets_generator_test.rb +6 -4
  161. data/test/generators/cms_controllers_generator_test.rb +7 -5
  162. data/test/generators/cms_generator_test.rb +12 -10
  163. data/test/generators/cms_models_generator_test.rb +7 -5
  164. data/test/generators/cms_views_generator_test.rb +6 -4
  165. data/test/generators/scaffold_generator_test.rb +18 -16
  166. data/test/helpers/cms_helper_test.rb +5 -2
  167. data/test/integration/access_control_test.rb +29 -20
  168. data/test/integration/i18n_test.rb +8 -7
  169. data/test/integration/js_variables_test.rb +2 -1
  170. data/test/integration/render_cms_test.rb +93 -88
  171. data/test/integration/routing_test.rb +4 -3
  172. data/test/integration/seeds_test.rb +21 -22
  173. data/test/integration/sites_test.rb +26 -25
  174. data/test/integration/view_hooks_test.rb +15 -14
  175. data/test/lib/configuration_test.rb +13 -15
  176. data/test/lib/content/block_test.rb +1 -1
  177. data/test/lib/content/params_parser_test.rb +11 -10
  178. data/test/lib/content/renderer_test.rb +16 -11
  179. data/test/lib/content/tag_test.rb +7 -3
  180. data/test/lib/content/tags/asset_test.rb +4 -3
  181. data/test/lib/content/tags/checkbox_test.rb +2 -1
  182. data/test/lib/content/tags/date_test.rb +2 -1
  183. data/test/lib/content/tags/datetime_test.rb +2 -1
  184. data/test/lib/content/tags/file_link_test.rb +3 -2
  185. data/test/lib/content/tags/file_test.rb +3 -2
  186. data/test/lib/content/tags/files_test.rb +4 -3
  187. data/test/lib/content/tags/fragment_test.rb +2 -1
  188. data/test/lib/content/tags/helper_test.rb +4 -3
  189. data/test/lib/content/tags/markdown_test.rb +2 -1
  190. data/test/lib/content/tags/number_test.rb +2 -1
  191. data/test/lib/content/tags/partial_test.rb +4 -3
  192. data/test/lib/content/tags/snippet_test.rb +2 -1
  193. data/test/lib/content/tags/template_test.rb +2 -1
  194. data/test/lib/content/tags/text_test.rb +2 -1
  195. data/test/lib/content/tags/textarea_test.rb +2 -1
  196. data/test/lib/content/tags/wysiwyg_test.rb +2 -1
  197. data/test/lib/revisions_test.rb +44 -42
  198. data/test/lib/seeds/files_test.rb +30 -29
  199. data/test/lib/seeds/layouts_test.rb +13 -12
  200. data/test/lib/seeds/pages_test.rb +32 -29
  201. data/test/lib/seeds/snippets_test.rb +21 -20
  202. data/test/lib/seeds_test.rb +9 -8
  203. data/test/models/categorization_test.rb +10 -9
  204. data/test/models/category_test.rb +1 -1
  205. data/test/models/file_test.rb +1 -1
  206. data/test/models/fragment_test.rb +11 -10
  207. data/test/models/layout_test.rb +71 -70
  208. data/test/models/page_test.rb +170 -159
  209. data/test/models/site_test.rb +17 -16
  210. data/test/models/snippet_test.rb +1 -0
  211. data/test/models/translation_test.rb +2 -1
  212. data/test/tasks/cms_seeds_test.rb +3 -2
  213. data/test/test_helper.rb +42 -40
  214. metadata +55 -51
  215. data/.rubocop_todo.yml +0 -974
  216. data/script/rails +0 -6
@@ -1,4 +1,4 @@
1
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
2
2
 
3
3
  class JsVariablesIntegrationTest < ActionDispatch::IntegrationTest
4
4
 
@@ -17,4 +17,5 @@ class JsVariablesIntegrationTest < ActionDispatch::IntegrationTest
17
17
 
18
18
  assert response.body.match(js_vars)
19
19
  end
20
+
20
21
  end
@@ -1,18 +1,18 @@
1
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
2
2
 
3
3
  class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
4
4
 
5
5
  def setup
6
6
  super
7
7
  Rails.application.routes.draw do
8
- get '/render-basic' => 'render_test#render_basic'
9
- get '/render-page' => 'render_test#render_page'
10
- get '/site-path/render-page' => 'render_test#render_page'
11
- get '/render-layout' => 'render_test#render_layout'
8
+ get "/render-basic" => "render_test#render_basic"
9
+ get "/render-page" => "render_test#render_page"
10
+ get "/site-path/render-page" => "render_test#render_page"
11
+ get "/render-layout" => "render_test#render_layout"
12
12
  end
13
- comfy_cms_layouts(:default).update_columns(content: '{{cms:text content}}')
13
+ comfy_cms_layouts(:default).update_columns(content: "{{cms:text content}}")
14
14
  comfy_cms_pages(:child).update_attributes(fragments_attributes: [
15
- { identifier: 'content', content: 'TestBlockContent' }
15
+ { identifier: "content", content: "TestBlockContent" }
16
16
  ])
17
17
  end
18
18
 
@@ -21,28 +21,32 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
21
21
  end
22
22
 
23
23
  def create_site_b
24
- site = Comfy::Cms::Site.create!(
25
- identifier: 'site-b',
26
- hostname: 'site-b.test')
27
- layout = site.layouts.create!(
28
- identifier: 'default',
29
- content: 'site-b {{cms:text content}}')
30
- page = site.pages.create!(
31
- label: 'default',
24
+ site = Comfy::Cms::Site.create!(
25
+ identifier: "site-b",
26
+ hostname: "site-b.test"
27
+ )
28
+ layout = site.layouts.create!(
29
+ identifier: "default",
30
+ content: "site-b {{cms:text content}}"
31
+ )
32
+ site.pages.create!(
33
+ label: "default",
32
34
  layout: layout,
33
- fragments_attributes: [{identifier: 'content', content: 'SiteBContent'}])
35
+ fragments_attributes: [{ identifier: "content", content: "SiteBContent" }]
36
+ )
34
37
  end
35
38
 
36
39
  class ::RenderTestController < ApplicationController
37
- append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
40
+
41
+ append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
38
42
 
39
43
  def render_basic
40
44
  case params[:type]
41
- when 'text'
42
- render plain: 'TestText'
43
- when 'update'
45
+ when "text"
46
+ render plain: "TestText"
47
+ when "update"
44
48
  render :update do |page|
45
- page.alert('rendered text')
49
+ page.alert("rendered text")
46
50
  end
47
51
  else
48
52
  render
@@ -51,146 +55,146 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
51
55
 
52
56
  def render_page
53
57
  case params[:type]
54
- when 'page_implicit'
58
+ when "page_implicit"
55
59
  render
56
- when 'page_explicit'
57
- render cms_page: '/test-page'
58
- when 'page_explicit_with_status'
59
- render cms_page: '/test-page', status: 404
60
- when 'page_explicit_with_site'
61
- render cms_page: '/', cms_site: 'site-b'
62
- when 'page_explicit_with_blocks'
63
- render cms_page: '/test-page', cms_fragments: {
64
- content: 'custom page content'
60
+ when "page_explicit"
61
+ render cms_page: "/test-page"
62
+ when "page_explicit_with_status"
63
+ render cms_page: "/test-page", status: 404
64
+ when "page_explicit_with_site"
65
+ render cms_page: "/", cms_site: "site-b"
66
+ when "page_explicit_with_blocks"
67
+ render cms_page: "/test-page", cms_fragments: {
68
+ content: "custom page content"
65
69
  }
66
70
  else
67
- raise 'Invalid or no param[:type] provided'
71
+ raise "Invalid or no param[:type] provided"
68
72
  end
69
73
  end
70
74
 
71
75
  def render_layout
72
- @test_value = 'TestValue'
76
+ @test_value = "TestValue"
73
77
  case params[:type]
74
- when 'layout_defaults'
75
- render cms_layout: 'default'
76
- when 'layout'
77
- render cms_layout: 'default', cms_fragments: {
78
- content: 'TestText',
79
- content_b: {partial: 'render_test/test' },
80
- content_c: {template: 'render_test/render_layout' }
78
+ when "layout_defaults"
79
+ render cms_layout: "default"
80
+ when "layout"
81
+ render cms_layout: "default", cms_fragments: {
82
+ content: "TestText",
83
+ content_b: { partial: "render_test/test" },
84
+ content_c: { template: "render_test/render_layout" }
81
85
  }
82
- when 'layout_with_status'
83
- render cms_layout: 'default', status: 404
84
- when 'layout_invalid'
85
- render cms_layout: 'invalid'
86
- when 'layout_defaults_with_site'
87
- render cms_layout: 'default', cms_site: 'site-b'
88
- when 'layout_with_action'
89
- render cms_layout: 'default', action: :new
86
+ when "layout_with_status"
87
+ render cms_layout: "default", status: 404
88
+ when "layout_invalid"
89
+ render cms_layout: "invalid"
90
+ when "layout_defaults_with_site"
91
+ render cms_layout: "default", cms_site: "site-b"
92
+ when "layout_with_action"
93
+ render cms_layout: "default", action: :new
90
94
  else
91
- raise 'Invalid or no param[:type] provided'
95
+ raise "Invalid or no param[:type] provided"
92
96
  end
93
97
  end
94
98
 
95
- def new
96
- end
99
+ def new; end
100
+
97
101
  end
98
102
 
99
103
  # -- Basic Render Tests ------------------------------------------------------
100
104
  def test_text
101
- get '/render-basic?type=text'
105
+ get "/render-basic?type=text"
102
106
  assert_response :success
103
- assert_equal 'TestText', response.body
107
+ assert_equal "TestText", response.body
104
108
  end
105
109
 
106
110
  def test_implicit_cms_page_failure
107
111
  Comfy::Cms::Site.destroy_all
108
112
  assert_exception_raised ActionView::MissingTemplate do
109
- get '/render-basic'
113
+ get "/render-basic"
110
114
  end
111
115
  end
112
116
 
113
117
  # -- Page Render Test --------------------------------------------------------
114
118
  def test_implicit_cms_page
115
119
  page = comfy_cms_pages(:child)
116
- page.update_attributes(slug: 'render-basic')
117
- get '/render-basic?type=page_implicit'
120
+ page.update_attributes(slug: "render-basic")
121
+ get "/render-basic?type=page_implicit"
118
122
  assert_response :success
119
123
  assert assigns(:cms_site)
120
124
  assert assigns(:cms_layout)
121
125
  assert assigns(:cms_page)
122
126
  assert_equal page, assigns(:cms_page)
123
- assert_equal 'TestBlockContent', response.body
127
+ assert_equal "TestBlockContent", response.body
124
128
  end
125
129
 
126
130
  def test_implicit_cms_page_with_site_path
127
- comfy_cms_sites(:default).update_column(:path, 'site-path')
128
- comfy_cms_pages(:child).update_attributes(slug: 'render-page')
129
- get '/site-path/render-page?type=page_implicit'
131
+ comfy_cms_sites(:default).update_column(:path, "site-path")
132
+ comfy_cms_pages(:child).update_attributes(slug: "render-page")
133
+ get "/site-path/render-page?type=page_implicit"
130
134
  assert_response :success
131
- assert_equal 'TestBlockContent', response.body
135
+ assert_equal "TestBlockContent", response.body
132
136
  end
133
137
 
134
138
  def test_explicit_cms_page
135
139
  page = comfy_cms_pages(:child)
136
- page.update_attributes(slug: 'test-page')
137
- get '/render-page?type=page_explicit'
140
+ page.update_attributes(slug: "test-page")
141
+ get "/render-page?type=page_explicit"
138
142
  assert_response :success
139
143
  assert assigns(:cms_site)
140
144
  assert assigns(:cms_layout)
141
145
  assert assigns(:cms_page)
142
146
  assert_equal page, assigns(:cms_page)
143
- assert_equal 'TestBlockContent', response.body
147
+ assert_equal "TestBlockContent", response.body
144
148
  end
145
149
 
146
150
  def test_explicit_cms_page_with_status
147
151
  page = comfy_cms_pages(:child)
148
- page.update_attributes(slug: 'test-page')
149
- get '/render-page?type=page_explicit_with_status'
152
+ page.update_attributes(slug: "test-page")
153
+ get "/render-page?type=page_explicit_with_status"
150
154
  assert_response :not_found
151
155
  assert assigns(:cms_site)
152
156
  assert assigns(:cms_layout)
153
157
  assert assigns(:cms_page)
154
158
  assert_equal page, assigns(:cms_page)
155
- assert_equal 'TestBlockContent', response.body
159
+ assert_equal "TestBlockContent", response.body
156
160
  end
157
161
 
158
162
  def test_explicit_cms_page_failure
159
163
  page = comfy_cms_pages(:child)
160
- page.update_attributes(slug: 'invalid')
164
+ page.update_attributes(slug: "invalid")
161
165
  assert_exception_raised ComfortableMexicanSofa::MissingPage do
162
- get '/render-page?type=page_explicit'
166
+ get "/render-page?type=page_explicit"
163
167
  end
164
168
  end
165
169
 
166
170
  def test_explicit_with_site
167
171
  create_site_b
168
- get '/render-page?type=page_explicit_with_site'
172
+ get "/render-page?type=page_explicit_with_site"
169
173
  assert_response :success
170
174
  assert assigns(:cms_site)
171
- assert_equal 'site-b', assigns(:cms_site).identifier
172
- assert_equal 'site-b SiteBContent', response.body
175
+ assert_equal "site-b", assigns(:cms_site).identifier
176
+ assert_equal "site-b SiteBContent", response.body
173
177
  end
174
178
 
175
179
  def test_explicit_with_site_failure
176
180
  assert_exception_raised ComfortableMexicanSofa::MissingSite do
177
- get '/render-page?type=page_explicit_with_site'
181
+ get "/render-page?type=page_explicit_with_site"
178
182
  end
179
183
  end
180
184
 
181
185
  def test_explicit_with_page_blocks
182
186
  page = comfy_cms_pages(:child)
183
- page.update_attributes(slug: 'test-page')
184
- get '/render-page?type=page_explicit_with_blocks'
187
+ page.update_attributes(slug: "test-page")
188
+ get "/render-page?type=page_explicit_with_blocks"
185
189
  assert_response :success
186
- assert_equal 'custom page content', response.body
190
+ assert_equal "custom page content", response.body
187
191
  end
188
192
 
189
193
  # -- Layout Render Tests -----------------------------------------------------
190
194
  def test_cms_layout_defaults
191
- get '/render-layout?type=layout_defaults'
195
+ get "/render-layout?type=layout_defaults"
192
196
  assert_response :success
193
- assert_equal 'TestTemplate TestValue', response.body
197
+ assert_equal "TestTemplate TestValue", response.body
194
198
  assert assigns(:cms_site)
195
199
  assert assigns(:cms_layout)
196
200
  assert_equal comfy_cms_layouts(:default), assigns(:cms_layout)
@@ -199,18 +203,18 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
199
203
  def test_cms_layout
200
204
  content = "{{cms:text content}} {{cms:text content_b}} {{cms:text content_c}}"
201
205
  comfy_cms_layouts(:default).update_columns(content: content)
202
- get '/render-layout?type=layout'
206
+ get "/render-layout?type=layout"
203
207
  assert_response :success
204
- assert_equal 'TestText TestPartial TestValue TestTemplate TestValue', response.body
208
+ assert_equal "TestText TestPartial TestValue TestTemplate TestValue", response.body
205
209
  assert assigns(:cms_site)
206
210
  assert assigns(:cms_layout)
207
211
  assert_equal comfy_cms_layouts(:default), assigns(:cms_layout)
208
212
  end
209
213
 
210
214
  def test_cms_layout_with_status
211
- get '/render-layout?type=layout_with_status'
215
+ get "/render-layout?type=layout_with_status"
212
216
  assert_response 404
213
- assert_equal 'TestTemplate TestValue', response.body
217
+ assert_equal "TestTemplate TestValue", response.body
214
218
  assert assigns(:cms_site)
215
219
  assert assigns(:cms_layout)
216
220
  assert_equal comfy_cms_layouts(:default), assigns(:cms_layout)
@@ -219,7 +223,7 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
219
223
  def test_cms_layout_with_action
220
224
  content = "{{cms:text content}} {{cms:text content_b}} {{cms:text content_c}}"
221
225
  comfy_cms_layouts(:default).update_columns(content: content)
222
- get '/render-layout?type=layout_with_action'
226
+ get "/render-layout?type=layout_with_action"
223
227
  assert_response :success
224
228
  assert_equal "Can render CMS layout and specify action\n ", response.body
225
229
  assert assigns(:cms_site)
@@ -229,22 +233,23 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
229
233
 
230
234
  def test_cms_layout_failure
231
235
  assert_exception_raised ComfortableMexicanSofa::MissingLayout do
232
- get '/render-layout?type=layout_invalid'
236
+ get "/render-layout?type=layout_invalid"
233
237
  end
234
238
  end
235
239
 
236
240
  def test_cms_layout_defaults_with_site
237
241
  create_site_b
238
- get '/render-layout?type=layout_defaults_with_site'
242
+ get "/render-layout?type=layout_defaults_with_site"
239
243
  assert_response :success
240
244
  assert assigns(:cms_site)
241
- assert_equal 'site-b', assigns(:cms_site).identifier
242
- assert_equal 'site-b TestTemplate TestValue', response.body
245
+ assert_equal "site-b", assigns(:cms_site).identifier
246
+ assert_equal "site-b TestTemplate TestValue", response.body
243
247
  end
244
248
 
245
249
  def test_cms_layout_defaults_with_site_failure
246
250
  assert_exception_raised ComfortableMexicanSofa::MissingSite do
247
- get '/render-layout?type=layout_defaults_with_site'
251
+ get "/render-layout?type=layout_defaults_with_site"
248
252
  end
249
253
  end
254
+
250
255
  end
@@ -1,4 +1,4 @@
1
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
2
2
 
3
3
  class RoutingIntergrationTest < ActionDispatch::IntegrationTest
4
4
 
@@ -10,9 +10,10 @@ class RoutingIntergrationTest < ActionDispatch::IntegrationTest
10
10
  assert_nil ComfortableMexicanSofa.config.public_cms_path
11
11
 
12
12
  Rails.application.routes.draw do
13
- comfy_route :cms, path: '/custom'
13
+ comfy_route :cms, path: "/custom"
14
14
  end
15
15
 
16
- assert_equal '/custom', ComfortableMexicanSofa.config.public_cms_path
16
+ assert_equal "/custom", ComfortableMexicanSofa.config.public_cms_path
17
17
  end
18
+
18
19
  end
@@ -1,20 +1,20 @@
1
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
2
2
 
3
3
  class SeedsIntergrationTest < ActionDispatch::IntegrationTest
4
4
 
5
5
  setup do
6
6
  @site = comfy_cms_sites(:default)
7
- @site.update_columns(identifier: 'sample-site')
7
+ @site.update_columns(identifier: "sample-site")
8
8
  end
9
9
 
10
10
  def test_seeds_disabled
11
- assert_no_difference ['Comfy::Cms::Layout.count', 'Comfy::Cms::Page.count', 'Comfy::Cms::Snippet.count'] do
12
- get '/'
11
+ assert_no_difference ["Comfy::Cms::Layout.count", "Comfy::Cms::Page.count", "Comfy::Cms::Snippet.count"] do
12
+ get "/"
13
13
  assert_response :success
14
14
 
15
- assert_equal 'Default Page', Comfy::Cms::Page.root.label
16
- assert_equal 'Default Layout', Comfy::Cms::Layout.find_by_identifier('default').label
17
- assert_equal 'Default Snippet', Comfy::Cms::Snippet.find_by_identifier('default').label
15
+ assert_equal "Default Page", Comfy::Cms::Page.root.label
16
+ assert_equal "Default Layout", Comfy::Cms::Layout.find_by_identifier("default").label
17
+ assert_equal "Default Snippet", Comfy::Cms::Snippet.find_by_identifier("default").label
18
18
  end
19
19
  end
20
20
 
@@ -24,18 +24,17 @@ class SeedsIntergrationTest < ActionDispatch::IntegrationTest
24
24
  Comfy::Cms::Page.destroy_all
25
25
  Comfy::Cms::Snippet.destroy_all
26
26
 
27
- assert_difference 'Comfy::Cms::Page.count', 3 do
28
- assert_difference 'Comfy::Cms::Layout.count', 2 do
29
- assert_difference 'Comfy::Cms::Snippet.count', 1 do
30
- get '/'
27
+ assert_difference "Comfy::Cms::Page.count", 3 do
28
+ assert_difference "Comfy::Cms::Layout.count", 2 do
29
+ assert_difference "Comfy::Cms::Snippet.count", 1 do
30
+ get "/"
31
31
  assert_response :success
32
32
 
33
- assert_equal 'Home Seed Page', Comfy::Cms::Page.root.label
34
- assert_equal 'Default Seed Layout', Comfy::Cms::Layout.find_by_identifier('default').label
35
- assert_equal 'Default Seed Snippet', Comfy::Cms::Snippet.find_by_identifier('default').label
33
+ assert_equal "Home Seed Page", Comfy::Cms::Page.root.label
34
+ assert_equal "Default Seed Layout", Comfy::Cms::Layout.find_by_identifier("default").label
35
+ assert_equal "Default Seed Snippet", Comfy::Cms::Snippet.find_by_identifier("default").label
36
36
 
37
-
38
- file_path = url_for(ActiveStorage::Blob.find_by(filename: 'header.png'))
37
+ file_path = url_for(ActiveStorage::Blob.find_by(filename: "header.png"))
39
38
  file_path = file_path.sub("http://test.host", "")
40
39
  out = <<-HTML.strip_heredoc
41
40
  <html>
@@ -62,12 +61,12 @@ class SeedsIntergrationTest < ActionDispatch::IntegrationTest
62
61
  Comfy::Cms::Page.destroy_all
63
62
  Comfy::Cms::Snippet.destroy_all
64
63
 
65
- assert_difference 'Comfy::Cms::Page.count', 3 do
66
- assert_difference 'Comfy::Cms::Layout.count', 2 do
67
- assert_difference 'Comfy::Cms::Snippet.count', 1 do
68
- r :get, "/admin/sites/#{@site.id}/pages"
69
- assert_response :success
70
- assert_equal 'CMS Seeds are enabled. All changes done here will be discarded.', flash[:warning]
64
+ assert_difference "Comfy::Cms::Page.count", 3 do
65
+ assert_difference "Comfy::Cms::Layout.count", 2 do
66
+ assert_difference "Comfy::Cms::Snippet.count", 1 do
67
+ r :get, "/admin/sites/#{@site.id}/pages"
68
+ assert_response :success
69
+ assert_equal "CMS Seeds are enabled. All changes done here will be discarded.", flash[:warning]
71
70
  end
72
71
  end
73
72
  end
@@ -1,4 +1,4 @@
1
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
2
2
 
3
3
  class SitesIntegrationTest < ActionDispatch::IntegrationTest
4
4
 
@@ -15,63 +15,63 @@ class SitesIntegrationTest < ActionDispatch::IntegrationTest
15
15
  r :get, comfy_admin_cms_path
16
16
  assert_response :redirect
17
17
  assert_redirected_to new_comfy_admin_cms_site_path
18
- assert_equal 'Site not found', flash[:danger]
18
+ assert_equal "Site not found", flash[:danger]
19
19
  end
20
20
 
21
21
  def test_get_public_page_with_single_site
22
- host! 'bogus.host'
23
- get '/'
22
+ host! "bogus.host"
23
+ get "/"
24
24
  assert_response :success
25
25
  assert assigns(:cms_site)
26
- assert_equal 'test.host', assigns(:cms_site).hostname
26
+ assert_equal "test.host", assigns(:cms_site).hostname
27
27
  end
28
28
 
29
29
  def test_get_public_page_with_sites_with_different_paths
30
30
  Comfy::Cms::Site.delete_all
31
- site_a = Comfy::Cms::Site.create!(identifier: 'site-a', hostname: 'test.host', path: '')
32
- site_b = Comfy::Cms::Site.create!(identifier: 'site-b', hostname: 'test.host', path: 'path-b')
33
- site_c = Comfy::Cms::Site.create!(identifier: 'site-c', hostname: 'test.host', path: 'path-c/child')
31
+ site_a = Comfy::Cms::Site.create!(identifier: "site-a", hostname: "test.host", path: "")
32
+ site_b = Comfy::Cms::Site.create!(identifier: "site-b", hostname: "test.host", path: "path-b")
33
+ site_c = Comfy::Cms::Site.create!(identifier: "site-c", hostname: "test.host", path: "path-c/child")
34
34
 
35
35
  [site_a, site_b, site_c].each do |site|
36
- layout = site.layouts.create!(identifier: 'test')
37
- site.pages.create!(label: 'index', layout: layout)
38
- site.pages.create!(label: '404', slug: '404', layout: layout)
36
+ layout = site.layouts.create!(identifier: "test")
37
+ site.pages.create!(label: "index", layout: layout)
38
+ site.pages.create!(label: "404", slug: "404", layout: layout)
39
39
  end
40
40
 
41
- %w(/ /path-a /path-a/child /path-c).each do |path|
41
+ %w[/ /path-a /path-a/child /path-c].each do |path|
42
42
  get path
43
43
  assert assigns(:cms_site), path
44
44
  assert_equal site_a, assigns(:cms_site)
45
- assert_equal path.gsub(/^\//, ''), @controller.params[:cms_path].to_s
45
+ assert_equal path.gsub(%r{^/}, ""), @controller.params[:cms_path].to_s
46
46
  end
47
47
 
48
- %w(/path-b /path-b/child).each do |path|
48
+ %w[/path-b /path-b/child].each do |path|
49
49
  get path
50
50
  assert assigns(:cms_site), path
51
51
  assert_equal site_b, assigns(:cms_site)
52
- assert_equal path.gsub(/^\/path-b/, '').gsub(/^\//, ''), @controller.params[:cms_path].to_s
52
+ assert_equal path.gsub(%r{^/path-b}, "").gsub(%r{^/}, ""), @controller.params[:cms_path].to_s
53
53
  end
54
54
 
55
- %w(/path-c/child /path-c/child/child).each do |path|
55
+ %w[/path-c/child /path-c/child/child].each do |path|
56
56
  get path
57
57
  assert assigns(:cms_site), path
58
58
  assert_equal site_c, assigns(:cms_site)
59
- assert_equal path.gsub(/^\/path-c\/child/, '').gsub(/^\//, ''), @controller.params[:cms_path].to_s
59
+ assert_equal path.gsub(%r{^/path-c/child}, "").gsub(%r{^/}, ""), @controller.params[:cms_path].to_s
60
60
  end
61
61
  end
62
62
 
63
63
  def test_get_public_page_with_host_with_port
64
64
  Comfy::Cms::Site.delete_all
65
- site_a = Comfy::Cms::Site.create!(identifier: 'site-a', hostname: 'test.host:3000')
66
- site_b = Comfy::Cms::Site.create!(identifier: 'site-b', hostname: 'test.host')
65
+ site_a = Comfy::Cms::Site.create!(identifier: "site-a", hostname: "test.host:3000")
66
+ site_b = Comfy::Cms::Site.create!(identifier: "site-b", hostname: "test.host")
67
67
 
68
68
  [site_a, site_b].each do |site|
69
- layout = site.layouts.create!(identifier: 'test')
70
- site.pages.create!(label: 'index', layout: layout)
71
- site.pages.create!(label: '404', slug: '404', layout: layout)
69
+ layout = site.layouts.create!(identifier: "test")
70
+ site.pages.create!(label: "index", layout: layout)
71
+ site.pages.create!(label: "404", slug: "404", layout: layout)
72
72
  end
73
73
 
74
- get '/'
74
+ get "/"
75
75
  assert assigns(:cms_site)
76
76
  assert_equal site_b, assigns(:cms_site)
77
77
  end
@@ -81,7 +81,7 @@ class SitesIntegrationTest < ActionDispatch::IntegrationTest
81
81
  assert_response :success
82
82
  assert_equal :en, I18n.locale
83
83
 
84
- comfy_cms_sites(:default).update_columns(locale: 'fr')
84
+ comfy_cms_sites(:default).update_columns(locale: "fr")
85
85
  r :get, comfy_admin_cms_site_pages_path(comfy_cms_sites(:default))
86
86
  assert_response :success
87
87
  assert_equal :fr, I18n.locale
@@ -90,7 +90,7 @@ class SitesIntegrationTest < ActionDispatch::IntegrationTest
90
90
  def test_get_admin_with_forced_locale
91
91
  ComfortableMexicanSofa.config.admin_locale = :en
92
92
 
93
- comfy_cms_sites(:default).update_columns(locale: 'fr')
93
+ comfy_cms_sites(:default).update_columns(locale: "fr")
94
94
  r :get, comfy_admin_cms_site_pages_path(comfy_cms_sites(:default))
95
95
  assert_response :success
96
96
  assert_equal :en, I18n.locale
@@ -103,4 +103,5 @@ class SitesIntegrationTest < ActionDispatch::IntegrationTest
103
103
 
104
104
  I18n.default_locale = :en
105
105
  end
106
+
106
107
  end
@@ -1,4 +1,4 @@
1
- require_relative '../test_helper'
1
+ require_relative "../test_helper"
2
2
 
3
3
  class ViewHooksIntegrationTest < ActionDispatch::IntegrationTest
4
4
 
@@ -7,33 +7,33 @@ class ViewHooksIntegrationTest < ActionDispatch::IntegrationTest
7
7
  end
8
8
 
9
9
  def test_hooks_rendering
10
- Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
11
- ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook')
10
+ Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
11
+ ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook")
12
12
 
13
13
  r :get, comfy_admin_cms_sites_path
14
14
  assert_response :success
15
- assert_match /hook_content/, response.body
15
+ assert_match %r{hook_content}, response.body
16
16
  end
17
17
 
18
18
  def test_hooks_rendering_with_multiples
19
- Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
20
- ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook')
21
- ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook_2')
19
+ Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
20
+ ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook")
21
+ ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook_2")
22
22
 
23
23
  r :get, comfy_admin_cms_sites_path
24
24
  assert_response :success
25
- assert_match /hook_content/, response.body
26
- assert_match /<hook_content_2>/, response.body
25
+ assert_match %r{hook_content}, response.body
26
+ assert_match %r{<hook_content_2>}, response.body
27
27
  end
28
28
 
29
29
  def test_hooks_rendering_with_proper_order
30
- Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
31
- ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook_2', 0)
32
- ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook', 1)
30
+ Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
31
+ ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook_2", 0)
32
+ ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook", 1)
33
33
 
34
34
  r :get, comfy_admin_cms_sites_path
35
35
  assert_response :success
36
- assert_match /<hook_content_2>hook_content/, response.body
36
+ assert_match %r{<hook_content_2>hook_content}, response.body
37
37
  end
38
38
 
39
39
  def test_hooks_rendering_with_no_hook
@@ -41,6 +41,7 @@ class ViewHooksIntegrationTest < ActionDispatch::IntegrationTest
41
41
 
42
42
  r :get, comfy_admin_cms_sites_path
43
43
  assert_response :success
44
- assert_no_match /hook_content/, response.body
44
+ assert_no_match %r{hook_content}, response.body
45
45
  end
46
+
46
47
  end