File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,9 @@ def hijack_methods
98
98
around_save :run_on_shard , :unless => -> { self . class . custom_octopus_connection }
99
99
after_initialize :set_current_shard
100
100
101
+ cattr_accessor :custom_octopus_connection
102
+
101
103
class << self
102
- attr_accessor :custom_octopus_connection
103
104
attr_accessor :custom_octopus_table_name
104
105
105
106
alias_method_chain :connection , :octopus
Original file line number Diff line number Diff line change 263
263
expect ( CustomConnection . connection . current_database ) . to eq ( 'octopus_shard_2' )
264
264
end
265
265
266
+ it 'reuses parent model connection' do
267
+ klass = Class . new ( CustomConnection )
268
+
269
+ expect ( klass . connection ) . to be klass . connection
270
+ end
271
+
266
272
it 'should not mess with custom connection table names' do
267
273
expect ( Advert . connection . current_database ) . to eq ( 'octopus_shard_1' )
268
274
Advert . create! ( :name => 'Teste' )
You can’t perform that action at this time.
0 commit comments