aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-07 22:46:39 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-07 22:46:39 -0300
commitd3af6225867d84bbaccde1af5e1c69f6998e85a5 (patch)
tree3a4d99741adcd39c02c21ba244b93797e034fc77 /railties/test
parentfb9eb7019e5e880807b903bc1c7b3f4f819302eb (diff)
downloadrails-d3af6225867d84bbaccde1af5e1c69f6998e85a5.tar.gz
rails-d3af6225867d84bbaccde1af5e1c69f6998e85a5.tar.bz2
rails-d3af6225867d84bbaccde1af5e1c69f6998e85a5.zip
Stop using mocha on configuration_test
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/configuration_test.rb30
1 files changed, 23 insertions, 7 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 2e056be561..0a563f7a2d 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -66,13 +66,25 @@ module ApplicationTests
config.action_dispatch.show_exceptions = true
RUBY
+ app_file 'db/migrate/20140708012246_create_user.rb', <<-RUBY
+ class CreateUser < ActiveRecord::Migration
+ def change
+ create_table :users
+ end
+ end
+ RUBY
+
require "#{app_path}/config/environment"
- ActiveRecord::Migrator.stubs(:needs_migration?).returns(true)
- ActiveRecord::NullMigration.any_instance.stubs(:mtime).returns(1)
- get "/foo"
- assert_equal 500, last_response.status
- assert_match "ActiveRecord::PendingMigrationError", last_response.body
+ ActiveRecord::Migrator.migrations_paths = ["#{app_path}/db/migrate"]
+
+ begin
+ get "/foo"
+ assert_equal 500, last_response.status
+ assert_match "ActiveRecord::PendingMigrationError", last_response.body
+ ensure
+ ActiveRecord::Migrator.migrations_paths = nil
+ end
end
test "Rails.groups returns available groups" do
@@ -372,6 +384,8 @@ module ApplicationTests
end
RUBY
+ token = "cf50faa3fe97702ca1ae"
+
app_file 'app/controllers/posts_controller.rb', <<-RUBY
class PostsController < ApplicationController
def show
@@ -381,6 +395,10 @@ module ApplicationTests
def update
render text: "update"
end
+
+ private
+
+ def form_authenticity_token; token; end # stub the authenticy token
end
RUBY
@@ -392,8 +410,6 @@ module ApplicationTests
require "#{app_path}/config/environment"
- token = "cf50faa3fe97702ca1ae"
- PostsController.any_instance.stubs(:form_authenticity_token).returns(token)
params = {authenticity_token: token}
get "/posts/1"