comfortable_mexican_sofa 1.0.51 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/README.md +8 -18
  2. data/Rakefile +1 -4
  3. data/VERSION +1 -1
  4. data/app/controllers/cms_admin/base_controller.rb +8 -9
  5. data/app/controllers/cms_admin/layouts_controller.rb +5 -5
  6. data/app/controllers/cms_admin/pages_controller.rb +14 -14
  7. data/app/controllers/cms_admin/sites_controller.rb +4 -4
  8. data/app/controllers/cms_admin/snippets_controller.rb +4 -4
  9. data/app/controllers/cms_admin/uploads_controller.rb +2 -2
  10. data/app/controllers/cms_content_controller.rb +21 -8
  11. data/app/models/cms/block.rb +13 -0
  12. data/app/models/{cms_layout.rb → cms/layout.rb} +16 -44
  13. data/app/models/{cms_page.rb → cms/page.rb} +26 -57
  14. data/app/models/{cms_site.rb → cms/site.rb} +8 -6
  15. data/app/models/cms/snippet.rb +36 -0
  16. data/app/models/{cms_upload.rb → cms/upload.rb} +5 -3
  17. data/app/views/cms_admin/layouts/_form.html.erb +2 -2
  18. data/app/views/cms_admin/pages/_form.html.erb +5 -5
  19. data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -3
  20. data/app/views/cms_admin/uploads/_index.html.erb +1 -1
  21. data/app/views/layouts/cms_admin.html.erb +2 -38
  22. data/app/views/layouts/cms_admin/_body.html.erb +17 -0
  23. data/app/views/layouts/cms_admin/_center.html.erb +6 -0
  24. data/app/views/layouts/cms_admin/_head.html.erb +11 -0
  25. data/app/views/layouts/cms_admin/_left.html.erb +7 -0
  26. data/app/views/layouts/cms_admin/_right.html.erb +1 -0
  27. data/comfortable_mexican_sofa.gemspec +94 -96
  28. data/config/environments/development.rb +1 -1
  29. data/config/environments/production.rb +1 -1
  30. data/config/environments/test.rb +1 -1
  31. data/config/initializers/comfortable_mexican_sofa.rb +10 -12
  32. data/db/cms_fixtures/example.com/layouts/default/_default.yml +1 -0
  33. data/db/cms_fixtures/example.com/layouts/default/content.html +5 -0
  34. data/db/cms_fixtures/example.com/layouts/default/css.css +1 -0
  35. data/db/cms_fixtures/example.com/layouts/default/js.js +1 -0
  36. data/db/cms_fixtures/example.com/layouts/default/nested/_nested.yml +1 -0
  37. data/db/cms_fixtures/example.com/layouts/default/nested/content.html +2 -0
  38. data/db/cms_fixtures/example.com/layouts/default/nested/css.css +1 -0
  39. data/db/cms_fixtures/example.com/layouts/default/nested/js.js +1 -0
  40. data/db/cms_fixtures/example.com/pages/index/_index.yml +2 -0
  41. data/db/cms_fixtures/example.com/pages/index/child/_child.yml +2 -0
  42. data/db/cms_fixtures/example.com/pages/index/child/left.html +1 -0
  43. data/db/cms_fixtures/example.com/pages/index/child/right.html +1 -0
  44. data/db/cms_fixtures/example.com/pages/index/content.html +2 -0
  45. data/db/cms_fixtures/example.com/snippets/default/_default.yml +1 -0
  46. data/db/cms_fixtures/example.com/snippets/default/content.html +1 -0
  47. data/db/migrate/01_create_cms.rb +11 -11
  48. data/db/migrate/upgrades/02_upgrade_to_1_1_0.rb +19 -0
  49. data/lib/comfortable_mexican_sofa.rb +6 -13
  50. data/lib/comfortable_mexican_sofa/configuration.rb +21 -20
  51. data/lib/comfortable_mexican_sofa/controller_methods.rb +3 -4
  52. data/lib/comfortable_mexican_sofa/engine.rb +1 -1
  53. data/lib/comfortable_mexican_sofa/fixtures.rb +155 -0
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +7 -15
  55. data/lib/comfortable_mexican_sofa/{cms_tag.rb → tag.rb} +42 -23
  56. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_datetime.rb +4 -5
  57. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_integer.rb +4 -5
  58. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_string.rb +4 -5
  59. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_text.rb +4 -5
  60. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/helper.rb +2 -5
  61. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_datetime.rb +4 -5
  62. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_integer.rb +4 -5
  63. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_rich_text.rb +4 -5
  64. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_string.rb +4 -5
  65. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_text.rb +4 -5
  66. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/partial.rb +2 -5
  67. data/lib/comfortable_mexican_sofa/tags/snippet.rb +13 -0
  68. data/lib/comfortable_mexican_sofa/view_methods.rb +4 -3
  69. data/lib/generators/cms_generator.rb +1 -1
  70. data/lib/tasks/comfortable_mexican_sofa.rake +12 -272
  71. data/public/javascripts/comfortable_mexican_sofa/cms.js +1 -1
  72. data/test/fixtures/{cms_blocks.yml → cms/blocks.yml} +2 -2
  73. data/test/fixtures/{cms_layouts.yml → cms/layouts.yml} +3 -3
  74. data/test/fixtures/{cms_pages.yml → cms/pages.yml} +4 -4
  75. data/test/fixtures/{cms_sites.yml → cms/sites.yml} +0 -0
  76. data/test/fixtures/{cms_snippets.yml → cms/snippets.yml} +1 -1
  77. data/test/fixtures/{cms_uploads.yml → cms/uploads.yml} +1 -1
  78. data/test/functional/cms_admin/layouts_controller_test.rb +6 -6
  79. data/test/functional/cms_admin/pages_controller_test.rb +64 -64
  80. data/test/functional/cms_admin/sites_controller_test.rb +5 -5
  81. data/test/functional/cms_admin/snippets_controller_test.rb +6 -6
  82. data/test/functional/cms_admin/uploads_controller_test.rb +4 -4
  83. data/test/functional/cms_content_controller_test.rb +27 -11
  84. data/test/integration/fixtures_test.rb +43 -0
  85. data/test/integration/sites_test.rb +23 -13
  86. data/test/test_helper.rb +9 -8
  87. data/test/unit/{cms_configuration_test.rb → configuration_test.rb} +5 -3
  88. data/test/unit/fixtures_test.rb +198 -0
  89. data/test/unit/models/block_test.rb +33 -0
  90. data/test/unit/models/layout_test.rb +129 -0
  91. data/test/unit/models/page_test.rb +199 -0
  92. data/test/unit/models/site_test.rb +41 -0
  93. data/test/unit/models/snippet_test.rb +32 -0
  94. data/test/unit/models/upload_test.rb +32 -0
  95. data/test/unit/{cms_tag_test.rb → tag_test.rb} +61 -44
  96. data/test/unit/tags/field_datetime_test.rb +44 -0
  97. data/test/unit/tags/field_integer_test.rb +43 -0
  98. data/test/unit/tags/field_string_test.rb +46 -0
  99. data/test/unit/tags/field_text_test.rb +42 -0
  100. data/test/unit/{cms_tags → tags}/helper_test.rb +18 -6
  101. data/test/unit/tags/page_datetime_test.rb +44 -0
  102. data/test/unit/tags/page_integer_test.rb +43 -0
  103. data/test/unit/tags/page_rich_text.rb +43 -0
  104. data/test/unit/{cms_tags → tags}/page_string_test.rb +15 -5
  105. data/test/unit/tags/page_text_test.rb +46 -0
  106. data/test/unit/{cms_tags → tags}/partial_test.rb +24 -8
  107. data/test/unit/tags/snippet_test.rb +45 -0
  108. data/test/unit/view_methods_test.rb +2 -2
  109. metadata +95 -121
  110. data/app/models/cms_block.rb +0 -28
  111. data/app/models/cms_snippet.rb +0 -69
  112. data/db/cms_seeds/example.local/layouts/default.yml +0 -8
  113. data/db/cms_seeds/example.local/layouts/nested.yml +0 -6
  114. data/db/cms_seeds/example.local/pages/child.yml +0 -10
  115. data/db/cms_seeds/example.local/pages/child/subchild.yml +0 -14
  116. data/db/cms_seeds/example.local/pages/index.yml +0 -11
  117. data/db/cms_seeds/example.local/snippets/example.yml +0 -4
  118. data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +0 -18
  119. data/test/cms_seeds/test.host/layouts/broken.yml +0 -1
  120. data/test/cms_seeds/test.host/layouts/default.yml +0 -3
  121. data/test/cms_seeds/test.host/layouts/nested.yml +0 -4
  122. data/test/cms_seeds/test.host/pages/broken.yml +0 -1
  123. data/test/cms_seeds/test.host/pages/child.yml +0 -10
  124. data/test/cms_seeds/test.host/pages/child/subchild.yml +0 -10
  125. data/test/cms_seeds/test.host/pages/index.yml +0 -10
  126. data/test/cms_seeds/test.host/snippets/broken.yml +0 -1
  127. data/test/cms_seeds/test.host/snippets/default.yml +0 -3
  128. data/test/integration/rake_tasks_test.rb +0 -65
  129. data/test/integration/render_cms_seed_test.rb +0 -34
  130. data/test/unit/cms_block_test.rb +0 -43
  131. data/test/unit/cms_layout_test.rb +0 -179
  132. data/test/unit/cms_page_test.rb +0 -257
  133. data/test/unit/cms_site_test.rb +0 -41
  134. data/test/unit/cms_snippet_test.rb +0 -77
  135. data/test/unit/cms_tags/field_datetime_test.rb +0 -34
  136. data/test/unit/cms_tags/field_integer_test.rb +0 -33
  137. data/test/unit/cms_tags/field_string_test.rb +0 -34
  138. data/test/unit/cms_tags/field_text_test.rb +0 -32
  139. data/test/unit/cms_tags/page_datetime_test.rb +0 -34
  140. data/test/unit/cms_tags/page_integer_test.rb +0 -33
  141. data/test/unit/cms_tags/page_rich_text.rb +0 -33
  142. data/test/unit/cms_tags/page_text_test.rb +0 -34
  143. data/test/unit/cms_tags/snippet_test.rb +0 -33
  144. data/test/unit/cms_upload_test.rb +0 -26
@@ -1,32 +0,0 @@
1
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
-
3
- class FieldTextTest < ActiveSupport::TestCase
4
-
5
- def test_initialize_tag
6
- assert tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), '{{ cms:field:content:text }}')
7
- assert_equal 'content', tag.label
8
- assert tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), '{{cms:field:content:text}}')
9
- assert_equal 'content', tag.label
10
- assert tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), '{{cms:field:dash-content:text}}')
11
- assert_equal 'dash-content', tag.label
12
- end
13
-
14
- def test_initialize_tag_failure
15
- [
16
- '{{cms:field:content:not_text}}',
17
- '{{cms:not_field:content:text}}',
18
- '{not_a_tag}'
19
- ].each do |tag_signature|
20
- assert_nil CmsTag::FieldText.initialize_tag(cms_pages(:default), tag_signature)
21
- end
22
- end
23
-
24
- def test_content_and_render
25
- tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), '{{cms:field:content:text}}')
26
- assert tag.content.blank?
27
- tag.content = 'test_content'
28
- assert_equal 'test_content', tag.content
29
- assert_equal '', tag.render
30
- end
31
-
32
- end
@@ -1,34 +0,0 @@
1
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
-
3
- class PageDateTimeTest < ActiveSupport::TestCase
4
-
5
- def test_initialize_tag
6
- assert tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), '{{ cms:page:content:datetime }}')
7
- assert_equal 'content', tag.label
8
- assert tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), '{{cms:page:content:datetime}}')
9
- assert_equal 'content', tag.label
10
- assert tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), '{{cms:page:dash-content:datetime}}')
11
- assert_equal 'dash-content', tag.label
12
- end
13
-
14
- def test_initialize_tag_failure
15
- [
16
- '{{cms:page:content:not_datetime}}',
17
- '{{cms:page:content}}',
18
- '{{cms:not_page:content}}',
19
- '{not_a_tag}'
20
- ].each do |tag_signature|
21
- assert_nil CmsTag::PageDateTime.initialize_tag(cms_pages(:default), tag_signature)
22
- end
23
- end
24
-
25
- def test_content_and_render
26
- tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), '{{cms:page:content:datetime}}')
27
- assert tag.content.blank?
28
- time = 2.days.ago
29
- tag.content = time
30
- assert_equal time, tag.content
31
- assert_equal time.to_s, tag.render
32
- end
33
-
34
- end
@@ -1,33 +0,0 @@
1
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
-
3
- class PageIntegerTest < ActiveSupport::TestCase
4
-
5
- def test_initialize_tag
6
- assert tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), '{{ cms:page:content:integer }}')
7
- assert_equal 'content', tag.label
8
- assert tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), '{{cms:page:content:integer}}')
9
- assert_equal 'content', tag.label
10
- assert tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), '{{cms:page:dash-content:integer}}')
11
- assert_equal 'dash-content', tag.label
12
- end
13
-
14
- def test_initialize_tag_failure
15
- [
16
- '{{cms:page:content:not_integer}}',
17
- '{{cms:page:content}}',
18
- '{{cms:not_page:content}}',
19
- '{not_a_tag}'
20
- ].each do |tag_signature|
21
- assert_nil CmsTag::PageInteger.initialize_tag(cms_pages(:default), tag_signature)
22
- end
23
- end
24
-
25
- def test_content_and_render
26
- tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), '{{cms:page:content:integer}}')
27
- assert tag.content.blank?
28
- tag.content = '5'
29
- assert_equal '5', tag.content
30
- assert_equal '5', tag.render
31
- end
32
-
33
- end
@@ -1,33 +0,0 @@
1
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
-
3
- class PageRichTextTest < ActiveSupport::TestCase
4
-
5
- def test_initialize_tag
6
- assert tag = CmsTag::PageRichText.initialize_tag(cms_pages(:default), '{{ cms:page:content:rich_text }}')
7
- assert_equal 'content', tag.label
8
- assert tag = CmsTag::PageRichText.initialize_tag(cms_pages(:default), '{{cms:page:content:rich_text}}')
9
- assert_equal 'content', tag.label
10
- assert tag = CmsTag::PageRichText.initialize_tag(cms_pages(:default), '{{cms:page:dash-content:rich_text}}')
11
- assert_equal 'dash-content', tag.label
12
- end
13
-
14
- def test_initialize_tag_failure
15
- [
16
- '{{cms:page:content:not_rich_text}}',
17
- '{{cms:page:content}}',
18
- '{{cms:not_page:content}}',
19
- '{not_a_tag}'
20
- ].each do |tag_signature|
21
- assert_nil CmsTag::PageRichText.initialize_tag(cms_pages(:default), tag_signature)
22
- end
23
- end
24
-
25
- def test_content_and_render
26
- tag = CmsTag::PageRichText.initialize_tag(cms_pages(:default), '{{cms:page:content:rich_text}}')
27
- assert tag.content.blank?
28
- tag.content = 'test_content'
29
- assert_equal 'test_content', tag.content
30
- assert_equal 'test_content', tag.render
31
- end
32
-
33
- end
@@ -1,34 +0,0 @@
1
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
-
3
- class PageTextTest < ActiveSupport::TestCase
4
-
5
- def test_initialize_tag
6
- assert tag = CmsTag::PageText.initialize_tag(cms_pages(:default), '{{ cms:page:content:text }}')
7
- assert_equal 'content', tag.label
8
- assert tag = CmsTag::PageText.initialize_tag(cms_pages(:default), '{{cms:page:content}}')
9
- assert_equal 'content', tag.label
10
- assert tag = CmsTag::PageText.initialize_tag(cms_pages(:default), '{{cms:page:content:text}}')
11
- assert_equal 'content', tag.label
12
- assert tag = CmsTag::PageText.initialize_tag(cms_pages(:default), '{{cms:page:dash-content}}')
13
- assert_equal 'dash-content', tag.label
14
- end
15
-
16
- def test_initialize_tag_failure
17
- [
18
- '{{cms:page:content:not_text}}',
19
- '{{cms:not_page:content}}',
20
- '{not_a_tag}'
21
- ].each do |tag_signature|
22
- assert_nil CmsTag::PageText.initialize_tag(cms_pages(:default), tag_signature)
23
- end
24
- end
25
-
26
- def test_content_and_render
27
- tag = CmsTag::PageText.initialize_tag(cms_pages(:default), '{{cms:page:content}}')
28
- assert tag.content.blank?
29
- tag.content = 'test_content'
30
- assert_equal 'test_content', tag.content
31
- assert_equal 'test_content', tag.render
32
- end
33
-
34
- end
@@ -1,33 +0,0 @@
1
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
-
3
- class SnippetTest < ActiveSupport::TestCase
4
-
5
- def test_initialize_tag
6
- assert tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), '{{ cms:snippet:label }}')
7
- assert_equal 'label', tag.slug
8
- assert tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), '{{cms:snippet:label}}')
9
- assert_equal 'label', tag.slug
10
- assert tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), '{{cms:snippet:dash-label}}')
11
- assert_equal 'dash-label', tag.slug
12
- end
13
-
14
- def test_initialize_tag_failure
15
- [
16
- '{{cms:snippet}}',
17
- '{{cms:not_snippet:label}}',
18
- '{not_a_tag}'
19
- ].each do |tag_signature|
20
- assert_nil CmsTag::Snippet.initialize_tag(cms_pages(:default), tag_signature)
21
- end
22
- end
23
-
24
- def test_content_and_render
25
- tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), '{{cms:snippet:default}}')
26
- assert_equal 'default_snippet_content', tag.content
27
- assert_equal 'default_snippet_content', tag.render
28
-
29
- tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), "{{cms:snippet:doesnot_exist}}")
30
- assert_equal nil, tag.content
31
- assert_equal '', tag.render
32
- end
33
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path('../test_helper', File.dirname(__FILE__))
2
-
3
- class CmsUploadTest < ActiveSupport::TestCase
4
-
5
- def test_validations
6
- assert_no_difference 'CmsUpload.count' do
7
- upload = CmsUpload.create
8
- assert upload.errors.present?
9
- assert_has_errors_on upload, [:file_file_name]
10
- end
11
- end
12
-
13
- def test_create
14
- assert_difference 'CmsUpload.count' do
15
- cms_sites(:default).cms_uploads.create(
16
- :file => fixture_file_upload('files/valid_image.jpg')
17
- )
18
- end
19
- end
20
-
21
- def test_create_failure
22
- assert_no_difference 'CmsUpload.count' do
23
- cms_sites(:default).cms_uploads.create(:file => '')
24
- end
25
- end
26
- end