comfortable_mexican_sofa 1.5.11 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. data/.travis.yml +2 -2
  2. data/Gemfile +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/images/comfortable_mexican_sofa/checkerboard.gif +0 -0
  5. data/app/assets/images/comfortable_mexican_sofa/elrte/elrte-toolbar.png +0 -0
  6. data/app/assets/images/comfortable_mexican_sofa/elrte/google-maps.png +0 -0
  7. data/app/assets/images/comfortable_mexican_sofa/elrte/iframe.png +0 -0
  8. data/app/assets/images/comfortable_mexican_sofa/elrte/media-director.png +0 -0
  9. data/app/assets/images/comfortable_mexican_sofa/elrte/media-flash.png +0 -0
  10. data/app/assets/images/comfortable_mexican_sofa/elrte/media-quicktime.png +0 -0
  11. data/app/assets/images/comfortable_mexican_sofa/elrte/media-realaudio.png +0 -0
  12. data/app/assets/images/comfortable_mexican_sofa/elrte/media-rutube.png +0 -0
  13. data/app/assets/images/comfortable_mexican_sofa/elrte/media-vimeo.png +0 -0
  14. data/app/assets/images/comfortable_mexican_sofa/elrte/media-winmedia.png +0 -0
  15. data/app/assets/images/comfortable_mexican_sofa/elrte/media-youtube.png +0 -0
  16. data/app/assets/images/comfortable_mexican_sofa/elrte/outline-div.png +0 -0
  17. data/app/assets/images/comfortable_mexican_sofa/elrte/outline-p.png +0 -0
  18. data/app/assets/images/comfortable_mexican_sofa/elrte/pagebreak.gif +0 -0
  19. data/app/assets/images/comfortable_mexican_sofa/elrte/pixel.gif +0 -0
  20. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/evilgrin.png +0 -0
  21. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/grin.png +0 -0
  22. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/happy.png +0 -0
  23. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/smile.png +0 -0
  24. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/surprised.png +0 -0
  25. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/tongue.png +0 -0
  26. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/unhappy.png +0 -0
  27. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/waii.png +0 -0
  28. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/wink.png +0 -0
  29. data/app/assets/images/comfortable_mexican_sofa/x.png +0 -0
  30. data/app/assets/javascripts/comfortable_mexican_sofa/application.js +28 -3
  31. data/app/assets/javascripts/comfortable_mexican_sofa/codemirror/codemirror.js +1 -1
  32. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.codemirror.js +35 -0
  33. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.js +267 -0
  34. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js +61 -0
  35. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js +58 -0
  36. data/app/assets/javascripts/comfortable_mexican_sofa/jquery.js +4 -18
  37. data/app/assets/stylesheets/comfortable_mexican_sofa/application.css +3 -0
  38. data/app/assets/stylesheets/comfortable_mexican_sofa/codemirror.css +6 -0
  39. data/app/assets/stylesheets/comfortable_mexican_sofa/content.css +0 -65
  40. data/app/assets/stylesheets/comfortable_mexican_sofa/dialogs.css +45 -0
  41. data/app/assets/stylesheets/comfortable_mexican_sofa/elrte.css +173 -0
  42. data/app/assets/stylesheets/comfortable_mexican_sofa/files.css +82 -0
  43. data/app/assets/stylesheets/comfortable_mexican_sofa/form.css +2 -2
  44. data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
  45. data/app/assets/stylesheets/comfortable_mexican_sofa/widgets.css +14 -56
  46. data/app/controllers/cms_admin/categories_controller.rb +2 -2
  47. data/app/controllers/cms_admin/dialogs_controller.rb +13 -0
  48. data/app/controllers/cms_admin/files_controller.rb +4 -1
  49. data/app/controllers/cms_admin/revisions_controller.rb +2 -2
  50. data/app/controllers/cms_content_controller.rb +1 -1
  51. data/app/models/cms/block.rb +2 -2
  52. data/app/models/cms/category.rb +3 -0
  53. data/app/models/cms/file.rb +9 -1
  54. data/app/models/cms/layout.rb +2 -2
  55. data/app/models/cms/page.rb +7 -5
  56. data/app/models/cms/site.rb +10 -5
  57. data/app/models/cms/snippet.rb +5 -3
  58. data/app/views/cms_admin/categories/_form.html.erb +1 -1
  59. data/app/views/cms_admin/categories/_index.html.erb +2 -2
  60. data/app/views/cms_admin/dialogs/image.html.erb +7 -0
  61. data/app/views/cms_admin/dialogs/link.html.erb +5 -0
  62. data/app/views/cms_admin/files/_file.html.erb +17 -9
  63. data/app/views/cms_admin/files/_index.html.erb +8 -18
  64. data/app/views/cms_admin/files/create.js.erb +1 -1
  65. data/app/views/cms_admin/layouts/_form.html.erb +1 -1
  66. data/app/views/cms_admin/layouts/_index_branch.html.erb +1 -1
  67. data/app/views/cms_admin/pages/_form_blocks.html.erb +1 -1
  68. data/app/views/cms_admin/revisions/show.html.erb +1 -1
  69. data/app/views/cms_admin/sites/_form.html.erb +2 -1
  70. data/app/views/cms_admin/snippets/_form.html.erb +1 -1
  71. data/app/views/cms_admin/snippets/index.html.erb +1 -1
  72. data/app/views/layouts/cms_admin/_head.html.erb +7 -6
  73. data/comfortable_mexican_sofa.gemspec +46 -47
  74. data/config/initializers/paperclip.rb +0 -25
  75. data/config/locales/en.yml +6 -0
  76. data/config/locales/es.yml +6 -0
  77. data/config/routes.rb +3 -2
  78. data/db/migrate/01_create_cms.rb +37 -35
  79. data/db/migrate/upgrades/07_upgrade_to_1_6_0.rb +25 -0
  80. data/lib/comfortable_mexican_sofa/error.rb +4 -4
  81. data/lib/comfortable_mexican_sofa/extensions/is_categorized.rb +3 -1
  82. data/lib/comfortable_mexican_sofa/extensions/is_mirrored.rb +8 -8
  83. data/lib/comfortable_mexican_sofa/fixtures.rb +19 -19
  84. data/lib/comfortable_mexican_sofa/form_builder.rb +4 -4
  85. data/lib/comfortable_mexican_sofa/render_methods.rb +8 -8
  86. data/lib/comfortable_mexican_sofa/tag.rb +14 -13
  87. data/lib/comfortable_mexican_sofa/tags/asset.rb +6 -6
  88. data/lib/comfortable_mexican_sofa/tags/collection.rb +3 -3
  89. data/lib/comfortable_mexican_sofa/tags/field_datetime.rb +3 -3
  90. data/lib/comfortable_mexican_sofa/tags/field_integer.rb +3 -3
  91. data/lib/comfortable_mexican_sofa/tags/field_string.rb +3 -3
  92. data/lib/comfortable_mexican_sofa/tags/field_text.rb +3 -3
  93. data/lib/comfortable_mexican_sofa/tags/file.rb +5 -5
  94. data/lib/comfortable_mexican_sofa/tags/helper.rb +4 -4
  95. data/lib/comfortable_mexican_sofa/tags/page_datetime.rb +3 -3
  96. data/lib/comfortable_mexican_sofa/tags/page_file.rb +8 -6
  97. data/lib/comfortable_mexican_sofa/tags/page_files.rb +6 -4
  98. data/lib/comfortable_mexican_sofa/tags/page_integer.rb +3 -3
  99. data/lib/comfortable_mexican_sofa/tags/page_rich_text.rb +3 -3
  100. data/lib/comfortable_mexican_sofa/tags/page_string.rb +3 -3
  101. data/lib/comfortable_mexican_sofa/tags/page_text.rb +3 -3
  102. data/lib/comfortable_mexican_sofa/tags/partial.rb +4 -4
  103. data/lib/comfortable_mexican_sofa/tags/snippet.rb +5 -4
  104. data/lib/comfortable_mexican_sofa/view_methods.rb +6 -6
  105. data/test/fixtures/cms/blocks.yml +2 -2
  106. data/test/fixtures/cms/categories.yml +1 -0
  107. data/test/fixtures/cms/layouts.yml +3 -3
  108. data/test/fixtures/cms/revisions.yml +4 -4
  109. data/test/fixtures/cms/sites.yml +1 -0
  110. data/test/fixtures/cms/snippets.yml +1 -1
  111. data/test/fixtures/files/data.zip +0 -0
  112. data/test/functional/cms_admin/dialogs_controller_test.rb +24 -0
  113. data/test/functional/cms_admin/files_controller_test.rb +1 -1
  114. data/test/functional/cms_admin/layouts_controller_test.rb +7 -7
  115. data/test/functional/cms_admin/pages_controller_test.rb +34 -35
  116. data/test/functional/cms_admin/revisions_controller_test.rb +2 -2
  117. data/test/functional/cms_admin/sites_controller_test.rb +3 -2
  118. data/test/functional/cms_admin/snippets_controller_test.rb +8 -8
  119. data/test/functional/cms_content_controller_test.rb +10 -11
  120. data/test/gemfiles/{Gemfile.rails-3.0.10 → Gemfile.rails-3.0} +1 -1
  121. data/test/gemfiles/{Gemfile.rails-3.1.1 → Gemfile.rails-3.1} +1 -1
  122. data/test/integration/fixtures_test.rb +4 -4
  123. data/test/integration/mirrors_test.rb +1 -1
  124. data/test/integration/render_cms_test.rb +10 -10
  125. data/test/integration/sites_test.rb +3 -3
  126. data/test/test_helper.rb +3 -0
  127. data/test/unit/fixtures_test.rb +11 -11
  128. data/test/unit/mirrors_test.rb +25 -25
  129. data/test/unit/models/block_test.rb +29 -29
  130. data/test/unit/models/categorization_test.rb +1 -1
  131. data/test/unit/models/category_test.rb +2 -2
  132. data/test/unit/models/file_test.rb +18 -0
  133. data/test/unit/models/layout_test.rb +21 -18
  134. data/test/unit/models/page_test.rb +3 -3
  135. data/test/unit/models/site_test.rb +26 -17
  136. data/test/unit/models/snippet_test.rb +6 -6
  137. data/test/unit/revisions_test.rb +13 -13
  138. data/test/unit/tag_test.rb +39 -45
  139. data/test/unit/tags/asset_test.rb +1 -1
  140. data/test/unit/tags/collection_test.rb +12 -10
  141. data/test/unit/tags/field_datetime_test.rb +3 -3
  142. data/test/unit/tags/field_integer_test.rb +3 -3
  143. data/test/unit/tags/field_string_test.rb +4 -4
  144. data/test/unit/tags/field_text_test.rb +3 -3
  145. data/test/unit/tags/file_test.rb +1 -1
  146. data/test/unit/tags/helper_test.rb +3 -3
  147. data/test/unit/tags/page_datetime_test.rb +3 -3
  148. data/test/unit/tags/page_file_test.rb +7 -4
  149. data/test/unit/tags/page_files_test.rb +7 -4
  150. data/test/unit/tags/page_integer_test.rb +3 -3
  151. data/test/unit/tags/page_rich_text_test.rb +3 -3
  152. data/test/unit/tags/page_string_test.rb +3 -3
  153. data/test/unit/tags/page_text_test.rb +4 -4
  154. data/test/unit/tags/partial_test.rb +4 -4
  155. data/test/unit/tags/snippet_test.rb +3 -3
  156. metadata +51 -52
  157. data/app/assets/images/comfortable_mexican_sofa/wym_icons.png +0 -0
  158. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-blockquote.png +0 -0
  159. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h1.png +0 -0
  160. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h2.png +0 -0
  161. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h3.png +0 -0
  162. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h4.png +0 -0
  163. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h5.png +0 -0
  164. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h6.png +0 -0
  165. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-p.png +0 -0
  166. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-pre.png +0 -0
  167. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.css +0 -52
  168. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.html +0 -26
  169. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +0 -342
  170. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.embed.js +0 -19
  171. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.pack.js +0 -1
  172. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/bg.js +0 -45
  173. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ca.js +0 -45
  174. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cs.js +0 -45
  175. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cy.js +0 -45
  176. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/de.js +0 -45
  177. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/en.js +0 -45
  178. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/es.js +0 -45
  179. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fa.js +0 -46
  180. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fi.js +0 -44
  181. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fr.js +0 -45
  182. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/gl.js +0 -45
  183. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/he.js +0 -45
  184. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hr.js +0 -45
  185. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hu.js +0 -45
  186. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/it.js +0 -45
  187. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nb.js +0 -45
  188. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nl.js +0 -45
  189. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nn.js +0 -45
  190. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pl.js +0 -45
  191. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt-br.js +0 -45
  192. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt.js +0 -45
  193. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ru.js +0 -45
  194. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/sv.js +0 -45
  195. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/tr.js +0 -45
  196. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/zh_cn.js +0 -47
@@ -10,8 +10,8 @@ class CmsBlockTest < ActiveSupport::TestCase
10
10
 
11
11
  def test_tag
12
12
  block = cms_blocks(:default_page_text)
13
- assert block.page.tags(true).collect(&:identifier).member?('page_text_default_page_text')
14
- assert_equal 'page_text_default_page_text', block.tag.identifier
13
+ assert block.page.tags(true).collect(&:id).member?('page_text_default_page_text')
14
+ assert_equal 'page_text_default_page_text', block.tag.id
15
15
  end
16
16
 
17
17
  def test_creation_via_page_nested_attributes
@@ -24,14 +24,14 @@ class CmsBlockTest < ActiveSupport::TestCase
24
24
  :parent_id => cms_pages(:default).id,
25
25
  :blocks_attributes => [
26
26
  {
27
- :label => 'default_page_text',
28
- :content => 'test_content'
27
+ :identifier => 'default_page_text',
28
+ :content => 'test_content'
29
29
  }
30
30
  ]
31
31
  )
32
32
  assert_equal 1, page.blocks.count
33
33
  block = page.blocks.first
34
- assert_equal 'default_page_text', block.label
34
+ assert_equal 'default_page_text', block.identifier
35
35
  assert_equal 'test_content', block.content
36
36
  end
37
37
  end
@@ -46,14 +46,14 @@ class CmsBlockTest < ActiveSupport::TestCase
46
46
  :parent_id => cms_pages(:default).id,
47
47
  :blocks_attributes => {
48
48
  '0' => {
49
- :label => 'default_page_text',
50
- :content => 'test_content'
49
+ :identifier => 'default_page_text',
50
+ :content => 'test_content'
51
51
  }
52
52
  }
53
53
  )
54
54
  assert_equal 1, page.blocks.count
55
55
  block = page.blocks.first
56
- assert_equal 'default_page_text', block.label
56
+ assert_equal 'default_page_text', block.identifier
57
57
  assert_equal 'test_content', block.content
58
58
  end
59
59
  end
@@ -68,18 +68,18 @@ class CmsBlockTest < ActiveSupport::TestCase
68
68
  :parent_id => cms_pages(:default).id,
69
69
  :blocks_attributes => {
70
70
  '0' => {
71
- :label => 'default_page_text',
72
- :content => 'test_content'
71
+ :identifier => 'default_page_text',
72
+ :content => 'test_content'
73
73
  },
74
74
  '1' => {
75
- :label => 'default_page_text',
76
- :content => 'test_content'
75
+ :identifier => 'default_page_text',
76
+ :content => 'test_content'
77
77
  }
78
78
  }
79
79
  )
80
80
  assert_equal 1, page.blocks.count
81
81
  block = page.blocks.first
82
- assert_equal 'default_page_text', block.label
82
+ assert_equal 'default_page_text', block.identifier
83
83
  assert_equal 'test_content', block.content
84
84
  end
85
85
  end
@@ -97,13 +97,13 @@ class CmsBlockTest < ActiveSupport::TestCase
97
97
  :slug => 'test_page',
98
98
  :parent_id => cms_pages(:default).id,
99
99
  :blocks_attributes => [
100
- { :label => 'file',
101
- :content => [fixture_file_upload('files/image.jpg'), fixture_file_upload('files/document.pdf')] }
100
+ { :identifier => 'file',
101
+ :content => [fixture_file_upload('files/image.jpg'), fixture_file_upload('files/document.pdf')] }
102
102
  ]
103
103
  )
104
104
  assert_equal 1, page.blocks.count
105
105
  block = page.blocks.first
106
- assert_equal 'file', block.label
106
+ assert_equal 'file', block.identifier
107
107
  assert_equal nil, block.content
108
108
  assert_equal 1, block.files.count
109
109
  assert_equal 'image.jpg', block.files.first.file_file_name
@@ -115,8 +115,8 @@ class CmsBlockTest < ActiveSupport::TestCase
115
115
  assert_no_difference ['Cms::Block.count', 'Cms::File.count'] do
116
116
  page.update_attributes!(
117
117
  :blocks_attributes => [
118
- { :label => 'file',
119
- :content => fixture_file_upload('files/document.pdf') }
118
+ { :identifier => 'file',
119
+ :content => fixture_file_upload('files/document.pdf') }
120
120
  ]
121
121
  )
122
122
  page.reload
@@ -141,13 +141,13 @@ class CmsBlockTest < ActiveSupport::TestCase
141
141
  :slug => 'test_page',
142
142
  :parent_id => cms_pages(:default).id,
143
143
  :blocks_attributes => [
144
- { :label => 'files',
145
- :content => [fixture_file_upload('files/image.jpg'), fixture_file_upload('files/image.gif')] }
144
+ { :identifier => 'files',
145
+ :content => [fixture_file_upload('files/image.jpg'), fixture_file_upload('files/image.gif')] }
146
146
  ]
147
147
  )
148
148
  assert_equal 1, page.blocks.count
149
149
  block = page.blocks.first
150
- assert_equal 'files', block.label
150
+ assert_equal 'files', block.identifier
151
151
  assert_equal nil, block.content
152
152
  assert_equal 2, block.files.count
153
153
  assert_equal ['image.jpg', 'image.gif'], block.files.collect(&:file_file_name)
@@ -158,8 +158,8 @@ class CmsBlockTest < ActiveSupport::TestCase
158
158
  assert_difference 'Cms::File.count', 2 do
159
159
  page.update_attributes!(
160
160
  :blocks_attributes => [
161
- { :label => 'files',
162
- :content => [fixture_file_upload('files/document.pdf'), fixture_file_upload('files/image.gif')] }
161
+ { :identifier => 'files',
162
+ :content => [fixture_file_upload('files/document.pdf'), fixture_file_upload('files/image.gif')] }
163
163
  ]
164
164
  )
165
165
  page.reload
@@ -185,16 +185,16 @@ class CmsBlockTest < ActiveSupport::TestCase
185
185
  :parent_id => cms_pages(:default).id,
186
186
  :blocks_attributes => {
187
187
  '0' => {
188
- :label => 'header',
189
- :content => 'header content'
188
+ :identifier => 'header',
189
+ :content => 'header content'
190
190
  },
191
191
  '1' => {
192
- :label => 'file',
193
- :content => fixture_file_upload('files/document.pdf')
192
+ :identifier => 'file',
193
+ :content => fixture_file_upload('files/document.pdf')
194
194
  },
195
195
  '2' => {
196
- :label => 'footer',
197
- :content => 'footer content'
196
+ :identifier => 'footer',
197
+ :content => 'footer content'
198
198
  }
199
199
  }
200
200
  )
@@ -67,7 +67,7 @@ class CmsCategorizationTest < ActiveSupport::TestCase
67
67
  assert_equal 1, Cms::File.for_category(category.label, 'invalid').count
68
68
  assert_equal 1, Cms::File.for_category(nil).count
69
69
 
70
- new_category = Cms::Category.create!(:label => 'Test Category', :categorized_type => 'Cms::File')
70
+ new_category = cms_sites(:default).categories.create!(:label => 'Test Category', :categorized_type => 'Cms::File')
71
71
  new_category.categorizations.create!(:categorized => cms_files(:default))
72
72
  assert_equal 1, Cms::File.for_category(category.label, new_category.label).all.size
73
73
  assert_equal 1, Cms::File.for_category(category.label, new_category.label).count('cms_files.id', :distinct => true)
@@ -11,12 +11,12 @@ class CmsCategoryTest < ActiveSupport::TestCase
11
11
  def test_validation
12
12
  category = Cms::Category.new
13
13
  assert category.invalid?
14
- assert_has_errors_on category, [:label, :categorized_type]
14
+ assert_has_errors_on category, [:site_id, :label, :categorized_type]
15
15
  end
16
16
 
17
17
  def test_creation
18
18
  assert_difference 'Cms::Category.count' do
