File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ def inheritance_enabled
187187 # Elasticsearch::Model.inheritance_enabled = true
188188 #
189189 def inheritance_enabled = ( inheritance_enabled )
190- warn STI_DEPRECATION_WARNING
190+ warn STI_DEPRECATION_WARNING if inheritance_enabled
191191 @settings [ :inheritance_enabled ] = inheritance_enabled
192192 end
193193
Original file line number Diff line number Diff line change @@ -89,5 +89,30 @@ def self.search(query, options={})
8989 expect ( Elasticsearch ::Model . settings [ :foo ] ) . to eq ( 'bar' )
9090 end
9191 end
92+
93+ context 'when \'inheritance_enabled\' is set' do
94+
95+ around do |example |
96+ original_value = Elasticsearch ::Model . settings [ :inheritance_enabled ]
97+ example . run
98+ Elasticsearch ::Model . settings [ :inheritance_enabled ] = original_value
99+ end
100+
101+ context 'when \'inheritance_enabled\' is true' do
102+
103+ it 'warns with a deprecation message' do
104+ expect ( Elasticsearch ::Model ) . to receive ( :warn )
105+ Elasticsearch ::Model . inheritance_enabled = true
106+ end
107+ end
108+
109+ context 'when \'inheritance_enabled\' is false' do
110+
111+ it 'does not warn' do
112+ expect ( Elasticsearch ::Model ) . not_to receive ( :warn )
113+ Elasticsearch ::Model . inheritance_enabled = false
114+ end
115+ end
116+ end
92117 end
93118end
You can’t perform that action at this time.
0 commit comments