comfortable_mexican_sofa 1.12.2 → 1.12.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/comfortable_mexican_sofa/admin/application.js +1 -1
  3. data/app/assets/javascripts/comfortable_mexican_sofa/application.js.coffee +50 -57
  4. data/app/assets/javascripts/comfortable_mexican_sofa/cms/files.js.coffee +29 -0
  5. data/app/assets/javascripts/comfortable_mexican_sofa/cms/uploader.js.coffee +139 -0
  6. data/app/assets/stylesheets/comfortable_mexican_sofa/admin/application.css +1 -1
  7. data/app/assets/stylesheets/comfortable_mexican_sofa/application.css.sass +1 -0
  8. data/app/assets/stylesheets/comfortable_mexican_sofa/base.css.sass +67 -84
  9. data/app/controllers/comfy/admin/cms/base_controller.rb +11 -8
  10. data/app/controllers/comfy/admin/cms/categories_controller.rb +10 -9
  11. data/app/controllers/comfy/admin/cms/files_controller.rb +38 -69
  12. data/app/controllers/comfy/admin/cms/layouts_controller.rb +4 -3
  13. data/app/controllers/comfy/admin/cms/pages_controller.rb +17 -11
  14. data/app/controllers/comfy/admin/cms/revisions_controller.rb +10 -9
  15. data/app/controllers/comfy/admin/cms/sites_controller.rb +2 -1
  16. data/app/controllers/comfy/admin/cms/snippets_controller.rb +3 -2
  17. data/app/controllers/comfy/cms/assets_controller.rb +17 -9
  18. data/app/controllers/comfy/cms/content_controller.rb +20 -14
  19. data/app/models/comfy/cms/file.rb +16 -15
  20. data/app/models/comfy/cms/page.rb +2 -1
  21. data/app/models/comfy/cms/site.rb +5 -0
  22. data/app/views/comfy/admin/cms/files/_file.html.haml +26 -13
  23. data/app/views/comfy/admin/cms/files/_form.html.haml +8 -5
  24. data/app/views/comfy/admin/cms/files/_modal.html.haml +4 -0
  25. data/app/views/comfy/admin/cms/files/create.js.erb +1 -0
  26. data/app/views/comfy/admin/cms/files/destroy.js.coffee +2 -2
  27. data/app/views/comfy/admin/cms/files/index.html.haml +33 -31
  28. data/app/views/comfy/admin/cms/layouts/_form.html.haml +2 -5
  29. data/app/views/comfy/admin/cms/pages/_form.html.haml +7 -8
  30. data/app/views/comfy/admin/cms/pages/_form_blocks.html.haml +3 -3
  31. data/app/views/comfy/admin/cms/sites/_form.html.haml +2 -2
  32. data/app/views/comfy/admin/cms/sites/index.html.haml +1 -2
  33. data/app/views/comfy/admin/cms/snippets/_form.html.haml +5 -8
  34. data/app/views/kaminari/comfy/_paginator.html.haml +10 -11
  35. data/app/views/layouts/comfy/admin/cms.html.haml +3 -2
  36. data/app/views/layouts/comfy/admin/cms/_body.html.haml +8 -7
  37. data/app/views/layouts/comfy/admin/cms/{_center.html.haml → _flash.html.haml} +0 -3
  38. data/app/views/layouts/comfy/admin/cms/_footer_js.html.haml +0 -4
  39. data/app/views/layouts/comfy/admin/cms/_left.html.haml +10 -5
  40. data/comfortable_mexican_sofa.gemspec +9 -8
  41. data/config/cms_routes.rb +2 -2
  42. data/config/initializers/comfortable_mexican_sofa.rb +31 -13
  43. data/config/initializers/plupload.rb +9 -0
  44. data/config/locales/en.yml +18 -16
  45. data/db/upgrade_migrations/08_upgrade_to_1_12_0.rb +3 -0
  46. data/lib/comfortable_mexican_sofa.rb +6 -5
  47. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +20 -0
  48. data/lib/comfortable_mexican_sofa/access_control/admin_authorization.rb +8 -0
  49. data/lib/comfortable_mexican_sofa/access_control/public_authentication.rb +8 -0
  50. data/lib/comfortable_mexican_sofa/configuration.rb +11 -3
  51. data/lib/comfortable_mexican_sofa/engine.rb +1 -0
  52. data/lib/comfortable_mexican_sofa/fixture.rb +7 -5
  53. data/lib/comfortable_mexican_sofa/fixture/category.rb +10 -3
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +1 -1
  55. data/lib/comfortable_mexican_sofa/routes/cms.rb +3 -0
  56. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  57. data/lib/generators/comfy/cms/assets_generator.rb +15 -0
  58. data/lib/generators/comfy/cms/cms_generator.rb +19 -12
  59. data/lib/generators/comfy/cms/controllers_generator.rb +13 -0
  60. data/lib/generators/comfy/cms/models_generator.rb +13 -0
  61. data/lib/generators/comfy/cms/views_generator.rb +13 -0
  62. data/test/controllers/comfy/admin/cms/files_controller_test.rb +22 -95
  63. data/test/controllers/comfy/admin/cms/layouts_controller_test.rb +9 -10
  64. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +26 -27
  65. data/test/controllers/comfy/admin/cms/snippets_controller_test.rb +7 -8
  66. data/test/controllers/comfy/cms/content_controller_test.rb +30 -4
  67. data/test/gemfiles/Gemfile.rails.4.0 +3 -2
  68. data/test/gemfiles/Gemfile.rails.4.1 +3 -2
  69. data/test/gemfiles/Gemfile.rails.master +3 -2
  70. data/test/generators/cms_assets_generator_test.rb +13 -0
  71. data/test/generators/cms_controllers_generator_test.rb +12 -0
  72. data/test/generators/cms_generator_test.rb +10 -8
  73. data/test/generators/cms_models_generator_test.rb +12 -0
  74. data/test/generators/cms_views_generator_test.rb +12 -0
  75. data/test/generators/scaffold_generator_test.rb +6 -7
  76. data/test/integration/access_control_test.rb +141 -0
  77. data/test/integration/routing_test.rb +19 -0
  78. data/test/lib/configuration_test.rb +8 -7
  79. data/test/lib/fixtures/categories_test.rb +1 -0
  80. data/test/lib/fixtures/files_test.rb +5 -0
  81. data/test/lib/fixtures/pages_test.rb +17 -1
  82. data/test/lib/fixtures/snippets_test.rb +5 -0
  83. data/test/models/page_test.rb +6 -0
  84. data/test/models/site_test.rb +9 -0
  85. data/test/test_helper.rb +28 -19
  86. metadata +82 -48
  87. data/app/views/comfy/admin/cms/files/_index.html.haml +0 -11
  88. data/lib/comfortable_mexican_sofa/authentication/dummy_auth.rb +0 -8
  89. data/lib/comfortable_mexican_sofa/authentication/http_auth.rb +0 -25
  90. data/test/integration/authentication_test.rb +0 -48
@@ -15,6 +15,7 @@ require 'codemirror-rails'
15
15
  require 'kaminari'
16
16
  require 'tinymce-rails'
17
17
  require 'bootstrap-sass'
18
+ require 'plupload-rails'
18
19
 
19
20
  module ComfortableMexicanSofa
20
21
  class Engine < ::Rails::Engine
@@ -29,14 +29,16 @@ module ComfortableMexicanSofa::Fixture
29
29
 
30
30
  def save_categorizations!(object, categories)
31
31
  object.categorizations.delete_all
32
+
32
33
  [categories].flatten.compact.each do |label|
33
- category = self.site.categories.find_or_create_by(
34
+ category = self.site.categories.where(
34
35
  :label => label,
35
36
  :categorized_type => object.class.to_s
36
- )
37
- category.categorizations.create!(
38
- :categorized => object
39
- )
37
+ ).first
38
+
39
+ next unless category
40
+
41
+ category.categorizations.create!(:categorized => object)
40
42
  end
41
43
  end
42
44
 
@@ -7,9 +7,16 @@ module ComfortableMexicanSofa::Fixture::Category
7
7
  'snippets' => 'Comfy::Cms::Snippet'
8
8
  }.each do |file, type|
9
9
  if File.exists?(attrs_path = File.join(path, "#{file}.yml"))
10
- categories = get_attributes(attrs_path)
11
- [categories].flatten.each do |label|
12
- self.site.categories.find_or_create_by(:label => label, :categorized_type => type)
10
+ categories = [get_attributes(attrs_path)].flatten
11
+ existing_categories = self.site.categories.where(:categorized_type => type).map(&:label)
12
+
13
+ self.site.categories.where(
14
+ :categorized_type => type,
15
+ :label => existing_categories - categories
16
+ ).destroy_all
17
+
18
+ (categories - existing_categories).each do |label|
19
+ self.site.categories.create(:label => label, :categorized_type => type)
13
20
  end
