Commit 248e6650 by Mal McKay

Allow models with non standard capitalization

parent ddfba1f7
...@@ -239,7 +239,11 @@ module AnnotateModels ...@@ -239,7 +239,11 @@ module AnnotateModels
begin begin
parts.inject(Object) {|klass, part| klass.const_get(part) } parts.inject(Object) {|klass, part| klass.const_get(part) }
rescue LoadError, NameError rescue LoadError, NameError
Object.const_get(parts.last) begin
Object.const_get(parts.last)
rescue LoadError, NameError
Object.const_get(Module.constants.detect{|c|parts.last.downcase == c.downcase})
end
end end
end end
......
...@@ -69,6 +69,11 @@ EOS ...@@ -69,6 +69,11 @@ EOS
acts_as_awesome :yah acts_as_awesome :yah
end end
EOS EOS
create('foo_with_capitals.rb', <<-EOS)
class FooWithCAPITALS < ActiveRecord::Base
acts_as_awesome :yah
end
EOS
end end
it "should work" do it "should work" do
klass = AnnotateModels.get_model_class("foo.rb") klass = AnnotateModels.get_model_class("foo.rb")
...@@ -78,6 +83,10 @@ EOS ...@@ -78,6 +83,10 @@ EOS
klass = AnnotateModels.get_model_class("foo_with_macro.rb") klass = AnnotateModels.get_model_class("foo_with_macro.rb")
klass.name.should == "FooWithMacro" klass.name.should == "FooWithMacro"
end end
it "should find models with non standard capitalization" do
klass = AnnotateModels.get_model_class("foo_with_capitals.rb")
klass.name.should == "FooWithCAPITALS"
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment