diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/abstract_unit.rb | 1 | ||||
-rw-r--r-- | railties/test/application/basic_rendering_test.rb | 62 | ||||
-rw-r--r-- | railties/test/application/url_generation_test.rb | 1 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 5 | ||||
-rw-r--r-- | railties/test/generators/generators_test_helper.rb | 1 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 7 | ||||
-rw-r--r-- | railties/test/rails_info_controller_test.rb | 2 |
7 files changed, 79 insertions, 0 deletions
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 491faf4af9..643cc6b0ee 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -8,6 +8,7 @@ require 'fileutils' require 'active_support' require 'action_controller' +require 'action_view' require 'rails/all' module TestApp diff --git a/railties/test/application/basic_rendering_test.rb b/railties/test/application/basic_rendering_test.rb new file mode 100644 index 0000000000..00ba433a05 --- /dev/null +++ b/railties/test/application/basic_rendering_test.rb @@ -0,0 +1,62 @@ +require 'isolation/abstract_unit' +require 'rack/test' + +module ApplicationTests + class BasicRenderingTest < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation + include Rack::Test::Methods + + def setup + build_app + end + + def teardown + teardown_app + end + + test "Rendering without ActionView" do + gsub_app_file 'config/application.rb', "require 'rails/all'", <<-RUBY + require "active_model/railtie" + require "action_controller/railtie" + RUBY + + # Turn off ActionView and jquery-rails (it depends on AV) + $:.reject! {|path| path =~ /(actionview|jquery\-rails)/ } + boot_rails + + app_file 'app/controllers/pages_controller.rb', <<-RUBY + class PagesController < ApplicationController + def render_hello_world + render text: "Hello World!" + end + + def render_nothing + render nothing: true + end + + def no_render; end + + def raise_error + render foo: "bar" + end + end + RUBY + + get '/pages/render_hello_world' + assert_equal 200, last_response.status + assert_equal "Hello World!", last_response.body + assert_equal "text/plain; charset=utf-8", last_response.content_type + + get '/pages/render_nothing' + assert_equal 200, last_response.status + assert_equal " ", last_response.body + assert_equal "text/plain; charset=utf-8", last_response.content_type + + get '/pages/no_render' + assert_equal 500, last_response.status + + get '/pages/raise_error' + assert_equal 500, last_response.status + end + end +end diff --git a/railties/test/application/url_generation_test.rb b/railties/test/application/url_generation_test.rb index 2767779719..efbc853d7b 100644 --- a/railties/test/application/url_generation_test.rb +++ b/railties/test/application/url_generation_test.rb @@ -12,6 +12,7 @@ module ApplicationTests boot_rails require "rails" require "action_controller/railtie" + require "action_view/railtie" class MyApp < Rails::Application config.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4" diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 42b6275932..2f0dfc7d3e 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -222,6 +222,11 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_generator_if_skip_action_view_is_given + run_generator [destination_root, "--skip-action-view"] + assert_file "config/application.rb", /#\s+require\s+["']action_view\/railtie["']/ + end + def test_generator_if_skip_sprockets_is_given run_generator [destination_root, "--skip-sprockets"] assert_file "config/application.rb" do |content| diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 7fdd54fc30..32a3d072c9 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -16,6 +16,7 @@ Rails.application.load_generators require 'active_record' require 'action_dispatch' +require 'action_view' module GeneratorsTestHelper def self.included(base) diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index a3295a6e69..913e2b5e29 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -135,6 +135,7 @@ module TestHelpers def make_basic_app require "rails" require "action_controller/railtie" + require "action_view/railtie" app = Class.new(Rails::Application) app.config.eager_load = false @@ -242,6 +243,12 @@ module TestHelpers end end + def gsub_app_file(path, regexp, *args, &block) + path = "#{app_path}/#{path}" + content = File.read(path).gsub(regexp, *args, &block) + File.open(path, 'wb') { |f| f.write(content) } + end + def remove_file(path) FileUtils.rm_rf "#{app_path}/#{path}" end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index a9b237d0a5..e45a5228a1 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -1,5 +1,7 @@ require 'abstract_unit' +ActionController::Base.superclass.send(:include, ActionView::Layouts) + module ActionController class Base include ActionController::Testing |