mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Remove trailing whitespace.
This commit is contained in:
parent
d154059572
commit
51b03097f2
3 changed files with 27 additions and 27 deletions
|
@ -193,9 +193,9 @@ module Draper
|
|||
def method_missing(method, *args, &block)
|
||||
if allow?(method)
|
||||
begin
|
||||
self.class.send :define_method, method do |*args, &block|
|
||||
self.class.send :define_method, method do |*args, &block|
|
||||
model.send(method, *args, &block)
|
||||
end
|
||||
end
|
||||
self.send(method, *args, &block)
|
||||
rescue NoMethodError
|
||||
super
|
||||
|
@ -218,9 +218,9 @@ module Draper
|
|||
end
|
||||
|
||||
def context
|
||||
options.fetch(:context, {})
|
||||
options.fetch(:context, {})
|
||||
end
|
||||
|
||||
|
||||
def context=(input)
|
||||
options[:context] = input
|
||||
end
|
||||
|
|
|
@ -177,27 +177,27 @@ describe Draper::Base do
|
|||
pd.context.should == :admin
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context ".find_by_(x)" do
|
||||
it "runs the similarly named finder" do
|
||||
Product.should_receive(:find_by_name)
|
||||
ProductDecorator.find_by_name("apples")
|
||||
end
|
||||
|
||||
|
||||
it "returns a decorated result" do
|
||||
ProductDecorator.find_by_name("apples").should be_kind_of(ProductDecorator)
|
||||
end
|
||||
|
||||
|
||||
it "runs complex finders" do
|
||||
Product.should_receive(:find_by_name_and_size)
|
||||
ProductDecorator.find_by_name_and_size("apples", "large")
|
||||
end
|
||||
|
||||
|
||||
it "accepts an options hash" do
|
||||
Product.should_receive(:find_by_name_and_size).with("apples", "large", {:role => :admin})
|
||||
ProductDecorator.find_by_name_and_size("apples", "large", {:role => :admin})
|
||||
end
|
||||
|
||||
|
||||
it "uses the options hash in the decorator instantiation" do
|
||||
pending "Figure out an implementation that supports multiple args (find_by_name_and_count_and_size) plus an options hash"
|
||||
Product.should_receive(:find_by_name_and_size).with("apples", "large", {:role => :admin})
|
||||
|
@ -224,19 +224,19 @@ describe Draper::Base do
|
|||
let(:source) { Product.new }
|
||||
|
||||
it { should be_instance_of(Draper::Base) }
|
||||
|
||||
|
||||
context "when the input is already decorated" do
|
||||
it "does not perform double-decoration" do
|
||||
decorated = ProductDecorator.decorate(source)
|
||||
ProductDecorator.decorate(decorated).object_id.should == decorated.object_id
|
||||
end
|
||||
|
||||
|
||||
it "overwrites options with provided options" do
|
||||
first_run = ProductDecorator.decorate(source, :context => {:role => :user})
|
||||
second_run = ProductDecorator.decorate(first_run, :context => {:role => :admin})
|
||||
second_run.context[:role].should == :admin
|
||||
end
|
||||
|
||||
|
||||
it "leaves existing options if none are supplied" do
|
||||
first_run = ProductDecorator.decorate(source, :context => {:role => :user})
|
||||
second_run = ProductDecorator.decorate(first_run)
|
||||
|
@ -265,12 +265,12 @@ describe Draper::Base do
|
|||
its(:context) { should eq(context) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with options" do
|
||||
let(:options) {{ :more => "settings" }}
|
||||
|
||||
|
||||
subject { Draper::Base.decorate(source, options ) }
|
||||
|
||||
|
||||
its(:options) { should eq(options) }
|
||||
end
|
||||
|
||||
|
@ -407,10 +407,10 @@ describe Draper::Base do
|
|||
subject = ProductDecorator.decorate(paged_array)
|
||||
subject[0].should be_instance_of ProductDecorator
|
||||
end
|
||||
|
||||
|
||||
context "pretends to be of kind of wrapped collection class" do
|
||||
subject { ProductDecorator.decorate(paged_array) }
|
||||
|
||||
|
||||
it "#kind_of? DecoratedEnumerableProxy" do
|
||||
subject.should be_kind_of Draper::DecoratedEnumerableProxy
|
||||
end
|
||||
|
@ -535,7 +535,7 @@ describe Draper::Base do
|
|||
decorator.sample_truncate.should == "Once..."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#method_missing" do
|
||||
context "when #hello_world is called for the first time" do
|
||||
it "hits method missing" do
|
||||
|
@ -543,7 +543,7 @@ describe Draper::Base do
|
|||
subject.hello_world
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "when #hello_world is called again" do
|
||||
before { subject.hello_world }
|
||||
it "proxies method directly after first hit" do
|
||||
|
@ -554,7 +554,7 @@ describe Draper::Base do
|
|||
end
|
||||
|
||||
describe "#kind_of?" do
|
||||
context "pretends to be of kind of model class" do
|
||||
context "pretends to be of kind of model class" do
|
||||
it "#kind_of? decorator class" do
|
||||
subject.should be_kind_of subject.class
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Product < ActiveRecord::Base
|
||||
include Draper::ModelSupport
|
||||
|
||||
|
||||
def self.find_by_name(name)
|
||||
@@dummy ||= Product.new
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ class Product < ActiveRecord::Base
|
|||
def self.last
|
||||
@@last ||= Product.new
|
||||
end
|
||||
|
||||
|
||||
def self.all
|
||||
[Product.new, Product.new]
|
||||
end
|
||||
|
@ -28,23 +28,23 @@ class Product < ActiveRecord::Base
|
|||
def self.find(id)
|
||||
return 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
|
||||
|
|
Loading…
Add table
Reference in a new issue