File tree 3 files changed +20
-4
lines changed
3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,6 @@ def self.establish_connection(config = nil)
6
6
end
7
7
end
8
8
end
9
+
10
+ class OriginalAdapterConnection < ConnectionBase ; end
9
11
end
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ def reconnect_with_percona
81
81
# enabled in a previous migration.
82
82
def reconnect_without_percona
83
83
return unless connection_config [ :adapter ] == 'percona'
84
- Departure ::ConnectionBase . establish_connection ( connection_config . merge ( adapter : original_adapter ) )
84
+ Departure ::OriginalAdapterConnection . establish_connection ( connection_config . merge ( adapter : original_adapter ) )
85
85
end
86
86
87
87
private
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
+ require 'fixtures/migrate/0022_add_timestamp_on_comments'
2
3
3
4
# TODO: Handle #change_table syntax
4
5
describe Departure , integration : true do
5
6
class Comment < ActiveRecord ::Base ; end
6
7
7
- let ( :migration_fixtures ) do
8
- ActiveRecord ::MigrationContext . new ( [ MIGRATION_FIXTURES ] , ActiveRecord ::SchemaMigration ) . migrations
9
- end
8
+ let ( :migration_paths ) { [ MIGRATION_FIXTURES ] }
9
+ let ( :migration_context ) { ActiveRecord ::MigrationContext . new ( migration_paths , ActiveRecord ::SchemaMigration ) }
10
+ let ( :migration_fixtures ) { migration_context . migrations }
10
11
11
12
let ( :direction ) { :up }
12
13
let ( :pool ) { ActiveRecord ::Base . connection_pool }
@@ -204,4 +205,17 @@ class Comment < ActiveRecord::Base; end
204
205
end
205
206
end
206
207
end
208
+
209
+ context 'when there are migrations that do not use departure' do
210
+ let ( :migration ) { AddTimestampOnComments }
211
+
212
+ before do
213
+ allow ( migration ) . to receive ( :uses_departure ) . and_return ( false )
214
+ end
215
+
216
+ it 'uses Departure::OriginalConnectionAdapter' do
217
+ expect ( Departure ::OriginalAdapterConnection ) . to receive ( :establish_connection )
218
+ migration_context . run ( direction , 22 )
219
+ end
220
+ end
207
221
end
You can’t perform that action at this time.
0 commit comments