From a0b948e9f554979282baff6464944a33e4f89883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 19 Aug 2013 10:52:01 -0300 Subject: Fix the indentation on the from template of the scaffold generator --- railties/test/generators/scaffold_generator_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 4b837da483..524bbde2b7 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -305,8 +305,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end assert_file "app/views/accounts/_form.html.erb" do |content| - assert_match(/<%= f\.text_field :name %>/, content) - assert_match(/<%= f\.text_field :currency_id %>/, content) + assert_match(/^\W{4}<%= f\.text_field :name %>/, content) + assert_match(/^\W{4}<%= f\.text_field :currency_id %>/, content) end end -- cgit v1.2.3 From 718332536c4f6c715a7b77f68749e4c75f8a6eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Thu, 18 Jul 2013 17:07:28 +0200 Subject: Fix railtie tests --- railties/test/rails_info_controller_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/test') 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 -- cgit v1.2.3 From d7d3e3417273945029cd049cb6b8f9ab25f466ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Tue, 30 Jul 2013 02:24:20 +0200 Subject: Add AV as development dependency for railties It's needed for tests --- railties/test/abstract_unit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/test') 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 -- cgit v1.2.3 From e291e6a479d9942515251ab5d4f37f5f5125217a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Tue, 30 Jul 2013 10:22:39 +0200 Subject: Include AV railtie in railties isolation tests --- railties/test/isolation/abstract_unit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/test') diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index a3295a6e69..ab3ca106dc 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 -- cgit v1.2.3 From ac036cc38c5af3bae436940d2f1c73316eeb726f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Tue, 30 Jul 2013 11:28:31 +0200 Subject: Missing AV requires in railties tests --- railties/test/application/url_generation_test.rb | 1 + railties/test/generators/generators_test_helper.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'railties/test') 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/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) -- cgit v1.2.3 From 1b1c23599bf0b4c16fec260ed993b27a8cc92724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Wed, 31 Jul 2013 17:10:10 +0200 Subject: Add --skip-action-view to app generator --- railties/test/generators/app_generator_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'railties/test') 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| -- cgit v1.2.3 From a2ca04bb3ac178bbe1503ac65dc88f5f3f8cb37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Sun, 11 Aug 2013 23:19:22 +0200 Subject: Extend basic rendering, test it in railties --- railties/test/application/basic_rendering_test.rb | 62 +++++++++++++++++++++++ railties/test/isolation/abstract_unit.rb | 6 +++ 2 files changed, 68 insertions(+) create mode 100644 railties/test/application/basic_rendering_test.rb (limited to 'railties/test') 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 -- cgit v1.2.3 From c2df74938e0dcd03b297efe2d3db4299ec33ceeb Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Fri, 30 Aug 2013 11:21:22 +0530 Subject: Fix typo in generators test helpr -> helper [ci skip] --- railties/test/generators/namespaced_generators_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index a4d8b3d1b0..e17925ff65 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -44,7 +44,7 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase end end - def test_helpr_is_also_namespaced + def test_helper_is_also_namespaced run_generator assert_file "app/helpers/test_app/account_helper.rb", /module TestApp/, / module AccountHelper/ assert_file "test/helpers/test_app/account_helper_test.rb", /module TestApp/, / class AccountHelperTest/ -- cgit v1.2.3