diff options
author | Xavier Noria <fxn@hashref.com> | 2012-02-22 09:00:53 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-02-22 09:00:53 -0800 |
commit | 7f2548e34d79c47ca138ca0378f4a06390c407f1 (patch) | |
tree | 4807b806fe8f3cfe30314fc522599b776e4a6d36 /railties/test | |
parent | f28d9f15482addeb95ab05545b7a8467a4e0182d (diff) | |
parent | 002713c64568114f3754799acc0723ea0d442f7a (diff) | |
download | rails-7f2548e34d79c47ca138ca0378f4a06390c407f1.tar.gz rails-7f2548e34d79c47ca138ca0378f4a06390c407f1.tar.bz2 rails-7f2548e34d79c47ca138ca0378f4a06390c407f1.zip |
Merge pull request #5130 from dlee/revised_patch_verb
Add config.default_method_for_update to support PATCH
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/configuration_test.rb | 47 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 5 |
2 files changed, 50 insertions, 2 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 3dffd1c74c..bf44a8b10b 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -146,7 +146,7 @@ module ApplicationTests test "frameworks are not preloaded by default" do require "#{app_path}/config/environment" - assert ActionController.autoload?(:RecordIdentifier) + assert ActionController.autoload?(:Caching) end test "frameworks are preloaded with config.preload_frameworks is set" do @@ -156,7 +156,7 @@ module ApplicationTests require "#{app_path}/config/environment" - assert !ActionController.autoload?(:RecordIdentifier) + assert !ActionController.autoload?(:Caching) end test "filter_parameters should be able to set via config.filter_parameters" do @@ -246,6 +246,49 @@ module ApplicationTests assert last_response.body =~ /csrf\-param/ end + test "default method for update can be changed" do + app_file 'app/models/post.rb', <<-RUBY + class Post + extend ActiveModel::Naming + def to_key; [1]; end + def persisted?; true; end + end + RUBY + + app_file 'app/controllers/posts_controller.rb', <<-RUBY + class PostsController < ApplicationController + def show + render :inline => "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>" + end + + def update + render :text => "update" + end + end + RUBY + + add_to_config <<-RUBY + config.default_method_for_update = :patch + routes.prepend do + resources :posts + end + RUBY + + require "#{app_path}/config/environment" + + assert_equal ActionView::Base.default_method_for_update, :patch + assert_equal ActionDispatch::Routing::Mapper.default_method_for_update, :patch + + get "/posts/1" + assert_match /patch/, last_response.body + + patch "/posts/1" + assert_match /update/, last_response.body + + put "/posts/1" + assert_equal 404, last_response.status + end + test "request forgery token param can be changed" do make_basic_app do app.config.action_controller.request_forgery_protection_token = '_xsrf_token_here' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index a3c24c392b..55c7ce1047 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -325,6 +325,11 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ end + def test_default_method_for_update_is_not_patch + run_generator [destination_root, "--skip-test-unit", "--skip-active-record"] + assert_file "config/application.rb", /#\s+config\.default_method_for_update\s+=\s+:patch/ + end + def test_new_hash_style run_generator [destination_root] assert_file "config/initializers/session_store.rb" do |file| |