comfortable_mexican_sofa 1.12.8 → 1.12.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/app/assets/fonts/comfy/admin/cms/lib/redactor-font.eot +0 -0
  4. data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +46 -11
  5. data/app/assets/javascripts/comfy/admin/cms/lib/redactor.js +1807 -570
  6. data/app/assets/stylesheets/comfy/admin/cms/bootstrap_overrides.sass +6 -1
  7. data/app/assets/stylesheets/comfy/admin/cms/lib/redactor.css +79 -52
  8. data/app/controllers/comfy/admin/cms/base_controller.rb +2 -1
  9. data/app/controllers/comfy/admin/cms/pages_controller.rb +4 -1
  10. data/app/controllers/comfy/cms/base_controller.rb +5 -5
  11. data/app/controllers/comfy/cms/content_controller.rb +4 -0
  12. data/app/helpers/comfy/cms_helper.rb +72 -70
  13. data/app/models/comfy/cms/file.rb +0 -1
  14. data/app/views/comfy/admin/cms/files/_file.html.haml +1 -1
  15. data/app/views/comfy/admin/cms/layouts/_index_branch.html.haml +2 -1
  16. data/config/environments/test.rb +2 -0
  17. data/config/initializers/comfortable_mexican_sofa.rb +12 -0
  18. data/config/locales/cs.yml +2 -3
  19. data/config/locales/da.yml +2 -3
  20. data/config/locales/de.yml +2 -3
  21. data/config/locales/en.yml +2 -3
  22. data/config/locales/es.yml +2 -3
  23. data/config/locales/fr.yml +2 -3
  24. data/config/locales/it.yml +2 -3
  25. data/config/locales/ja.yml +2 -3
  26. data/config/locales/nb.yml +2 -3
  27. data/config/locales/nl.yml +2 -3
  28. data/config/locales/pl.yml +40 -41
  29. data/config/locales/pt-BR.yml +2 -3
  30. data/config/locales/ru.yml +2 -3
  31. data/config/locales/sv.yml +2 -3
  32. data/config/locales/uk.yml +2 -3
  33. data/config/locales/zh-CN.yml +2 -3
  34. data/config/locales/zh-TW.yml +16 -17
  35. data/db/migrate/01_create_cms.rb +18 -25
  36. data/db/upgrade_migrations/08_upgrade_to_1_12_0.rb +2 -2
  37. data/doc/preview.png +0 -0
  38. data/lib/comfortable_mexican_sofa.rb +1 -0
  39. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +3 -2
  40. data/lib/comfortable_mexican_sofa/access_control/public_authorization.rb +8 -0
  41. data/lib/comfortable_mexican_sofa/configuration.rb +4 -0
  42. data/lib/comfortable_mexican_sofa/engine.rb +5 -1
  43. data/lib/comfortable_mexican_sofa/fixture/file.rb +22 -22
  44. data/lib/comfortable_mexican_sofa/tags/asset.rb +8 -3
  45. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  46. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +22 -0
  47. data/test/controllers/comfy/cms/content_controller_test.rb +12 -0
  48. data/test/integration/access_control_test.rb +24 -1
  49. data/test/lib/fixtures/files_test.rb +29 -27
  50. data/test/lib/tags/asset_test.rb +42 -9
  51. data/test/test_helper.rb +8 -3
  52. metadata +5 -3
@@ -10,14 +10,19 @@ class ComfortableMexicanSofa::Tag::Asset
10
10
  return unless (layout = Comfy::Cms::Layout.find_by_identifier(identifier))
11
11
  type = params[0]
12
12
  format = params[1]
13
-
13
+
14
+ base = ComfortableMexicanSofa.config.public_cms_path || ''
15
+ unless base.ends_with?("/") # => true
16
+ base = base + "/"
17
+ end
18
+
14
19
  case type
15
20
  when 'css'
16
- out = "/cms-css/#{blockable.site.id}/#{identifier}/#{layout.cache_buster}.css"
21
+ out = "#{base}cms-css/#{blockable.site.id}/#{identifier}/#{layout.cache_buster}.css"
17
22
  out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
18
23
  out
19
24
  when 'js'
