@@ -761,6 +761,49 @@ def mock_column(name, type, options = {})
761
761
end
762
762
end
763
763
end
764
+
765
+ context 'with Globalize gem' do
766
+ let :translation_klass do
767
+ double ( 'Post::Translation' ,
768
+ to_s : 'Post::Translation' ,
769
+ columns : [
770
+ mock_column ( :id , :integer , limit : 8 ) ,
771
+ mock_column ( :post_id , :integer , limit : 8 ) ,
772
+ mock_column ( :locale , :string , limit : 50 ) ,
773
+ mock_column ( :title , :string , limit : 50 ) ,
774
+ ] )
775
+ end
776
+
777
+ let :klass do
778
+ mock_class ( :posts , primary_key , columns , indexes , foreign_keys ) . tap do |mock_klass |
779
+ allow ( mock_klass ) . to receive ( :translation_class ) . and_return ( translation_klass )
780
+ end
781
+ end
782
+
783
+ let :columns do
784
+ [
785
+ mock_column ( :id , :integer , limit : 8 ) ,
786
+ mock_column ( :author_name , :string , limit : 50 ) ,
787
+ ]
788
+ end
789
+
790
+ let :expected_result do
791
+ <<~EOS
792
+ # Schema Info
793
+ #
794
+ # Table name: posts
795
+ #
796
+ # id :integer not null, primary key
797
+ # author_name :string(50) not null
798
+ # title :string(50) not null
799
+ #
800
+ EOS
801
+ end
802
+
803
+ it 'returns schema info' do
804
+ is_expected . to eq expected_result
805
+ end
806
+ end
764
807
end
765
808
766
809
context 'when the primary key is an array (using composite_primary_keys)' do
@@ -1140,39 +1183,6 @@ def mock_column(name, type, options = {})
1140
1183
end
1141
1184
end
1142
1185
1143
- it 'should work with the Globalize gem' do
1144
- klass = mock_class ( :posts ,
1145
- :id ,
1146
- [
1147
- mock_column ( :id , :integer , limit : 8 ) ,
1148
- mock_column ( :author_name , :string , limit : 50 ) ,
1149
- ] )
1150
-
1151
- options = {
1152
- to_s : 'Post::Translation' ,
1153
- columns : [
1154
- mock_column ( :id , :integer , limit : 8 ) ,
1155
- mock_column ( :post_id , :integer , limit : 8 ) ,
1156
- mock_column ( :locale , :string , limit : 50 ) ,
1157
- mock_column ( :title , :string , limit : 50 ) ,
1158
- ]
1159
- }
1160
- translation_klass = double ( 'Post::Translation' , options )
1161
- allow ( klass ) . to receive ( :translation_class ) . and_return ( translation_klass )
1162
-
1163
- expected_schema_info = <<~EOS
1164
- # Schema Info
1165
- #
1166
- # Table name: posts
1167
- #
1168
- # id :integer not null, primary key
1169
- # author_name :string(50) not null
1170
- # title :string(50) not null
1171
- #
1172
- EOS
1173
- expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' ) ) . to eql ( expected_schema_info )
1174
- end
1175
-
1176
1186
describe '.set_defaults' do
1177
1187
subject do
1178
1188
Annotate ::Helpers . true? ( ENV [ 'show_complete_foreign_keys' ] )
0 commit comments