mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Rails 3.0 compatibility
This commit is contained in:
parent
453980906c
commit
d528fffe78
13 changed files with 22 additions and 39 deletions
|
@ -76,7 +76,7 @@ describe Draper::CollectionDecorator do
|
|||
end
|
||||
|
||||
it "raises error on invalid options" do
|
||||
expect { Draper::CollectionDecorator.new(source, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, 'Unknown key: foo')
|
||||
expect { Draper::CollectionDecorator.new(source, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, /Unknown key/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ describe Draper::DecoratedAssociation do
|
|||
end
|
||||
|
||||
it "raises error on invalid options" do
|
||||
expect { Draper::DecoratedAssociation.new(owner, :association, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, 'Unknown key: foo')
|
||||
expect { Draper::DecoratedAssociation.new(owner, :association, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, /Unknown key/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ describe Draper::Decorator do
|
|||
end
|
||||
|
||||
it "raises error on invalid options" do
|
||||
expect { decorator_class.new(source, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, 'Unknown key: foo')
|
||||
expect { decorator_class.new(source, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, /Unknown key/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -87,7 +87,7 @@ describe Draper::Decorator do
|
|||
end
|
||||
|
||||
it "raises error on invalid options" do
|
||||
expect { ProductDecorator.decorate_collection(source, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, 'Unknown key: foo')
|
||||
expect { ProductDecorator.decorate_collection(source, valid_options.merge(foo: 'bar')) }.to raise_error(ArgumentError, /Unknown key/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -272,7 +272,7 @@ describe Draper::Decorator do
|
|||
end
|
||||
|
||||
it "raises error on invalid options" do
|
||||
expect { decorator_class.decorates_association :similar_products, valid_options.merge(foo: 'bar') }.to raise_error(ArgumentError, 'Unknown key: foo')
|
||||
expect { decorator_class.decorates_association :similar_products, valid_options.merge(foo: 'bar') }.to raise_error(ArgumentError, /Unknown key/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module LocalizedUrls
|
||||
def default_url_options(options = {})
|
||||
{locale: I18n.locale, host: "www.example.com", port: nil}
|
||||
{locale: I18n.locale, host: "www.example.com", port: 12345}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,13 +47,13 @@ module Dummy
|
|||
# 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
|
||||
# config.active_record.whitelist_attributes = true
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = true
|
||||
# config.assets.enabled = true
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.0'
|
||||
# config.assets.version = '1.0'
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
|
|
|
@ -20,15 +20,15 @@ Dummy::Application.configure do
|
|||
config.action_dispatch.best_standards_support = :builtin
|
||||
|
||||
# Raise exception on mass assignment protection for Active Record models
|
||||
config.active_record.mass_assignment_sanitizer = :strict
|
||||
# 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
|
||||
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
# config.assets.compress = false
|
||||
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
# config.assets.debug = true
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ Dummy::Application.configure do
|
|||
config.cache_classes = true
|
||||
|
||||
# Configure static asset server for tests with Cache-Control for performance
|
||||
config.serve_static_assets = true
|
||||
# config.serve_static_assets = true
|
||||
config.static_cache_control = "public, max-age=3600"
|
||||
|
||||
# Log error messages when you accidentally call methods on nil
|
||||
|
@ -25,7 +25,7 @@ Dummy::Application.configure do
|
|||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Raise exception on mass assignment protection for Active Record models
|
||||
config.active_record.mass_assignment_sanitizer = :strict
|
||||
# config.active_record.mass_assignment_sanitizer = :strict
|
||||
|
||||
# Print deprecation notices to the stderr
|
||||
config.active_support.deprecation = :stderr
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
||||
# Disable root element in JSON by default.
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
self.include_root_in_json = false
|
||||
end
|
|
@ -13,11 +13,11 @@ describe PostDecorator do
|
|||
end
|
||||
|
||||
it "can use url helpers with its model" do
|
||||
subject.url_with_model.should == "http://www.example.com/en/posts/#{source.id}"
|
||||
subject.url_with_model.should == "http://www.example.com:12345/en/posts/#{source.id}"
|
||||
end
|
||||
|
||||
it "can use url helpers with its id" do
|
||||
subject.url_with_id.should == "http://www.example.com/en/posts/#{source.id}"
|
||||
subject.url_with_id.should == "http://www.example.com:12345/en/posts/#{source.id}"
|
||||
end
|
||||
|
||||
it "can be passed implicitly to url_for" do
|
||||
|
|
|
@ -19,11 +19,11 @@ describe PostMailer do
|
|||
end
|
||||
|
||||
it "can use url helpers with a model" do
|
||||
subject.should have_css "#url_with_model", text: "http://www.example.com/en/posts/#{post.id}"
|
||||
subject.should have_css "#url_with_model", text: "http://www.example.com:12345/en/posts/#{post.id}"
|
||||
end
|
||||
|
||||
it "can use url helpers with an id" do
|
||||
subject.should have_css "#url_with_id", text: "http://www.example.com/en/posts/#{post.id}"
|
||||
subject.should have_css "#url_with_id", text: "http://www.example.com:12345/en/posts/#{post.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ describe Post do
|
|||
subject { Post.first }
|
||||
|
||||
it "is true for other instances' decorators" do
|
||||
pending if Rails.version.start_with?("3.0")
|
||||
other = Post.first
|
||||
subject.should_not be other
|
||||
(subject == other.decorate).should be_true
|
||||
|
|
|
@ -22,11 +22,11 @@ app.start_server do
|
|||
end
|
||||
|
||||
it "can use url helpers with a model" do
|
||||
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_model")
|
||||
page.should have_text("http://www.example.com:12345/en/posts/1").in("#url_with_model")
|
||||
end
|
||||
|
||||
it "can use url helpers with an id" do
|
||||
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_id")
|
||||
page.should have_text("http://www.example.com:12345/en/posts/1").in("#url_with_id")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,3 @@ require 'support/decorators/specific_product_decorator'
|
|||
require 'support/decorators/products_decorator'
|
||||
require 'support/decorators/some_thing_decorator'
|
||||
require 'support/decorators/decorator_with_application_helper'
|
||||
|
||||
class << Rails
|
||||
undef application # Avoid silly Rails bug: https://github.com/rails/rails/pull/6429
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue