From bca866e6f1c1c044933ca71b7ae456e53c81dcf0 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Fri, 26 Apr 2013 14:17:05 +0200 Subject: Minor code duplication removed --- railties/lib/rails/generators/app_base.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 57dc7e797b..853d6fa4b9 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -186,20 +186,20 @@ module Rails # Use SCSS for stylesheets gem 'sass-rails', github: 'rails/sass-rails' - - # Use Uglifier as compressor for JavaScript assets - gem 'uglifier', '>= 1.3.0' GEMFILE else <<-GEMFILE.strip_heredoc # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.0.rc1' - - # Use Uglifier as compressor for JavaScript assets - gem 'uglifier', '>= 1.3.0' GEMFILE end + gemfile += <<-GEMFILE.strip_heredoc + + # Use Uglifier as compressor for JavaScript assets + gem 'uglifier', '>= 1.3.0' + GEMFILE + if options[:skip_javascript] gemfile += <<-GEMFILE #{coffee_gemfile_entry} -- cgit v1.2.3 From 5aec73daf5ea144ac9f2a4e15c6807cc2dcb87b6 Mon Sep 17 00:00:00 2001 From: Teng Siong Ong Date: Tue, 30 Apr 2013 06:49:03 -0700 Subject: Make `rake doc:guides` works again. Fix #10384. --- railties/lib/rails/tasks/documentation.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 1c3426028d..f89d6b12e1 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -57,8 +57,8 @@ namespace :doc do # desc "Generate Rails Guides" task :guides do - # FIXME: Reaching outside lib directory is a bad idea - require File.expand_path('../../../../../guides/rails_guides', __FILE__) + rails_gem_dir = Gem::Specification.find_by_name("rails").gem_dir + require File.expand_path(File.join(rails_gem_dir, "/guides/rails_guides")) RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate end end -- cgit v1.2.3 From 9703d67048d87a6e0986035f2827bf6b378c32a0 Mon Sep 17 00:00:00 2001 From: wangjohn Date: Tue, 30 Apr 2013 12:26:55 -0400 Subject: Removing the app constant and replacing it with Rails.application syntax. This helps removing the class level abstraction of an application. --- railties/lib/rails/engine.rb | 8 ++++---- railties/lib/rails/generators/actions.rb | 2 +- railties/lib/rails/generators/rails/app/templates/Rakefile | 2 +- .../rails/generators/rails/app/templates/config/environment.rb | 2 +- .../rails/app/templates/config/environments/development.rb.tt | 2 +- .../rails/app/templates/config/environments/production.rb.tt | 2 +- .../generators/rails/app/templates/config/environments/test.rb.tt | 2 +- .../rails/app/templates/config/initializers/secret_token.rb.tt | 2 +- .../rails/app/templates/config/initializers/session_store.rb.tt | 2 +- .../lib/rails/generators/rails/app/templates/config/routes.rb | 2 +- railties/lib/rails/railtie.rb | 6 +++++- railties/test/generators/actions_test.rb | 2 +- railties/test/generators/app_generator_test.rb | 6 +++--- 13 files changed, 22 insertions(+), 18 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 94edcd352a..bfb9b456db 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -124,7 +124,7 @@ module Rails # # Now you can mount your engine in application's routes just like that: # - # MyRailsApp::Application.routes.draw do + # Rails.application.routes.draw do # mount MyEngine::Engine => "/engine" # end # @@ -154,7 +154,7 @@ module Rails # Note that now there can be more than one router in your application, and it's better to avoid # passing requests through many routers. Consider this situation: # - # MyRailsApp::Application.routes.draw do + # Rails.application.routes.draw do # mount MyEngine::Engine => "/blog" # get "/blog/omg" => "main#omg" # end @@ -164,7 +164,7 @@ module Rails # and if there is no such route in +Engine+'s routes, it will be dispatched to main#omg. # It's much better to swap that: # - # MyRailsApp::Application.routes.draw do + # Rails.application.routes.draw do # get "/blog/omg" => "main#omg" # mount MyEngine::Engine => "/blog" # end @@ -251,7 +251,7 @@ module Rails # created to allow you to do that. Consider such a scenario: # # # config/routes.rb - # MyApplication::Application.routes.draw do + # Rails.application.routes.draw do # mount MyEngine::Engine => "/my_engine", as: "my_engine" # get "/foo" => "foo#index" # end diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 28593c5907..366c72ebaa 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -86,7 +86,7 @@ module Rails # end def environment(data=nil, options={}, &block) sentinel = /class [a-z_:]+ < Rails::Application/i - env_file_sentinel = /::Application\.configure do/ + env_file_sentinel = /Rails\.application\.configure do/ data = block.call if !data && block_given? in_root do diff --git a/railties/lib/rails/generators/rails/app/templates/Rakefile b/railties/lib/rails/generators/rails/app/templates/Rakefile index 6eb23f68a3..ba6b733dd2 100644 --- a/railties/lib/rails/generators/rails/app/templates/Rakefile +++ b/railties/lib/rails/generators/rails/app/templates/Rakefile @@ -3,4 +3,4 @@ require File.expand_path('../config/application', __FILE__) -<%= app_const %>.load_tasks +Rails.application.load_tasks diff --git a/railties/lib/rails/generators/rails/app/templates/config/environment.rb b/railties/lib/rails/generators/rails/app/templates/config/environment.rb index e080ebd74e..00a613ff04 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the rails application. -<%= app_const %>.initialize! +Rails.application.initialize! diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index 8b64881dbc..91253d1508 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -1,4 +1,4 @@ -<%= app_const %>.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index c40eef145f..1dfc9f136b 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -1,4 +1,4 @@ -<%= app_const %>.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt index 7073d8db33..ba0742f97f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt @@ -1,4 +1,4 @@ -<%= app_const %>.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt index efccf72d3d..f3cc6098a3 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt @@ -9,4 +9,4 @@ # Make sure your secret_key_base is kept private # if you're sharing your code publicly. -<%= app_const %>.config.secret_key_base = '<%= app_secret %>' +Rails.application.config.secret_key_base = '<%= app_secret %>' diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt index 4a099a4ce2..2bb9b82c61 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -<%= app_const %>.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %> +Rails.application.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %> diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb index f877fa1f8a..89399bcc9f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb @@ -1,4 +1,4 @@ -<%= app_const %>.routes.draw do +Rails.application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 2b6ad1ff2d..89ca8cbe11 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -179,7 +179,7 @@ module Rails # Railtie::Configurable, but this module is no longer required for all # subclasses of Railtie so we provide the class method here. def configure(&block) - class_eval(&block) + instance.configure(&block) end protected @@ -206,6 +206,10 @@ module Rails end end + def configure(&block) + instance_eval(&block) + end + def config @config ||= Railtie::Configuration.new end diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index f8fa8ee153..0db40c1d32 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -103,7 +103,7 @@ class ActionsTest < Rails::Generators::TestCase run_generator autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]' action :environment, autoload_paths, env: 'development' - assert_file "config/environments/development.rb", /Application\.configure do\n #{Regexp.escape(autoload_paths)}/ + assert_file "config/environments/development.rb", /Rails\.application\.configure do\n #{Regexp.escape(autoload_paths)}/ end def test_environment_with_block_should_include_block_contents_in_environment_initializer_block diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 5fdf58c8ee..f70c90bffa 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -65,7 +65,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_invalid_application_name_is_fixed run_generator [File.join(destination_root, "things-43")] - assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/ + assert_file "things-43/config/environment.rb", /Rails\.application\.initialize!/ assert_file "things-43/config/application.rb", /^module Things43$/ end @@ -111,7 +111,7 @@ class AppGeneratorTest < Rails::Generators::TestCase destination_root: app_moved_root, shell: @shell generator.send(:app_const) quietly { generator.send(:create_config_files) } - assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/ + assert_file "myapp_moved/config/environment.rb", /Rails\.application\.initialize!/ assert_file "myapp_moved/config/initializers/session_store.rb", /_myapp_session/ end @@ -131,7 +131,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_application_names_are_not_singularized run_generator [File.join(destination_root, "hats")] - assert_file "hats/config/environment.rb", /Hats::Application\.initialize!/ + assert_file "hats/config/environment.rb", /Rails\.application\.initialize!/ end def test_gemfile_has_no_whitespace_errors -- cgit v1.2.3 From 727d0af28cbc3a917afdea8631beac5db3f4ee49 Mon Sep 17 00:00:00 2001 From: Thiago Pinto Date: Wed, 1 May 2013 00:11:43 -0400 Subject: routes.rb should teach how to use concerns --- railties/lib/rails/generators/rails/app/templates/config/routes.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb index f877fa1f8a..1794ffa833 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb @@ -39,6 +39,13 @@ # get 'recent', on: :collection # end # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable # Example resource route within a namespace: # namespace :admin do -- cgit v1.2.3 From 558d402472b49c4c99bf6753d341d7aef2e25dd4 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Wed, 1 May 2013 18:10:10 -0400 Subject: Make railties version match RAILS_VERSION --- railties/lib/rails/version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index dcbf57a4df..5a6d8d0983 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -1,9 +1,9 @@ module Rails module VERSION MAJOR = 4 - MINOR = 0 + MINOR = 1 TINY = 0 - PRE = "rc1" + PRE = "beta" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From dfd5dc93a1ead62353cc33f5065e23b4fdf25b3e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 1 May 2013 23:17:44 -0300 Subject: Remove not used module from initializable test --- railties/test/initializable_test.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'railties') diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb index 16e259be5d..ed9573453b 100644 --- a/railties/test/initializable_test.rb +++ b/railties/test/initializable_test.rb @@ -20,14 +20,6 @@ module InitializableTests end end - module Word - include Rails::Initializable - - initializer :word do - $word = "bird" - end - end - class Parent include Rails::Initializable @@ -235,4 +227,4 @@ module InitializableTests assert_equal [1, 2, 3, 4], $arr end end -end \ No newline at end of file +end -- cgit v1.2.3 From 062a93a05e11e1307efc950ef03b20a88630e6de Mon Sep 17 00:00:00 2001 From: wangjohn Date: Thu, 2 May 2013 11:16:20 -0400 Subject: Refactoring the creation of TestTasks to remove code duplication. --- railties/lib/rails/test_unit/testing.rake | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 877dd6d254..9263b9b81d 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -121,31 +121,17 @@ namespace :test do Rails::TestTask.new(single: "test:prepare") - Rails::TestTask.new(models: "test:prepare") do |t| - t.pattern = 'test/models/**/*_test.rb' - end - - Rails::TestTask.new(helpers: "test:prepare") do |t| - t.pattern = 'test/helpers/**/*_test.rb' + ["models", "helpers", "controllers", "mailers", "integration"].each do |name| + Rails::TestTask.new(name => "test:prepare") do |t| + t.pattern = "test/#{name}/**/*_test.rb" + end end Rails::TestTask.new(units: "test:prepare") do |t| t.pattern = 'test/{models,helpers,unit}/**/*_test.rb' end - Rails::TestTask.new(controllers: "test:prepare") do |t| - t.pattern = 'test/controllers/**/*_test.rb' - end - - Rails::TestTask.new(mailers: "test:prepare") do |t| - t.pattern = 'test/mailers/**/*_test.rb' - end - Rails::TestTask.new(functionals: "test:prepare") do |t| t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb' end - - Rails::TestTask.new(integration: "test:prepare") do |t| - t.pattern = 'test/integration/**/*_test.rb' - end end -- cgit v1.2.3 From 9a4268db99d93190c58bddcb150832727a0d5129 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 May 2013 16:42:31 +0200 Subject: Fix generating route from engine to other engine A regression was introduced in 5b3bb6, generating route from within an engine to an another engine resulted in prefixing a path with the SCRIPT_NAME value. The regression was caused by the fact that SCRIPT_NAME should be appended only if it's the SCRIPT_NAME for the application, not if it's SCRIPT_NAME from the current engine. closes #10409 --- railties/lib/rails/application.rb | 1 + railties/test/railties/mounted_engine_test.rb | 45 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 2d5aa9d952..914e4393c4 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -93,6 +93,7 @@ module Rails # dispatches the request to the underlying middleware stack. def call(env) env["ORIGINAL_FULLPATH"] = build_original_fullpath(env) + env["ORIGINAL_SCRIPT_NAME"] = env["SCRIPT_NAME"] super(env) end diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb index 80559a6e36..c94937f964 100644 --- a/railties/test/railties/mounted_engine_test.rb +++ b/railties/test/railties/mounted_engine_test.rb @@ -13,6 +13,7 @@ module ApplicationTests @simple_plugin = engine "weblog" @plugin = engine "blog" + @metrics_plugin = engine "metrics" app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do @@ -28,6 +29,7 @@ module ApplicationTests scope "/:user", :user => "anonymous" do mount Blog::Engine => "/blog" end + mount Metrics::Engine => "/metrics" root :to => 'main#index' end RUBY @@ -54,6 +56,34 @@ module ApplicationTests end RUBY + @metrics_plugin.write "lib/metrics.rb", <<-RUBY + module Metrics + class Engine < ::Rails::Engine + isolate_namespace(Metrics) + end + end + RUBY + + @metrics_plugin.write "config/routes.rb", <<-RUBY + Metrics::Engine.routes.draw do + get '/generate_blog_route', to: 'generating#generate_blog_route' + get '/generate_blog_route_in_view', to: 'generating#generate_blog_route_in_view' + end + RUBY + + @metrics_plugin.write "app/controllers/metrics/generating_controller.rb", <<-RUBY + module Metrics + class GeneratingController < ActionController::Base + def generate_blog_route + render text: blog.post_path(1) + end + + def generate_blog_route_in_view + render inline: "<%= blog.post_path(1) -%>" + end + end + end + RUBY @plugin.write "app/models/blog/post.rb", <<-RUBY module Blog @@ -201,6 +231,21 @@ module ApplicationTests get "/somone/blog/application_route_in_view" assert_equal "/", last_response.body + # test generating engine's route from other engine + get "/metrics/generate_blog_route" + assert_equal '/anonymous/blog/posts/1', last_response.body + + get "/metrics/generate_blog_route_in_view" + assert_equal '/anonymous/blog/posts/1', last_response.body + + # test generating engine's route from other engine with default_url_options + get "/metrics/generate_blog_route", {}, 'SCRIPT_NAME' => '/foo' + assert_equal '/foo/anonymous/blog/posts/1', last_response.body + + get "/metrics/generate_blog_route_in_view", {}, 'SCRIPT_NAME' => '/foo' + assert_equal '/foo/anonymous/blog/posts/1', last_response.body + + # test generating application's route from engine with default_url_options get "/someone/blog/generate_application_route", {}, 'SCRIPT_NAME' => '/foo' assert_equal "/foo/", last_response.body -- cgit v1.2.3 From ec92d8440fa51aea40de1567eed7974422bff000 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Fri, 3 May 2013 10:37:22 -0400 Subject: Add a test case for comparing Rails versions https://github.com/rails/rails/commit/558d402472b49c4c99bf6753d341d7aef2e25dd4 --- railties/test/rails_info_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'railties') diff --git a/railties/test/rails_info_test.rb b/railties/test/rails_info_test.rb index 5b9088cb64..44a5fd1904 100644 --- a/railties/test/rails_info_test.rb +++ b/railties/test/rails_info_test.rb @@ -37,6 +37,11 @@ class InfoTest < ActiveSupport::TestCase assert_property 'Goodbye', 'World' end + def test_rails_version + assert_property 'Rails version', + File.read(File.realpath('../../../RAILS_VERSION', __FILE__)).chomp + end + def test_framework_version assert_property 'Active Support version', ActiveSupport.version.to_s end -- cgit v1.2.3 From cf733bce5e14f42f0bf4c91b00fa0de9aadc1cfb Mon Sep 17 00:00:00 2001 From: Pavel Pravosud Date: Sat, 4 May 2013 13:46:01 +0700 Subject: Relaxed jbuilder dependency in Gemfile template --- railties/lib/rails/generators/rails/app/templates/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index f6bd107eba..10bb2c9d5d 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -10,7 +10,7 @@ source 'https://rubygems.org' <%= javascript_gemfile_entry -%> # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 1.0.1' +gem 'jbuilder', '~> 1.2' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' -- cgit v1.2.3 From f354ad1b69188009b5dc2827f19f634730fcf923 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 3 May 2013 08:28:37 +0500 Subject: generate 'app/assets/images' directory when creating new rails app --- railties/lib/rails/generators/rails/app/app_generator.rb | 1 + .../lib/rails/generators/rails/app/templates/app/assets/images/.keep | 0 railties/test/generators/app_generator_test.rb | 5 +++++ 3 files changed, 6 insertions(+) delete mode 100644 railties/lib/rails/generators/rails/app/templates/app/assets/images/.keep (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index b2d1be9b51..5877579fc4 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -56,6 +56,7 @@ module Rails def app directory 'app' + keep_file 'app/assets/images' keep_file 'app/mailers' keep_file 'app/models' diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/images/.keep b/railties/lib/rails/generators/rails/app/templates/app/assets/images/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index f70c90bffa..0ffb615764 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -260,6 +260,11 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file 'test' end + def test_creation_of_app_assets_images_directory + run_generator + assert_file "app/assets/images" + end + def test_creation_of_vendor_assets_javascripts_directory run_generator assert_file "vendor/assets/javascripts" -- cgit v1.2.3 From f1805a697831b356a2a6877291628fea8e2216e6 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Fri, 3 May 2013 11:42:30 +0200 Subject: Fixes Scaffold generator with --assets=false Scaffold generator with --assets=false option outputs an error See #9525 --- railties/CHANGELOG.md | 4 ++++ .../rails/generators/rails/scaffold/scaffold_generator.rb | 2 ++ railties/test/generators/scaffold_generator_test.rb | 14 ++++++++++++++ 3 files changed, 20 insertions(+) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index e1b98eda55..58bd77836c 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fixes bug with Scaffold generator with --assets=false --resource-route=false See #9525 for more details. + + *Arun Agrawal* + * Rails::Railtie no longer forces the Rails::Configurable module on everything that subclassess it. Instead, the methods from Rails::Configurable have been moved to class methods in Railtie and the Railtie has been made abstract. diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb index 2a0522e81c..d3b42813e1 100644 --- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb @@ -8,6 +8,8 @@ module Rails class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets" class_option :stylesheet_engine, desc: "Engine for Stylesheets" + class_option :assets, :type => :boolean + class_option :resource_route, :type => :boolean def handle_skip @options = @options.merge(stylesheets: false) unless options[:assets] diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 25f299118c..e3dc323b24 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -246,6 +246,20 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase assert_no_file "app/assets/stylesheets/posts.css" end + def test_scaffold_generator_no_assets + run_generator [ "posts", "--assets=false" ] + assert_file "app/assets/stylesheets/scaffold.css" + assert_no_file "app/assets/javascripts/posts.js" + assert_no_file "app/assets/stylesheets/posts.css" + end + + def test_scaffold_generator_no_assets + run_generator [ "posts", "--resource-route=false" ] + assert_file "config/routes.rb" do |route| + assert_no_match(/resources :posts$/, route) + end + end + def test_scaffold_generator_no_stylesheets run_generator [ "posts", "--no-stylesheets" ] assert_no_file "app/assets/stylesheets/scaffold.css" -- cgit v1.2.3 From d093f8437a110762770ae4595b3f38bde4eda7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 4 May 2013 10:53:53 -0300 Subject: Review the CHANGELOG entry [ci skip] --- railties/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 58bd77836c..04cdbec428 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,4 +1,5 @@ -* Fixes bug with Scaffold generator with --assets=false --resource-route=false See #9525 for more details. +* Fixes bug with scaffold generator with `--assets=false --resource-route=false`. + Fixes #9525. *Arun Agrawal* -- cgit v1.2.3 From 8e0d43bc500f751d72a3f65caafa9fec2f2bda96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 4 May 2013 10:59:56 -0300 Subject: Use Ruby 1.9 syntax --- railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb index d3b42813e1..e89789e72b 100644 --- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb @@ -8,8 +8,8 @@ module Rails class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets" class_option :stylesheet_engine, desc: "Engine for Stylesheets" - class_option :assets, :type => :boolean - class_option :resource_route, :type => :boolean + class_option :assets, type: :boolean + class_option :resource_route, type: :boolean def handle_skip @options = @options.merge(stylesheets: false) unless options[:assets] -- cgit v1.2.3 From e1bd8d1a5c1ee7a296fca5bb62bace53809e3b95 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sat, 4 May 2013 20:13:42 +0530 Subject: dir -> directory [ci skip] --- railties/lib/rails/commands.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 0d1286031c..e8c42b149b 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -66,7 +66,7 @@ when 'console' Rails::Console.start(Rails.application, options) when 'server' - # Change to the application's path if there is no config.ru file in current dir. + # Change to the application's path if there is no config.ru file in current directory. # This allows us to run `rails server` from other directories, but still get # the main config.ru and properly set the tmp directory. Dir.chdir(File.expand_path('../../', APP_PATH)) unless File.exists?(File.expand_path("config.ru")) -- cgit v1.2.3 From 9e8c4679456680faedef9eda79bc09c7716bca99 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sun, 5 May 2013 11:33:27 +0530 Subject: Fixes warning 'method redefined' in scaffold generators tests - f1805a697831 Redefined 'test_scaffold_generator_no_assets' twice. - Only the last instance of these three definitions of the same method was getting called when the tests were actually running. - This commit changes names of this method so that all three definitions will be called - scaffold.css is not generated by --assets=false switch. - Test was expecting the presence of the file with --assets=false - This issue was not discovered in f1805a697831b because it was redefining the same method twice --- railties/test/generators/scaffold_generator_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index e3dc323b24..d5ad978986 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -239,21 +239,21 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase assert_file "config/routes.rb", /\.routes\.draw do\s*\|map\|\s*$/ end - def test_scaffold_generator_no_assets + def test_scaffold_generator_no_assets_with_switch_no_assets run_generator [ "posts", "--no-assets" ] assert_no_file "app/assets/stylesheets/scaffold.css" assert_no_file "app/assets/javascripts/posts.js" assert_no_file "app/assets/stylesheets/posts.css" end - def test_scaffold_generator_no_assets + def test_scaffold_generator_no_assets_with_switch_assets_false run_generator [ "posts", "--assets=false" ] - assert_file "app/assets/stylesheets/scaffold.css" + assert_no_file "app/assets/stylesheets/scaffold.css" assert_no_file "app/assets/javascripts/posts.js" assert_no_file "app/assets/stylesheets/posts.css" end - def test_scaffold_generator_no_assets + def test_scaffold_generator_no_assets_with_switch_resource_route_false run_generator [ "posts", "--resource-route=false" ] assert_file "config/routes.rb" do |route| assert_no_match(/resources :posts$/, route) -- cgit v1.2.3 From 42275a6badc251363a852f9d381b275be477e7aa Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sun, 5 May 2013 20:33:24 +0530 Subject: Updated link to to GitHub article about ignoring files [ci skip] - http://help.github.com/ignore-files redirects to https://help.github.com/articles/ignoring-files --- railties/lib/rails/generators/rails/app/templates/gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore b/railties/lib/rails/generators/rails/app/templates/gitignore index 25a742dff0..6a502e997f 100644 --- a/railties/lib/rails/generators/rails/app/templates/gitignore +++ b/railties/lib/rails/generators/rails/app/templates/gitignore @@ -1,4 +1,4 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. +# See https://help.github.com/articles/ignoring-files for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: -- cgit v1.2.3 From ebfe41ca2126132e780b47f73245d8f4e4a13187 Mon Sep 17 00:00:00 2001 From: Matthew Michihara Date: Sun, 5 May 2013 16:00:18 -0700 Subject: Improve model generator USAGE grammar --- railties/lib/rails/generators/rails/model/USAGE | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE index 1998a392aa..145d9ee6e0 100644 --- a/railties/lib/rails/generators/rails/model/USAGE +++ b/railties/lib/rails/generators/rails/model/USAGE @@ -46,18 +46,18 @@ Available field types: `rails generate model photo title:string album:references` - It will generate an album_id column. You should generate this kind of fields when - you will use a `belongs_to` association for instance. `references` also support - the polymorphism, you could enable the polymorphism like this: + It will generate an `album_id` column. You should generate these kinds of fields when + you will use a `belongs_to` association, for instance. `references` also supports + polymorphism, you can enable polymorphism like this: `rails generate model product supplier:references{polymorphic}` - For integer, string, text and binary fields an integer in curly braces will + For integer, string, text and binary fields, an integer in curly braces will be set as the limit: `rails generate model user pseudo:string{30}` - For decimal two integers separated by a comma in curly braces will be used + For decimal, two integers separated by a comma in curly braces will be used for precision and scale: `rails generate model product price:decimal{10,2}` -- cgit v1.2.3 From c9e4c9acdc0b68500fab7a5a4887303cbd3975d2 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 6 May 2013 22:02:56 +0200 Subject: let rake tasks be robust to a missing RDoc in Rubinius [Fixes #10462] See the comment in the rescue clause towards the top of the patch for the rationale. --- railties/lib/rails/tasks/documentation.rake | 101 +++++++++++++++------------- 1 file changed, 56 insertions(+), 45 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f89d6b12e1..d45e892424 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,61 +1,72 @@ -require 'rdoc/task' -require 'rails/api/task' +begin + require 'rdoc/task' +rescue LoadError + # Rubinius installs RDoc as a gem, and for this interpreter "rdoc/task" is + # available only if the application bundle includes "rdoc" (normally as a + # dependency of the "sdoc" gem.) + # + # If RDoc is not available it is fine that we do not generate the tasks that + # depend on it. Just be robust to this gotcha and go on. +else + require 'rails/api/task' -# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise -class RDocTaskWithoutDescriptions < RDoc::Task - include ::Rake::DSL + # Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise + class RDocTaskWithoutDescriptions < RDoc::Task + include ::Rake::DSL - def define - task rdoc_task_name + def define + task rdoc_task_name - task rerdoc_task_name => [clobber_task_name, rdoc_task_name] + task rerdoc_task_name => [clobber_task_name, rdoc_task_name] - task clobber_task_name do - rm_r rdoc_dir rescue nil - end + task clobber_task_name do + rm_r rdoc_dir rescue nil + end - task :clobber => [clobber_task_name] + task :clobber => [clobber_task_name] - directory @rdoc_dir - task rdoc_task_name => [rdoc_target] - file rdoc_target => @rdoc_files + [Rake.application.rakefile] do - rm_r @rdoc_dir rescue nil - @before_running_rdoc.call if @before_running_rdoc - args = option_list + @rdoc_files - if @external - argstring = args.join(' ') - sh %{ruby -Ivendor vendor/rd #{argstring}} - else - require 'rdoc/rdoc' - RDoc::RDoc.new.document(args) + directory @rdoc_dir + task rdoc_task_name => [rdoc_target] + file rdoc_target => @rdoc_files + [Rake.application.rakefile] do + rm_r @rdoc_dir rescue nil + @before_running_rdoc.call if @before_running_rdoc + args = option_list + @rdoc_files + if @external + argstring = args.join(' ') + sh %{ruby -Ivendor vendor/rd #{argstring}} + else + require 'rdoc/rdoc' + RDoc::RDoc.new.document(args) + end end + self end - self end -end -namespace :doc do - def gem_path(gem_name) - path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first - yield File.dirname(path) if path - end + namespace :doc do + def gem_path(gem_name) + path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first + yield File.dirname(path) if path + end - RDocTaskWithoutDescriptions.new("app") { |rdoc| - rdoc.rdoc_dir = 'doc/app' - rdoc.template = ENV['template'] if ENV['template'] - rdoc.title = ENV['title'] || "Rails Application Documentation" - rdoc.options << '--line-numbers' - rdoc.options << '--charset' << 'utf-8' - rdoc.rdoc_files.include('README.rdoc') - rdoc.rdoc_files.include('app/**/*.rb') - rdoc.rdoc_files.include('lib/**/*.rb') - } - Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")" + RDocTaskWithoutDescriptions.new("app") { |rdoc| + rdoc.rdoc_dir = 'doc/app' + rdoc.template = ENV['template'] if ENV['template'] + rdoc.title = ENV['title'] || "Rails Application Documentation" + rdoc.options << '--line-numbers' + rdoc.options << '--charset' << 'utf-8' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('app/**/*.rb') + rdoc.rdoc_files.include('lib/**/*.rb') + } + Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")" - # desc 'Generate documentation for the Rails framework.' - Rails::API::AppTask.new('rails') + # desc 'Generate documentation for the Rails framework.' + Rails::API::AppTask.new('rails') + end +end - # desc "Generate Rails Guides" +namespace :doc do task :guides do rails_gem_dir = Gem::Specification.find_by_name("rails").gem_dir require File.expand_path(File.join(rails_gem_dir, "/guides/rails_guides")) -- cgit v1.2.3 From 3073c531983de243219fb55be93fbcebfdd9c44e Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Mon, 6 May 2013 17:38:45 -0700 Subject: Updates to make rails 4 happy with minitest 5: + Namespace changes, overhaul of runners. + Internal ivar name changes - Removed a logger globally applied to tests that spew everywhere?!? + Override Minitest#__run to sort tests by name. + Reworked testing isolation to work with the new cleaner architecture. - Removed a bunch of tests that just test minitest straight up. I think these changes were all merged to minitest 4 a long time ago. - Minor report output differences. --- railties/test/application/rake_test.rb | 4 ++-- railties/test/application/test_runner_test.rb | 20 ++++++++++---------- .../test/generators/plugin_new_generator_test.rb | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'railties') diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index fa3ab969ae..6703f8df51 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -214,7 +214,7 @@ module ApplicationTests bundle exec rake db:migrate db:test:clone test` end - assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output) + assert_match(/7 runs, 13 assertions, 0 failures, 0 errors/, output) assert_no_match(/Errors running/, output) end @@ -224,7 +224,7 @@ module ApplicationTests bundle exec rake db:migrate db:test:clone test` end - assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output) + assert_match(/7 runs, 13 assertions, 0 failures, 0 errors/, output) assert_no_match(/Errors running/, output) end diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 1cf53aa4fb..118f22995e 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -32,13 +32,13 @@ module ApplicationTests def test_run_single_file create_test_file :models, 'foo' create_test_file :models, 'bar' - assert_match "1 tests, 1 assertions, 0 failures", run_test_command("test/models/foo_test.rb") + assert_match "1 runs, 1 assertions, 0 failures", run_test_command("test/models/foo_test.rb") end def test_run_multiple_files create_test_file :models, 'foo' create_test_file :models, 'bar' - assert_match "2 tests, 2 assertions, 0 failures", run_test_command("test/models/foo_test.rb test/models/bar_test.rb") + assert_match "2 runs, 2 assertions, 0 failures", run_test_command("test/models/foo_test.rb test/models/bar_test.rb") end def test_run_file_with_syntax_error @@ -59,7 +59,7 @@ module ApplicationTests run_test_models_command.tap do |output| assert_match "FooTest", output assert_match "BarTest", output - assert_match "2 tests, 2 assertions, 0 failures", output + assert_match "2 runs, 2 assertions, 0 failures", output end end @@ -70,7 +70,7 @@ module ApplicationTests run_test_helpers_command.tap do |output| assert_match "FooHelperTest", output assert_match "BarHelperTest", output - assert_match "2 tests, 2 assertions, 0 failures", output + assert_match "2 runs, 2 assertions, 0 failures", output end end @@ -83,7 +83,7 @@ module ApplicationTests assert_match "FooTest", output assert_match "BarHelperTest", output assert_match "BazUnitTest", output - assert_match "3 tests, 3 assertions, 0 failures", output + assert_match "3 runs, 3 assertions, 0 failures", output end end @@ -94,7 +94,7 @@ module ApplicationTests run_test_controllers_command.tap do |output| assert_match "FooControllerTest", output assert_match "BarControllerTest", output - assert_match "2 tests, 2 assertions, 0 failures", output + assert_match "2 runs, 2 assertions, 0 failures", output end end @@ -105,7 +105,7 @@ module ApplicationTests run_test_mailers_command.tap do |output| assert_match "FooMailerTest", output assert_match "BarMailerTest", output - assert_match "2 tests, 2 assertions, 0 failures", output + assert_match "2 runs, 2 assertions, 0 failures", output end end @@ -118,7 +118,7 @@ module ApplicationTests assert_match "FooMailerTest", output assert_match "BarControllerTest", output assert_match "BazFunctionalTest", output - assert_match "3 tests, 3 assertions, 0 failures", output + assert_match "3 runs, 3 assertions, 0 failures", output end end @@ -127,7 +127,7 @@ module ApplicationTests create_test_file :models, 'foo' run_test_integration_command.tap do |output| assert_match "FooIntegration", output - assert_match "1 tests, 1 assertions, 0 failures", output + assert_match "1 runs, 1 assertions, 0 failures", output end end @@ -136,7 +136,7 @@ module ApplicationTests suites.each { |suite| create_test_file suite, "foo_#{suite}" } run_test_command('') .tap do |output| suites.each { |suite| assert_match "Foo#{suite.to_s.camelize}Test", output } - assert_match "7 tests, 7 assertions, 0 failures", output + assert_match "7 runs, 7 assertions, 0 failures", output end end diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index ac71fb5884..32c7612a8f 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -168,14 +168,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase run_generator FileUtils.cd destination_root quietly { system 'bundle install' } - assert_match(/1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`) + assert_match(/1 runs, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`) end def test_ensure_that_tests_works_in_full_mode run_generator [destination_root, "--full", "--skip_active_record"] FileUtils.cd destination_root quietly { system 'bundle install' } - assert_match(/1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`) + assert_match(/1 runs, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`) end def test_ensure_that_migration_tasks_work_with_mountable_option -- cgit v1.2.3 From b5429eec6084cfe9f1283620391f81e3f6fefda4 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Tue, 7 May 2013 22:34:11 +0530 Subject: Fix Typo existant -> existent [ci skip] --- railties/test/generators/shared_generator_tests.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 2724882a23..369a0ee46c 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -77,9 +77,9 @@ module SharedGeneratorTests end def test_template_raises_an_error_with_invalid_path - content = capture(:stderr){ run_generator([destination_root, "-m", "non/existant/path"]) } + content = capture(:stderr){ run_generator([destination_root, "-m", "non/existent/path"]) } assert_match(/The template \[.*\] could not be loaded/, content) - assert_match(/non\/existant\/path/, content) + assert_match(/non\/existent\/path/, content) end def test_template_is_executed_when_supplied -- cgit v1.2.3 From cd3177d315cd537a2810a27e0aff7e3a7af111f2 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 9 May 2013 08:36:37 +0200 Subject: "rails" -> "Rails" [ci skip] --- .../lib/rails/generators/rails/app/templates/config/environment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/environment.rb b/railties/lib/rails/generators/rails/app/templates/config/environment.rb index 00a613ff04..ee8d90dc65 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application. +# Load the Rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application. +# Initialize the Rails application. Rails.application.initialize! -- cgit v1.2.3 From 39b8b8fdbf6c175a64f07198ff1c950e33c72cd0 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Thu, 9 May 2013 17:27:08 +0530 Subject: rails -> Rails [ci skip] --- railties/lib/rails/engine.rb | 2 +- railties/lib/rails/engine/commands.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index bfb9b456db..8000fc3b1e 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -447,7 +447,7 @@ module Rails self end - # Load rails generators and invoke the registered hooks. + # Load Rails generators and invoke the registered hooks. # Check Rails::Railtie.generators for more info. def load_generators(app=self) require "rails/generators" diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb index 072d16291b..f39f926109 100644 --- a/railties/lib/rails/engine/commands.rb +++ b/railties/lib/rails/engine/commands.rb @@ -27,7 +27,7 @@ else puts <<-EOT Usage: rails COMMAND [ARGS] -The common rails commands available for engines are: +The common Rails commands available for engines are: generate Generate new code (short-cut alias: "g") destroy Undo code generated with "generate" (short-cut alias: "d") -- cgit v1.2.3 From 430e5dce42523066368d46f6d5a769dd1ffcd743 Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Fri, 10 May 2013 13:04:40 -0500 Subject: Removed jruby-openssl gem from default template Gemfile --- railties/lib/rails/generators/rails/app/templates/Gemfile | 2 -- railties/test/generators/app_generator_test.rb | 3 --- 2 files changed, 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 243e7e9da8..577ff651e5 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -4,8 +4,6 @@ source 'https://rubygems.org' <%= database_gemfile_entry -%> -<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%> - <%= assets_gemfile_entry %> <%= javascript_gemfile_entry -%> diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 0ffb615764..e992534938 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -183,9 +183,6 @@ class AppGeneratorTest < Rails::Generators::TestCase run_generator([destination_root, "-d", "jdbcmysql"]) assert_file "config/database.yml", /mysql/ assert_gem "activerecord-jdbcmysql-adapter" - # TODO: When the JRuby guys merge jruby-openssl in - # jruby this will be removed - assert_gem "jruby-openssl" if defined?(JRUBY_VERSION) end def test_config_jdbcsqlite3_database -- cgit v1.2.3 From 524f09a5e7fe8f8a8ee1bdbaa32a944e1981f10c Mon Sep 17 00:00:00 2001 From: Teng Siong Ong Date: Sat, 11 May 2013 03:12:59 -0700 Subject: Clean up unused method for `rake doc`. --- railties/lib/rails/tasks/documentation.rake | 5 ----- 1 file changed, 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index d45e892424..8544890553 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -44,11 +44,6 @@ else end namespace :doc do - def gem_path(gem_name) - path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first - yield File.dirname(path) if path - end - RDocTaskWithoutDescriptions.new("app") { |rdoc| rdoc.rdoc_dir = 'doc/app' rdoc.template = ENV['template'] if ENV['template'] -- cgit v1.2.3 From bde14bef61b16fe3f7190f66cf9d93f14c4c7b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Sun, 12 May 2013 22:55:41 +0200 Subject: better error message when app name is not passed in `rails new` Prior to this change, for the following command: $ rails new we received "Options should be given after the application name" as an error message. This is outdated and should be "Application name should be provided in arguments". --- railties/lib/rails/generators/rails/app/app_generator.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 5877579fc4..d48dcf9ef3 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -151,7 +151,15 @@ module Rails desc: "Show Rails version number and quit" def initialize(*args) - raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank? + if args[0].blank? + if args[1].blank? + # rails new + raise Error, "Application name should be provided in arguments. For details run: rails --help" + else + # rails new --skip-bundle my_new_application + raise Error, "Options should be given after the application name. For details run: rails --help" + end + end super -- cgit v1.2.3 From 2a57cbc762ef9c8c9aca7965a2b863486000ab65 Mon Sep 17 00:00:00 2001 From: AJ Acevedo Date: Sun, 12 May 2013 22:47:25 -0400 Subject: Updated comment to Rails 4 --- railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt b/railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt index aa87d1b50c..c8de9f3e0f 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt +++ b/railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt @@ -1,4 +1,4 @@ -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. ENGINE_ROOT = File.expand_path('../..', __FILE__) ENGINE_PATH = File.expand_path('../../lib/<%= name -%>/engine', __FILE__) -- cgit v1.2.3 From 886f439cb58e96bc0249a7146a0a490849608091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Mon, 13 May 2013 12:14:47 +0200 Subject: exit with non-zero to signal failure --- railties/lib/rails/commands/console.rb | 4 ++-- railties/lib/rails/rack/debugger.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 96229bb4f6..f6bdf129d6 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -94,8 +94,8 @@ module Rails require 'debugger' puts "=> Debugger enabled" rescue LoadError - puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle, and try again." - exit + puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again." + exit(1) end end end diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index 902361ce77..f7b77bcb3b 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -12,8 +12,8 @@ module Rails ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) puts "=> Debugger enabled" rescue LoadError - puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle, and try again." - exit + puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again." + exit(1) end def call(env) -- cgit v1.2.3 From 877920ba55d99eac1d68859f4f83d626645afa3e Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 15 May 2013 11:38:49 +0700 Subject: Removed incorrect warning from application.js templates and replaced it with stub command description --- .../rails/app/templates/app/assets/javascripts/application.js.tt | 3 +-- .../rails/generators/rails/plugin_new/templates/rails/javascripts.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt index 7342bffd9d..6899dfe9c9 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt @@ -7,8 +7,7 @@ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. +// stub path allows dependency to be excluded from the asset bundle. // <% unless options[:skip_javascript] -%> //= require <%= options[:javascript] %> diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js b/railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js index 084d5d1c49..f84de00fd3 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js +++ b/railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js @@ -7,7 +7,6 @@ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. +// stub path allows dependency to be excluded from the asset bundle. // //= require_tree . -- cgit v1.2.3 From 46faadfacc70254ebfe693c662b6883556147dac Mon Sep 17 00:00:00 2001 From: Colin Bartlett Date: Thu, 16 May 2013 00:49:17 -0400 Subject: Remove trailing line break If you generate a fresh app without ActiverRecord, this template exhibited a lone trailing line break. My watchful pre-commit hook told me about it so I've fixed it here. --- .../rails/app/templates/config/initializers/wrap_parameters.rb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt index 4f1d56cd2f..f2110c2c70 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt @@ -7,8 +7,8 @@ ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end - <%- unless options.skip_active_record? -%> + # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true -- cgit v1.2.3 From f96478369e0e01a00d1d6909814d388c49642b1a Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 16 May 2013 11:04:07 -0400 Subject: restore whitespace in Gemfile between sqlite3 and sprockets --- railties/lib/rails/generators/app_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 853d6fa4b9..675ada7ed0 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -116,7 +116,7 @@ module Rails def database_gemfile_entry options[:skip_active_record] ? "" : - <<-GEMFILE.strip_heredoc.chomp + <<-GEMFILE.strip_heredoc # Use #{options[:database]} as the database for Active Record gem '#{gem_for_database}' GEMFILE -- cgit v1.2.3 From 00e43ccc363deae6e426f0d1a6e444a4351bf6aa Mon Sep 17 00:00:00 2001 From: AJ Acevedo Date: Thu, 16 May 2013 21:02:39 -0400 Subject: plugin new missing license spec When bundling a gem created with rails plugin new Bundler outputs the following warning when building the gem: WARNING: licenses is empty modified: railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec --- railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec | 1 + 1 file changed, 1 insertion(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec index f7c12e67dd..5fdf0e1554 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec @@ -12,6 +12,7 @@ Gem::Specification.new do |s| s.homepage = "TODO" s.summary = "TODO: Summary of <%= camelized %>." s.description = "TODO: Description of <%= camelized %>." + s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] <% unless options.skip_test_unit? -%> -- cgit v1.2.3