20
- out = "/cms-js/#{blockable.site.id}/#{identifier}/#{layout.cache_buster}.js"
25
+ out = "#{base}cms-js/#{blockable.site.id}/#{identifier}/#{layout.cache_buster}.js"
21
26
  out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
22
27
  out
23
28
  end
@@ -1,3 +1,3 @@
1
1
  module ComfortableMexicanSofa
2
- VERSION = "1.12.8"
2
+ VERSION = "1.12.9"
3
3
  end
@@ -449,6 +449,28 @@ class Comfy::Admin::Cms::PagesControllerTest < ActionController::TestCase
449
449
  end
450
450
  end
451
451
 
452
+ def test_preview_language
453
+ site = @site
454
+ site.update_columns(:locale => 'de')
455
+ layout = comfy_cms_layouts(:default)
456
+
457
+ assert_equal :en, I18n.locale
458
+
459
+ post :create, :site_id => site, :preview => 'Preview', :page => {
460
+ :label => 'Test Page',
461
+ :slug => 'test-page',
462
+ :parent_id => comfy_cms_pages(:default).id,
463
+ :layout_id => layout.id,
464
+ :blocks_attributes => [
465
+ { :identifier => 'default_page_text',
466
+ :content => 'preview content' }
467
+ ]
468
+ }
469
+
470
+ assert_response :success
471
+ assert_equal :de, I18n.locale
472
+ end
473
+
452
474
  def test_get_new_with_no_layout
453
475
  Comfy::Cms::Layout.destroy_all
454
476
  get :new, :site_id => @site
@@ -20,6 +20,18 @@ class Comfy::Cms::ContentControllerTest < ActionController::TestCase
20
20
  layout_content_c'
21
21
  ), response.body
22
22
  assert_equal 'text/html', response.content_type
23
+
24
+ assert_equal :en, assigns(:locale)
25
+ assert_equal :en, I18n.locale
26
+ end
27
+
28
+ def test_show_with_locale
29
+ comfy_cms_sites(:default).update_column(:locale, 'fr')
30
+ get :show, :cms_path => ''
31
+ assert_response :success
32
+
33
+ assert_equal :fr, assigns(:locale)
34
+ assert_equal :fr, I18n.locale
23
35
  end
24
36
 
25
37
  def test_show_default_html
@@ -24,6 +24,7 @@ class AccessControlTest < ActionDispatch::IntegrationTest
24
24
  end
25
25
 
26
26
  # faking ComfortableMexicanSofa.config.admin_authorization = 'AccessControlTest::TestAuthorization'
27
+ # faking ComfortableMexicanSofa.config.public_authorization = 'AccessControlTest::TestAuthorization'
27
28
  class SitesController < Comfy::Admin::Cms::SitesController; include Authorize; end
28
29
  class LayoutsController < Comfy::Admin::Cms::LayoutsController; include Authorize; end
29
30
  class PagesController < Comfy::Admin::Cms::PagesController; include Authorize; end
@@ -31,6 +32,7 @@ class AccessControlTest < ActionDispatch::IntegrationTest
31
32
  class FilesController < Comfy::Admin::Cms::FilesController; include Authorize; end
32
33
  class CategoriesController < Comfy::Admin::Cms::CategoriesController; include Authorize; end
33
34
  class RevisionsController < Comfy::Admin::Cms::RevisionsController; include Authorize; end
35
+ class ContentController < Comfy::Cms::ContentController; include Authorize; end
34
36
  end
35
37
 
36
38
 
@@ -127,6 +129,14 @@ class AccessControlTest < ActionDispatch::IntegrationTest
127
129
  assert_response :success, response.body
128
130
  end
129
131
 
132
+ def test_public_authorization_default
133
+ assert_equal 'ComfortableMexicanSofa::AccessControl::PublicAuthorization',
134
+ ComfortableMexicanSofa.config.public_authorization
135
+
136
+ get '/'
137
+ assert_response :success, response.body
138
+ end
139
+
130
140
  def test_public_authentication_custom
131
141
  with_routing do |routes|
132
142
  routes.draw do
@@ -138,4 +148,17 @@ class AccessControlTest < ActionDispatch::IntegrationTest
138
148
  assert_equal 'Test Login Denied', response.body
139
149
  end
