From b0665345f85e4b7f3b3367ee36fa205e7ff78d12 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 15 Nov 2010 13:09:05 -0600 Subject: Allow running `rails plugin new` command inside rails application --- railties/test/application/generators_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 551e966c85..581cc71f89 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -25,6 +25,12 @@ module ApplicationTests yield app_const.config end + test "allow running plugin new generator inside Rails app directory" do + FileUtils.cd rails_root + `./script/rails plugin new vendor/plugins/bukkits` + assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) + end + test "generators default values" do with_bare_config do |c| assert_equal(true, c.generators.colorize_logging) -- cgit v1.2.3 From bf176e9c7a1aa46b021384b91f4f9ec9a1132c0f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 15 Nov 2010 13:09:39 -0600 Subject: Do not allow to use plugin_new generator directly, you should use Usage: rails new APP_PATH [options] Options: -G, [--skip-git] # Skip Git ignores and keeps -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: /Users/drogus/.rvm/rubies/ruby-1.8.7-p302/bin/ruby -b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL) [--edge] # Setup the application with Gemfile pointing to Rails repository [--dev] # Setup the application with Gemfile pointing to your Rails checkout [--skip-gemfile] # Don't create a Gemfile -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 -O, [--skip-active-record] # Skip Active Record files -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) -J, [--skip-prototype] # Skip Prototype files -T, [--skip-test-unit] # Skip Test::Unit files Runtime options: -s, [--skip] # Skip files that already exist -p, [--pretend] # Run but do not make any changes -f, [--force] # Overwrite files that already exist -q, [--quiet] # Supress status output Rails options: -v, [--version] # Show Rails version number and quit -h, [--help] # Show this help message and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going. command --- railties/test/application/generators_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 581cc71f89..3a3e28179a 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -31,6 +31,12 @@ module ApplicationTests assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) end + test "don't allow running plugin_new generator as a generator" do + FileUtils.cd rails_root + output = `./script/rails g plugin_new vendor/plugins/bukkits` + assert_match /This generator should not be used directly as a generator. You should use `rails plugin new` command instead/, output + end + test "generators default values" do with_bare_config do |c| assert_equal(true, c.generators.colorize_logging) -- cgit v1.2.3 From aafac200be0691aa97daf67b4a12ff8199dd7fe3 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 17 Nov 2010 22:46:28 +0100 Subject: Fix generators tests on ruby 1.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/test/application/generators_test.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'railties/test/application') diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 3a3e28179a..3c52a07bdb 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -26,15 +26,17 @@ module ApplicationTests end test "allow running plugin new generator inside Rails app directory" do - FileUtils.cd rails_root - `./script/rails plugin new vendor/plugins/bukkits` - assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) + FileUtils.cd rails_root do + `ruby script/rails plugin new vendor/plugins/bukkits` + assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) + end end test "don't allow running plugin_new generator as a generator" do - FileUtils.cd rails_root - output = `./script/rails g plugin_new vendor/plugins/bukkits` - assert_match /This generator should not be used directly as a generator. You should use `rails plugin new` command instead/, output + FileUtils.cd rails_root do + output = `ruby script/rails g plugin_new vendor/plugins/bukkits` + assert_match /This generator should not be used directly as a generator. You should use `rails plugin new` command instead/, output + end end test "generators default values" do -- cgit v1.2.3 From 7b2f2c8b477adae9bc7243fb9c895f8a823188a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 17 Nov 2010 23:31:29 +0100 Subject: Tidy up generators commits. --- railties/test/application/generators_test.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'railties/test/application') diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 3c52a07bdb..8b840fffd0 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -26,17 +26,8 @@ module ApplicationTests end test "allow running plugin new generator inside Rails app directory" do - FileUtils.cd rails_root do - `ruby script/rails plugin new vendor/plugins/bukkits` - assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) - end - end - - test "don't allow running plugin_new generator as a generator" do - FileUtils.cd rails_root do - output = `ruby script/rails g plugin_new vendor/plugins/bukkits` - assert_match /This generator should not be used directly as a generator. You should use `rails plugin new` command instead/, output - end + FileUtils.cd(rails_root){ `ruby script/rails plugin new vendor/plugins/bukkits` } + assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb")) end test "generators default values" do -- cgit v1.2.3 From 250fb3f6c297e1f0bdc80a44ae6ac77c04cd9c85 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 18 Nov 2010 00:06:03 +0100 Subject: Add config.action_controller.include_all_helpers, by default it is set to true. In older rails versions there was a way to use only helpers from helper file corresponding to current controller and you could also include all helpers by saying 'helper :all' in controller. This config allows to return to older behavior by setting it to false. --- .../application/initializers/frameworks_test.rb | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index 6970ea7b7a..475091f789 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -65,6 +65,66 @@ module ApplicationTests assert_equal ["notify"], Foo.action_methods end + test "allows to not load all helpers for controllers" do + add_to_config "config.action_controller.include_all_helpers = false" + + app_file "app/controllers/application_controller.rb", <<-RUBY + class ApplicationController < ActionController::Base + end + RUBY + + app_file "app/controllers/foo_controller.rb", <<-RUBY + class FooController < ApplicationController + def included_helpers + render :inline => "<%= from_app_helper -%> <%= from_foo_helper %>" + end + + def not_included_helper + render :inline => "<%= respond_to?(:from_bar_helper) -%>" + end + end + RUBY + + app_file "app/helpers/application_helper.rb", <<-RUBY + module ApplicationHelper + def from_app_helper + "from_app_helper" + end + end + RUBY + + app_file "app/helpers/foo_helper.rb", <<-RUBY + module FooHelper + def from_foo_helper + "from_foo_helper" + end + end + RUBY + + app_file "app/helpers/bar_helper.rb", <<-RUBY + module BarHelper + def from_bar_helper + "from_bar_helper" + end + end + RUBY + + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + match "/:controller(/:action)" + end + RUBY + + require 'rack/test' + extend Rack::Test::Methods + + get "/foo/included_helpers" + assert_equal "from_app_helper from_foo_helper", last_response.body + + get "/foo/not_included_helper" + assert_equal "false", last_response.body + end + # AD test "action_dispatch extensions are applied to ActionDispatch" do add_to_config "config.action_dispatch.tld_length = 2" -- cgit v1.2.3 From 77fc0cc165bb389527edc7eae3cf2c4249da857f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 18 Nov 2010 17:19:29 +0100 Subject: Ensure that initializers are executed before loading rake tasks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/test/application/rake_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 719550f9d9..23cd2378c7 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -34,6 +34,22 @@ module ApplicationTests assert_match "SuperMiddleware", Dir.chdir(app_path){ `rake middleware` } end + def test_initializers_are_executed_in_rake_tasks + add_to_config <<-RUBY + initializer "do_something" do + puts "Doing something..." + end + + rake_tasks do + task :do_nothing => :environment do + end + end + RUBY + + output = Dir.chdir(app_path){ `rake do_nothing` } + assert_match "Doing something...", output + end + def test_code_statistics_sanity assert_match "Code LOC: 5 Test LOC: 0 Code to Test Ratio: 1:0.0", Dir.chdir(app_path){ `rake stats` } -- cgit v1.2.3