File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,11 @@ def get_model_class(file)
239
239
begin
240
240
parts . inject ( Object ) { |klass , part | klass . const_get ( part ) }
241
241
rescue LoadError , NameError
242
- Object . const_get ( parts . last )
242
+ begin
243
+ Object . const_get ( parts . last )
244
+ rescue LoadError , NameError
245
+ Object . const_get ( Module . constants . detect { |c |parts . last . downcase == c . downcase } )
246
+ end
243
247
end
244
248
end
245
249
Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ class FooWithMacro < ActiveRecord::Base
69
69
acts_as_awesome :yah
70
70
end
71
71
EOS
72
+ create ( 'foo_with_capitals.rb' , <<-EOS )
73
+ class FooWithCAPITALS < ActiveRecord::Base
74
+ acts_as_awesome :yah
75
+ end
76
+ EOS
72
77
end
73
78
it "should work" do
74
79
klass = AnnotateModels . get_model_class ( "foo.rb" )
@@ -78,6 +83,10 @@ class FooWithMacro < ActiveRecord::Base
78
83
klass = AnnotateModels . get_model_class ( "foo_with_macro.rb" )
79
84
klass . name . should == "FooWithMacro"
80
85
end
86
+ it "should find models with non standard capitalization" do
87
+ klass = AnnotateModels . get_model_class ( "foo_with_capitals.rb" )
88
+ klass . name . should == "FooWithCAPITALS"
89
+ end
81
90
end
82
91
83
92
end
You can’t perform that action at this time.
0 commit comments