Skip to content

Instantly share code, notes, and snippets.

@the-undefined
Created September 12, 2015 04:03
Show Gist options
  • Select an option

  • Save the-undefined/140ac95b4a4d0ac1ef40 to your computer and use it in GitHub Desktop.

Select an option

Save the-undefined/140ac95b4a4d0ac1ef40 to your computer and use it in GitHub Desktop.
Bug templates for Rails Engine Issue #20738 - assertions last passed on Rails Version 4.1.9
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'
gem 'rails', '4.1.9'
end
require 'rack/test'
require 'action_controller/railtie'
require 'rails/engine'
module Blog
class MyEngine < Rails::Engine
def self.inspect
"Blog::Engine"
end
def config
@config ||= Configuration.new
end
routes.draw do
resources :posts do
resources :comments
end
end
end
class PostsController < ActionController::Base
def index
end
end
end
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'
mount Blog::MyEngine => "/blog", as: "blog"
namespace :blog do
resources :news_stories
end
end
end
class Blog::NewsStoriesController < ActionController::Base
include Rails.application.routes.url_helpers
include ActionDispatch::Routing::RouteSet::MountedHelpers
def index
# on rails 4.1.9
# [1] pry(#<Blog::NewsStoriesController>)> blog.posts_path
# => "/blog/posts"
# on rails 4.2.0
# [1] pry(#<Blog::NewsStoriesController>)> blog.posts_path
# => "/posts"
redirect_to blog.posts_path
end
end
require 'minitest/autorun'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
class Blog::NewsStoriesControllerTest < ActionController::TestCase
include Rack::Test::Methods
test "should redirect to the expected location" do
response = get '/blog/news_stories'
assert_equal 302, response.status
assert_equal response.headers["location"], "http://example.org/blog/posts"
end
private
def app
Rails.application
end
end
# Running:
I, [2015-09-12T04:58:32.800335 #7801] INFO -- : ------------------------------------------------------------------------------
I, [2015-09-12T04:58:32.800400 #7801] INFO -- : Blog::NewsStoriesControllerTest: test_should_redirect_to_the_expected_location
I, [2015-09-12T04:58:32.800413 #7801] INFO -- : ------------------------------------------------------------------------------
D, [2015-09-12T04:58:32.816405 #7801] DEBUG -- :
D, [2015-09-12T04:58:32.816447 #7801] DEBUG -- :
I, [2015-09-12T04:58:32.816740 #7801] INFO -- : Started GET "/blog/news_stories" for 127.0.0.1 at 2015-09-12 04:58:32 +0100
.
Finished in 0.027469s, 36.4050 runs/s, 72.8101 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment