diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-14 22:30:01 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-14 22:30:01 +0100 |
commit | 6db930cb5bbff9ad824590b5844e04768de240b1 (patch) | |
tree | 2bc3a70028087aed19b398da96de97a53762f43d /railties/lib | |
parent | 1efeb072bf39c3eeef9a0d8874e58a4bd9850db6 (diff) | |
download | rails-6db930cb5bbff9ad824590b5844e04768de240b1.tar.gz rails-6db930cb5bbff9ad824590b5844e04768de240b1.tar.bz2 rails-6db930cb5bbff9ad824590b5844e04768de240b1.zip |
Remove --http.
Diffstat (limited to 'railties/lib')
10 files changed, 7 insertions, 179 deletions
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 0fb463c44d..d81206bdc6 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -6,20 +6,6 @@ require 'rails/rack' module Rails module Configuration - module HttpOnly #:nodoc: - def initialize - @http_only = false - end - - def http_only! - @http_only = true - end - - def http_only? - @http_only - end - end - # MiddlewareStackProxy is a proxy for the Rails middleware stack that allows # you to configure middlewares in your application. It works basically as a # command recorder, saving each command to be applied after initialization @@ -58,10 +44,7 @@ module Rails # Cookies, Session and Flash, BestStandardsSupport, and MethodOverride. You # can always add any of them later manually if you want. class MiddlewareStackProxy - include HttpOnly - def initialize - super @operations = [] end @@ -99,10 +82,7 @@ module Rails attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging attr_reader :hidden_namespaces - include HttpOnly - def initialize - super @aliases = Hash.new { |h,k| h[k] = {} } @options = Hash.new { |h,k| h[k] = {} } @fallbacks = {} diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 3965e05823..b9c1b01f54 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -46,7 +46,6 @@ module Rails :assets => true, :force_plural => false, :helper => true, - :http => false, :integration_tool => nil, :javascripts => true, :javascript_engine => :js, @@ -62,7 +61,6 @@ module Rails } def self.configure!(config) #:nodoc: - http_only! if config.http_only? no_color! unless config.colorize_logging aliases.deep_merge! config.aliases options.deep_merge! config.options @@ -72,7 +70,7 @@ module Rails hide_namespaces(*config.hidden_namespaces) end - def self.templates_path + def self.templates_path #:nodoc: @templates_path ||= [] end @@ -106,25 +104,6 @@ module Rails Thor::Base.shell = Thor::Shell::Basic end - # Configure generators for http only applications. It basically hides - # everything that is usually browser related, such as assets and session - # migration generators, and completely disable views, helpers and assets - # so generators such as scaffold won't create them. - def self.http_only! - hide_namespaces "assets", "css", "js", "session_migration" - - options[:rails].merge!( - :assets => false, - :helper => false, - :http => true, - :javascripts => false, - :javascript_engine => nil, - :stylesheets => false, - :stylesheet_engine => nil, - :template_engine => nil - ) - end - # Track all generators subclasses. def self.subclasses @subclasses ||= [] diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index ffdfb32aba..f0745df667 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -144,9 +144,6 @@ module Rails class AppGenerator < AppBase add_shared_options_for "application" - class_option :http, :type => :boolean, :default => false, - :desc => "Preconfigure smaller stack for HTTP only apps" - # Add bin/rails options class_option :version, :type => :boolean, :aliases => "-v", :group => :rails, :desc => "Show Rails version number and quit" @@ -159,10 +156,6 @@ module Rails if !options[:skip_active_record] && !DATABASES.include?(options[:database]) raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}." end - - # Force sprockets to be skipped when generating http only app. - # Can't modify options hash as it's frozen by default. - self.options = options.merge(:skip_sprockets => true).freeze if options.http? end public_task :create_root @@ -177,7 +170,6 @@ module Rails def create_app_files build(:app) - remove_file("app/views") if options.http? end def create_config_files diff --git a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt index 4dc85ec156..3ddc86ae0a 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt @@ -1,5 +1,5 @@ -class ApplicationController < ActionController::<%= options.http? ? "HTTP" : "Base" %> +class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :reset_session instead. - <%= comment_if :http %>protect_from_forgery :with => :exception -end + protect_from_forgery :with => :exception +end
\ No newline at end of file diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index ba3785be35..c8a3c13b95 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -67,14 +67,5 @@ module <%= app_const_base %> # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' <% end -%> -<% if options.http? -%> - - # Only loads a smaller set of middleware suitable for HTTP only apps. - # Middleware like session, flash, cookies can be added back manually. - config.middleware.http_only! - - # Skip views, helpers and assets when generating a new resource. - config.generators.http_only! -<% end -%> end end diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb index 11326388b4..7c7b289d19 100644 --- a/railties/lib/rails/generators/rails/resource/resource_generator.rb +++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb @@ -21,7 +21,6 @@ module Rails return if options[:actions].present? route_config = regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ") route_config << "resources :#{file_name.pluralize}" - route_config << ", except: :edit" if options.http? route_config << " end" * regular_class_path.size route route_config end diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb index 17d462fa40..083eb49d65 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -14,8 +14,7 @@ module Rails :desc => "Generate controller with HTTP actions only" def create_controller_files - template_file = options.http? ? "http_controller.rb" : "controller.rb" - template template_file, File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") + template "controller.rb", File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") end hook_for :template_engine, :test_framework, :as => :scaffold diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/http_controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/http_controller.rb deleted file mode 100644 index 3f44ac18a4..0000000000 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/http_controller.rb +++ /dev/null @@ -1,60 +0,0 @@ -<% module_namespacing do -%> -class <%= controller_class_name %>Controller < ApplicationController - # GET <%= route_url %> - # GET <%= route_url %>.json - def index - @<%= plural_table_name %> = <%= orm_class.all(class_name) %> - - render json: @<%= plural_table_name %> - end - - # GET <%= route_url %>/1 - # GET <%= route_url %>/1.json - def show - @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> - - render json: @<%= singular_table_name %> - end - - # GET <%= route_url %>/new - # GET <%= route_url %>/new.json - def new - @<%= singular_table_name %> = <%= orm_class.build(class_name) %> - - render json: @<%= singular_table_name %> - end - - # POST <%= route_url %> - # POST <%= route_url %>.json - def create - @<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %> - - if @<%= orm_instance.save %> - render json: @<%= singular_table_name %>, status: :created, location: @<%= singular_table_name %> - else - render json: @<%= orm_instance.errors %>, status: :unprocessable_entity - end - end - - # PATCH/PUT <%= route_url %>/1 - # PATCH/PUT <%= route_url %>/1.json - def update - @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> - - if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %> - head :no_content - else - render json: @<%= orm_instance.errors %>, status: :unprocessable_entity - end - end - - # DELETE <%= route_url %>/1 - # DELETE <%= route_url %>/1.json - def destroy - @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> - @<%= orm_instance.destroy %> - - head :no_content - end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index e875c81340..9e76587a0d 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -14,10 +14,8 @@ module TestUnit :desc => "Generate functional test with HTTP actions only" def create_test_files - template_file = options.http? ? "http_functional_test.rb" : "functional_test.rb" - - template template_file, - File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb") + template "functional_test.rb", + File.join("test/functional", controller_class_path, "#{controller_file_name}_controller_test.rb") end private diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/http_functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/http_functional_test.rb deleted file mode 100644 index 5bb61cb263..0000000000 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/http_functional_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= controller_class_name %>ControllerTest < ActionController::TestCase - setup do - @<%= singular_table_name %> = <%= table_name %>(:one) - @request.accept = "application/json" - 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_response 201 - assert_not_nil assigns(:<%= singular_table_name %>) - end - - test "should show <%= singular_table_name %>" do - get :show, id: @<%= singular_table_name %> - assert_response :success - end - - test "should update <%= singular_table_name %>" do - put :update, id: @<%= singular_table_name %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> - assert_response 204 - assert_not_nil 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_response 204 - assert_not_nil assigns(:<%= singular_table_name %>) - end -end -<% end -%> |