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.
- data/README.md +8 -18
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/app/controllers/cms_admin/base_controller.rb +8 -9
- data/app/controllers/cms_admin/layouts_controller.rb +5 -5
- data/app/controllers/cms_admin/pages_controller.rb +14 -14
- data/app/controllers/cms_admin/sites_controller.rb +4 -4
- data/app/controllers/cms_admin/snippets_controller.rb +4 -4
- data/app/controllers/cms_admin/uploads_controller.rb +2 -2
- data/app/controllers/cms_content_controller.rb +21 -8
- data/app/models/cms/block.rb +13 -0
- data/app/models/{cms_layout.rb → cms/layout.rb} +16 -44
- data/app/models/{cms_page.rb → cms/page.rb} +26 -57
- data/app/models/{cms_site.rb → cms/site.rb} +8 -6
- data/app/models/cms/snippet.rb +36 -0
- data/app/models/{cms_upload.rb → cms/upload.rb} +5 -3
- data/app/views/cms_admin/layouts/_form.html.erb +2 -2
- data/app/views/cms_admin/pages/_form.html.erb +5 -5
- data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -3
- data/app/views/cms_admin/uploads/_index.html.erb +1 -1
- data/app/views/layouts/cms_admin.html.erb +2 -38
- data/app/views/layouts/cms_admin/_body.html.erb +17 -0
- data/app/views/layouts/cms_admin/_center.html.erb +6 -0
- data/app/views/layouts/cms_admin/_head.html.erb +11 -0
- data/app/views/layouts/cms_admin/_left.html.erb +7 -0
- data/app/views/layouts/cms_admin/_right.html.erb +1 -0
- data/comfortable_mexican_sofa.gemspec +94 -96
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +1 -1
- data/config/environments/test.rb +1 -1
- data/config/initializers/comfortable_mexican_sofa.rb +10 -12
- data/db/cms_fixtures/example.com/layouts/default/_default.yml +1 -0
- data/db/cms_fixtures/example.com/layouts/default/content.html +5 -0
- data/db/cms_fixtures/example.com/layouts/default/css.css +1 -0
- data/db/cms_fixtures/example.com/layouts/default/js.js +1 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/_nested.yml +1 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/content.html +2 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/css.css +1 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/js.js +1 -0
- data/db/cms_fixtures/example.com/pages/index/_index.yml +2 -0
- data/db/cms_fixtures/example.com/pages/index/child/_child.yml +2 -0
- data/db/cms_fixtures/example.com/pages/index/child/left.html +1 -0
- data/db/cms_fixtures/example.com/pages/index/child/right.html +1 -0
- data/db/cms_fixtures/example.com/pages/index/content.html +2 -0
- data/db/cms_fixtures/example.com/snippets/default/_default.yml +1 -0
- data/db/cms_fixtures/example.com/snippets/default/content.html +1 -0
- data/db/migrate/01_create_cms.rb +11 -11
- data/db/migrate/upgrades/02_upgrade_to_1_1_0.rb +19 -0
- data/lib/comfortable_mexican_sofa.rb +6 -13
- data/lib/comfortable_mexican_sofa/configuration.rb +21 -20
- data/lib/comfortable_mexican_sofa/controller_methods.rb +3 -4
- data/lib/comfortable_mexican_sofa/engine.rb +1 -1
- data/lib/comfortable_mexican_sofa/fixtures.rb +155 -0
- data/lib/comfortable_mexican_sofa/form_builder.rb +7 -15
- data/lib/comfortable_mexican_sofa/{cms_tag.rb → tag.rb} +42 -23
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_datetime.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_integer.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_string.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_text.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/helper.rb +2 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_datetime.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_integer.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_rich_text.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_string.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_text.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/partial.rb +2 -5
- data/lib/comfortable_mexican_sofa/tags/snippet.rb +13 -0
- data/lib/comfortable_mexican_sofa/view_methods.rb +4 -3
- data/lib/generators/cms_generator.rb +1 -1
- data/lib/tasks/comfortable_mexican_sofa.rake +12 -272
- data/public/javascripts/comfortable_mexican_sofa/cms.js +1 -1
- data/test/fixtures/{cms_blocks.yml → cms/blocks.yml} +2 -2
- data/test/fixtures/{cms_layouts.yml → cms/layouts.yml} +3 -3
- data/test/fixtures/{cms_pages.yml → cms/pages.yml} +4 -4
- data/test/fixtures/{cms_sites.yml → cms/sites.yml} +0 -0
- data/test/fixtures/{cms_snippets.yml → cms/snippets.yml} +1 -1
- data/test/fixtures/{cms_uploads.yml → cms/uploads.yml} +1 -1
- data/test/functional/cms_admin/layouts_controller_test.rb +6 -6
- data/test/functional/cms_admin/pages_controller_test.rb +64 -64
- data/test/functional/cms_admin/sites_controller_test.rb +5 -5
- data/test/functional/cms_admin/snippets_controller_test.rb +6 -6
- data/test/functional/cms_admin/uploads_controller_test.rb +4 -4
- data/test/functional/cms_content_controller_test.rb +27 -11
- data/test/integration/fixtures_test.rb +43 -0
- data/test/integration/sites_test.rb +23 -13
- data/test/test_helper.rb +9 -8
- data/test/unit/{cms_configuration_test.rb → configuration_test.rb} +5 -3
- data/test/unit/fixtures_test.rb +198 -0
- data/test/unit/models/block_test.rb +33 -0
- data/test/unit/models/layout_test.rb +129 -0
- data/test/unit/models/page_test.rb +199 -0
- data/test/unit/models/site_test.rb +41 -0
- data/test/unit/models/snippet_test.rb +32 -0
- data/test/unit/models/upload_test.rb +32 -0
- data/test/unit/{cms_tag_test.rb → tag_test.rb} +61 -44
- data/test/unit/tags/field_datetime_test.rb +44 -0
- data/test/unit/tags/field_integer_test.rb +43 -0
- data/test/unit/tags/field_string_test.rb +46 -0
- data/test/unit/tags/field_text_test.rb +42 -0
- data/test/unit/{cms_tags → tags}/helper_test.rb +18 -6
- data/test/unit/tags/page_datetime_test.rb +44 -0
- data/test/unit/tags/page_integer_test.rb +43 -0
- data/test/unit/tags/page_rich_text.rb +43 -0
- data/test/unit/{cms_tags → tags}/page_string_test.rb +15 -5
- data/test/unit/tags/page_text_test.rb +46 -0
- data/test/unit/{cms_tags → tags}/partial_test.rb +24 -8
- data/test/unit/tags/snippet_test.rb +45 -0
- data/test/unit/view_methods_test.rb +2 -2
- metadata +95 -121
- data/app/models/cms_block.rb +0 -28
- data/app/models/cms_snippet.rb +0 -69
- data/db/cms_seeds/example.local/layouts/default.yml +0 -8
- data/db/cms_seeds/example.local/layouts/nested.yml +0 -6
- data/db/cms_seeds/example.local/pages/child.yml +0 -10
- data/db/cms_seeds/example.local/pages/child/subchild.yml +0 -14
- data/db/cms_seeds/example.local/pages/index.yml +0 -11
- data/db/cms_seeds/example.local/snippets/example.yml +0 -4
- data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +0 -18
- data/test/cms_seeds/test.host/layouts/broken.yml +0 -1
- data/test/cms_seeds/test.host/layouts/default.yml +0 -3
- data/test/cms_seeds/test.host/layouts/nested.yml +0 -4
- data/test/cms_seeds/test.host/pages/broken.yml +0 -1
- data/test/cms_seeds/test.host/pages/child.yml +0 -10
- data/test/cms_seeds/test.host/pages/child/subchild.yml +0 -10
- data/test/cms_seeds/test.host/pages/index.yml +0 -10
- data/test/cms_seeds/test.host/snippets/broken.yml +0 -1
- data/test/cms_seeds/test.host/snippets/default.yml +0 -3
- data/test/integration/rake_tasks_test.rb +0 -65
- data/test/integration/render_cms_seed_test.rb +0 -34
- data/test/unit/cms_block_test.rb +0 -43
- data/test/unit/cms_layout_test.rb +0 -179
- data/test/unit/cms_page_test.rb +0 -257
- data/test/unit/cms_site_test.rb +0 -41
- data/test/unit/cms_snippet_test.rb +0 -77
- data/test/unit/cms_tags/field_datetime_test.rb +0 -34
- data/test/unit/cms_tags/field_integer_test.rb +0 -33
- data/test/unit/cms_tags/field_string_test.rb +0 -34
- data/test/unit/cms_tags/field_text_test.rb +0 -32
- data/test/unit/cms_tags/page_datetime_test.rb +0 -34
- data/test/unit/cms_tags/page_integer_test.rb +0 -33
- data/test/unit/cms_tags/page_rich_text.rb +0 -33
- data/test/unit/cms_tags/page_text_test.rb +0 -34
- data/test/unit/cms_tags/snippet_test.rb +0 -33
- data/test/unit/cms_upload_test.rb +0 -26
data/test/unit/cms_page_test.rb
DELETED
@@ -1,257 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class CmsPageTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_fixtures_validity
|
6
|
-
CmsPage.all.each do |page|
|
7
|
-
assert page.valid?, page.errors.full_messages.to_s
|
8
|
-
assert_equal page.read_attribute(:content), page.content(true)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_validations
|
13
|
-
page = CmsPage.new
|
14
|
-
page.save
|
15
|
-
assert page.invalid?
|
16
|
-
assert_has_errors_on page, [:cms_layout, :slug, :label]
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_validation_of_parent_presence
|
20
|
-
page = cms_sites(:default).cms_pages.new(new_params)
|
21
|
-
assert !page.parent
|
22
|
-
assert page.valid?, page.errors.full_messages.to_s
|
23
|
-
assert_equal cms_pages(:default), page.parent
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_validation_of_parent_relationship
|
27
|
-
page = cms_pages(:default)
|
28
|
-
assert !page.parent
|
29
|
-
page.parent = page
|
30
|
-
assert page.invalid?
|
31
|
-
assert_has_errors_on page, :parent_id
|
32
|
-
page.parent = cms_pages(:child)
|
33
|
-
assert page.invalid?
|
34
|
-
assert_has_errors_on page, :parent_id
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_validation_of_target_page
|
38
|
-
page = cms_pages(:child)
|
39
|
-
page.target_page = cms_pages(:default)
|
40
|
-
page.save!
|
41
|
-
assert_equal cms_pages(:default), page.target_page
|
42
|
-
page.target_page = page
|
43
|
-
assert page.invalid?
|
44
|
-
assert_has_errors_on page, :target_page_id
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_creation
|
48
|
-
assert_difference ['CmsPage.count', 'CmsBlock.count'] do
|
49
|
-
page = cms_sites(:default).cms_pages.create!(
|
50
|
-
:label => 'test',
|
51
|
-
:slug => 'test',
|
52
|
-
:parent_id => cms_pages(:default).id,
|
53
|
-
:cms_layout_id => cms_layouts(:default).id,
|
54
|
-
:cms_blocks_attributes => [
|
55
|
-
{ :label => 'test',
|
56
|
-
:content => 'test' }
|
57
|
-
]
|
58
|
-
)
|
59
|
-
assert page.is_published?
|
60
|
-
assert_equal 1, page.position
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_initialization_of_full_path
|
65
|
-
page = CmsPage.new
|
66
|
-
assert_equal '/', page.full_path
|
67
|
-
|
68
|
-
page = CmsPage.new(new_params)
|
69
|
-
assert page.invalid?
|
70
|
-
assert_has_errors_on page, :cms_site_id
|
71
|
-
|
72
|
-
page = cms_sites(:default).cms_pages.new(new_params(:parent => cms_pages(:default)))
|
73
|
-
assert page.valid?
|
74
|
-
assert_equal '/test-page', page.full_path
|
75
|
-
|
76
|
-
page = cms_sites(:default).cms_pages.new(new_params(:parent => cms_pages(:child)))
|
77
|
-
assert page.valid?
|
78
|
-
assert_equal '/child-page/test-page', page.full_path
|
79
|
-
|
80
|
-
CmsPage.destroy_all
|
81
|
-
page = cms_sites(:default).cms_pages.new(new_params)
|
82
|
-
assert page.valid?
|
83
|
-
assert_equal '/', page.full_path
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_sync_child_pages
|
87
|
-
page = cms_pages(:child)
|
88
|
-
page_1 = cms_sites(:default).cms_pages.create!(new_params(:parent => page, :slug => 'test-page-1'))
|
89
|
-
page_2 = cms_sites(:default).cms_pages.create!(new_params(:parent => page, :slug => 'test-page-2'))
|
90
|
-
page_3 = cms_sites(:default).cms_pages.create!(new_params(:parent => page_2, :slug => 'test-page-3'))
|
91
|
-
page_4 = cms_sites(:default).cms_pages.create!(new_params(:parent => page_1, :slug => 'test-page-4'))
|
92
|
-
assert_equal '/child-page/test-page-1', page_1.full_path
|
93
|
-
assert_equal '/child-page/test-page-2', page_2.full_path
|
94
|
-
assert_equal '/child-page/test-page-2/test-page-3', page_3.full_path
|
95
|
-
assert_equal '/child-page/test-page-1/test-page-4', page_4.full_path
|
96
|
-
|
97
|
-
page.update_attributes!(:slug => 'updated-page')
|
98
|
-
assert_equal '/updated-page', page.full_path
|
99
|
-
page_1.reload; page_2.reload; page_3.reload; page_4.reload
|
100
|
-
assert_equal '/updated-page/test-page-1', page_1.full_path
|
101
|
-
assert_equal '/updated-page/test-page-2', page_2.full_path
|
102
|
-
assert_equal '/updated-page/test-page-2/test-page-3', page_3.full_path
|
103
|
-
assert_equal '/updated-page/test-page-1/test-page-4', page_4.full_path
|
104
|
-
|
105
|
-
page_2.update_attributes!(:parent => page_1)
|
106
|
-
page_1.reload; page_2.reload; page_3.reload; page_4.reload
|
107
|
-
assert_equal '/updated-page/test-page-1', page_1.full_path
|
108
|
-
assert_equal '/updated-page/test-page-1/test-page-2', page_2.full_path
|
109
|
-
assert_equal '/updated-page/test-page-1/test-page-2/test-page-3', page_3.full_path
|
110
|
-
assert_equal '/updated-page/test-page-1/test-page-4', page_4.full_path
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_children_count_updating
|
114
|
-
page_1 = cms_pages(:default)
|
115
|
-
page_2 = cms_pages(:child)
|
116
|
-
assert_equal 1, page_1.children_count
|
117
|
-
assert_equal 0, page_2.children_count
|
118
|
-
|
119
|
-
page_3 = cms_sites(:default).cms_pages.create!(new_params(:parent => page_2))
|
120
|
-
page_1.reload; page_2.reload
|
121
|
-
assert_equal 1, page_1.children_count
|
122
|
-
assert_equal 1, page_2.children_count
|
123
|
-
assert_equal 0, page_3.children_count
|
124
|
-
|
125
|
-
page_3.update_attributes!(:parent => page_1)
|
126
|
-
page_1.reload; page_2.reload
|
127
|
-
assert_equal 2, page_1.children_count
|
128
|
-
assert_equal 0, page_2.children_count
|
129
|
-
|
130
|
-
page_3.destroy
|
131
|
-
page_1.reload; page_2.reload
|
132
|
-
assert_equal 1, page_1.children_count
|
133
|
-
assert_equal 0, page_2.children_count
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_cascading_destroy
|
137
|
-
assert_difference 'CmsPage.count', -2 do
|
138
|
-
cms_pages(:default).destroy
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_options_for_select
|
143
|
-
assert_equal ['Default Page', '. . Child Page'],
|
144
|
-
CmsPage.options_for_select(cms_sites(:default)).collect{|t| t.first }
|
145
|
-
assert_equal ['Default Page'],
|
146
|
-
CmsPage.options_for_select(cms_sites(:default), cms_pages(:child)).collect{|t| t.first }
|
147
|
-
assert_equal [],
|
148
|
-
CmsPage.options_for_select(cms_sites(:default), cms_pages(:default))
|
149
|
-
|
150
|
-
page = CmsPage.new(new_params(:parent => cms_pages(:default)))
|
151
|
-
assert_equal ['Default Page', '. . Child Page'],
|
152
|
-
CmsPage.options_for_select(cms_sites(:default), page).collect{|t| t.first }
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_load_from_file
|
156
|
-
assert !CmsPage.load_from_file(cms_sites(:default), '/')
|
157
|
-
|
158
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
159
|
-
|
160
|
-
assert !CmsPage.load_from_file(cms_sites(:default), '/bogus')
|
161
|
-
|
162
|
-
assert page = CmsPage.load_from_file(cms_sites(:default), '/')
|
163
|
-
assert_equal 'Default Page', page.label
|
164
|
-
assert_equal 1, page.cms_blocks.size
|
165
|
-
assert page.cms_layout
|
166
|
-
assert_equal '<html>Default Page Content</html>', page.content
|
167
|
-
|
168
|
-
assert page = CmsPage.load_from_file(cms_sites(:default), '/child')
|
169
|
-
assert_equal 1, page.cms_blocks.size
|
170
|
-
assert page.cms_layout
|
171
|
-
assert_equal '<html>Child Page Content</html>', page.content
|
172
|
-
|
173
|
-
assert page = CmsPage.load_from_file(cms_sites(:default), '/child/subchild')
|
174
|
-
assert_equal 1, page.cms_blocks.size
|
175
|
-
assert page.cms_layout
|
176
|
-
assert_equal 'Nested Layout', page.cms_layout.label
|
177
|
-
assert_equal '<html><div>Sub Child Page Content Content for Default Snippet</div></html>', page.content
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_load_from_file_broken
|
181
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
182
|
-
error_message = "Failed to load from #{ComfortableMexicanSofa.configuration.seed_data_path}/test.host/pages/broken.yml"
|
183
|
-
assert_exception_raised RuntimeError, error_message do
|
184
|
-
CmsPage.load_from_file(cms_sites(:default), '/broken')
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_load_for_full_path
|
189
|
-
assert page = CmsPage.load_for_full_path!(cms_sites(:default), '/')
|
190
|
-
assert !page.new_record?
|
191
|
-
db_content = page.content
|
192
|
-
|
193
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
194
|
-
assert page = CmsPage.load_for_full_path!(cms_sites(:default), '/')
|
195
|
-
assert page.new_record?
|
196
|
-
file_content = page.content
|
197
|
-
assert_not_equal db_content, file_content
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_load_for_full_path_exceptions
|
201
|
-
assert_exception_raised ActiveRecord::RecordNotFound, 'CmsPage with path: /invalid_page cannot be found' do
|
202
|
-
CmsPage.load_for_full_path!(cms_sites(:default), '/invalid_page')
|
203
|
-
end
|
204
|
-
assert !CmsPage.load_for_full_path(cms_sites(:default), '/invalid_page')
|
205
|
-
|
206
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
207
|
-
assert_exception_raised ActiveRecord::RecordNotFound, 'CmsPage with path: /invalid_page cannot be found' do
|
208
|
-
CmsPage.load_for_full_path!(cms_sites(:default), '/invalid_page')
|
209
|
-
end
|
210
|
-
assert !CmsPage.load_for_full_path(cms_sites(:default), '/invalid_page')
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_cms_blocks_attributes_accessor
|
214
|
-
page = cms_pages(:default)
|
215
|
-
assert_equal page.cms_blocks.count, page.cms_blocks_attributes.size
|
216
|
-
assert_equal 'default_field_text', page.cms_blocks_attributes.first[:label]
|
217
|
-
assert_equal 'default_field_text_content', page.cms_blocks_attributes.first[:content]
|
218
|
-
assert page.cms_blocks_attributes.first[:id]
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_content_caching
|
222
|
-
page = cms_pages(:default)
|
223
|
-
assert_equal page.read_attribute(:content), page.content
|
224
|
-
assert_equal page.read_attribute(:content), page.content(true)
|
225
|
-
|
226
|
-
page.update_attribute(:content, 'changed')
|
227
|
-
assert_equal page.read_attribute(:content), page.content
|
228
|
-
assert_equal page.read_attribute(:content), page.content(true)
|
229
|
-
assert_not_equal 'changed', page.read_attribute(:content)
|
230
|
-
end
|
231
|
-
|
232
|
-
def test_scope_published
|
233
|
-
assert_equal 2, CmsPage.published.count
|
234
|
-
cms_pages(:child).update_attribute(:is_published, false)
|
235
|
-
assert_equal 1, CmsPage.published.count
|
236
|
-
end
|
237
|
-
|
238
|
-
def test_root?
|
239
|
-
assert cms_pages(:default).root?
|
240
|
-
assert !cms_pages(:child).root?
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_url
|
244
|
-
assert_equal 'http://test.host/', cms_pages(:default).url
|
245
|
-
assert_equal 'http://test.host/child-page', cms_pages(:child).url
|
246
|
-
end
|
247
|
-
|
248
|
-
protected
|
249
|
-
|
250
|
-
def new_params(options = {})
|
251
|
-
{
|
252
|
-
:label => 'Test Page',
|
253
|
-
:slug => 'test-page',
|
254
|
-
:cms_layout => cms_layouts(:default)
|
255
|
-
}.merge(options)
|
256
|
-
end
|
257
|
-
end
|
data/test/unit/cms_site_test.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class CmsSiteTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_fixtures_validity
|
6
|
-
CmsSite.all.each do |site|
|
7
|
-
assert site.valid?, site.errors.full_messages.to_s
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_validation
|
12
|
-
site = CmsSite.new
|
13
|
-
assert site.invalid?
|
14
|
-
assert_has_errors_on site, [:label, :hostname]
|
15
|
-
|
16
|
-
site = CmsSite.new(:label => 'My Site', :hostname => 'http://mysite.com')
|
17
|
-
assert site.invalid?
|
18
|
-
assert_has_errors_on site, :hostname
|
19
|
-
|
20
|
-
site = CmsSite.new(:label => 'My Site', :hostname => 'mysite.com')
|
21
|
-
assert site.valid?
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_cascading_destroy
|
25
|
-
assert_difference 'CmsSite.count', -1 do
|
26
|
-
assert_difference 'CmsLayout.count', -3 do
|
27
|
-
assert_difference 'CmsPage.count', -2 do
|
28
|
-
assert_difference 'CmsSnippet.count', -1 do
|
29
|
-
cms_sites(:default).destroy
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_options_for_select
|
37
|
-
assert_equal 1, CmsSite.options_for_select.size
|
38
|
-
assert_equal 'Default Site (test.host)', CmsSite.options_for_select[0][0]
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class CmsSnippetTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_fixtures_validity
|
6
|
-
CmsSnippet.all.each do |snippet|
|
7
|
-
assert snippet.valid?, snippet.errors.full_messages.to_s
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_validations
|
12
|
-
snippet = CmsSnippet.new
|
13
|
-
snippet.save
|
14
|
-
assert snippet.invalid?
|
15
|
-
assert_has_errors_on snippet, [:label, :slug]
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_method_content
|
19
|
-
assert_equal cms_snippets(:default).content, CmsSnippet.content_for('default')
|
20
|
-
assert_equal '', CmsSnippet.content_for('nonexistent_snippet')
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_load_from_file
|
24
|
-
assert !CmsSnippet.load_from_file(cms_sites(:default), 'default')
|
25
|
-
|
26
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
27
|
-
|
28
|
-
assert !CmsSnippet.load_from_file(cms_sites(:default), 'bogus')
|
29
|
-
|
30
|
-
assert snippet = CmsSnippet.load_from_file(cms_sites(:default), 'default')
|
31
|
-
assert_equal 'Default Snippet', snippet.label
|
32
|
-
assert_equal 'Content for Default Snippet', snippet.content
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_load_from_file_broken
|
36
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
37
|
-
error_message = "Failed to load from #{ComfortableMexicanSofa.configuration.seed_data_path}/test.host/snippets/broken.yml"
|
38
|
-
assert_exception_raised RuntimeError, error_message do
|
39
|
-
CmsSnippet.load_from_file(cms_sites(:default), 'broken')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_load_for_slug
|
44
|
-
assert snippet = CmsSnippet.load_for_slug!(cms_sites(:default), 'default')
|
45
|
-
assert !snippet.new_record?
|
46
|
-
db_content = snippet.content
|
47
|
-
|
48
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
49
|
-
assert snippet = CmsSnippet.load_for_slug!(cms_sites(:default), 'default')
|
50
|
-
assert snippet.new_record?
|
51
|
-
file_content = snippet.content
|
52
|
-
assert_not_equal db_content, file_content
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_load_for_slug_exceptions
|
56
|
-
assert_exception_raised ActiveRecord::RecordNotFound, 'CmsSnippet with slug: not_found cannot be found' do
|
57
|
-
CmsSnippet.load_for_slug!(cms_sites(:default), 'not_found')
|
58
|
-
end
|
59
|
-
assert !CmsSnippet.load_for_slug(cms_sites(:default), 'not_found')
|
60
|
-
|
61
|
-
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
62
|
-
assert_exception_raised ActiveRecord::RecordNotFound, 'CmsSnippet with slug: not_found cannot be found' do
|
63
|
-
CmsSnippet.load_for_slug!(cms_sites(:default), 'not_found')
|
64
|
-
end
|
65
|
-
assert !CmsSnippet.load_for_slug(cms_sites(:default), 'not_found')
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_update_forces_page_content_reload
|
69
|
-
snippet = cms_snippets(:default)
|
70
|
-
page = cms_pages(:default)
|
71
|
-
assert_match snippet.content, page.content
|
72
|
-
snippet.update_attribute(:content, 'new_snippet_content')
|
73
|
-
page.reload
|
74
|
-
assert_match /new_snippet_content/, page.content
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class FieldDateTimeTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_initialize_tag
|
6
|
-
assert tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), '{{ cms:field:content:datetime }}')
|
7
|
-
assert_equal 'content', tag.label
|
8
|
-
assert tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), '{{cms:field:content:datetime}}')
|
9
|
-
assert_equal 'content', tag.label
|
10
|
-
assert tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), '{{cms:field:dash-content:datetime}}')
|
11
|
-
assert_equal 'dash-content', tag.label
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_initialize_tag_failure
|
15
|
-
[
|
16
|
-
'{{cms:field:content:not_datetime}}',
|
17
|
-
'{{cms:field:content}}',
|
18
|
-
'{{cms:not_field:content}}',
|
19
|
-
'{not_a_tag}'
|
20
|
-
].each do |tag_signature|
|
21
|
-
assert_nil CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), tag_signature)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_content_and_render
|
26
|
-
tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), '{{cms:field: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 '', tag.render
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class FieldIntegerTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_initialize_tag
|
6
|
-
assert tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), '{{ cms:field:content:integer }}')
|
7
|
-
assert_equal 'content', tag.label
|
8
|
-
assert tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), '{{cms:field:content:integer}}')
|
9
|
-
assert_equal 'content', tag.label
|
10
|
-
assert tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), '{{cms:field:dash-content:integer}}')
|
11
|
-
assert_equal 'dash-content', tag.label
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_initialize_tag_failure
|
15
|
-
[
|
16
|
-
'{{cms:field:content:not_integer}}',
|
17
|
-
'{{cms:field:content}}',
|
18
|
-
'{{cms:not_field:content}}',
|
19
|
-
'{not_a_tag}'
|
20
|
-
].each do |tag_signature|
|
21
|
-
assert_nil CmsTag::FieldInteger.initialize_tag(cms_pages(:default), tag_signature)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_content_and_render
|
26
|
-
tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), '{{cms:field:content:integer}}')
|
27
|
-
assert tag.content.blank?
|
28
|
-
tag.content = '5'
|
29
|
-
assert_equal '5', tag.content
|
30
|
-
assert_equal '', tag.render
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class FieldStringTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_initialize_tag
|
6
|
-
assert tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), '{{ cms:field:content:string }}')
|
7
|
-
assert_equal 'content', tag.label
|
8
|
-
assert tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), '{{cms:field:content:string}}')
|
9
|
-
assert_equal 'content', tag.label
|
10
|
-
assert tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), '{{cms:field:content}}')
|
11
|
-
assert_equal 'content', tag.label
|
12
|
-
assert tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), '{{cms:field:dash-content}}')
|
13
|
-
assert_equal 'dash-content', tag.label
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_initialize_tag_failure
|
17
|
-
[
|
18
|
-
'{{cms:field:content:not_string}}',
|
19
|
-
'{{cms:not_field:content}}',
|
20
|
-
'{not_a_tag}'
|
21
|
-
].each do |tag_signature|
|
22
|
-
assert_nil CmsTag::FieldString.initialize_tag(cms_pages(:default), tag_signature)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_content_and_render
|
27
|
-
tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), '{{cms:field:content}}')
|
28
|
-
assert tag.content.blank?
|
29
|
-
tag.content = 'test_content'
|
30
|
-
assert_equal 'test_content', tag.content
|
31
|
-
assert_equal '', tag.render
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|