140
150
  end
141
- end
151
+
152
+ def test_public_authorization_custom
153
+ with_routing do |routes|
154
+ routes.draw do
155
+ get '/:format' => 'access_control_test/test_authorization/content#show', :path => "(*cms_path)"
156
+ end
157
+
158
+ get '/'
159
+ assert_response :forbidden
160
+ assert_equal 'Test Access Denied', response.body
161
+ end
162
+ end
163
+
164
+ end
@@ -3,105 +3,107 @@
3
3
  require_relative '../../test_helper'
4
4
 
5
5
  class FixtureFilesTest < ActiveSupport::TestCase
6
-
6
+
7
7
  def test_creation
8
8
  Comfy::Cms::File.delete_all
9
-
9
+
10
10
  # need to have categories present before linking
11
11
  site = comfy_cms_sites(:default)
12
12
  site.categories.create!(:categorized_type => 'Comfy::Cms::File', :label => 'category_a')
13
13
  site.categories.create!(:categorized_type => 'Comfy::Cms::File', :label => 'category_b')
14
-
14
+
15
15
  assert_difference 'Comfy::Cms::File.count' do
16
16
  ComfortableMexicanSofa::Fixture::File::Importer.new('sample-site', 'default-site').import!
17
17
  assert file = Comfy::Cms::File.last
18
-
19
- assert_equal 'Fixture File', file.label
20
- assert_equal 'sample.jpg', file.file_file_name
18
+
19
+ assert_equal 'Fixture File', file.label
20
+ assert_equal 'sample.jpg', file.file_file_name
21
21
  assert_equal 'Fixture Description', file.description
22
-
22
+
23
23
  assert_equal 2, file.categories.count
24
24
  assert_equal ['category_a', 'category_b'], file.categories.map{|c| c.label}
25
25
  end
26
26
  end
27
-
27
+
28
28
  def test_update
29
29
  file = comfy_cms_files(:default)
30
30
  file.update_column(:updated_at, 10.years.ago)
31
- assert_equal 'sample.jpg', file.file_file_name
31
+ assert_equal 'sample.jpg', file.file_file_name
32
32
  assert_equal 'Default File', file.label
33
33
  assert_equal 'Default Description', file.description
34
-
34
+
35
35
  assert_no_difference 'Comfy::Cms::Snippet.count' do
36
36
  ComfortableMexicanSofa::Fixture::File::Importer.new('sample-site', 'default-site').import!
37
37
  file.reload
38
- assert_equal 'sample.jpg', file.file_file_name
39
- assert_equal 'Fixture File', file.label
38
+ assert_equal 'sample.jpg', file.file_file_name
39
+ assert_equal 'Fixture File', file.label
40
40
  assert_equal 'Fixture Description', file.description
41
41
  end
42
42
  end
43
-
43
+
44
44
  def test_update_ignore
45
45
  file = comfy_cms_files(:default)
46
46
  file_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'sample-site', 'files', 'sample.jpg')
47
47
  attr_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'sample-site', 'files', '_sample.jpg.yml')
48
-
48
+
49
49
  assert file.updated_at >= File.mtime(file_path)
50
50
  assert file.updated_at >= File.mtime(attr_path)
51
-
51
+
52
52
  ComfortableMexicanSofa::Fixture::File::Importer.new('sample-site', 'default-site').import!
53
53
  file.reload
54
54
  assert_equal 'sample.jpg', file.file_file_name
55
55
  assert_equal 'Default File', file.label
56
56
  assert_equal 'Default Description', file.description
57
57
  end
58
-
58
+
59
59
  def test_update_force
60
60
  file = comfy_cms_files(:default)
61
61
  ComfortableMexicanSofa::Fixture::File::Importer.new('sample-site', 'default-site').import!
62
62
  file.reload
63
63
  assert_equal 'Default File', file.label
64
-
64
+
65
65
  ComfortableMexicanSofa::Fixture::File::Importer.new('sample-site', 'default-site', :forced).import!
66
66
  file.reload
67
67
  assert_equal 'Fixture File', file.label
68
68
  end
69
-
69
+
70
70
  def test_delete
71
71
  old_file = comfy_cms_files(:default)
