Skip to content

Commit

Permalink
Fix page seed import with attached file path containing white space c…
Browse files Browse the repository at this point in the history
…haracters (#837)

* Fix errors when importing page seed with attached file path containing whitespace characters. Issue #836

* Update seed data & test to fail prior to fix for Issue #836
  • Loading branch information
morgant authored and GBH committed Aug 5, 2018
1 parent b7bdfd3 commit 542d768
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 2 deletions.
Binary file added db/cms_seeds/sample-site/pages/index/cms logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions db/cms_seeds/sample-site/pages/index/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
[files attachments]
header.png
footer.png
cms logo.png
2 changes: 1 addition & 1 deletion lib/comfortable_mexican_sofa/seeds/page/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def construct_fragments_attributes(hash, record, path)
# ActiveStorage and a list of ids of old attachements to destroy
def files_content(record, identifier, path, frag_content)
# preparing attachments
files = frag_content.split.collect do |filename|
files = frag_content.split("\n").collect do |filename|
file_handler = File.open(File.join(path, filename))
{
io: file_handler,
Expand Down
2 changes: 1 addition & 1 deletion test/lib/seeds/pages_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_creation
assert_equal 1, frag.attachments.count

frag = page.fragments.find_by(identifier: "attachments")
assert_equal 2, frag.attachments.count
assert_equal 3, frag.attachments.count

assert_equal 2, page.categories.count
assert_equal %w[category_a category_b], page.categories.map(&:label)
Expand Down

0 comments on commit 542d768

Please sign in to comment.