Commit 248e6650 by Mal McKay

Allow models with non standard capitalization

parent ddfba1f7
......@@ -239,7 +239,11 @@ module AnnotateModels
begin
parts.inject(Object) {|klass, part| klass.const_get(part) }
rescue LoadError, NameError
begin
Object.const_get(parts.last)
rescue LoadError, NameError
Object.const_get(Module.constants.detect{|c|parts.last.downcase == c.downcase})
end
end
end
......
......@@ -69,6 +69,11 @@ EOS
acts_as_awesome :yah
end
EOS
create('foo_with_capitals.rb', <<-EOS)
class FooWithCAPITALS < ActiveRecord::Base
acts_as_awesome :yah
end
EOS
end
it "should work" do
klass = AnnotateModels.get_model_class("foo.rb")
......@@ -78,6 +83,10 @@ EOS
klass = AnnotateModels.get_model_class("foo_with_macro.rb")
klass.name.should == "FooWithMacro"
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
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