Created
April 10, 2017 06:08
-
-
Save LukasSkywalker/594dee2b6448a2e37aa912fdeafc0858 to your computer and use it in GitHub Desktop.
default_url_options in GET form
This file contains 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
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
# Activate the gem you are reporting the issue against. | |
gem "rails", "5.1.0.rc1" | |
gem 'minitest-rails-capybara' | |
end | |
require "rack/test" | |
require "action_controller/railtie" | |
class TestApp < Rails::Application | |
config.root = File.dirname(__FILE__) | |
config.session_store :cookie_store, key: "cookie_store_key" | |
secrets.secret_token = "secret_token" | |
secrets.secret_key_base = "secret_key_base" | |
config.logger = Logger.new($stdout) | |
Rails.logger = config.logger | |
routes.draw do | |
get "/" => "test#index", as: :root | |
get "/foo" => "test#foo" | |
end | |
end | |
class ApplicationController < ActionController::Base | |
def default_url_options(options = {}) | |
{ locale: 'de' } | |
end | |
end | |
class TestController < ApplicationController | |
include Rails.application.routes.url_helpers | |
def index | |
form = "<h1>Form test</h1>" | |
form << "<a href='" + root_path + "'>Root</a>" | |
form << "<form action='/foo' method='get'>" | |
form << "<input name='bar' value='baz'/>" | |
form << "<button id='send' type='submit'>Send</button>" | |
form << "</form>" | |
render html: form.html_safe | |
end | |
def foo | |
render plain: params | |
end | |
end | |
require "minitest/autorun" | |
require 'rails/test_help' | |
require 'minitest/rails/capybara' | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
class BugTest < Minitest::Test | |
include Rack::Test::Methods | |
feature "Register" do | |
scenario "visit link" do | |
visit root_path | |
click_link 'Root' | |
current_url.must_equal 'http://www.example.com/?locale=de' | |
end | |
scenario "submit form" do | |
visit root_path | |
click_button 'Send' | |
current_url.must_equal 'http://www.example.com/foo?bar=baz&locale=de' | |
end | |
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