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.
- data/.travis.yml +2 -2
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/images/comfortable_mexican_sofa/checkerboard.gif +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/elrte-toolbar.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/google-maps.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/iframe.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-director.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-flash.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-quicktime.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-realaudio.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-rutube.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-vimeo.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-winmedia.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-youtube.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/outline-div.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/outline-p.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/pagebreak.gif +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/pixel.gif +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/evilgrin.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/grin.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/happy.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/smile.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/surprised.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/tongue.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/unhappy.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/waii.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/wink.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/x.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/application.js +28 -3
- data/app/assets/javascripts/comfortable_mexican_sofa/codemirror/codemirror.js +1 -1
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.codemirror.js +35 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.js +267 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js +61 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js +58 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/jquery.js +4 -18
- data/app/assets/stylesheets/comfortable_mexican_sofa/application.css +3 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/codemirror.css +6 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/content.css +0 -65
- data/app/assets/stylesheets/comfortable_mexican_sofa/dialogs.css +45 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/elrte.css +173 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/files.css +82 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/form.css +2 -2
- data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
- data/app/assets/stylesheets/comfortable_mexican_sofa/widgets.css +14 -56
- data/app/controllers/cms_admin/categories_controller.rb +2 -2
- data/app/controllers/cms_admin/dialogs_controller.rb +13 -0
- data/app/controllers/cms_admin/files_controller.rb +4 -1
- data/app/controllers/cms_admin/revisions_controller.rb +2 -2
- data/app/controllers/cms_content_controller.rb +1 -1
- data/app/models/cms/block.rb +2 -2
- data/app/models/cms/category.rb +3 -0
- data/app/models/cms/file.rb +9 -1
- data/app/models/cms/layout.rb +2 -2
- data/app/models/cms/page.rb +7 -5
- data/app/models/cms/site.rb +10 -5
- data/app/models/cms/snippet.rb +5 -3
- data/app/views/cms_admin/categories/_form.html.erb +1 -1
- data/app/views/cms_admin/categories/_index.html.erb +2 -2
- data/app/views/cms_admin/dialogs/image.html.erb +7 -0
- data/app/views/cms_admin/dialogs/link.html.erb +5 -0
- data/app/views/cms_admin/files/_file.html.erb +17 -9
- data/app/views/cms_admin/files/_index.html.erb +8 -18
- data/app/views/cms_admin/files/create.js.erb +1 -1
- data/app/views/cms_admin/layouts/_form.html.erb +1 -1
- data/app/views/cms_admin/layouts/_index_branch.html.erb +1 -1
- data/app/views/cms_admin/pages/_form_blocks.html.erb +1 -1
- data/app/views/cms_admin/revisions/show.html.erb +1 -1
- data/app/views/cms_admin/sites/_form.html.erb +2 -1
- data/app/views/cms_admin/snippets/_form.html.erb +1 -1
- data/app/views/cms_admin/snippets/index.html.erb +1 -1
- data/app/views/layouts/cms_admin/_head.html.erb +7 -6
- data/comfortable_mexican_sofa.gemspec +46 -47
- data/config/initializers/paperclip.rb +0 -25
- data/config/locales/en.yml +6 -0
- data/config/locales/es.yml +6 -0
- data/config/routes.rb +3 -2
- data/db/migrate/01_create_cms.rb +37 -35
- data/db/migrate/upgrades/07_upgrade_to_1_6_0.rb +25 -0
- data/lib/comfortable_mexican_sofa/error.rb +4 -4
- data/lib/comfortable_mexican_sofa/extensions/is_categorized.rb +3 -1
- data/lib/comfortable_mexican_sofa/extensions/is_mirrored.rb +8 -8
- data/lib/comfortable_mexican_sofa/fixtures.rb +19 -19
- data/lib/comfortable_mexican_sofa/form_builder.rb +4 -4
- data/lib/comfortable_mexican_sofa/render_methods.rb +8 -8
- data/lib/comfortable_mexican_sofa/tag.rb +14 -13
- data/lib/comfortable_mexican_sofa/tags/asset.rb +6 -6
- data/lib/comfortable_mexican_sofa/tags/collection.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_datetime.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_integer.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_string.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_text.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/file.rb +5 -5
- data/lib/comfortable_mexican_sofa/tags/helper.rb +4 -4
- data/lib/comfortable_mexican_sofa/tags/page_datetime.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_file.rb +8 -6
- data/lib/comfortable_mexican_sofa/tags/page_files.rb +6 -4
- data/lib/comfortable_mexican_sofa/tags/page_integer.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_rich_text.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_string.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_text.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/partial.rb +4 -4
- data/lib/comfortable_mexican_sofa/tags/snippet.rb +5 -4
- data/lib/comfortable_mexican_sofa/view_methods.rb +6 -6
- data/test/fixtures/cms/blocks.yml +2 -2
- data/test/fixtures/cms/categories.yml +1 -0
- data/test/fixtures/cms/layouts.yml +3 -3
- data/test/fixtures/cms/revisions.yml +4 -4
- data/test/fixtures/cms/sites.yml +1 -0
- data/test/fixtures/cms/snippets.yml +1 -1
- data/test/fixtures/files/data.zip +0 -0
- data/test/functional/cms_admin/dialogs_controller_test.rb +24 -0
- data/test/functional/cms_admin/files_controller_test.rb +1 -1
- data/test/functional/cms_admin/layouts_controller_test.rb +7 -7
- data/test/functional/cms_admin/pages_controller_test.rb +34 -35
- data/test/functional/cms_admin/revisions_controller_test.rb +2 -2
- data/test/functional/cms_admin/sites_controller_test.rb +3 -2
- data/test/functional/cms_admin/snippets_controller_test.rb +8 -8
- data/test/functional/cms_content_controller_test.rb +10 -11
- data/test/gemfiles/{Gemfile.rails-3.0.10 → Gemfile.rails-3.0} +1 -1
- data/test/gemfiles/{Gemfile.rails-3.1.1 → Gemfile.rails-3.1} +1 -1
- data/test/integration/fixtures_test.rb +4 -4
- data/test/integration/mirrors_test.rb +1 -1
- data/test/integration/render_cms_test.rb +10 -10
- data/test/integration/sites_test.rb +3 -3
- data/test/test_helper.rb +3 -0
- data/test/unit/fixtures_test.rb +11 -11
- data/test/unit/mirrors_test.rb +25 -25
- data/test/unit/models/block_test.rb +29 -29
- data/test/unit/models/categorization_test.rb +1 -1
- data/test/unit/models/category_test.rb +2 -2
- data/test/unit/models/file_test.rb +18 -0
- data/test/unit/models/layout_test.rb +21 -18
- data/test/unit/models/page_test.rb +3 -3
- data/test/unit/models/site_test.rb +26 -17
- data/test/unit/models/snippet_test.rb +6 -6
- data/test/unit/revisions_test.rb +13 -13
- data/test/unit/tag_test.rb +39 -45
- data/test/unit/tags/asset_test.rb +1 -1
- data/test/unit/tags/collection_test.rb +12 -10
- data/test/unit/tags/field_datetime_test.rb +3 -3
- data/test/unit/tags/field_integer_test.rb +3 -3
- data/test/unit/tags/field_string_test.rb +4 -4
- data/test/unit/tags/field_text_test.rb +3 -3
- data/test/unit/tags/file_test.rb +1 -1
- data/test/unit/tags/helper_test.rb +3 -3
- data/test/unit/tags/page_datetime_test.rb +3 -3
- data/test/unit/tags/page_file_test.rb +7 -4
- data/test/unit/tags/page_files_test.rb +7 -4
- data/test/unit/tags/page_integer_test.rb +3 -3
- data/test/unit/tags/page_rich_text_test.rb +3 -3
- data/test/unit/tags/page_string_test.rb +3 -3
- data/test/unit/tags/page_text_test.rb +4 -4
- data/test/unit/tags/partial_test.rb +4 -4
- data/test/unit/tags/snippet_test.rb +3 -3
- metadata +51 -52
- data/app/assets/images/comfortable_mexican_sofa/wym_icons.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-blockquote.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h1.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h2.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h3.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h4.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h5.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h6.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-p.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-pre.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.css +0 -52
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.html +0 -26
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +0 -342
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.embed.js +0 -19
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.pack.js +0 -1
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/bg.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ca.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cs.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cy.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/de.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/en.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/es.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fa.js +0 -46
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fi.js +0 -44
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fr.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/gl.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/he.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hr.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hu.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/it.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nb.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nl.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nn.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pl.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt-br.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ru.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/sv.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/tr.js +0 -45
- 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(&:
|
14
|
-
assert_equal 'page_text_default_page_text', block.tag.
|
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
|
-
:
|
28
|
-
: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.
|
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
|
-
:
|
50
|
-
: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.
|
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
|
-
:
|
72
|
-
:content
|
71
|
+
:identifier => 'default_page_text',
|
72
|
+
:content => 'test_content'
|
73
73
|
},
|
74
74
|
'1' => {
|
75
|
-
:
|
76
|
-
: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.
|
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
|
-
{ :
|
101
|
-
:content
|
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.
|
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
|
-
{ :
|
119
|
-
:content
|
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
|
-
{ :
|
145
|
-
:content
|
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.
|
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
|
-
{ :
|
162
|
-
:content
|
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
|
-
:
|
189
|
-
:content
|
188
|
+
:identifier => 'header',
|
189
|
+
:content => 'header content'
|
190
190
|
},
|
191
191
|
'1' => {
|
192
|
-
:
|
193
|
-
:content
|
192
|
+
:identifier => 'file',
|
193
|
+
:content => fixture_file_upload('files/document.pdf')
|
194
194
|
},
|
195
195
|
'2' => {
|
196
|
-
:
|
197
|
-
: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 =
|
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
|
-
|
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, :
|
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(
|
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
|
27
|
-
:
|
28
|
-
:content
|
29
|
-
:css
|
30
|
-
: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.
|
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
|
-
{ :
|
91
|
-
:content
|
92
|
-
{ :
|
93
|
-
: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
|
-
{ :
|
104
|
-
:content
|
105
|
-
{ :
|
106
|
-
:content
|
107
|
-
{ :
|
108
|
-
: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
|
-
{ :
|
66
|
-
:content
|
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[:
|
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(:
|
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(:
|
21
|
-
assert site.
|
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
|
-
:
|
28
|
-
:
|
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
|
-
:
|
35
|
-
:
|
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 '
|
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
|
-
:
|
58
|
-
:
|
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
|
-
|
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, :
|
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
|
-
:
|
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
|
30
|
-
:
|
31
|
-
: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.
|
34
|
+
assert_equal 'test', snippet.identifier
|
35
35
|
assert_equal 'Test Content', snippet.content
|
36
36
|
assert_equal 1, snippet.position
|
37
37
|
end
|
data/test/unit/revisions_test.rb
CHANGED
@@ -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
|
-
{ '
|
13
|
-
{ '
|
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
|
-
{ :
|
63
|
-
: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
|
-
{ :
|
72
|
-
:content
|
73
|
-
{ :
|
74
|
-
:content
|
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
|
111
|
-
:
|
112
|
-
: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
|
-
{ :
|
141
|
-
{ :
|
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
|