diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/railties/engine_test.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 0cc729907e..fabd561bd2 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -544,5 +544,62 @@ module RailtiesTest response = AppTemplate::Application.call(env) assert response[2].body =~ /name="post\[title\]"/ end + + test "creating symlinks" do + @plugin.write "lib/bukkits.rb", <<-RUBY + module Bukkits + class Engine < ::Rails::Engine + namespace(Bukkits) + end + end + RUBY + + @plugin.write "public/hello.txt", "foo" + @plugin.write "alternate_public/hello.txt", "bar" + + Dir.chdir(app_path) do + output = `rake railties:create_symlinks` + + assert_match /Created symlink/, output + assert_match /#{app_path}\/public\/bukkits/, output + assert_match /#{@plugin.path}\/public/, output + + assert File.symlink?(File.join(app_path, 'public/bukkits')) + assert_equal "foo\n", File.read(File.join(app_path, 'public/bukkits/hello.txt')) + + @plugin.write "lib/bukkits.rb", <<-RUBY + module Bukkits + class Engine < ::Rails::Engine + namespace(Bukkits) + config.paths.public = "#{File.join(@plugin.path, "alternate_public")}" + end + end + RUBY + + output = `rake railties:create_symlinks` + + assert_match /Created symlink/, output + assert_match /#{app_path}\/public\/bukkits/, output + assert_match /#{@plugin.path}\/alternate_public/, output + + assert File.symlink?(File.join(app_path, 'public/bukkits')) + assert_equal "bar\n", File.read(File.join(app_path, 'public/bukkits/hello.txt')) + + @plugin.write "lib/bukkits.rb", <<-RUBY + module Bukkits + class Engine < ::Rails::Engine + namespace(Bukkits) + config.paths.public = "#{File.join(@plugin.path, "not_existing")}" + end + end + RUBY + + FileUtils.rm File.join(app_path, 'public/bukkits') + + output = `rake railties:create_symlinks` + assert_no_match /Created symlink/, output + assert !File.exist?(File.join(app_path, 'public/bukkits')) + end + end end end |