aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorŁukasz Strzałkowski <lukasz.strzalkowski@gmail.com>2013-08-11 23:19:22 +0200
committerŁukasz Strzałkowski <lukasz.strzalkowski@gmail.com>2013-08-25 11:40:10 +0200
commita2ca04bb3ac178bbe1503ac65dc88f5f3f8cb37f (patch)
tree22857d7f2c78d12f6dfcd4b8a03e8dfa560af792 /railties
parentc40c362ec1ac9ec96e92ddb046b67b713a434e48 (diff)
downloadrails-a2ca04bb3ac178bbe1503ac65dc88f5f3f8cb37f.tar.gz
rails-a2ca04bb3ac178bbe1503ac65dc88f5f3f8cb37f.tar.bz2
rails-a2ca04bb3ac178bbe1503ac65dc88f5f3f8cb37f.zip
Extend basic rendering, test it in railties
Diffstat (limited to 'railties')
-rw-r--r--railties/test/application/basic_rendering_test.rb62
-rw-r--r--railties/test/isolation/abstract_unit.rb6
2 files changed, 68 insertions, 0 deletions
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/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index ab3ca106dc..913e2b5e29 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -243,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