mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Added a test to demonstrate classify vs. camelize; Updated Draper::Base#decorates to use camelize instead of classify
This commit is contained in:
parent
8f9223778a
commit
3709bf4077
2 changed files with 18 additions and 1 deletions
|
@ -21,7 +21,7 @@ module Draper
|
|||
end
|
||||
|
||||
def self.decorates(input)
|
||||
self.model_class = input.to_s.classify.constantize
|
||||
self.model_class = input.to_s.camelize.constantize
|
||||
model_class.send :include, Draper::ModelSupport
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,23 @@ describe Draper::Base do
|
|||
subject{ Draper::Base.new(source) }
|
||||
let(:source){ Product.new }
|
||||
|
||||
context("classify_vs_camelize") do
|
||||
it "should create 'Busines' when using classify" do
|
||||
:business.to_s.classify.should == 'Busines'
|
||||
end
|
||||
|
||||
it "should create 'Business' when using camelize" do
|
||||
:business.to_s.camelize.should == 'Business'
|
||||
end
|
||||
|
||||
it "should fail for 'decorates :business'" do
|
||||
class Business; end
|
||||
lambda do
|
||||
Draper::Base.decorates(:business)
|
||||
end.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context(".lazy_helpers") do
|
||||
it "makes Rails helpers available without using the h. proxy" do
|
||||
Draper::Base.lazy_helpers
|
||||
|
|
Loading…
Reference in a new issue