19
- Cms::Category.create(
19
+ cms_sites(:default).categories.create(
20
20
  :label => 'Test Category',
21
21
  :categorized_type => 'Cms::Snippet'
22
22
  )
@@ -43,6 +43,17 @@ class CmsFileTest < ActiveSupport::TestCase
43
43
  end
44
44
  end
45
45
 
46
+ def test_create_with_non_image
47
+ assert_difference 'Cms::File.count' do
48
+ file = cms_sites(:default).files.create!(
49
+ :file => fixture_file_upload('files/data.zip', 'application/zip')
50
+ )
51
+ assert_equal 'Data', file.label
52
+ assert_equal 'data.zip', file.file_file_name
53
+ assert_equal 'application/zip', file.file_content_type
54
+ end
55
+ end
56
+
46
57
  def test_create_failure
47
58
  assert_no_difference 'Cms::File.count' do
48
59
  cms_sites(:default).files.create(:file => '')
@@ -64,4 +75,11 @@ class CmsFileTest < ActiveSupport::TestCase
64
75
  assert_equal 0, Cms::File.images.count
65
76
  assert_equal 1, Cms::File.not_images.count
66
77
  end
78
+
79
+ def test_image?
80
+ file = cms_files(:default)
81
+ assert_equal 'image/jpeg', file.file_content_type
82
+ assert file.is_image?
83
+ end
84
+
67
85
  end
@@ -11,11 +11,14 @@ class CmsLayoutTest < ActiveSupport::TestCase
11
11
  def test_validations
12
12
  layout = cms_sites(:default).layouts.create
13
13
  assert layout.errors.present?
14
- assert_has_errors_on layout, [:label, :slug]
14
+ assert_has_errors_on layout, [:label, :identifier]
15
15
  end
16
16
 
17
17
  def test_label_assignment
18
- layout = cms_sites(:default).layouts.new(:slug => 'test', :content => '{{cms:page:content}}')
18
+ layout = cms_sites(:default).layouts.new(
19
+ :identifier => 'test',
20
+ :content => '{{cms:page:content}}'
21
+ )
19
22
  assert layout.valid?
20
23
  assert_equal 'Test', layout.label
21
24
  end
@@ -23,14 +26,14 @@ class CmsLayoutTest < ActiveSupport::TestCase
23
26
  def test_creation
24
27
  assert_difference 'Cms::Layout.count' do
25
28
  layout = cms_sites(:default).layouts.create(
26
- :label => 'New Layout',
27
- :slug => 'new-layout',
28
- :content => '{{cms:page:content}}',
29
- :css => 'css',
30
- :js => 'js'
29
+ :label => 'New Layout',
30
+ :identifier => 'new-layout',
31
+ :content => '{{cms:page:content}}',
32
+ :css => 'css',
33
+ :js => 'js'
31
34
  )
32
35
  assert_equal 'New Layout', layout.label
33
- assert_equal 'new-layout', layout.slug
36
+ assert_equal 'new-layout', layout.identifier
34
37
  assert_equal '{{cms:page:content}}', layout.content
35
38
  assert_equal 'css', layout.css
36
39
  assert_equal 'js', layout.js
@@ -87,10 +90,10 @@ class CmsLayoutTest < ActiveSupport::TestCase
87
90
  :layout_id => layout_1.id,
88
91
  :is_published => '1',
89
92
  :blocks_attributes => [
90
- { :label => 'header',
91
- :content => 'header_content' },
92
- { :label => 'content',
93
- :content => 'content_content' }
93
+ { :identifier => 'header',
94
+ :content => 'header_content' },
95
+ { :identifier => 'content',
96
+ :content => 'content_content' }
94
97
  ]
95
98
  )
96
99
  page_2 = cms_sites(:default).pages.create!(
@@ -100,12 +103,12 @@ class CmsLayoutTest < ActiveSupport::TestCase
100
103
  :layout_id => layout_2.id,
101
104
  :is_published => '1',
102
105
  :blocks_attributes => [
103
- { :label => 'header',
104
- :content => 'header_content' },
105
- { :label => 'left_column',
106
- :content => 'left_column_content' },
107
- { :label => 'right_column',
108
- :content => 'left_column_content' }
106
+ { :identifier => 'header',
107
+ :content => 'header_content' },
108
+ { :identifier => 'left_column',
109
+ :content => 'left_column_content' },
110
+ { :identifier => 'right_column',
111
+ :content => 'left_column_content' }
109
112
  ]
110
113
  )
111
114
  assert_equal "header_content\ncontent_content", page_1.content
@@ -62,8 +62,8 @@ class CmsPageTest < ActiveSupport::TestCase
62
62
  :parent => cms_pages(:default),
63
63
  :layout => cms_layouts(:default),
64
64
  :blocks_attributes => [
65
- { :label => 'default_page_text',
66
- :content => 'test' }
65
+ { :identifier => 'default_page_text',
66
+ :content => 'test' }
67
67
  ]
68
68
  )
69
69
  assert page.is_published?
@@ -165,7 +165,7 @@ class CmsPageTest < ActiveSupport::TestCase
165
165
  def test_cms_blocks_attributes_accessor
166
166
  page = cms_pages(:default)
167
167
  assert_equal page.blocks.count, page.blocks_attributes.size
168
- assert_equal 'default_field_text', page.blocks_attributes.first[:label]
168
+ assert_equal 'default_field_text', page.blocks_attributes.first[:identifier]
169
169
  assert_equal 'default_field_text_content', page.blocks_attributes.first[:content]
170
170
  end
171
171
 
@@ -11,51 +11,58 @@ class CmsSiteTest < ActiveSupport::TestCase
11
11
  def test_validation
12
12
  site = Cms::Site.new
13
13
  assert site.invalid?
