Merge pull request #348 from mattiassvedhem/include_active_model_serialization
Include ActiveModel::Serialization in Draper::Decorator.
This commit is contained in:
commit
bb55ba50fa
|
@ -3,6 +3,7 @@ require 'active_support/core_ext/array/extract_options'
|
|||
module Draper
|
||||
class Decorator
|
||||
include Draper::ViewHelpers
|
||||
include ActiveModel::Serialization if defined?(ActiveModel::Serialization)
|
||||
|
||||
attr_accessor :source, :options
|
||||
|
||||
|
|
|
@ -486,4 +486,12 @@ describe Draper::Decorator do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#serializable_hash" do
|
||||
let(:decorator_class) { ProductDecorator }
|
||||
|
||||
it "serializes overridden attributes" do
|
||||
subject.serializable_hash[:overridable].should be :overridden
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -8,6 +8,7 @@ require 'action_controller/test_case'
|
|||
|
||||
Bundler.require
|
||||
|
||||
require './spec/support/active_model'
|
||||
require './spec/support/active_record'
|
||||
require './spec/support/action_controller'
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
module ActiveModel
|
||||
module Serialization
|
||||
def serializable_hash
|
||||
{overridable: send(:overridable)}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
class Product < ActiveRecord::Base
|
||||
include Draper::Decoratable
|
||||
include ActiveModel::Serialization
|
||||
|
||||
delegate :delegated_method, to: :thing
|
||||
|
||||
|
|
Loading…
Reference in New Issue