not loading fixtures as binary, utf8 chars are not mangled anymore
Oleg
committed Dec 30, 2011
commit ca1e070805faaaebebafc2a529f88b0f25c0762b
Showing 4
changed files with
12 additions
and 8 deletions
cms_fixtures/example.com/pages/index/content.html b/db/cms_fixtures/example.com/pages/index/content.html
+1
-1
| @@ | @@ -1,2 +1,2 @@ |
| - | Home Page Fixture Content |
| + | Home Page Fixture Contént |
| {{ cms:snippet:default }} | |
| \ No newline at end of file | |
comfortable_mexican_sofa/fixtures.rb b/lib/comfortable_mexican_sofa/fixtures.rb
+5
-5
| @@ | @@ -38,17 +38,17 @@ module ComfortableMexicanSofa::Fixtures |
| # updating content | |
| if File.exists?(file_path = File.join(path, 'content.html')) | |
| if layout.new_record? || File.mtime(file_path) > layout.updated_at | |
| - | layout.content = File.open(file_path, 'rb').read |
| + | layout.content = File.open(file_path).read |
| end | |
| end | |
| if File.exists?(file_path = File.join(path, 'css.css')) | |
| if layout.new_record? || File.mtime(file_path) > layout.updated_at | |
| - | layout.css = File.open(file_path, 'rb').read |
| + | layout.css = File.open(file_path).read |
| end | |
| end | |
| if File.exists?(file_path = File.join(path, 'js.js')) | |
| if layout.new_record? || File.mtime(file_path) > layout.updated_at | |
| - | layout.js = File.open(file_path, 'rb').read |
| + | layout.js = File.open(file_path).read |
| end | |
| end | |
| @@ | @@ -110,7 +110,7 @@ module ComfortableMexicanSofa::Fixtures |
| identifier = file_path.split('/').last.split('.').first | |
| blocks_attributes << { | |
| :identifier => identifier, | |
| - | :content => File.open(file_path, 'rb').read |
| + | :content => File.open(file_path).read |
| } | |
| end | |
| end | |
| @@ | @@ -162,7 +162,7 @@ module ComfortableMexicanSofa::Fixtures |
| # updating content | |
| if File.exists?(file_path = File.join(path, 'content.html')) | |
| if snippet.new_record? || File.mtime(file_path) > snippet.updated_at | |
| - | snippet.content = File.open(file_path, 'rb').read |
| + | snippet.content = File.open(file_path).read |
| end | |
| end | |
test/integration/fixtures_test.rb
+3
-1
| @@ | @@ -1,3 +1,5 @@ |
| + | # encoding: utf-8 |
| + | |
| require File.expand_path('../test_helper', File.dirname(__FILE__)) | |
| class FixturesTest < ActionDispatch::IntegrationTest | |
| @@ | @@ -34,7 +36,7 @@ class FixturesTest < ActionDispatch::IntegrationTest |
| assert_equal 'Default Fixture Layout', Cms::Layout.find_by_identifier('default').label | |
| assert_equal 'Default Fixture Snippet', Cms::Snippet.find_by_identifier('default').label | |
| - | assert_equal "<html>\n <body>\n Home Page Fixture Content\nFixture Content for Default Snippet\n </body>\n</html>", response.body |
| + | assert_equal "<html>\n <body>\n Home Page Fixture Contént\nFixture Content for Default Snippet\n </body>\n</html>", response.body |
| end | |
| end | |
| end | |
test/unit/fixtures_test.rb
+3
-1
| @@ | @@ -1,3 +1,5 @@ |
| + | # encoding: utf-8 |
| + | |
| require File.expand_path('../test_helper', File.dirname(__FILE__)) | |
| class FixturesTest < ActiveSupport::TestCase | |
| @@ | @@ -88,7 +90,7 @@ class FixturesTest < ActiveSupport::TestCase |
| assert page = Cms::Page.find_by_full_path('/') | |
| assert_equal layout, page.layout | |
| assert_equal 'index', page.slug | |
| - | assert_equal "<html>Home Page Fixture Content\ndefault_snippet_content</html>", page.content |
| + | assert_equal "<html>Home Page Fixture Contént\ndefault_snippet_content</html>", page.content |
| assert page.is_published? | |
| assert child_page = Cms::Page.find_by_full_path('/child') | |