From bd360ad3c1d59273bf96ea01b17cf04285816dc2 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 10 Dec 2013 13:50:57 -0200 Subject: Rename not Ruby files to .tt --- .../rails/app/templates/config/application.rb | 34 ----------- .../rails/app/templates/config/application.rb.tt | 34 +++++++++++ .../rails/app/templates/test/test_helper.rb | 17 ------ .../rails/app/templates/test/test_helper.rb.tt | 17 ++++++ .../rails/controller/templates/controller.rb | 13 ----- .../rails/controller/templates/controller.rb.tt | 13 +++++ .../generators/rails/helper/templates/helper.rb | 4 -- .../generators/rails/helper/templates/helper.rb.tt | 4 ++ .../rails/plugin/templates/config/routes.rb | 6 -- .../rails/plugin/templates/config/routes.rb.tt | 6 ++ .../rails/plugin/templates/lib/%name%/engine.rb | 7 --- .../rails/plugin/templates/lib/%name%/engine.rb.tt | 7 +++ .../rails/plugin/templates/lib/%name%/version.rb | 3 - .../plugin/templates/lib/%name%/version.rb.tt | 3 + .../templates/test/integration/navigation_test.rb | 12 ---- .../test/integration/navigation_test.rb.tt | 12 ++++ .../scaffold_controller/templates/controller.rb | 68 ---------------------- .../scaffold_controller/templates/controller.rb.tt | 68 ++++++++++++++++++++++ .../rails/generators/rails/task/templates/task.rb | 8 --- .../generators/rails/task/templates/task.rb.tt | 8 +++ .../controller/templates/functional_test.rb | 19 ------ .../controller/templates/functional_test.rb.tt | 19 ++++++ .../generator/templates/generator_test.rb | 16 ----- .../generator/templates/generator_test.rb.tt | 16 +++++ .../test_unit/helper/templates/helper_test.rb | 6 -- .../test_unit/helper/templates/helper_test.rb.tt | 6 ++ .../integration/templates/integration_test.rb | 7 --- .../integration/templates/integration_test.rb.tt | 7 +++ .../test_unit/mailer/templates/functional_test.rb | 21 ------- .../mailer/templates/functional_test.rb.tt | 21 +++++++ .../scaffold/templates/functional_test.rb | 51 ---------------- .../scaffold/templates/functional_test.rb.tt | 51 ++++++++++++++++ 32 files changed, 292 insertions(+), 292 deletions(-) delete mode 100644 railties/lib/rails/generators/rails/app/templates/config/application.rb create mode 100644 railties/lib/rails/generators/rails/app/templates/config/application.rb.tt delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/test_helper.rb create mode 100644 railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt delete mode 100644 railties/lib/rails/generators/rails/controller/templates/controller.rb create mode 100644 railties/lib/rails/generators/rails/controller/templates/controller.rb.tt delete mode 100644 railties/lib/rails/generators/rails/helper/templates/helper.rb create mode 100644 railties/lib/rails/generators/rails/helper/templates/helper.rb.tt delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/config/routes.rb create mode 100644 railties/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb create mode 100644 railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb.tt delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb create mode 100644 railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb.tt delete mode 100644 railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb create mode 100644 railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt delete mode 100644 railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb create mode 100644 railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt delete mode 100644 railties/lib/rails/generators/rails/task/templates/task.rb create mode 100644 railties/lib/rails/generators/rails/task/templates/task.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb create mode 100644 railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb create mode 100644 railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb create mode 100644 railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb deleted file mode 100644 index 16fe50bab8..0000000000 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.expand_path('../boot', __FILE__) - -<% if include_all_railties? -%> -require 'rails/all' -<% else -%> -# Pick the frameworks you want: -require "active_model/railtie" -<%= comment_if :skip_active_record %>require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -<%= comment_if :skip_action_view %>require "action_view/railtie" -<%= comment_if :skip_sprockets %>require "sprockets/railtie" -<%= comment_if :skip_test_unit %>require "rails/test_unit/railtie" -<% end -%> - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) - -module <%= app_const_base %> - class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - end -end diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/application.rb.tt new file mode 100644 index 0000000000..16fe50bab8 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb.tt @@ -0,0 +1,34 @@ +require File.expand_path('../boot', __FILE__) + +<% if include_all_railties? -%> +require 'rails/all' +<% else -%> +# Pick the frameworks you want: +require "active_model/railtie" +<%= comment_if :skip_active_record %>require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +<%= comment_if :skip_action_view %>require "action_view/railtie" +<%= comment_if :skip_sprockets %>require "sprockets/railtie" +<%= comment_if :skip_test_unit %>require "rails/test_unit/railtie" +<% end -%> + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module <%= app_const_base %> + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb deleted file mode 100644 index 4fd060341e..0000000000 --- a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -ENV["RAILS_ENV"] ||= "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase -<% unless options[:skip_active_record] -%> - ActiveRecord::Migration.check_pending! - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - -<% end -%> - # Add more helper methods to be used by all tests here... -end diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt new file mode 100644 index 0000000000..4fd060341e --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt @@ -0,0 +1,17 @@ +ENV["RAILS_ENV"] ||= "test" +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase +<% unless options[:skip_active_record] -%> + ActiveRecord::Migration.check_pending! + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + +<% end -%> + # Add more helper methods to be used by all tests here... +end diff --git a/railties/lib/rails/generators/rails/controller/templates/controller.rb b/railties/lib/rails/generators/rails/controller/templates/controller.rb deleted file mode 100644 index 633e0b3177..0000000000 --- a/railties/lib/rails/generators/rails/controller/templates/controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -<% if namespaced? -%> -require_dependency "<%= namespaced_path %>/application_controller" - -<% end -%> -<% module_namespacing do -%> -class <%= class_name %>Controller < ApplicationController -<% actions.each do |action| -%> - def <%= action %> - end -<%= "\n" unless action == actions.last -%> -<% end -%> -end -<% end -%> diff --git a/railties/lib/rails/generators/rails/controller/templates/controller.rb.tt b/railties/lib/rails/generators/rails/controller/templates/controller.rb.tt new file mode 100644 index 0000000000..633e0b3177 --- /dev/null +++ b/railties/lib/rails/generators/rails/controller/templates/controller.rb.tt @@ -0,0 +1,13 @@ +<% if namespaced? -%> +require_dependency "<%= namespaced_path %>/application_controller" + +<% end -%> +<% module_namespacing do -%> +class <%= class_name %>Controller < ApplicationController +<% actions.each do |action| -%> + def <%= action %> + end +<%= "\n" unless action == actions.last -%> +<% end -%> +end +<% end -%> diff --git a/railties/lib/rails/generators/rails/helper/templates/helper.rb b/railties/lib/rails/generators/rails/helper/templates/helper.rb deleted file mode 100644 index b4173151b4..0000000000 --- a/railties/lib/rails/generators/rails/helper/templates/helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -<% module_namespacing do -%> -module <%= class_name %>Helper -end -<% end -%> diff --git a/railties/lib/rails/generators/rails/helper/templates/helper.rb.tt b/railties/lib/rails/generators/rails/helper/templates/helper.rb.tt new file mode 100644 index 0000000000..b4173151b4 --- /dev/null +++ b/railties/lib/rails/generators/rails/helper/templates/helper.rb.tt @@ -0,0 +1,4 @@ +<% module_namespacing do -%> +module <%= class_name %>Helper +end +<% end -%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb b/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb deleted file mode 100644 index 8e158d5831..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb +++ /dev/null @@ -1,6 +0,0 @@ -<% if mountable? -%> -<%= camelized %>::Engine.routes.draw do -<% else -%> -Rails.application.routes.draw do -<% end -%> -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt new file mode 100644 index 0000000000..8e158d5831 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt @@ -0,0 +1,6 @@ +<% if mountable? -%> +<%= camelized %>::Engine.routes.draw do +<% else -%> +Rails.application.routes.draw do +<% end -%> +end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb deleted file mode 100644 index 967668fe66..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +++ /dev/null @@ -1,7 +0,0 @@ -module <%= camelized %> - class Engine < ::Rails::Engine -<% if mountable? -%> - isolate_namespace <%= camelized %> -<% end -%> - end -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb.tt new file mode 100644 index 0000000000..967668fe66 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb.tt @@ -0,0 +1,7 @@ +module <%= camelized %> + class Engine < ::Rails::Engine +<% if mountable? -%> + isolate_namespace <%= camelized %> +<% end -%> + end +end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb deleted file mode 100644 index ef07ef2e19..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module <%= camelized %> - VERSION = "0.0.1" -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb.tt new file mode 100644 index 0000000000..ef07ef2e19 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb.tt @@ -0,0 +1,3 @@ +module <%= camelized %> + VERSION = "0.0.1" +end diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb b/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb deleted file mode 100644 index 824caecb24..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test_helper' - -class NavigationTest < ActionDispatch::IntegrationTest -<% unless options[:skip_active_record] -%> - fixtures :all -<% end -%> - - # test "the truth" do - # assert true - # end -end - diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt new file mode 100644 index 0000000000..824caecb24 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt @@ -0,0 +1,12 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest +<% unless options[:skip_active_record] -%> + fixtures :all +<% end -%> + + # test "the truth" do + # assert true + # end +end + diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb deleted file mode 100644 index 0e69aa101f..0000000000 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ /dev/null @@ -1,68 +0,0 @@ -<% if namespaced? -%> -require_dependency "<%= namespaced_file_path %>/application_controller" - -<% end -%> -<% module_namespacing do -%> -class <%= controller_class_name %>Controller < ApplicationController - before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy] - - # GET <%= route_url %> - def index - @<%= plural_table_name %> = <%= orm_class.all(class_name) %> - end - - # GET <%= route_url %>/1 - def show - end - - # GET <%= route_url %>/new - def new - @<%= singular_table_name %> = <%= orm_class.build(class_name) %> - end - - # GET <%= route_url %>/1/edit - def edit - end - - # POST <%= route_url %> - def create - @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %> - - if @<%= orm_instance.save %> - redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %> - else - render action: 'new' - end - end - - # PATCH/PUT <%= route_url %>/1 - def update - if @<%= orm_instance.update("#{singular_table_name}_params") %> - redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> - else - render action: 'edit' - end - end - - # DELETE <%= route_url %>/1 - def destroy - @<%= orm_instance.destroy %> - redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %> - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_<%= singular_table_name %> - @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> - end - - # Only allow a trusted parameter "white list" through. - def <%= "#{singular_table_name}_params" %> - <%- if attributes_names.empty? -%> - params[:<%= singular_table_name %>] - <%- else -%> - params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>) - <%- end -%> - end -end -<% end -%> diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt new file mode 100644 index 0000000000..0e69aa101f --- /dev/null +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt @@ -0,0 +1,68 @@ +<% if namespaced? -%> +require_dependency "<%= namespaced_file_path %>/application_controller" + +<% end -%> +<% module_namespacing do -%> +class <%= controller_class_name %>Controller < ApplicationController + before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy] + + # GET <%= route_url %> + def index + @<%= plural_table_name %> = <%= orm_class.all(class_name) %> + end + + # GET <%= route_url %>/1 + def show + end + + # GET <%= route_url %>/new + def new + @<%= singular_table_name %> = <%= orm_class.build(class_name) %> + end + + # GET <%= route_url %>/1/edit + def edit + end + + # POST <%= route_url %> + def create + @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %> + + if @<%= orm_instance.save %> + redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %> + else + render action: 'new' + end + end + + # PATCH/PUT <%= route_url %>/1 + def update + if @<%= orm_instance.update("#{singular_table_name}_params") %> + redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> + else + render action: 'edit' + end + end + + # DELETE <%= route_url %>/1 + def destroy + @<%= orm_instance.destroy %> + redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %> + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_<%= singular_table_name %> + @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> + end + + # Only allow a trusted parameter "white list" through. + def <%= "#{singular_table_name}_params" %> + <%- if attributes_names.empty? -%> + params[:<%= singular_table_name %>] + <%- else -%> + params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>) + <%- end -%> + end +end +<% end -%> diff --git a/railties/lib/rails/generators/rails/task/templates/task.rb b/railties/lib/rails/generators/rails/task/templates/task.rb deleted file mode 100644 index 1e3ed5f158..0000000000 --- a/railties/lib/rails/generators/rails/task/templates/task.rb +++ /dev/null @@ -1,8 +0,0 @@ -namespace :<%= file_name %> do -<% actions.each do |action| -%> - desc "TODO" - task <%= action %>: :environment do - end - -<% end -%> -end diff --git a/railties/lib/rails/generators/rails/task/templates/task.rb.tt b/railties/lib/rails/generators/rails/task/templates/task.rb.tt new file mode 100644 index 0000000000..1e3ed5f158 --- /dev/null +++ b/railties/lib/rails/generators/rails/task/templates/task.rb.tt @@ -0,0 +1,8 @@ +namespace :<%= file_name %> do +<% actions.each do |action| -%> + desc "TODO" + task <%= action %>: :environment do + end + +<% end -%> +end diff --git a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb deleted file mode 100644 index 509bd60564..0000000000 --- a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>ControllerTest < ActionController::TestCase -<% if actions.empty? -%> - # test "the truth" do - # assert true - # end -<% else -%> -<% actions.each do |action| -%> - test "should get <%= action %>" do - get :<%= action %> - assert_response :success - end - -<% end -%> -<% end -%> -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt new file mode 100644 index 0000000000..509bd60564 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt @@ -0,0 +1,19 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>ControllerTest < ActionController::TestCase +<% if actions.empty? -%> + # test "the truth" do + # assert true + # end +<% else -%> +<% actions.each do |action| -%> + test "should get <%= action %>" do + get :<%= action %> + assert_response :success + end + +<% end -%> +<% end -%> +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb deleted file mode 100644 index a7f1fc4fba..0000000000 --- a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'test_helper' -require '<%= generator_path %>' - -<% module_namespacing do -%> -class <%= class_name %>GeneratorTest < Rails::Generators::TestCase - tests <%= class_name %>Generator - destination Rails.root.join('tmp/generators') - setup :prepare_destination - - # test "generator runs without errors" do - # assert_nothing_raised do - # run_generator ["arguments"] - # end - # end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt new file mode 100644 index 0000000000..a7f1fc4fba --- /dev/null +++ b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt @@ -0,0 +1,16 @@ +require 'test_helper' +require '<%= generator_path %>' + +<% module_namespacing do -%> +class <%= class_name %>GeneratorTest < Rails::Generators::TestCase + tests <%= class_name %>Generator + destination Rails.root.join('tmp/generators') + setup :prepare_destination + + # test "generator runs without errors" do + # assert_nothing_raised do + # run_generator ["arguments"] + # end + # end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb b/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb deleted file mode 100644 index 7d37bda0f9..0000000000 --- a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>HelperTest < ActionView::TestCase -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb.tt b/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb.tt new file mode 100644 index 0000000000..7d37bda0f9 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb.tt @@ -0,0 +1,6 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>HelperTest < ActionView::TestCase +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb b/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb deleted file mode 100644 index dea7e22196..0000000000 --- a/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end diff --git a/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt b/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt new file mode 100644 index 0000000000..dea7e22196 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt @@ -0,0 +1,7 @@ +require 'test_helper' + +class <%= class_name %>Test < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb deleted file mode 100644 index 7e204105a3..0000000000 --- a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>Test < ActionMailer::TestCase -<% actions.each do |action| -%> - test "<%= action %>" do - mail = <%= class_name %>.<%= action %> - assert_equal <%= action.to_s.humanize.inspect %>, mail.subject - assert_equal ["to@example.org"], mail.to - assert_equal ["from@example.com"], mail.from - assert_match "Hi", mail.body.encoded - end - -<% end -%> -<% if actions.blank? -%> - # test "the truth" do - # assert true - # end -<% end -%> -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt new file mode 100644 index 0000000000..7e204105a3 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt @@ -0,0 +1,21 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>Test < ActionMailer::TestCase +<% actions.each do |action| -%> + test "<%= action %>" do + mail = <%= class_name %>.<%= action %> + assert_equal <%= action.to_s.humanize.inspect %>, mail.subject + assert_equal ["to@example.org"], mail.to + assert_equal ["from@example.com"], mail.from + assert_match "Hi", mail.body.encoded + end + +<% end -%> +<% if actions.blank? -%> + # test "the truth" do + # assert true + # end +<% end -%> +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb deleted file mode 100644 index 18bd1ece9d..0000000000 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= controller_class_name %>ControllerTest < ActionController::TestCase - setup do - @<%= singular_table_name %> = <%= table_name %>(:one) - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:<%= table_name %>) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create <%= singular_table_name %>" do - assert_difference('<%= class_name %>.count') do - post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %> - end - - assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>)) - end - - test "should show <%= singular_table_name %>" do - get :show, id: <%= "@#{singular_table_name}" %> - assert_response :success - end - - test "should get edit" do - get :edit, id: <%= "@#{singular_table_name}" %> - assert_response :success - end - - test "should update <%= singular_table_name %>" do - patch :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> - assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>)) - end - - test "should destroy <%= singular_table_name %>" do - assert_difference('<%= class_name %>.count', -1) do - delete :destroy, id: <%= "@#{singular_table_name}" %> - end - - assert_redirected_to <%= index_helper %>_path - end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt new file mode 100644 index 0000000000..18bd1ece9d --- /dev/null +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt @@ -0,0 +1,51 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= controller_class_name %>ControllerTest < ActionController::TestCase + setup do + @<%= singular_table_name %> = <%= table_name %>(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:<%= table_name %>) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create <%= singular_table_name %>" do + assert_difference('<%= class_name %>.count') do + post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %> + end + + assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>)) + end + + test "should show <%= singular_table_name %>" do + get :show, id: <%= "@#{singular_table_name}" %> + assert_response :success + end + + test "should get edit" do + get :edit, id: <%= "@#{singular_table_name}" %> + assert_response :success + end + + test "should update <%= singular_table_name %>" do + patch :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> + assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>)) + end + + test "should destroy <%= singular_table_name %>" do + assert_difference('<%= class_name %>.count', -1) do + delete :destroy, id: <%= "@#{singular_table_name}" %> + end + + assert_redirected_to <%= index_helper %>_path + end +end +<% end -%> -- cgit v1.2.3