@@ -383,6 +383,49 @@ def mock_column(name, type, options = {})
383
383
is_expected . to eq ( expected_result )
384
384
end
385
385
end
386
+
387
+ context 'with Globalize gem' do
388
+ let :translation_klass do
389
+ double ( 'Post::Translation' ,
390
+ to_s : 'Post::Translation' ,
391
+ columns : [
392
+ mock_column ( :id , :integer , limit : 8 ) ,
393
+ mock_column ( :post_id , :integer , limit : 8 ) ,
394
+ mock_column ( :locale , :string , limit : 50 ) ,
395
+ mock_column ( :title , :string , limit : 50 ) ,
396
+ ] )
397
+ end
398
+
399
+ let :klass do
400
+ mock_class ( :posts , primary_key , columns , indexes , foreign_keys ) . tap do |mock_klass |
401
+ allow ( mock_klass ) . to receive ( :translation_class ) . and_return ( translation_klass )
402
+ end
403
+ end
404
+
405
+ let :columns do
406
+ [
407
+ mock_column ( :id , :integer , limit : 8 ) ,
408
+ mock_column ( :author_name , :string , limit : 50 ) ,
409
+ ]
410
+ end
411
+
412
+ let :expected_result do
413
+ <<~EOS
414
+ # Schema Info
415
+ #
416
+ # Table name: posts
417
+ #
418
+ # id :integer not null, primary key
419
+ # author_name :string(50) not null
420
+ # title :string(50) not null
421
+ #
422
+ EOS
423
+ end
424
+
425
+ it 'returns schema info' do
426
+ is_expected . to eq expected_result
427
+ end
428
+ end
386
429
end
387
430
end
388
431
end
@@ -793,55 +836,6 @@ def mock_column(name, type, options = {})
793
836
end
794
837
795
838
context 'when the primary key is specified' do
796
- context 'when the primary_key is :id' do
797
- let :primary_key do
798
- :id
799
- end
800
-
801
- context 'with Globalize gem' do
802
- let :translation_klass do
803
- double ( 'Post::Translation' ,
804
- to_s : 'Post::Translation' ,
805
- columns : [
806
- mock_column ( :id , :integer , limit : 8 ) ,
807
- mock_column ( :post_id , :integer , limit : 8 ) ,
808
- mock_column ( :locale , :string , limit : 50 ) ,
809
- mock_column ( :title , :string , limit : 50 ) ,
810
- ] )
811
- end
812
-
813
- let :klass do
814
- mock_class ( :posts , primary_key , columns , indexes , foreign_keys ) . tap do |mock_klass |
815
- allow ( mock_klass ) . to receive ( :translation_class ) . and_return ( translation_klass )
816
- end
817
- end
818
-
819
- let :columns do
820
- [
821
- mock_column ( :id , :integer , limit : 8 ) ,
822
- mock_column ( :author_name , :string , limit : 50 ) ,
823
- ]
824
- end
825
-
826
- let :expected_result do
827
- <<~EOS
828
- # Schema Info
829
- #
830
- # Table name: posts
831
- #
832
- # id :integer not null, primary key
833
- # author_name :string(50) not null
834
- # title :string(50) not null
835
- #
836
- EOS
837
- end
838
-
839
- it 'returns schema info' do
840
- is_expected . to eq expected_result
841
- end
842
- end
843
- end
844
-
845
839
context 'when the primary key is an array (using composite_primary_keys)' do
846
840
let :primary_key do
847
841
[ :a_id , :b_id ]
0 commit comments