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
@@ -4,281 +4,21 @@ namespace :db do
4
4
  end
5
5
 
6
6
  namespace :comfortable_mexican_sofa do
7
-
8
- # Example use:
9
- # rake comfortable_mexican_sofa:import:all FROM=mysite.local TO=mysite.com SEED_PATH=/path/to/seed_data
10
- namespace :import do
7
+ namespace :fixtures do
11
8
 
12
- task :check_for_requirements => :environment do |task, args|
13
- @from = args[:from].present?? args[:from] : nil
14
- @site = args[:to].present?? args[:to] : nil
15
- @seed_path =
16
- ComfortableMexicanSofa.config.seed_data_path =
17
- (args[:seed_path].present?? args[:seed_path] : nil) || ComfortableMexicanSofa.config.seed_data_path
18
-
19
- if !@seed_path
20
- abort 'SEED_PATH is not set. Please define where cms fixtures are located.'
21
- end
22
- unless File.exists?((@from && @seed_path = "#{@seed_path}/#{@from}").to_s)
23
- abort "FROM is not properly set. Cannot find fixtures in '#{@seed_path}'"
24
- end
25
- if !(@site = CmsSite.find_by_hostname(args[:to]))
26
- abort "TO is not properly set. Cannot find site with hostname '#{args[:to]}'"
9
+ desc 'Import Fixture data into database. (options: SITE=example.com)'
10
+ task :import => :environment do |task, args|
11
+ site = if ComfortableMexicanSofa.config.enable_multiple_sites
12
+ Cms::Site.find_by_hostname(args[:site])
13
+ else
14
+ Cms::Site.first
27
15
  end
16
+ abort 'SITE is not found. Aborting.' if !site
28
17
 
29
- # a small hack to ensure that #load_from_file looks in the right directory
30
- @site.hostname = args[:from]
18
+ puts "Syncing for #{site.hostname}"
19
+ ComfortableMexicanSofa::Fixtures.sync(site)
31
20
 
32
- puts "Starting import into #{@site.label} (#{@site.hostname}) from '#{@seed_path}'"
33
- end
34
-
35
- desc 'Import layouts into database'
36
- task :layouts => [:environment, :check_for_requirements] do |task, args|
37
- puts 'Importing Layouts'
38
- puts '-----------------'
39
- layouts = Dir.glob(File.expand_path('layouts/*.yml', @seed_path)).collect do |layout_file_path|
40
- begin
41
- attributes = YAML.load_file(layout_file_path).symbolize_keys!
42
- @site.cms_layouts.load_from_file(@site, attributes[:slug])
43
- rescue
44
- nil
45
- end
46
- end.compact
47
- CmsLayout.connection.transaction do
48
- # Fixtures are not ordered in any particular way. Saving order matters,
49
- # so we cycle them until there nothing left to save
50
- while layouts.present?
51
- layout = layouts.shift
52
- if !layout.parent || layout.parent && parent = @site.cms_layouts.find_by_slug(layout.parent.slug)
53
- layout.parent = (parent rescue nil)
54
- should_write = true
55
- existing_layout = nil
56
-
57
- if existing_layout = @site.cms_layouts.find_by_slug(layout.slug)
58
- print "Found layout in database with slug: #{layout.slug}. Overwrite? (y/N): "
59
- should_write = ($stdin.gets.to_s.strip.downcase == 'y')
60
- end
61
- if should_write
62
- if existing_layout
63
- existing_layout.attributes = layout.attributes.slice('label', 'content', 'css', 'js')
64
- layout = existing_layout
65
- end
66
- puts "Saving layout: #{layout.label} (#{layout.slug})"
67
- layout.save!
68
- else
69
- puts "Skipping layout: #{layout.label} (#{layout.slug})"
70
- end
71
- else
72
- layouts.push layout
73
- end
74
- end
75
- end
76
- end
77
-
78
- desc 'Import pages into database'
79
- task :pages => [:environment, :check_for_requirements] do |task, args|
80
- puts 'Importing Pages'
81
- puts '---------------'
82
- pages = Dir.glob(File.expand_path('pages/**/*.yml', @seed_path)).collect do |page_file_path|
83
- begin
84
- attributes = YAML.load_file(page_file_path).symbolize_keys!
85
- @site.cms_pages.load_from_file(@site, attributes[:full_path])
86
- rescue
87
- nil
88
- end
89
- end.compact
90
- CmsPage.connection.transaction do
91
- # Fixtures are not ordered in any particular way. Saving order matters,
92
- # so we cycle them until there nothing left to save
93
- while pages.present?
94
- page = pages.shift
95
- if !page.parent || page.parent && parent = @site.cms_pages.find_by_full_path(page.parent.full_path)
96
- page.parent = (parent rescue nil)
97
- page.cms_layout = @site.cms_layouts.find_by_slug(page.cms_layout.slug)
98
- should_write = true
99
- existing_page = nil
100
-
101
- if existing_page = @site.cms_pages.find_by_full_path(page.full_path)
102
- print "Found page in database with full_path: #{page.full_path}. Overwrite? (y/N): "
103
- should_write = ($stdin.gets.to_s.strip.downcase == 'y')
104
- end
105
-
106
- if should_write
107
- if existing_page
108
- # merging cms_blocks_attributes with the existing page
109
- attrs = page.cms_blocks_attributes.collect do |block_attrs|
110
- existing_block = existing_page.cms_blocks_attributes.find{|b| b[:label] == block_attrs[:label]}
111
- block_attrs[:id] = existing_block[:id] if existing_block
112
- block_attrs.stringify_keys
113
- end
114
-
115
- existing_page.attributes = page.attributes.slice('label')
116
- existing_page.cms_blocks_attributes = attrs
117
- page = existing_page
118
- end
119
- puts "... Saving page: #{page.label} (#{page.full_path})"
120
- page.save!
121
- else
122
- puts "... Skipping page: #{page.label} (#{page.full_path})"
123
- end
124
- else
125
- pages.push page
126
- end
127
- end
128
- end
21
+ puts 'Done!'
129
22
  end
130
-
131
- desc 'Import snippets into database'
132
- task :snippets => [:environment, :check_for_requirements] do |task, args|
133
- puts 'Importing Snippets'
134
- puts '------------------'
135
- snippets = Dir.glob(File.expand_path('snippets/*.yml', @seed_path)).collect do |snippet_file_path|
136
- begin
137
- attributes = YAML.load_file(snippet_file_path).symbolize_keys!
138
- @site.cms_snippets.load_from_file(@site, attributes[:slug])
139
- rescue
140
- nil
141
- end
142
- end.compact
143
- CmsSnippet.connection.transaction do
144
- snippets.each do |snippet|
145
- should_write = true
146
- existing_snippet = nil
147
- if existing_snippet = @site.cms_snippets.find_by_slug(snippet.slug)
148
- print "Found snippet in database with slug: #{snippet.slug}. Overwrite? (y/N): "
149
- should_write = ($stdin.gets.to_s.strip.downcase == 'y')
150
- end
151
- if should_write
152
- if existing_snippet
153
- existing_snippet.attributes = snippet.attributes.slice('label', 'content')
154
- snippet = existing_snippet
155
- end
156
- puts "... Saving snippet: #{snippet.label} (#{snippet.slug})"
157
- snippet.save!
158
- else
159
- puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})"
160
- end
161
- end
162
- end
163
- end
164
-
165
- desc 'Import layouts, pages and snippets all in one go'
166
- task :all => [:layouts, :pages, :snippets]
167
-
168
23
  end
169
-
170
- # Example use:
171
- # rake comfortable_mexican_sofa:import:all FROM=mysite.com TO=mysite.local SEED_PATH=/path/to/seed_data
172
- namespace :export do
173
-
174
- task :check_for_requirements => :environment do |task, args|
175
- @site = args[:from].present?? args[:from] : nil
176
- @to = args[:to].present?? args[:to] : nil
177
- @seed_path =
178
- ComfortableMexicanSofa.config.seed_data_path =
179
- (args[:seed_path].present?? args[:seed_path] : nil) || ComfortableMexicanSofa.config.seed_data_path
180
-
181
- if !@seed_path
182
- abort 'SEED_PATH is not set. Please define where cms fixtures are located.'
183
- end
184
- if !(@site = CmsSite.find_by_hostname(args[:from]))
185
- abort "FROM is not properly set. Cannot find site with hostname '#{args[:from]}'"
186
- end
187
- unless @to && @seed_path = "#{@seed_path}/#{@to}"
188
- abort "TO is not properly set. What's the target hostname?"
189
- end
190
-
191
- FileUtils.mkdir_p @seed_path
192
- FileUtils.mkdir_p "#{@seed_path}/layouts"
193
- FileUtils.mkdir_p "#{@seed_path}/pages"
194
- FileUtils.mkdir_p "#{@seed_path}/snippets"
195
-
196
- puts "Starting export from #{@site.label} (#{@site.hostname}) to '#{@seed_path}'"
197
- end
198
-
199
- desc 'Export layouts to yaml files'
200
- task :layouts => [:environment, :check_for_requirements] do |task, args|
201
- puts 'Exporting Layouts'
202
- puts '-----------------'
203
- CmsLayout.all.each do |layout|
204
- should_write = true
205
- file_path = File.join(@seed_path, 'layouts', "#{layout.slug}.yml")
206
- if File.exists?(file_path)
207
- print "Found layout fixture: #{file_path} Overwrite? (y/N): "
208
- should_write = ($stdin.gets.to_s.strip.downcase == 'y')
209
- end
210
- if should_write
211
- attributes = layout.attributes.slice('label', 'slug', 'content', 'css', 'js')
212
- attributes['parent'] = layout.parent.slug if layout.parent
213
- open(file_path, 'w') do |f|
214
- f.write(attributes.to_yaml)
215
- end
216
- puts "... Saving layout: #{layout.label} (#{layout.slug})"
217
- else
218
- puts "... Skipping layout: #{layout.label} (#{layout.slug})"
219
- end
220
- end
221
- end
222
-
223
- desc 'Export pages to yaml files'
224
- task :pages => [:environment, :check_for_requirements] do |task, args|
225
- puts 'Exporting Pages'
226
- puts '---------------'
227
- CmsPage.all.each do |page|
228
- should_write = true
229
- page_name = page.full_path.split('/').last || 'index'
230
- page_path = (p = page.full_path.split('/')) && p.pop && p.join('/')
231
-
232
- FileUtils.mkdir_p "#{@seed_path}/pages/#{page_path}"
233
- file_path = File.join(@seed_path, 'pages', "#{page_path}/#{page_name}.yml")
234
-
235
- if File.exists?(file_path)
236
- print "Found page fixture: #{file_path} Overwrite? (y/N): "
237
- should_write = ($stdin.gets.to_s.strip.downcase == 'y')
238
- end
239
- if should_write
240
-
241
- attributes = page.attributes.slice('label', 'slug', 'full_path', 'is_published')
242
- attributes['targe_page'] = page.target_page.full_path if page.target_page
243
- attributes['parent'] = page.parent.full_path if page.parent
244
- attributes['cms_layout'] = page.cms_layout.slug
245
- attributes['cms_blocks_attributes'] = page.cms_blocks_attributes.collect{|b| b.delete(:id) && b.stringify_keys}
246
-
247
- open(file_path, 'w') do |f|
248
- f.write(attributes.to_yaml)
249
- end
250
- puts "... Saving page: #{page.label} (#{page.full_path})"
251
- else
252
- puts "... Skipping page: #{page.label} (#{page.full_path})"
253
- end
254
- end
255
- end
256
-
257
- desc 'Export snippets to yaml files'
258
- task :snippets => [:environment, :check_for_requirements] do |task, args|
259
- puts 'Exporting Snippets'
260
- puts '------------------'
261
- CmsSnippet.all.each do |snippet|
262
- should_write = true
263
- file_path = File.join(@seed_path, 'snippets', "#{snippet.slug}.yml")
264
- if File.exists?(file_path)
265
- print "Found snippet fixture: #{file_path} Overwrite? (y/N): "
266
- should_write = ($stdin.gets.to_s.strip.downcase == 'y')
267
- end
268
- if should_write
269
- attributes = snippet.attributes.slice('label', 'slug', 'content')
270
- open(file_path, 'w') do |f|
271
- f.write(attributes.to_yaml)
272
- end
273
- puts "... Saving snippet: #{snippet.label} (#{snippet.slug})"
274
- else
275
- puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})"
276
- end
277
- end
278
- end
279
-
280
- desc 'Export layouts, pages and snippets all in one go'
281
- task :all => [:layouts, :pages, :snippets]
282
-
283
- end
284
- end
24
+ end
@@ -54,7 +54,7 @@ $.CMS = function(){
54
54
 
55
55
  // Load Page Blocks on layout change
56
56
  load_page_blocks: function(){
57
- $('select#cms_page_cms_layout_id').bind('change.cms', function() {
57
+ $('select#cms_page_layout_id').bind('change.cms', function() {
58
58
  $.ajax({
59
59
  url: ['/' + admin_path_prefix, 'pages', $(this).attr('data-page-id'), 'form_blocks'].join('/'),
60
60
  data: ({
@@ -1,10 +1,10 @@
1
1
  default_field_text:
2
- cms_page: default
2
+ page: default
3
3
  label: default_field_text
4
4
  content: default_field_text_content
5
5
 
6
6
  default_page_text:
7
- cms_page: default
7
+ page: default
8
8
  label: default_page_text
9
9
  content: |-
10
10
  default_page_text_content_a
@@ -1,5 +1,5 @@
1
1
  default:
2
- cms_site: default
2
+ site: default
3
3
  label: Default Layout
4
4
  slug: default
5
5
  parent:
@@ -14,7 +14,7 @@ default:
14
14
  js: default_js
15
15
 
16
16
  nested:
17
- cms_site: default
17
+ site: default
18
18
  label: Nested Layout
19
19
  slug: nested
20
20
  parent:
@@ -25,7 +25,7 @@ nested:
25
25
  js: nested_js
26
26
 
27
27
  child:
28
- cms_site: default
28
+ site: default
29
29
  label: Child Layout
30
30
  slug: child
31
31
  parent: nested
@@ -1,8 +1,8 @@
1
1
  default:
2
- cms_site: default
2
+ site: default
3
3
  parent:
4
4
  target_page:
5
- cms_layout: default
5
+ layout: default
6
6
  label: Default Page
7
7
  slug:
8
8
  full_path: '/'
@@ -20,10 +20,10 @@ default:
20
20
  layout_content_c
21
21
 
22
22
  child:
23
- cms_site: default
23
+ site: default
24
24
  parent: default
25
25
  target_page:
26
- cms_layout: default
26
+ layout: default
27
27
  label: Child Page
28
28
  slug: 'child-page'
29
29
  full_path: '/child-page'
File without changes
@@ -1,5 +1,5 @@
1
1
  default:
2
- cms_site: default
2
+ site: default
3
3
  label: Default Snippet
4
4
  slug: default
5
5
  content: default_snippet_content
@@ -1,5 +1,5 @@
1
1
  default:
2
- cms_site: default
2
+ site: default
3
3
  file_file_name: sample.jpg
4
4
  file_content_type: image/jpeg
5
5
  file_file_size: 20099
@@ -10,7 +10,7 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
10
10
  end
11
11
 
12
12
  def test_get_index_with_no_layouts
13
- CmsLayout.delete_all
13
+ Cms::Layout.delete_all
14
14
  get :index
15
15
  assert_response :redirect
16
16
  assert_redirected_to :action => :new
@@ -42,22 +42,22 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
42
42
  end
43
43
 
44
44
  def test_creation
45
- assert_difference 'CmsLayout.count' do
45
+ assert_difference 'Cms::Layout.count' do
46
46
  post :create, :cms_layout => {
47
47
  :label => 'Test Layout',
48
48
  :slug => 'test',
49
49
  :content => 'Test {{cms:page:content}}'
50
50
  }
51
51
  assert_response :redirect
52
- layout = CmsLayout.last
53
- assert_equal cms_sites(:default), layout.cms_site
52
+ layout = Cms::Layout.last
53
+ assert_equal cms_sites(:default), layout.site
54
54
  assert_redirected_to :action => :edit, :id => layout
55
55
  assert_equal 'Layout created', flash[:notice]
56
56
  end
57
57
  end
58
58
 
59
59
  def test_creation_failure
60
- assert_no_difference 'CmsLayout.count' do
60
+ assert_no_difference 'Cms::Layout.count' do
61
61
  post :create, :cms_layout => { }
62
62
  assert_response :success
63
63
  assert_template :new
@@ -92,7 +92,7 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
92
92
  end
93
93
 
94
94
  def test_destroy
95
- assert_difference 'CmsLayout.count', -1 do
95
+ assert_difference 'Cms::Layout.count', -1 do
96
96
  delete :destroy, :id => cms_layouts(:default)
97
97
  assert_response :redirect
98
98
  assert_redirected_to :action => :index
@@ -10,7 +10,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
10
10
  end
11
11
 
12
12
  def test_get_index_with_no_pages
13
- CmsPage.delete_all
13
+ Cms::Page.delete_all
14
14
  get :index
15
15
  assert_response :redirect
16
16
  assert_redirected_to :action => :new
@@ -20,7 +20,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
20
20
  get :new
21
21
  assert_response :success
22
22
  assert assigns(:cms_page)
23
- assert_equal cms_layouts(:default), assigns(:cms_page).cms_layout
23
+ assert_equal cms_layouts(:default), assigns(:cms_page).layout
24
24
 
25
25
  assert_template :new
26
26
  assert_select 'form[action=/cms-admin/pages]'
@@ -29,64 +29,64 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
29
29
  def test_get_new_with_field_datetime
30
30
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:datetime}}')
31
31
  get :new
32
- assert_select "input[type='datetime'][name='cms_page[cms_blocks_attributes][][content]']"
33
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
32
+ assert_select "input[type='datetime'][name='cms_page[blocks_attributes][][content]']"
33
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
34
34
  end
35
35
 
36
36
  def test_get_new_with_field_integer
37
37
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:integer}}')
38
38
  get :new
39
- assert_select "input[type='number'][name='cms_page[cms_blocks_attributes][][content]']"
40
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
39
+ assert_select "input[type='number'][name='cms_page[blocks_attributes][][content]']"
40
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
41
41
  end
42
42
 
43
43
  def test_get_new_with_field_string
44
44
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label}}')
45
45
  get :new
46
- assert_select "input[type='text'][name='cms_page[cms_blocks_attributes][][content]']"
47
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
46
+ assert_select "input[type='text'][name='cms_page[blocks_attributes][][content]']"
47
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
48
48
  end
49
49
 
50
50
  def test_get_new_with_field_text
51
51
  cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:text}}')
52
52
  get :new
53
- assert_select "textarea[name='cms_page[cms_blocks_attributes][][content]']"
54
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
53
+ assert_select "textarea[name='cms_page[blocks_attributes][][content]']"
54
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
55
55
  end
56
56
 
57
57
  def test_get_new_with_page_datetime
58
58
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:datetime}}')
59
59
  get :new
