Skip to content

Commit e97b8cb

Browse files
committed
Merge pull request rails#20605 from dcrec1/assert_file
assert_file understands paths with special characters
2 parents ee066af + 6074d0f commit e97b8cb

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

railties/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* `assert_file` understands paths with special characters
2+
(eg. `v0.1.4~alpha+nightly`).
3+
4+
*Diego Carrion*
5+
16
* Remove ContentLength middleware from the defaults. If you want it, just
27
add it as a middleware in your config.
38

railties/lib/rails/generators/testing/assertions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Assertions
2323
# end
2424
# end
2525
def assert_file(relative, *contents)
26-
absolute = File.expand_path(relative, destination_root).shellescape
26+
absolute = File.expand_path(relative, destination_root)
2727
assert File.exist?(absolute), "Expected file #{relative.inspect} to exist, but does not"
2828

2929
read = File.read(absolute) if block_given? || !contents.empty?

railties/test/generators/app_generator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def test_pretend_option
499499
end
500500

501501
def test_application_name_with_spaces
502-
path = File.join(destination_root, "foo bar".shellescape)
502+
path = File.join(destination_root, "foo bar")
503503

504504
# This also applies to MySQL apps but not with SQLite
505505
run_generator [path, "-d", 'postgresql']

railties/test/railties/generators_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,13 @@ def test_helpers_are_not_namespaced_when_engine_is_not_mountable
122122
assert_no_file "app/helpers/foo_bar/topics_helper.rb"
123123
end
124124
end
125+
126+
def test_assert_file_with_special_characters
127+
path = "#{app_path}/tmp"
128+
file_name = "#{path}/v0.1.4~alpha+nightly"
129+
FileUtils.mkdir_p path
130+
FileUtils.touch file_name
131+
assert_file file_name
132+
end
125133
end
126134
end

0 commit comments

Comments
 (0)