Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set the routes file in a deeper level

Due to unknown and weird problems in travis, the config setting
'config/routes' wasn't being set by the rails engine, so we set it here
directly. It's not our responsibility to test it anyway
  • Loading branch information...
commit ab02597ecaa3ea60a0406cfa1cb882af1a3260b2 1 parent c2bfa52
@enriclluelles authored
Showing with 9 additions and 10 deletions.
  1. +4 −2 test/route_translator_test.rb
  2. +5 −8 test/test_helper.rb
View
6 test/route_translator_test.rb
@@ -44,7 +44,7 @@ def teardown
config_force_locale false
config_generate_unlocalized_routes false
config_default_locale_settings("en")
- app_file routes_config, ""
+ routes_file ""
FileUtils.rm_rf "#{tmp_path}/log"
end
@@ -388,7 +388,8 @@ def test_config_translation_file
end
def test_auto_translate
- app_file routes_config, <<-RUBY
+
+ routes_file <<-RUBY
Rails.application.routes.draw do
localized do
root :to => 'people#index'
@@ -398,6 +399,7 @@ def test_auto_translate
config_default_locale_settings 'es'
config_translation_file File.expand_path('locales/routes.yml', File.dirname(__FILE__))
+
app.reload_routes!
@routes = app.routes
View
13 test/test_helper.rb
@@ -37,11 +37,6 @@ def setup_application
app = @@app = Class.new(Rails::Application)
app.config.active_support.deprecation = :stderr
app.paths["log"] = "#{tmp_path}/log/test.log"
- if (app.paths.config rescue nil)
- app.paths.config.routes = File.join(app_path, routes_config)
- else
- app.paths["config/routes"] = File.join(app_path, routes_config)
- end
app.initialize!
Rails.application = app
end
@@ -59,11 +54,13 @@ def app_path(*args)
tmp_path(*%w[app] + args)
end
- def app_file(path, contents)
- FileUtils.mkdir_p File.dirname("#{app_path}/#{path}")
- File.open("#{app_path}/#{path}", 'w') do |f|
+ def routes_file(contents)
+ fn = File.join(app_path, routes_config)
+ FileUtils.mkdir_p File.dirname(fn)
+ File.open(fn, 'w') do |f|
f.puts contents
end
+ app.routes_reloader.paths.unshift(fn)
end
def routes_config
Please sign in to comment.
Something went wrong with that request. Please try again.