14
21
  end
15
22
  end
@@ -59,7 +59,7 @@ class ComfortableMexicanSofa::FormBuilder < BootstrapForm::FormBuilder
59
59
  content = @template.hidden_field_tag("#{fieldname}[blocks_attributes][#{index}][content]", '', :id => nil)
60
60
  content << @template.check_box_tag("#{fieldname}[blocks_attributes][#{index}][content]", '1', tag.content.present?, :id => nil)
61
61
  content << @template.hidden_field_tag("#{fieldname}[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil)
62
- form_group :label => {:text => tag.identifier.titleize + "?"} do
62
+ form_group :label => {:text => (tag.blockable.class.human_attribute_name(tag.identifier.to_s) || tag.identifier.titleize + "?")} do
63
63
  content
64
64
  end
65
65
  end
@@ -1,6 +1,9 @@
1
1
  class ActionDispatch::Routing::Mapper
2
2
 
3
3
  def comfy_route_cms(options = {})
4
+
5
+ ComfortableMexicanSofa.configuration.public_cms_path = options[:path]
6
+
4
7
  scope :module => :comfy, :as => :comfy do
5
8
  namespace :cms, :path => options[:path] do
6
9
  get 'cms-css/:site_id/:identifier(/:cache_buster)' => 'assets#render_css', :as => 'render_css'
@@ -1,3 +1,3 @@
1
1
  module ComfortableMexicanSofa
2
- VERSION = "1.12.2"
2
+ VERSION = "1.12.3"
3
3
  end
@@ -0,0 +1,15 @@
1
+ module Comfy
2
+ module Generators
3
+ module Cms
4
+ class AssetsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/assets'))
6
+
7
+ def generate_assets
8
+ directory 'images/comfortable_mexican_sofa', 'app/assets/images/comfortable_mexican_sofa'
9
+ directory 'javascripts/comfortable_mexican_sofa', 'app/assets/javascripts/comfortable_mexican_sofa'
10
+ directory 'stylesheets/comfortable_mexican_sofa', 'app/assets/stylesheets/comfortable_mexican_sofa'
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -3,55 +3,62 @@ require 'rails/generators/active_record'
3
3
  module Comfy
4
4
  module Generators
5
5
  class CmsGenerator < Rails::Generators::Base
6
-
6
+
7
7
  include Rails::Generators::Migration
8
8
  include Thor::Actions
9
-
9
+
10
10
  source_root File.expand_path('../../../../..', __FILE__)
11
-
11
+
12
12
  def generate_migration
13
13
  destination = File.expand_path('db/migrate/01_create_cms.rb', self.destination_root)
14
14
  migration_dir = File.dirname(destination)
15
15
  destination = self.class.migration_exists?(migration_dir, 'create_cms')
16
-
16
+
17
17
  if destination
18
18
  puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m"
19
19
  else
20
20
  migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb'
21
21
  end
22
22
  end
23
-
24
- def generate_initialization
23
+
24
+ def generate_initializer
25
25
  copy_file 'config/initializers/comfortable_mexican_sofa.rb',
26
26
  'config/initializers/comfortable_mexican_sofa.rb'
27
27
  end
28
-
28
+
29
+ def generate_mime_types
30
+ create_file 'config/initializers/mime_types.rb'
31
+ append_to_file 'config/initializers/mime_types.rb' do
32
+ "Mime::Type.register 'text/plupload', :plupload"
33
+ end
34
+ end
35
+
29
36
  def generate_routing
30
37
  route_string = " comfy_route :cms_admin, :path => '/admin'\n\n"
31
38
  route_string << " # Make sure this routeset is defined last\n"
32
39
  route_string << " comfy_route :cms, :path => '/', :sitemap => false\n"
33
40
  route route_string[2..-1]
34
41
  end
35
-
42
+
36
43
  def generate_cms_seeds
37
44
  directory 'db/cms_fixtures', 'db/cms_fixtures'
38
45
  end
39
-
46
+
40
47
  def generate_assets
41
48
  directory 'app/assets/javascripts/comfortable_mexican_sofa/admin',
42
49
  'app/assets/javascripts/comfortable_mexican_sofa/admin'
43
50
  directory 'app/assets/stylesheets/comfortable_mexican_sofa/admin',
44
51
  'app/assets/stylesheets/comfortable_mexican_sofa/admin'
45
52
  end
46
-
53
+
47
54
  def show_readme
48
55
  readme 'lib/generators/comfy/cms/README'
49
56
  end
50
-
57
+
51
58
  def self.next_migration_number(dirname)
52
59
  ActiveRecord::Generators::Base.next_migration_number(dirname)
53
60
  end
54
-
61
+
55
62
  end
56
63
  end
57
64
  end
@@ -0,0 +1,13 @@
1
+ module Comfy
2
+ module Generators
3
+ module Cms
4
+ class ControllersGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/controllers'))
6
+
7
+ def generate_controllers
8
+ directory 'comfy', 'app/controllers/comfy'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Comfy
2
+ module Generators
3
+ module Cms
4
+ class ModelsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/models'))
6
+
7
+ def generate_models
8
+ directory 'comfy', 'app/models/comfy'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Comfy
2
+ module Generators
3
+ module Cms
4
+ class ViewsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/views'))
6
+
7
+ def generate_views
8
+ directory 'comfy', 'app/views/comfy'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,21 +1,14 @@
1
1
  require_relative '../../../../test_helper'
2
2
 
3
3
  class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
4
-
4
+
5
5
  def test_get_index
6
6
  get :index, :site_id => comfy_cms_sites(:default)
7
7
  assert_response :success
8
8
  assert assigns(:files)
9
9
  assert_template :index
10
10
  end
11
-
12
- def test_get_index_with_no_files
13
- Comfy::Cms::File.delete_all
14
- get :index, :site_id => comfy_cms_sites(:default)
15
- assert_response :redirect
16
- assert_redirected_to :action => :new
17
- end
18
-
11
+
19
12
  def test_get_index_with_category
20
13
  get :index, :site_id => comfy_cms_sites(:default), :category => comfy_cms_categories(:default).label
21
14
  assert_response :success
@@ -23,38 +16,14 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
23
16
  assert_equal 1, assigns(:files).count
24
17
  assert assigns(:files).first.categories.member? comfy_cms_categories(:default)
25
18
  end
26
-
19
+
27
20
  def test_get_index_with_category_invalid
28
21
  get :index, :site_id => comfy_cms_sites(:default), :category => 'invalid'
29
22
  assert_response :success
30
23
  assert assigns(:files)
31
24
  assert_equal 0, assigns(:files).count
32
25
  end
33
-
34
- def test_get_index_as_ajax
35
- get :index, :site_id => comfy_cms_sites(:default), :ajax => true
36
- assert_response :success
37
- r = JSON.parse(response.body)
38
- file = comfy_cms_files(:default)
39
- assert_equal [{
40
- 'thumb' => file.file.url(:cms_thumb),
41
- 'image' => file.file.url
42
- }], r
43
- end
44
26
 
45
- def test_get_index_as_ajax_with_no_images
46
- file = comfy_cms_files(:default)
47
- file.update_attribute(:file_content_type, 'text/plain')
48
- get :index, :site_id => comfy_cms_sites(:default), :not_images => 1, :ajax => true
49
- assert_response :success
50
- r = JSON.parse(response.body)
51
- assert_equal [{
52
- 'label' => file.label,
53
- 'filename' => file.file_file_name,
54
- 'url' => file.file.url
55
- }], r
56
- end
57
-
58
27
  def test_get_index_with_page_files
59
28
  file = comfy_cms_files(:default)
60
29
  file.update_column(:block_id, comfy_cms_blocks(:default_field_text).id)
@@ -71,7 +40,7 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
71
40
  assert_template :new
72
41
  assert_select "form[action=/admin/sites/#{site.id}/files][enctype=multipart/form-data]"
73
42
  end
74
-
43
+
75
44
  def test_get_edit
76
45
  file = comfy_cms_files(:default)
77
46
  get :edit, :site_id => file.site, :id => file
@@ -80,20 +49,20 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
80
49
  assert_template :edit
81
50
  assert_select "form[action=/admin/sites/#{file.site.id}/files/#{file.id}]"
82
51
  end
83
-
52
+
84
53
  def test_get_edit_failure
85
54
  get :edit, :site_id => comfy_cms_sites(:default), :id => 'not_found'
86
55
  assert_response :redirect
87
56
  assert_redirected_to :action => :index
88
57
  assert_equal 'File not found', flash[:danger]
89
58
  end
90
-
59
+
91
60
  def test_create
92
61
  assert_difference ['Comfy::Cms::File.count', 'Comfy::Cms::Categorization.count'] do
93
62
  post :create, :site_id => comfy_cms_sites(:default), :file => {
94
63
  :label => 'Test File',
95
64
  :description => 'Test Description',
96
- :file => [fixture_file_upload('files/image.jpg', 'image/jpeg')],
65
+ :file => fixture_file_upload('files/image.jpg', 'image/jpeg'),
97
66
  :category_ids => {comfy_cms_categories(:default).id => '1'}
98
67
  }
99
68
  assert_response :redirect
@@ -105,7 +74,7 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
105
74
  assert_equal 'Files uploaded', flash[:success]
106
75
  end
107
76
  end
108
-
77
+
109
78
  def test_create_failure
110
79
  assert_no_difference 'Comfy::Cms::File.count' do
111
80
  post :create, :site_id => comfy_cms_sites(:default), :file => { }
@@ -114,69 +83,28 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
114
83
  assert_equal 'Failed to upload files', flash[:danger]
115
84
  end
116
85
  end
117
-
118
- def test_create_multiple
119
- Comfy::Cms::File.delete_all
120
-
121
- assert_difference 'Comfy::Cms::File.count', 2 do
122
- post :create, :site_id => comfy_cms_sites(:default), :file => {
123
- :label => 'Test File',
124
- :description => 'Test Description',
125
- :file => [
126
- fixture_file_upload('files/image.jpg', 'image/jpeg'),
127
- fixture_file_upload('files/image.gif', 'image/gif')
128
- ]
129
- }
130
- assert_response :redirect
131
- file_a, file_b = Comfy::Cms::File.all
132
- assert_equal comfy_cms_sites(:default), file_a.site
133
-
134
- assert_equal 'image.jpg', file_a.file_file_name
135
- assert_equal 'image.gif', file_b.file_file_name
136
- assert_equal 'Test File 1', file_a.label
137
- assert_equal 'Test File 2', file_b.label
138
- assert_equal 'Test Description', file_a.description
139
- assert_equal 'Test Description', file_b.description
140
-
141
- assert_redirected_to :action => :edit, :id => file_b
142
- assert_equal 'Files uploaded', flash[:success]
143
- end
144
- end
145
-
146
- def test_create_as_ajax
86
+
87
+ def test_create_as_plupload
147
88
  assert_difference 'Comfy::Cms::File.count' do
148
89
  post :create,
149
- :ajax => true,
90
+ :format => :plupload,
150
91
  :site_id => comfy_cms_sites(:default),
151
92
  :file => {
152
- :file => [fixture_file_upload('files/image.jpg', 'image/jpeg')]
93
+ :file => fixture_file_upload('files/image.jpg', 'image/jpeg')
153
94
  }
154
95
  assert_response :success
155
- file = Comfy::Cms::File.last
156
- r = JSON.parse(response.body)
157
- assert_equal file.file.url, r['filelink']
158
- assert_equal file.file_file_name, r['filename']
159
- assert r['view'].present?
96
+ assert_no_select "body"
97
+ assert_select "tr[id=comfy_cms_file_#{Comfy::Cms::File.last.id}]"
160
98
  end
161
99
  end
162
-
163
- def test_create_as_ajax_failure
100
+
101
+ def test_create_as_plupload_failure
164
102
  assert_no_difference 'Comfy::Cms::File.count' do
165
- post :create, :ajax => true, :site_id => comfy_cms_sites(:default), :file => { }
103
+ post :create, :format => :plupload, :site_id => comfy_cms_sites(:default), :file => { }
166
104
  assert_response :unprocessable_entity
167
105
  end
168
106
  end
169
-
170
- def test_create_as_ajax_as_single_file
171
- assert_difference 'Comfy::Cms::File.count' do
172
- post :create,
173
- :ajax => true,
174
- :site_id => comfy_cms_sites(:default),
175
- :file => fixture_file_upload('files/image.jpg', 'image/jpeg')
176
- assert_response :success
177
- end
178
- end
179
-
107
+
180
108
  def test_update
181
109
  file = comfy_cms_files(:default)
182
110
  put :update, :site_id => file.site, :id => file, :file => {
@@ -191,7 +119,7 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
191
119
  assert_equal 'New File', file.label
192
120
  assert_equal 'New Description', file.description
193
121
  end
194
-
122
+
195
123
  def test_update_failure
196
124
  file = comfy_cms_files(:default)
197
125
  put :update, :site_id => file.site, :id => file, :file => {
@@ -203,7 +131,7 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
203
131
  assert_not_equal nil, file.file
204
132
  assert_equal 'Failed to update file', flash[:danger]
205
133
  end
206
-
134
+
207
135
  def test_destroy
208
136
  assert_difference 'Comfy::Cms::File.count', -1 do
209
137
  delete :destroy, :site_id => comfy_cms_sites(:default), :id => comfy_cms_files(:default)
@@ -212,14 +140,14 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
212
140
  assert_equal 'File deleted', flash[:success]
213
141
  end
214
142
  end
215
-
143
+
216
144
  def test_destroy_as_xhr
217
145
  assert_difference 'Comfy::Cms::File.count', -1 do
218
146
  xhr :delete, :destroy, :site_id => comfy_cms_sites(:default), :id => comfy_cms_files(:default)
219
147
  assert_response :success
220
148
  end
221
149
  end
222
-
150
+
223
151
  def test_reorder
224
152
  file_one = comfy_cms_files(:default)
225
153
  file_two = comfy_cms_sites(:default).files.create(
@@ -236,5 +164,4 @@ class Comfy::Admin::Cms::FilesControllerTest < ActionController::TestCase
236
164
  assert_equal 1, file_one.position
237
165
  assert_equal 0, file_two.position
238
166
  end
239
-
240
167
  end
@@ -11,7 +11,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
11
11
 
12
12
  def test_get_index_with_no_layouts
13
13
  Comfy::Cms::Layout.delete_all
14
- get :index, :site_id => comfy_cms_sites(:default)
14
+ get :index, :site_id => comfy_cms_sites(:default)
15
15
  assert_response :redirect
16
16
  assert_redirected_to :action => :new
17
17
  end
@@ -24,9 +24,8 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
24
24
  assert_equal '{{ cms:page:content:rich_text }}', assigns(:layout).content
25
25
  assert_template :new
26
26
  assert_select "form[action=/admin/sites/#{site.id}/layouts]"
27
- assert_select "form[action='/admin/sites/#{site.id}/files?ajax=true']"
28
27
  end
29
-
28
+
30
29
  def test_get_new_with_parent
31
30
  site = comfy_cms_sites(:default)
32
31
  layout = comfy_cms_layouts(:default)
@@ -51,7 +50,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
51
50
  assert_redirected_to :action => :index
52
51
  assert_equal 'Layout not found', flash[:danger]
53
52
  end
54
-
53
+
55
54
  def test_creation
56
55
  assert_difference 'Comfy::Cms::Layout.count' do
57
56
  post :create, :site_id => comfy_cms_sites(:default), :layout => {
@@ -66,7 +65,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
66
65
  assert_equal 'Layout created', flash[:success]
67
66
  end
68
67
  end
69
-
68
+
70
69
  def test_creation_failure
71
70
  assert_no_difference 'Comfy::Cms::Layout.count' do
72
71
  post :create, :site_id => comfy_cms_sites(:default), :layout => { }
@@ -75,7 +74,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
75
74
  assert_equal 'Failed to create layout', flash[:danger]
76
75
  end
77
76
  end
78
-
77
+
79
78
  def test_update
80
79
  layout = comfy_cms_layouts(:default)
81
80
  put :update, :site_id => comfy_cms_sites(:default), :id => layout, :layout => {
@@ -89,7 +88,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
89
88
  assert_equal 'New Label', layout.label
90
89
  assert_equal 'New {{cms:page:content}}', layout.content
91
90
  end
92
-
91
+
93
92
  def test_update_failure
94
93
  layout = comfy_cms_layouts(:default)
95
94
  put :update, :site_id => comfy_cms_sites(:default), :id => layout, :layout => {
@@ -101,7 +100,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
101
100
  assert_not_equal '', layout.identifier
102
101
  assert_equal 'Failed to update layout', flash[:danger]
103
102
  end
104
-
103
+
105
104
  def test_destroy
106
105
  assert_difference 'Comfy::Cms::Layout.count', -1 do
107
106
  delete :destroy, :site_id => comfy_cms_sites(:default), :id => comfy_cms_layouts(:default)
@@ -110,7 +109,7 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
110
109
  assert_equal 'Layout deleted', flash[:success]
111
110
  end
112
111
  end
113
-
112
+
114
113
  def test_reorder
115
114
  layout_one = comfy_cms_layouts(:default)
116
115
  layout_two = comfy_cms_sites(:default).layouts.create!(
@@ -129,4 +128,4 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionController::TestCase
129
128
  assert_equal 0, layout_two.position
130
129
  end
131
130
 
132
- end
131
+ end