72
72
  old_file.update_column(:file_file_name, 'old')
73
-
73
+
74
74
  assert_no_difference 'Comfy::Cms::File.count' do
75
75
  ComfortableMexicanSofa::Fixture::File::Importer.new('sample-site', 'default-site').import!
76
76
  assert file = Comfy::Cms::File.last
77
77
  assert_equal 'sample.jpg', file.file_file_name
78
78
  assert_equal 'Fixture File', file.label
79
79
  assert_equal 'Fixture Description', file.description
80
-
80
+
81
81
  assert Comfy::Cms::File.where(:id => old_file.id).blank?
82
82
  end
83
83
  end
84
-
84
+
85
85
  def test_export
86
+ comfy_cms_files(:default).update_column(:block_id, comfy_cms_blocks(:default_field_text))
87
+
86
88
  host_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'test-site')
87
89
  attr_path = File.join(host_path, 'files/_sample.jpg.yml')
88
90
  file_path = File.join(host_path, 'files/sample.jpg')
89
-
91
+
90
92
  Paperclip::Attachment.any_instance.stubs(:path).
91
93
  returns(File.join(Rails.root, 'db/cms_fixtures/sample-site/files/sample.jpg'))
92
94
  ComfortableMexicanSofa::Fixture::File::Exporter.new('default-site', 'test-site').export!
93
-
95
+
94
96
  assert File.exists?(attr_path)
95
97
  assert File.exists?(file_path)
96
98
  assert_equal ({
97
99
  'label' => 'Default File',
98
100
  'description' => 'Default Description',
99
101
  'categories' => ['Default'],
100
- 'page' => nil,
101
- 'block' => nil
102
+ 'page' => '/',
103
+ 'block' => 'default_field_text'
102
104
  }), YAML.load_file(attr_path)
103
-
105
+
104
106
  FileUtils.rm_rf(host_path)
105
107
  end
106
-
108
+
107
109
  end
@@ -1,7 +1,7 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  class AssetTagTest < ActiveSupport::TestCase
4
-
4
+
5
5
  def test_initialize_tag
6
6
  assert tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
7
7
  comfy_cms_pages(:default), '{{ cms:asset:default:css:html_tag }}'
@@ -9,7 +9,7 @@ class AssetTagTest < ActiveSupport::TestCase
9
9
  assert_equal 'default', tag.identifier
10
10
  assert_equal ['css', 'html_tag'], tag.params
11
11
  end
12
-
12
+
13
13
  def test_initialize_tag_failure
14
14
  [
15
15
  '{{cms:asset}}',
@@ -21,14 +21,14 @@ class AssetTagTest < ActiveSupport::TestCase
21
21
  )
22
22
  end
23
23
  end
24
-
24
+
25
25
  def test_render_no_params
26
26
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
27
27
  comfy_cms_pages(:default), '{{ cms:asset:default }}'
28
28
  )
29
29
  assert_equal '', tag.render
30
30
  end
31
-
31
+
32
32
  def test_render_for_css
33
33
  site = comfy_cms_sites(:default)
34
34
  layout = site.layouts.last
@@ -37,13 +37,30 @@ class AssetTagTest < ActiveSupport::TestCase
37
37
  comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:css }}"
38
38
  )
39
39
  assert_equal "/cms-css/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.css", tag.render
40
-
40
+
41
41
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
42
42
  comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:css:html_tag }}"
43
43
  )
44
44
  assert_equal "<link href='/cms-css/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.css' media='screen' rel='stylesheet' type='text/css' />", tag.render
45
45
  end
46
-
46
+
47
+ def test_render_for_css_with_non_root_mount
48
+ site = comfy_cms_sites(:default)
49
+ layout = site.layouts.last
50
+
51
+ ComfortableMexicanSofa.config.public_cms_path = '/custom'
52
+
53
+ tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
54
+ comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:css }}"
55
+ )
56
+ assert_equal "/custom/cms-css/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.css", tag.render
57
+
58
+ tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
59
+ comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:css:html_tag }}"
60
+ )
61
+ assert_equal "<link href='/custom/cms-css/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.css' media='screen' rel='stylesheet' type='text/css' />", tag.render
62
+ end
63
+
47
64
  def test_render_for_js
