Skip to content

Commit

Permalink
Stop using mocha on configuration_test
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Jul 8, 2014
1 parent fb9eb70 commit d3af622
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions railties/test/application/configuration_test.rb
Expand Up @@ -66,13 +66,25 @@ def teardown
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
Expand Down Expand Up @@ -372,6 +384,8 @@ def persisted?; true; end
end
RUBY

token = "cf50faa3fe97702ca1ae"

app_file 'app/controllers/posts_controller.rb', <<-RUBY
class PostsController < ApplicationController
def show
Expand All @@ -381,6 +395,10 @@ def show
def update
render text: "update"
end
private
def form_authenticity_token; token; end # stub the authenticy token
end
RUBY

Expand All @@ -392,8 +410,6 @@ def update

require "#{app_path}/config/environment"

token = "cf50faa3fe97702ca1ae"
PostsController.any_instance.stubs(:form_authenticity_token).returns(token)
params = {authenticity_token: token}

get "/posts/1"
Expand Down

0 comments on commit d3af622

Please sign in to comment.