14
- assert_has_errors_on site, [:label, :hostname]
14
+ assert_has_errors_on site, [:identifier, :label, :hostname]
15
15
 
16
- site = Cms::Site.new(:label => 'My Site', :hostname => 'http://my-site.host')
16
+ site = Cms::Site.new(:identifier => 'test', :hostname => 'http://site.host')
17
17
  assert site.invalid?
18
18
  assert_has_errors_on site, :hostname
19
19
 
20
- site = Cms::Site.new(:label => 'My Site', :hostname => 'my-site.host')
21
- assert site.valid?
20
+ site = Cms::Site.new(:identifier => cms_sites(:default).identifier, :hostname => 'site.host')
21
+ assert site.invalid?
22
+ assert_has_errors_on site, :identifier
23
+
24
+ site = Cms::Site.new(:identifier => 'test', :hostname => 'site.host')
25
+ assert site.valid?, site.errors.to_yaml
22
26
  end
23
27
 
24
28
  def test_validation_path_uniqueness
25
29
  s1 = cms_sites(:default)
26
30
  s2 = Cms::Site.new(
27
- :hostname => s1.hostname,
28
- :path => s1.path
31
+ :identifier => 'test',
32
+ :hostname => s1.hostname,
33
+ :path => s1.path
29
34
  )
30
35
  assert s2.invalid?
31
36
  assert_has_errors_on s2, :hostname
32
37
 
33
38
  s2 = Cms::Site.new(
34
- :hostname => s1.hostname,
35
- :path => '/en'
39
+ :identifier => 'test',
40
+ :hostname => s1.hostname,
41
+ :path => '/en'
36
42
  )
37
43
  assert s2.valid?
38
44
  end
39
45
 
40
46
  def test_label_assignment
41
- site = Cms::Site.new(:hostname => 'my-site.host')
47
+ site = Cms::Site.new(:identifier => 'test', :hostname => 'my-site.host')
42
48
  assert site.valid?
43
- assert_equal 'my-site.host', site.label
49
+ assert_equal 'Test', site.label
44
50
  end
45
51
 
46
52
  def test_clean_path
47
- site = Cms::Site.create!(:hostname => 'test.host', :path => '/en///test//')
53
+ site = Cms::Site.create!(:identifier => 'test_a', :hostname => 'test.host', :path => '/en///test//')
48
54
  assert_equal '/en/test', site.path
49
55
 
50
- site = Cms::Site.create!(:hostname => 'my-site.host', :path => '/')
56
+ site = Cms::Site.create!(:identifier => 'test_b', :hostname => 'my-site.host', :path => '/')
51
57
  assert_equal '', site.path
52
58
  end
53
59
 
54
60
  def test_creation
55
61
  assert_difference 'Cms::Site.count' do
56
62
  Cms::Site.create!(
57
- :label => 'Test Site',
58
- :hostname => 'test.test'
63
+ :identifier => 'test',
64
+ :label => 'Test Site',
65
+ :hostname => 'test.test'
59
66
  )
60
67
  end
61
68
  end
@@ -65,7 +72,9 @@ class CmsSiteTest < ActiveSupport::TestCase
65
72
  assert_difference 'Cms::Layout.count', -3 do
66
73
  assert_difference 'Cms::Page.count', -2 do
67
74
  assert_difference 'Cms::Snippet.count', -1 do
68
- cms_sites(:default).destroy
75
+ assert_difference 'Cms::Category.count', -1 do
76
+ cms_sites(:default).destroy
77
+ end
69
78
  end
70
79
  end
71
80
  end
@@ -89,8 +98,8 @@ class CmsSiteTest < ActiveSupport::TestCase
89
98
  assert_equal site_a, Cms::Site.find_site('test.host', '/some/path')
90
99
  assert_equal site_a, Cms::Site.find_site('test99.host', '/some/path')
91
100
 
92
- site_b = Cms::Site.create!(:hostname => 'test2.host', :path => 'en')
93
- site_c = Cms::Site.create!(:hostname => 'test2.host', :path => 'fr')
101
+ site_b = Cms::Site.create!(:identifier => 'test_a', :hostname => 'test2.host', :path => 'en')
102
+ site_c = Cms::Site.create!(:identifier => 'test_b', :hostname => 'test2.host', :path => 'fr')
94
103
 
95
104
  assert_equal site_a, Cms::Site.find_site('test.host')
96
105
  assert_equal site_a, Cms::Site.find_site('test.host', '/some/path')
