Created
October 8, 2014 13:00
-
-
Save victorarias/539afc9875d67cd03209 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "rails", "3.2.19" | |
require "rails" | |
require "action_controller/railtie" | |
class TestApp < Rails::Application | |
config.root = File.dirname(__FILE__) | |
config.session_store :cookie_store, key: "cookie_store_key" | |
config.secret_token = "1111111111111111111111111111111111111111111111111111111111111111111111111secret_token" | |
config.secret_key_base = "secret_key_base" | |
config.logger = Logger.new($stdout) | |
Rails.logger = config.logger | |
routes.draw do | |
scope "(:locale)", locale: /en|pt-BR/, module: :public do | |
get "/passing" => "test#passing" | |
get "/failing" => "test#failing" | |
get "foo" => "test#foo" | |
end | |
end | |
end | |
module Public; end | |
class Public::TestController < ActionController::Base | |
include Rails.application.routes.url_helpers | |
before_filter :set_locale | |
def set_locale(locale = :"pt-BR") | |
@locale = locale | |
end | |
def failing | |
# I18n.with_locale("en") do | |
# foo_path | |
# end | |
set_locale("en") | |
foo_path | |
set_locale | |
render text: foo_path | |
end | |
def passing | |
render text: foo_path | |
end | |
def default_url_options(options={}) | |
{ locale: @locale } | |
end | |
end | |
require "minitest/autorun" | |
require "rack/test" | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
class BugTest < Minitest::Test | |
include Rack::Test::Methods | |
def test_failing | |
get "pt-BR/failing" | |
assert_equal "/pt-BR/foo", last_response.body | |
end | |
def test_passing | |
get "pt-BR/passing" | |
assert_equal "/pt-BR/foo", last_response.body | |
end | |
private | |
def app | |
Rails.application | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment