@@ -10,7 +10,10 @@ def mock_class(table_name, primary_key, columns)
1010 :table_name => table_name ,
1111 :primary_key => primary_key ,
1212 :column_names => columns . map { |col | col . name . to_s } ,
13- :columns => columns
13+ :columns => columns ,
14+ :column_defaults => Hash [ columns . map { |col |
15+ [ col . name , col . default ]
16+ } ]
1417 }
1518
1619 double ( "An ActiveRecord class" , options )
@@ -106,6 +109,24 @@ def mock_column(name, type, options={})
106109EOS
107110 end
108111
112+ it "should get schema info for integer and boolean with default" do
113+ klass = mock_class ( :users , :id , [
114+ mock_column ( :id , :integer ) ,
115+ mock_column ( :size , :integer , :default => 20 ) ,
116+ mock_column ( :flag , :boolean , :default => false )
117+ ] )
118+ expect ( AnnotateModels . get_schema_info ( klass , "Schema Info" ) ) . to eql ( <<-EOS )
119+ # Schema Info
120+ #
121+ # Table name: users
122+ #
123+ # id :integer not null, primary key
124+ # size :integer default(20), not null
125+ # flag :boolean default(FALSE), not null
126+ #
127+ EOS
128+ end
129+
109130 it "should get schema info as RDoc" do
110131 klass = mock_class ( :users , :id , [
111132 mock_column ( :id , :integer ) ,
0 commit comments