@@ -12,12 +12,12 @@ class CmsSnippetTest < ActiveSupport::TestCase
12
12
  snippet = Cms::Snippet.new
13
13
  snippet.save
14
14
  assert snippet.invalid?
15
- assert_has_errors_on snippet, [:label, :slug]
15
+ assert_has_errors_on snippet, [:label, :identifier]
16
16
  end
17
17
 
18
18
  def test_label_assignment
19
19
  snippet = cms_sites(:default).snippets.new(
20
- :slug => 'test'
20
+ :identifier => 'test'
21
21
  )
22
22
  assert snippet.valid?
23
23
  assert_equal 'Test', snippet.label
@@ -26,12 +26,12 @@ class CmsSnippetTest < ActiveSupport::TestCase
26
26
  def test_create
27
27
  assert_difference 'Cms::Snippet.count' do
28
28
  snippet = cms_sites(:default).snippets.create(
29
- :label => 'Test Snippet',
30
- :slug => 'test',
31
- :content => 'Test Content'
29
+ :label => 'Test Snippet',
30
+ :identifier => 'test',
31
+ :content => 'Test Content'
32
32
  )
33
33
  assert_equal 'Test Snippet', snippet.label
34
- assert_equal 'test', snippet.slug
34
+ assert_equal 'test', snippet.identifier
35
35
  assert_equal 'Test Content', snippet.content
36
36
  assert_equal 1, snippet.position
37
37
  end
@@ -9,8 +9,8 @@ class RevisionsTest < ActiveSupport::TestCase
9
9
  'js' => 'revision js' }), cms_revisions(:layout).data
10
10
 
11
11
  assert_equal ({'blocks_attributes' => [
12
- { 'label' => 'default_page_text', 'content' => 'revision page content' },
13
- { 'label' => 'default_field_text', 'content' => 'revision field content' }
12
+ { 'identifier' => 'default_page_text', 'content' => 'revision page content' },
13
+ { 'identifier' => 'default_field_text', 'content' => 'revision field content' }
14
14
  ]}), cms_revisions(:page).data
15
15
 
16
16
  assert_equal ({
@@ -59,8 +59,8 @@ class RevisionsTest < ActiveSupport::TestCase
59
59
  assert_difference 'page.revisions.count' do
60
60
  page.update_attributes!(
61
61
  :blocks_attributes => [
62
- { :label => 'default_page_text',
63
- :content => 'new content' }
62
+ { :identifier => 'default_page_text',
63
+ :content => 'new content' }
64
64
  ]
65
65
  )
66
66
  page.reload
@@ -68,10 +68,10 @@ class RevisionsTest < ActiveSupport::TestCase
68
68
  revision = page.revisions.first
69
69
  assert_equal ({
70
70
  'blocks_attributes' => [
71
- { :label => 'default_field_text',
72
- :content => 'default_field_text_content' },
73
- { :label => 'default_page_text',
74
- :content => "default_page_text_content_a\n{{cms:snippet:default}}\ndefault_page_text_content_b" }]
71
+ { :identifier => 'default_field_text',
72
+ :content => 'default_field_text_content' },
73
+ { :identifier => 'default_page_text',
74
+ :content => "default_page_text_content_a\n{{cms:snippet:default}}\ndefault_page_text_content_b" }]
75
75
  }), revision.data
76
76
  end
77
77
  end
@@ -107,9 +107,9 @@ class RevisionsTest < ActiveSupport::TestCase
107
107
  assert_difference 'Cms::Snippet.count' do
108
108
  assert_no_difference 'Cms::Revision.count' do
109
109
  snippet = cms_sites(:default).snippets.create!(
110
- :label => 'test snippet',
111
- :slug => 'test_snippet',
112
- :content => 'test content'
110
+ :label => 'test snippet',
111
+ :identifier => 'test_snippet',
112
+ :content => 'test content'
113
113
  )
114
114
  assert_equal 0, snippet.revisions.count
115
115
  end
@@ -137,8 +137,8 @@ class RevisionsTest < ActiveSupport::TestCase
137
137
  page.restore_from_revision(revision)
138
138
  page.reload
139
139
  assert_equal [
140
- { :label => 'default_field_text', :content => 'revision field content' },
141
- { :label => 'default_page_text', :content => 'revision page content' }
140
+ { :identifier => 'default_field_text', :content => 'revision field content' },
141
+ { :identifier => 'default_page_text', :content => 'revision page content' }
142
142
  ], page.blocks_attributes
143
143
  end
144
144
  end