48
65
  site = comfy_cms_sites(:default)
49
66
  layout = site.layouts.last
@@ -52,11 +69,27 @@ class AssetTagTest < ActiveSupport::TestCase
52
69
  comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:js }}"
53
70
  )
54
71
  assert_equal "/cms-js/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.js", tag.render
55
-
72
+
56
73
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
57
74
  comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:js:html_tag }}"
58
75
  )
59
76
  assert_equal "<script src='/cms-js/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.js' type='text/javascript'></script>", tag.render
60
77
  end
61
-
62
- end
78
+
79
+ def test_render_for_js_with_non_root_mount
80
+ site = comfy_cms_sites(:default)
81
+ layout = site.layouts.last
82
+
83
+ ComfortableMexicanSofa.config.public_cms_path = '/custom'
84
+
85
+ tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
86
+ comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:js }}"
87
+ )
88
+ assert_equal "/custom/cms-js/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.js", tag.render
89
+
90
+ tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
91
+ comfy_cms_pages(:default), "{{ cms:asset:#{layout.identifier}:js:html_tag }}"
92
+ )
93
+ assert_equal "<script src='/custom/cms-js/#{site.id}/#{layout.identifier}/#{layout.cache_buster}.js' type='text/javascript'></script>", tag.render
94
+ end
95
+ end
@@ -1,9 +1,13 @@
1
1
  # encoding: utf-8
2
2
  ENV['RAILS_ENV'] = 'test'
3
3
 
4
+ require 'simplecov'
4
5
  require 'coveralls'
5
- Coveralls.wear! 'rails'
6
-
6
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
7
+ SimpleCov.start do
8
+ add_filter 'lib/generators'
9
+ add_filter 'lib/comfortable_mexican_sofa/engine.rb '
10
+ end
7
11
  require_relative '../config/environment'
8
12
 
9
13
  require 'rails/test_help'
@@ -30,6 +34,7 @@ class ActiveSupport::TestCase
30
34
  config.admin_auth = 'ComfortableMexicanSofa::AccessControl::AdminAuthentication'
31
35
  config.admin_authorization = 'ComfortableMexicanSofa::AccessControl::AdminAuthorization'
32
36
  config.public_auth = 'ComfortableMexicanSofa::AccessControl::PublicAuthentication'
37
+ config.public_authorization = 'ComfortableMexicanSofa::AccessControl::PublicAuthorization'
33
38
  config.admin_route_redirect = ''
34
39
  config.enable_fixtures = false
35
40
  config.fixtures_path = File.expand_path('db/cms_fixtures', Rails.root)
@@ -161,4 +166,4 @@ class Rails::Generators::TestCase
161
166
  )
162
167
  end
163
168
 
164
- end
169
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfortable_mexican_sofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.8
4
+ version: 1.12.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -226,6 +226,7 @@ files:
226
226
  - LICENSE
227
227
  - README.md
228
228
  - Rakefile
229
+ - app/assets/fonts/comfy/admin/cms/lib/redactor-font.eot
229
230
  - app/assets/images/comfy/admin/cms/arrow_bottom.gif
230
231
  - app/assets/images/comfy/admin/cms/arrow_right.gif
231
232
  - app/assets/images/comfy/admin/cms/checkerboard.gif
@@ -448,6 +449,7 @@ files:
448
449
  - lib/comfortable_mexican_sofa/access_control/admin_authentication.rb
449
450
  - lib/comfortable_mexican_sofa/access_control/admin_authorization.rb
450
451
  - lib/comfortable_mexican_sofa/access_control/public_authentication.rb
452
+ - lib/comfortable_mexican_sofa/access_control/public_authorization.rb
451
453
  - lib/comfortable_mexican_sofa/configuration.rb
452
454
  - lib/comfortable_mexican_sofa/engine.rb
453
455
  - lib/comfortable_mexican_sofa/error.rb
@@ -633,7 +635,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
633
635
  version: '0'
634
636
  requirements: []
635
637
  rubyforge_project:
636
- rubygems_version: 2.4.5
638
+ rubygems_version: 2.4.5.1
637
639
  signing_key:
638
640
  specification_version: 4
639
641
  summary: Rails 4 CMS Engine