From 1c3d5667b8406b80b490d876257379087b129f92 Mon Sep 17 00:00:00 2001 From: ayaya Date: Tue, 1 Nov 2011 01:55:20 +0800 Subject: [PATCH] add namespaced samples --- spec/support/samples/namespaced_product.rb | 51 +++++++++++++++++++ .../samples/namespaced_product_decorator.rb | 7 +++ 2 files changed, 58 insertions(+) create mode 100644 spec/support/samples/namespaced_product.rb create mode 100644 spec/support/samples/namespaced_product_decorator.rb diff --git a/spec/support/samples/namespaced_product.rb b/spec/support/samples/namespaced_product.rb new file mode 100644 index 0000000..1c6ed7e --- /dev/null +++ b/spec/support/samples/namespaced_product.rb @@ -0,0 +1,51 @@ +require './spec/support/samples/product' + +module Namespace + class Product < ActiveRecord::Base + include Draper::ModelSupport + + def self.first + @@first ||= Namespace::Product.new + end + + def self.last + @@last ||= Namespace::Product.new + end + + def self.all + [Namespace::Product.new, Namespace::Product.new] + end + + def self.scoped + [Namespace::Product.new] + end + + def self.model_name + "Namespace::Product" + end + + def self.find(id) + return Namespace::Product.new + end + + def self.sample_class_method + "sample class method" + end + + def hello_world + "Hello, World" + end + + def goodnight_moon + "Goodnight, Moon" + end + + def title + "Sample Title" + end + + def block + yield + end + end +end diff --git a/spec/support/samples/namespaced_product_decorator.rb b/spec/support/samples/namespaced_product_decorator.rb new file mode 100644 index 0000000..cec47cc --- /dev/null +++ b/spec/support/samples/namespaced_product_decorator.rb @@ -0,0 +1,7 @@ +require './spec/support/samples/product' + +module Namespace + class ProductDecorator < Draper::Base + decorates :product, :class => Namespace::Product + end +end