Skip to content

Commit

Permalink
Upgrade Rails to 4.2 and get all specs running
Browse files Browse the repository at this point in the history
  • Loading branch information
arsduo committed Apr 5, 2015
1 parent 65af464 commit e06dc24
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
6 changes: 0 additions & 6 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ class Application < Rails::Application
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql

# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true

# Enable the asset pipeline
config.assets.enabled = true

Expand Down
4 changes: 1 addition & 3 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
config.eager_load = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
Expand All @@ -22,9 +23,6 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Code is not reloaded between requests
config.cache_classes = true
config.eager_load = true

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
Expand Down
8 changes: 4 additions & 4 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

config.eager_load = false

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"

# Log error messages when you accidentally call methods on nil
Expand All @@ -29,9 +30,8 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

config.active_support.test_order = :random
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require_relative './shared_examples'

describe "Rails integration specs" do
describe "Rails integration specs", type: :request do
before :each do
BatchApi.stub(:rails?).and_return(true)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def headerize(hash)

before :each do
@t = Time.now
xhr :post, "/batch", {
begin
post "/batch", {
ops: [
get_request,
post_request,
Expand All @@ -155,6 +156,11 @@ def headerize(hash)
],
sequential: true
}.to_json, "CONTENT_TYPE" => "application/json"
rescue => err
puts err.message
puts err.backtrace.join("\n")
raise
end
end

it "returns a 200" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ def app
SinatraApp
end

# for compatibility with the Rails specs, which expect response
def response
last_response
end

it_should_behave_like "integrating with a server"
end
13 changes: 13 additions & 0 deletions spec/support/sinatra_xhr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module SinatraXhr
# add xhr method to specs for the Sinatra app
# modeled on Rails
# see
def xhr(request_method, action, parameters = nil, session = nil, flash = nil)
@request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
@request.env['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
__send__(request_method, action, parameters, session, flash).tap do
@request.env.delete 'HTTP_X_REQUESTED_WITH'
@request.env.delete 'HTTP_ACCEPT'
end
end
end

0 comments on commit e06dc24

Please sign in to comment.