60
- assert_select "input[type='datetime'][name='cms_page[cms_blocks_attributes][][content]']"
61
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
60
+ assert_select "input[type='datetime'][name='cms_page[blocks_attributes][][content]']"
61
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
62
62
  end
63
63
 
64
64
  def test_get_new_with_page_integer
65
65
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:integer}}')
66
66
  get :new
67
- assert_select "input[type='number'][name='cms_page[cms_blocks_attributes][][content]']"
68
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
67
+ assert_select "input[type='number'][name='cms_page[blocks_attributes][][content]']"
68
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
69
69
  end
70
70
 
71
71
  def test_get_new_with_page_string
72
72
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:string}}')
73
73
  get :new
74
- assert_select "input[type='text'][name='cms_page[cms_blocks_attributes][][content]']"
75
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
74
+ assert_select "input[type='text'][name='cms_page[blocks_attributes][][content]']"
75
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
76
76
  end
77
77
 
78
78
  def test_get_new_with_page_text
79
79
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label}}')
80
80
  get :new
81
- assert_select "textarea[name='cms_page[cms_blocks_attributes][][content]']"
82
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
81
+ assert_select "textarea[name='cms_page[blocks_attributes][][content]']"
82
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
83
83
  end
84
84
 
85
85
  def test_get_new_with_rich_page_text
