diff --git a/.gitignore b/.gitignore
index 5c99549c..564f5168 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
*.gem
-*.rvmrc
+.rvmrc
+.ruby-version
+.ruby-gemset
.bundle
Gemfile.lock
pkg/*
diff --git a/.travis.yml b/.travis.yml
index 0591b046..6efcf2df 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,10 +4,5 @@ services:
- mongodb
rvm:
- - 2.1.5
- - 2.2.1
-
-env:
- - "RAILS_VERSION=4.0"
- - "RAILS_VERSION=4.1"
- - "RAILS_VERSION=4.2"
+ - 2.2.5
+ - 2.3.1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9fe535c6..29dbbe8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Draper Changelog
+## 3.0.0 - 2016-07-XX
+
+* Added support for Rails 5, dropped 4.0 - 4.2
+ * Ruby >= 2.2 is required, matching Rails 5
+* Dropped support for ActiveModelSerializers 0.8
+
## 2.1.0 - 2015-03-26
* Cleared most issues and merged a few PRs
diff --git a/Gemfile b/Gemfile
index b3e3fc49..f7c1e112 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,10 +7,9 @@ platforms :ruby do
end
platforms :jruby do
- gem "minitest", ">= 3.0"
- gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta2"
+ gem "minitest"
+ gem "activerecord-jdbcsqlite3-adapter"
end
-version = ENV["RAILS_VERSION"] || "4.1"
-
-eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__)
+gem "rails", "~> 5.0"
+gem "mongoid", github: "mongodb/mongoid"
diff --git a/README.md b/README.md
index 4c4d2cc9..a625ebda 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# Draper: View Models for Rails
[![TravisCI Build Status](https://travis-ci.org/drapergem/draper.svg?branch=master)](http://travis-ci.org/drapergem/draper)
-[![Code Climate](https://codeclimate.com/github/drapergem/draper.png)](https://codeclimate.com/github/drapergem/draper)
-[![Inline docs](http://inch-ci.org/github/drapergem/draper.png?branch=master)](http://inch-ci.org/github/drapergem/draper)
+[![Code Climate](https://codeclimate.com/github/drapergem/draper.svg)](https://codeclimate.com/github/drapergem/draper)
+[![Inline docs](http://inch-ci.org/github/drapergem/draper.svg?branch=master)](http://inch-ci.org/github/drapergem/draper)
Draper adds an object-oriented layer of presentation logic to your Rails
application.
@@ -564,15 +564,15 @@ end
This is only necessary when proxying class methods.
-Once this association between the decorator and the model is set up, you can call `SomeModel.decorator_class` to access class methods defined in the decorator. If necessary, you can check if your model is decorated with `SomeModel.decorator_class?`.
+Once this association between the decorator and the model is set up, you can call
+`SomeModel.decorator_class` to access class methods defined in the decorator.
+If necessary, you can check if your model is decorated with `SomeModel.decorator_class?`.
### Making Models Decoratable
Models get their `decorate` method from the `Draper::Decoratable` module, which
is included in `ActiveRecord::Base` and `Mongoid::Document` by default. If
-you're [using another
-ORM](https://github.com/drapergem/draper/wiki/Using-other-ORMs) (including
-versions of Mongoid prior to 3.0), or want to decorate plain old Ruby objects,
+you're using another ORM, or want to decorate plain old Ruby objects,
you can include this module manually.
## Contributors
@@ -581,7 +581,11 @@ Draper was conceived by Jeff Casimir and heavily refined by Steve Klabnik and a
great community of open source
[contributors](https://github.com/drapergem/draper/contributors).
-### Core Team
+### Current maintainers
+
+* Sean Linsley
+
+### Historical maintainers
* Jeff Casimir (jeff@jumpstartlab.com)
* Steve Klabnik (steve@jumpstartlab.com)
diff --git a/Rakefile b/Rakefile
index 848fc54e..903687cd 100644
--- a/Rakefile
+++ b/Rakefile
@@ -16,7 +16,8 @@ desc "Run all specs"
task "spec" => "spec:all"
namespace "spec" do
- task "all" => ["draper", "generators", "integration"]
+ # TODOD: add back "generators"
+ task "all" => ["draper", "integration"]
def spec_task(name)
desc "Run #{name} specs"
@@ -64,6 +65,6 @@ namespace "db" do
run_in_dummy_app "rm -f db/*.sqlite3"
run_in_dummy_app "RAILS_ENV=development rake db:schema:load db:seed"
run_in_dummy_app "RAILS_ENV=production rake db:schema:load db:seed"
- run_in_dummy_app "RAILS_ENV=test rake db:schema:load"
+ run_in_dummy_app "RAILS_ENV=test rake db:environment:set db:schema:load"
end
end
diff --git a/draper.gemspec b/draper.gemspec
index abfd2eba..f0395425 100644
--- a/draper.gemspec
+++ b/draper.gemspec
@@ -17,15 +17,18 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency 'activesupport', '>= 3.0'
- s.add_dependency 'actionpack', '>= 3.0'
+ s.required_ruby_version = '>= 2.2.2'
+
+ s.add_dependency 'activesupport', '~> 5.0'
+ s.add_dependency 'actionpack', '~> 5.0'
s.add_dependency 'request_store', '~> 1.0'
- s.add_dependency 'activemodel', '>= 3.0'
+ s.add_dependency 'activemodel', '~> 5.0'
+ s.add_dependency 'activemodel-serializers-xml', '~> 1.0'
s.add_development_dependency 'ammeter'
- s.add_development_dependency 'rake', '>= 0.9.2'
- s.add_development_dependency 'rspec-rails', '~> 3.2'
- s.add_development_dependency 'minitest-rails', '>= 1.0'
+ s.add_development_dependency 'rake'
+ s.add_development_dependency 'rspec-rails'
+ s.add_development_dependency 'minitest-rails'
s.add_development_dependency 'capybara'
- s.add_development_dependency 'active_model_serializers'
+ s.add_development_dependency 'active_model_serializers', '~> 0.10'
end
diff --git a/gemfiles/4.0.gemfile b/gemfiles/4.0.gemfile
deleted file mode 100644
index 8e03c654..00000000
--- a/gemfiles/4.0.gemfile
+++ /dev/null
@@ -1,3 +0,0 @@
-gem "rails", "~> 4.0.0"
-gem "mongoid", "~> 4.0"
-gem "devise", "~> 3.0.0"
diff --git a/gemfiles/4.1.gemfile b/gemfiles/4.1.gemfile
deleted file mode 100644
index 34d85f4a..00000000
--- a/gemfiles/4.1.gemfile
+++ /dev/null
@@ -1,3 +0,0 @@
-gem "rails", "~> 4.1.0"
-gem "mongoid", "~> 4.0"
-gem "devise", "~> 3.2"
diff --git a/gemfiles/4.2.gemfile b/gemfiles/4.2.gemfile
deleted file mode 100644
index 8bac430b..00000000
--- a/gemfiles/4.2.gemfile
+++ /dev/null
@@ -1,3 +0,0 @@
-gem "rails", "~> 4.2.0"
-gem "mongoid", "~> 4.0"
-gem "devise", "~> 3.4"
diff --git a/lib/draper.rb b/lib/draper.rb
index 351a81c6..bc7a1aa9 100644
--- a/lib/draper.rb
+++ b/lib/draper.rb
@@ -33,7 +33,7 @@ def self.setup_action_controller(base)
extend Draper::HelperSupport
extend Draper::DecoratesAssigned
- before_filter :activate_draper
+ before_action :activate_draper
end
end
diff --git a/lib/draper/decoratable.rb b/lib/draper/decoratable.rb
index 3771e575..8804ed0c 100644
--- a/lib/draper/decoratable.rb
+++ b/lib/draper/decoratable.rb
@@ -56,8 +56,7 @@ module ClassMethods
# @param [Hash] options
# see {Decorator.decorate_collection}.
def decorate(options = {})
- collection = Rails::VERSION::MAJOR >= 4 ? all : scoped
- decorator_class.decorate_collection(collection, options.reverse_merge(with: nil))
+ decorator_class.decorate_collection(all, options.reverse_merge(with: nil))
end
def decorator_class?
diff --git a/lib/draper/decorator.rb b/lib/draper/decorator.rb
index 3a9d84fc..05d4b927 100755
--- a/lib/draper/decorator.rb
+++ b/lib/draper/decorator.rb
@@ -203,18 +203,6 @@ def instance_of?(klass)
super || object.instance_of?(klass)
end
- if RUBY_VERSION < "2.0"
- # nasty hack to stop 1.9.x using the delegated `to_s` in `inspect`
- alias_method :_to_s, :to_s
-
- def inspect
- ivars = instance_variables.map do |name|
- "#{name}=#{instance_variable_get(name).inspect}"
- end
- _to_s.insert(-2, " #{ivars.join(", ")}")
- end
- end
-
delegate :to_s
# In case object is nil
diff --git a/lib/draper/railtie.rb b/lib/draper/railtie.rb
index e75bda32..967f9a52 100755
--- a/lib/draper/railtie.rb
+++ b/lib/draper/railtie.rb
@@ -43,14 +43,6 @@ class Railtie < Rails::Railtie
end
end
- initializer "draper.setup_active_model_serializers" do |app|
- ActiveSupport.on_load :active_model_serializers do
- if defined?(ActiveModel::ArraySerializerSupport)
- Draper::CollectionDecorator.send :include, ActiveModel::ArraySerializerSupport
- end
- end
- end
-
initializer "draper.minitest-rails_integration" do |app|
ActiveSupport.on_load :minitest do
require "draper/test/minitest_integration"
diff --git a/lib/draper/tasks/test.rake b/lib/draper/tasks/test.rake
index 978607be..fbf31f10 100644
--- a/lib/draper/tasks/test.rake
+++ b/lib/draper/tasks/test.rake
@@ -1,22 +1,9 @@
require 'rake/testtask'
-
-test_task = if Rails.version.to_f < 3.2
- require 'rails/test_unit/railtie'
- Rake::TestTask
-else
- require 'rails/test_unit/sub_test_task'
- Rails::SubTestTask
-end
+require 'rails/test_unit/railtie'
namespace :test do
- test_task.new(:decorators => "test:prepare") do |t|
+ Rake::TestTask.new(:decorators => "test:prepare") do |t|
t.libs << "test"
t.pattern = "test/decorators/**/*_test.rb"
end
end
-
-if Rails.version.to_f < 4.2 && Rake::Task.task_defined?('test:run')
- Rake::Task['test:run'].enhance do
- Rake::Task['test:decorators'].invoke
- end
-end
diff --git a/lib/draper/test/rspec_integration.rb b/lib/draper/test/rspec_integration.rb
index d18f6362..013d8ff3 100755
--- a/lib/draper/test/rspec_integration.rb
+++ b/lib/draper/test/rspec_integration.rb
@@ -7,11 +7,7 @@ module DecoratorExampleGroup
end
RSpec.configure do |config|
- if RSpec::Core::Version::STRING.starts_with?("3")
- config.include DecoratorExampleGroup, file_path: %r{spec/decorators}, type: :decorator
- else
- config.include DecoratorExampleGroup, example_group: {file_path: %r{spec/decorators}}, type: :decorator
- end
+ config.include DecoratorExampleGroup, file_path: %r{spec/decorators}, type: :decorator
[:decorator, :controller, :mailer].each do |type|
config.before(:each, type: type) { Draper::ViewContext.clear! }
diff --git a/lib/draper/test_case.rb b/lib/draper/test_case.rb
index 334a8f73..99a424a2 100644
--- a/lib/draper/test_case.rb
+++ b/lib/draper/test_case.rb
@@ -29,14 +29,10 @@ module Behavior
end
end
-if defined?(ActionController::TestCase)
- class ActionController::TestCase
- include Draper::TestCase::ViewContextTeardown
- end
+if defined? ActionController::TestCase
+ ActionController::TestCase.include Draper::TestCase::ViewContextTeardown
end
-if defined?(ActionMailer::TestCase)
- class ActionMailer::TestCase
- include Draper::TestCase::ViewContextTeardown
- end
+if defined? ActionMailer::TestCase
+ ActionMailer::TestCase.include Draper::TestCase::ViewContextTeardown
end
diff --git a/lib/draper/view_context/build_strategy.rb b/lib/draper/view_context/build_strategy.rb
index 3d4dc117..33d87151 100644
--- a/lib/draper/view_context/build_strategy.rb
+++ b/lib/draper/view_context/build_strategy.rb
@@ -38,7 +38,7 @@ def call
def controller
(Draper::ViewContext.controller || ApplicationController.new).tap do |controller|
- controller.request ||= ActionController::TestRequest.new if defined?(ActionController::TestRequest)
+ controller.request ||= ActionController::TestRequest.create
end
end
end
diff --git a/spec/draper/decoratable_spec.rb b/spec/draper/decoratable_spec.rb
index 6f608f46..8b06c812 100644
--- a/spec/draper/decoratable_spec.rb
+++ b/spec/draper/decoratable_spec.rb
@@ -128,11 +128,9 @@ module Draper
end
describe ".decorate" do
- let(:scoping_method) { Rails::VERSION::MAJOR >= 4 ? :all : :scoped }
-
it "calls #decorate_collection on .decorator_class" do
scoped = [Product.new]
- Product.stub scoping_method => scoped
+ Product.stub all: scoped
Product.decorator_class.should_receive(:decorate_collection).with(scoped, with: nil).and_return(:decorated_collection)
expect(Product.decorate).to be :decorated_collection
@@ -140,7 +138,7 @@ module Draper
it "accepts options" do
options = {with: ProductDecorator, context: {some: "context"}}
- Product.stub scoping_method => []
+ Product.stub all: []
Product.decorator_class.should_receive(:decorate_collection).with([], options)
Product.decorate(options)
diff --git a/spec/dummy/app/views/posts/_post.html.erb b/spec/dummy/app/views/posts/_post.html.erb
index 22350a4e..4225361c 100644
--- a/spec/dummy/app/views/posts/_post.html.erb
+++ b/spec/dummy/app/views/posts/_post.html.erb
@@ -20,14 +20,16 @@
Helpers from the controller:
<%= post.goodnight_moon %>
- Path with decorator:
- <%= post_path(post) %>
+ <% unless defined? mailer %>
+ Path with decorator:
+ <%= post_url(post) %>
- Path with model:
- <%= post.path_with_model %>
+ Path with model:
+ <%= post.path_with_model %>
- Path with id:
- <%= post.path_with_id %>
+ Path with id:
+ <%= post.path_with_id %>
+ <% end %>
URL with decorator:
<%= post_url(post) %>
diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml
index 92d19323..ecbfb6d4 100644
--- a/spec/dummy/config/mongoid.yml
+++ b/spec/dummy/config/mongoid.yml
@@ -1,54 +1,117 @@
development:
- # Configure available database sessions. (required)
- sessions:
- # Defines the default session. (required)
+ # Configure available database clients. (required)
+ clients:
+ # Defines the default client. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: dummy_development
- # Provides the hosts the default session can connect to. Must be an array
+ # Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
- # Change whether the session persists in safe mode by default.
- # (default: false)
- # safe: false
-
- # Change the default consistency model to :eventual or :strong.
- # :eventual will send reads to secondaries, :strong sends everything
- # to master. (default: :eventual)
- # consistency: :eventual
-
- # How many times Moped should attempt to retry an operation after
- # failure. (default: 30)
- # max_retries: 30
-
- # The time in seconds that Moped should wait before retrying an
- # operation on failure. (default: 1)
- # retry_interval: 1
- # Configure Mongoid specific options. (optional)
- options:
- # Configuration for whether or not to allow access to fields that do
- # not have a field definition on the model. (default: true)
- # allow_dynamic_fields: true
+ # Change the default write concern. (default = { w: 1 })
+ # write:
+ # w: 1
+
+ # Change the default read preference. Valid options for mode are: :secondary,
+ # :secondary_preferred, :primary, :primary_preferred, :nearest
+ # (default: primary)
+ # read:
+ # mode: :secondary_preferred
+ # tag_sets:
+ # - use: web
+
+ # The name of the user for authentication.
+ # user: 'user'
+
+ # The password of the user for authentication.
+ # password: 'password'
+
+ # The user's database roles.
+ # roles:
+ # - 'dbOwner'
+
+ # Change the default authentication mechanism. Valid options are: :scram,
+ # :mongodb_cr, :mongodb_x509, and :plain. (default on 3.0 is :scram, default
+ # on 2.4 and 2.6 is :plain)
+ # auth_mech: :scram
+
+ # The database or source to authenticate the user against. (default: admin)
+ # auth_source: admin
+
+ # Force a the driver cluster to behave in a certain manner instead of auto-
+ # discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct
+ # when connecting to hidden members of a replica set.
+ # connect: :direct
+
+ # Changes the default time in seconds the server monitors refresh their status
+ # via ismaster commands. (default: 10)
+ # heartbeat_frequency: 10
+
+ # The time in seconds for selecting servers for a near read preference. (default: 5)
+ # local_threshold: 5
+
+ # The timeout in seconds for selecting a server for an operation. (default: 30)
+ # server_selection_timeout: 30
+
+ # The maximum number of connections in the connection pool. (default: 5)
+ # max_pool_size: 5
+
+ # The minimum number of connections in the connection pool. (default: 1)
+ # min_pool_size: 1
+
+ # The time to wait, in seconds, in the connection pool for a connection
+ # to be checked in before timing out. (default: 5)
+ # wait_queue_timeout: 5
- # Enable the identity map, needed for eager loading. (default: false)
- # identity_map_enabled: false
+ # The time to wait to establish a connection before timing out, in seconds.
+ # (default: 5)
+ # connect_timeout: 5
+ # The timeout to wait to execute operations on a socket before raising an error.
+ # (default: 5)
+ # socket_timeout: 5
+
+ # The name of the replica set to connect to. Servers provided as seeds that do
+ # not belong to this replica set will be ignored.
+ # replica_set: name
+
+ # Whether to connect to the servers via ssl. (default: false)
+ # ssl: true
+
+ # The certificate file used to identify the connection against MongoDB.
+ # ssl_cert: /path/to/my.cert
+
+ # The private keyfile used to identify the connection against MongoDB.
+ # Note that even if the key is stored in the same file as the certificate,
+ # both need to be explicitly specified.
+ # ssl_key: /path/to/my.key
+
+ # A passphrase for the private key.
+ # ssl_key_pass_phrase: password
+
+ # Whether or not to do peer certification validation. (default: true)
+ # ssl_verify: true
+
+ # The file containing a set of concatenated certification authority certifications
+ # used to validate certs passed from the other end of the connection.
+ # ssl_ca_cert: /path/to/ca.cert
+
+
+ # Configure Mongoid specific options. (optional)
+ options:
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
- # Include the _type field in serializaion. (default: false)
+ # Include the _type field in serialization. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
- # Protect id and type from mass assignment. (default: true)
- # protect_sensitive_fields: true
-
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
@@ -57,23 +120,23 @@ development:
# existing method. (default: false)
# scope_overwrite_exception: false
- # Skip the database version check, used when connecting to a db without
- # admin access. (default: false)
- # skip_version_check: false
-
- # User Active Support's time zone in conversions. (default: true)
+ # Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
+
+ # Set the Mongoid and Ruby driver log levels when not in a Rails
+ # environment. The Mongoid logger will be set to the Rails logger
+ # otherwise.(default: :info)
+ # log_level: :info
test:
- sessions:
+ clients:
default:
database: dummy_test
hosts:
- localhost:27017
options:
- # In the test environment we lower the retries and retry interval to
- # low amounts for fast failures.
- max_retries: 1
- retry_interval: 0
+ read:
+ mode: :primary
+ max_pool_size: 1
diff --git a/spec/dummy/spec/decorators/active_model_serializers_spec.rb b/spec/dummy/spec/decorators/active_model_serializers_spec.rb
index 7de50532..ee83e24d 100644
--- a/spec/dummy/spec/decorators/active_model_serializers_spec.rb
+++ b/spec/dummy/spec/decorators/active_model_serializers_spec.rb
@@ -2,15 +2,11 @@
describe Draper::CollectionDecorator do
describe "#active_model_serializer" do
- it "returns ActiveModel::ArraySerializer" do
- collection_decorator = Draper::CollectionDecorator.new([])
- if defined?(ActiveModel::ArraySerializerSupport)
- collection_serializer = collection_decorator.active_model_serializer
- else
- collection_serializer = ActiveModel::Serializer.serializer_for(collection_decorator)
- end
+ it "returns ActiveModel::Serializer::CollectionSerializer" do
+ collection_decorator = Draper::CollectionDecorator.new([])
+ collection_serializer = ActiveModel::Serializer.serializer_for(collection_decorator)
- expect(collection_serializer).to be ActiveModel::ArraySerializer
+ expect(collection_serializer).to be ActiveModel::Serializer::CollectionSerializer
end
end
end
diff --git a/spec/dummy/spec/decorators/post_decorator_spec.rb b/spec/dummy/spec/decorators/post_decorator_spec.rb
index 75aaf41d..57830adf 100755
--- a/spec/dummy/spec/decorators/post_decorator_spec.rb
+++ b/spec/dummy/spec/decorators/post_decorator_spec.rb
@@ -54,8 +54,6 @@
end
it "serializes to XML" do
- pending("Rails < 3.2 does not use `serializable_hash` in `to_xml`") if Rails.version.to_f < 3.2
-
xml = Capybara.string(decorator.to_xml)
expect(xml).to have_css "post > updated-at", text: "overridden"
end
diff --git a/spec/dummy/spec/mailers/post_mailer_spec.rb b/spec/dummy/spec/mailers/post_mailer_spec.rb
index 3d6699ad..4ab0135d 100644
--- a/spec/dummy/spec/mailers/post_mailer_spec.rb
+++ b/spec/dummy/spec/mailers/post_mailer_spec.rb
@@ -10,14 +10,6 @@
expect(email_body).to have_content "Today"
end
- it "can use path helpers with a model" do
- expect(email_body).to have_css "#path_with_model", text: "/en/posts/#{post.id}"
- end
-
- it "can use path helpers with an id" do
- expect(email_body).to have_css "#path_with_id", text: "/en/posts/#{post.id}"
- end
-
it "can use url helpers with a model" do
expect(email_body).to have_css "#url_with_model", text: "http://www.example.com:12345/en/posts/#{post.id}"
end
diff --git a/spec/dummy/spec/shared_examples/decoratable.rb b/spec/dummy/spec/shared_examples/decoratable.rb
index 90863bcb..72d46d16 100644
--- a/spec/dummy/spec/shared_examples/decoratable.rb
+++ b/spec/dummy/spec/shared_examples/decoratable.rb
@@ -11,8 +11,6 @@
describe "#==" do
it "is true for other instances' decorators" do
- pending "Mongoid < 3.1 overrides `#==`" if defined?(Mongoid) && Mongoid::VERSION.to_f < 3.1 && described_class < Mongoid::Document
-
described_class.create
one = described_class.first
other = described_class.first
diff --git a/spec/dummy/test/decorators/minitest/view_context_test.rb b/spec/dummy/test/decorators/minitest/view_context_test.rb
index c1df670e..c2d6b6f3 100644
--- a/spec/dummy/test/decorators/minitest/view_context_test.rb
+++ b/spec/dummy/test/decorators/minitest/view_context_test.rb
@@ -14,7 +14,7 @@ def it_does_not_leak_view_context
end
describe "A controller test" do
- tests Class.new(ActionController::Base)
+ subject{ Class.new(ActionController::Base) }
it_does_not_leak_view_context
end
diff --git a/spec/dummy/test/decorators/test_unit/view_context_test.rb b/spec/dummy/test/decorators/test_unit/view_context_test.rb
index 98b71a75..faa17389 100644
--- a/spec/dummy/test/decorators/test_unit/view_context_test.rb
+++ b/spec/dummy/test/decorators/test_unit/view_context_test.rb
@@ -14,7 +14,7 @@ class DecoratorTest < Draper::TestCase
end
class ControllerTest < ActionController::TestCase
- tests Class.new(ActionController::Base)
+ subject{ Class.new(ActionController::Base) }
it_does_not_leak_view_context
end
diff --git a/spec/integration/integration_spec.rb b/spec/integration/integration_spec.rb
index 3175b3c4..00ab9d7c 100644
--- a/spec/integration/integration_spec.rb
+++ b/spec/integration/integration_spec.rb
@@ -38,16 +38,19 @@
expect(page).to have_text("Goodnight, moon!").in("#goodnight_moon")
end
- it "can be passed to path helpers" do
- expect(page).to have_text("/en/posts/1").in("#path_with_decorator")
- end
+ # _path helpers aren't available in mailers
+ if type == :view
+ it "can be passed to path helpers" do
+ expect(page).to have_text("/en/posts/1").in("#path_with_decorator")
+ end
- it "can use path helpers with a model" do
- expect(page).to have_text("/en/posts/1").in("#path_with_model")
- end
+ it "can use path helpers with a model" do
+ expect(page).to have_text("/en/posts/1").in("#path_with_model")
+ end
- it "can use path helpers with an id" do
- expect(page).to have_text("/en/posts/1").in("#path_with_id")
+ it "can use path helpers with an id" do
+ expect(page).to have_text("/en/posts/1").in("#path_with_id")
+ end
end
it "can be passed to url helpers" do
diff --git a/spec/performance/benchmark.rb b/spec/performance/benchmark.rb
index 32c63e43..938131e5 100644
--- a/spec/performance/benchmark.rb
+++ b/spec/performance/benchmark.rb
@@ -1,7 +1,7 @@
require 'rubygems'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
-Bundler.require(:default) if defined?(Bundler)
+Bundler.require :default
require "benchmark"
require "draper"
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index df3aad9e..57aa9cf7 100755
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,6 +1,5 @@
require 'bundler/setup'
require 'draper'
-require 'rails/version'
require 'action_controller'
require 'action_controller/test_case'