86
86
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:rich_text}}')
87
87
  get :new
88
- assert_select "textarea[name='cms_page[cms_blocks_attributes][][content]']"
89
- assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
88
+ assert_select "textarea[name='cms_page[blocks_attributes][][content]']"
89
+ assert_select "input[type='hidden'][name='cms_page[blocks_attributes][][label]'][value='test_label']"
90
90
  end
91
91
 
92
92
  def test_get_new_as_child_page
@@ -104,8 +104,8 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
104
104
  assert assigns(:cms_page)
105
105
  assert_template :edit
106
106
  assert_select "form[action=/cms-admin/pages/#{page.id}]"
107
- assert_select "input[name='cms_page[cms_blocks_attributes][][id]'][value='#{cms_blocks(:default_field_text).id}']"
108
- assert_select "input[name='cms_page[cms_blocks_attributes][][id]'][value='#{cms_blocks(:default_field_text).id}']"
107
+ assert_select "input[name='cms_page[blocks_attributes][][id]'][value='#{cms_blocks(:default_field_text).id}']"
108
+ assert_select "input[name='cms_page[blocks_attributes][][id]'][value='#{cms_blocks(:default_field_text).id}']"
109
109
  end
110
110
 
111
111
  def test_get_edit_failure
@@ -117,22 +117,22 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
117
117
 
118
118
  def test_get_edit_with_blank_layout
119
119
  page = cms_pages(:default)
120
- page.update_attribute(:cms_layout_id, nil)
120
+ page.update_attribute(:layout_id, nil)
121
121
  get :edit, :id => page
122
122
  assert_response :success
123
123
  assert assigns(:cms_page)
124
- assert assigns(:cms_page).cms_layout
124
+ assert assigns(:cms_page).layout
125
125
  end
126
126
 
127
127
  def test_creation
128
- assert_difference 'CmsPage.count' do
129
- assert_difference 'CmsBlock.count', 2 do
128
+ assert_difference 'Cms::Page.count' do
129
+ assert_difference 'Cms::Block.count', 2 do
130
130
  post :create, :cms_page => {
131
- :label => 'Test Page',
132
- :slug => 'test-page',
133
- :parent_id => cms_pages(:default).id,
134
- :cms_layout_id => cms_layouts(:default).id,
135
- :cms_blocks_attributes => [
131
+ :label => 'Test Page',
132
+ :slug => 'test-page',
133
+ :parent_id => cms_pages(:default).id,
134
+ :layout_id => cms_layouts(:default).id,
135
+ :blocks_attributes => [
136
136
  { :label => 'default_page_text',
137
137
  :content => 'content content' },
138
138
  { :label => 'default_field_text',
@@ -140,8 +140,8 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
140
140
  ]
141
141
  }
142
142
  assert_response :redirect
143
- page = CmsPage.last
144
- assert_equal cms_sites(:default), page.cms_site
143
+ page = Cms::Page.last
144
+ assert_equal cms_sites(:default), page.site
145
145
  assert_redirected_to :action => :edit, :id => page
146
146
  assert_equal 'Page saved', flash[:notice]
147
147
  end
@@ -149,10 +149,10 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
149
149
  end
150
150
 
151
151
  def test_creation_failure
152
- assert_no_difference ['CmsPage.count', 'CmsBlock.count'] do
152
+ assert_no_difference ['Cms::Page.count', 'Cms::Block.count'] do
153
153
  post :create, :cms_page => {
154
- :cms_layout_id => cms_layouts(:default).id,
155
- :cms_blocks_attributes => [
154
+ :layout_id => cms_layouts(:default).id,
155
+ :blocks_attributes => [
156
156
  { :label => 'default_page_text',
157
157
  :content => 'content content' },
158
158
  { :label => 'default_field_text',
@@ -161,8 +161,8 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
161
161
  }
162
162
  assert_response :success
163
163
  page = assigns(:cms_page)
164
- assert_equal 2, page.cms_blocks.size
165
- assert_equal ['content content', 'title content'], page.cms_blocks.collect{|b| b.content}
164
+ assert_equal 2, page.blocks.size
165
+ assert_equal ['content content', 'title content'], page.blocks.collect{|b| b.content}
166
166
  assert_template :new
167
167
  assert_equal 'Failed to create page', flash[:error]
168
168
  end
@@ -170,7 +170,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
170
170
 
171
171
  def test_update
172
172
  page = cms_pages(:default)
173
- assert_no_difference 'CmsBlock.count' do
173
+ assert_no_difference 'Cms::Block.count' do
174
174
  put :update, :id => page, :cms_page => {
175
175
  :label => 'Updated Label'
176
176
  }
@@ -184,11 +184,11 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
184
184
 
185
185
  def test_update_with_layout_change
186
186
  page = cms_pages(:default)
187
- assert_difference 'CmsBlock.count', 1 do
187
+ assert_difference 'Cms::Block.count', 1 do
188
188
  put :update, :id => page, :cms_page => {
189
- :label => 'Updated Label',
190
- :cms_layout_id => cms_layouts(:nested).id,
191
- :cms_blocks_attributes => [
189
+ :label => 'Updated Label',
190
+ :layout_id => cms_layouts(:nested).id,
191
+ :blocks_attributes => [
192
192
  { :label => 'content',
193
193
  :content => 'new_page_text_content',
194
194
  :id => cms_blocks(:default_page_text).id },
@@ -201,7 +201,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
201
201
  assert_redirected_to :action => :edit, :id => page
202
202
  assert_equal 'Page updated', flash[:notice]
203
203
  assert_equal 'Updated Label', page.label
204
- assert_equal ['new_page_text_content', 'default_field_text_content', 'new_page_string_content'], page.cms_blocks.collect{|b| b.content}
204
+ assert_equal ['new_page_text_content', 'default_field_text_content', 'new_page_string_content'], page.blocks.collect{|b| b.content}
205
205
  end
206
206
  end
207
207
 
@@ -216,8 +216,8 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
216
216
  end
217
217
 
218
218
  def test_destroy
219
- assert_difference 'CmsPage.count', -2 do
220
- assert_difference 'CmsBlock.count', -2 do
219
+ assert_difference 'Cms::Page.count', -2 do
220
+ assert_difference 'Cms::Block.count', -2 do
221
221
  delete :destroy, :id => cms_pages(:default)
222
222
  assert_response :redirect
223
223
  assert_redirected_to :action => :index
@@ -230,13 +230,13 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
230
230
  xhr :get, :form_blocks, :id => cms_pages(:default), :layout_id => cms_layouts(:nested).id
231
231
  assert_response :success
232
232
  assert assigns(:cms_page)
233
- assert_equal 2, assigns(:cms_page).cms_tags.size
233
+ assert_equal 2, assigns(:cms_page).tags.size
234
234
  assert_template :form_blocks
235
235
 
236
236
  xhr :get, :form_blocks, :id => cms_pages(:default), :layout_id => cms_layouts(:default).id
237
237
  assert_response :success
238
238
  assert assigns(:cms_page)
239
- assert_equal 4, assigns(:cms_page).cms_tags.size
239
+ assert_equal 4, assigns(:cms_page).tags.size
240
240
  assert_template :form_blocks
241
241
  end
242
242
 
@@ -244,18 +244,18 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
244
244
  xhr :get, :form_blocks, :id => 0, :layout_id => cms_layouts(:default).id
245
245
  assert_response :success
246
246
  assert assigns(:cms_page)
247
- assert_equal 3, assigns(:cms_page).cms_tags.size
247
+ assert_equal 3, assigns(:cms_page).tags.size
248
248
  assert_template :form_blocks
249
249
  end
250
250
 
251
251
  def test_creation_preview
252
- assert_no_difference 'CmsPage.count' do
252
+ assert_no_difference 'Cms::Page.count' do
253
253
  post :create, :preview => 'Preview', :cms_page => {
254
- :label => 'Test Page',
255
- :slug => 'test-page',
256
- :parent_id => cms_pages(:default).id,
257
- :cms_layout_id => cms_layouts(:default).id,
258
- :cms_blocks_attributes => [
254
+ :label => 'Test Page',
255
+ :slug => 'test-page',
256
+ :parent_id => cms_pages(:default).id,
257
+ :layout_id => cms_layouts(:default).id,
258
+ :blocks_attributes => [
259
259
  { :label => 'default_page_text',
260
260
  :content => 'preview content' }
261
261
  ]
@@ -267,10 +267,10 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
267
267
 
268
268
  def test_update_preview
269
269
  page = cms_pages(:default)
270
- assert_no_difference 'CmsPage.count' do
270
+ assert_no_difference 'Cms::Page.count' do
271
271
  put :update, :preview => 'Preview', :id => page, :cms_page => {
272
272
  :label => 'Updated Label',
273
- :cms_blocks_attributes => [
273
+ :blocks_attributes => [
274
274
  { :label => 'default_page_text',
275
275
  :content => 'preview content',
276
276
  :id => cms_blocks(:default_page_text).id}
@@ -284,7 +284,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
284
284
  end
285
285
 
286
286
  def test_get_new_with_no_layout
287
- CmsLayout.destroy_all
287
+ Cms::Layout.destroy_all
288
288
  get :new
289
289
  assert_response :redirect
290
290
  assert_redirected_to new_cms_admin_layout_path
@@ -292,7 +292,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
292
292
  end
293
293
 
294
294
  def test_get_edit_with_no_layout
295
- CmsLayout.destroy_all
295
+ Cms::Layout.destroy_all
296
296
  page = cms_pages(:default)
297
297
  get :edit, :id => page
298
298
  assert_response :redirect
@@ -313,11 +313,11 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
313
313
 
314
314
  def test_reorder
315
315
  page_one = cms_pages(:child)
316
- page_two = cms_sites(:default).cms_pages.create!(
317
- :parent => cms_pages(:default),
318
- :cms_layout => cms_layouts(:default),
319
- :label => 'test',
320
- :slug => 'test'
316
+ page_two = cms_sites(:default).pages.create!(
317
+ :parent => cms_pages(:default),
318
+ :layout => cms_layouts(:default),
319
+ :label => 'test',
320
+ :slug => 'test'
321
321
  )
322
322
  assert_equal 0, page_one.position
323
323
  assert_equal 1, page_two.position