File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ def tag_content
176
176
key , value_input = tag
177
177
178
178
val = case value_input
179
- when nil then tag_value ( key ) if taggings . has_key? key
179
+ when nil then tag_value ( key )
180
180
when Proc then instance_exec ( &value_input )
181
181
else value_input
182
182
end
@@ -186,12 +186,14 @@ def tag_content
186
186
end
187
187
188
188
def tag_value ( key )
189
- value = taggings [ key ]
190
-
191
- if value . respond_to? ( :call )
192
- instance_exec ( &taggings [ key ] )
189
+ if value = taggings [ key ]
190
+ if value . respond_to? ( :call )
191
+ instance_exec ( &taggings [ key ] )
192
+ else
193
+ value
194
+ end
193
195
else
194
- value
196
+ context [ key ]
195
197
end
196
198
end
197
199
Original file line number Diff line number Diff line change @@ -137,6 +137,18 @@ def test_ensure_context_has_symbol_keys
137
137
ActiveRecord ::QueryLogs . update_context ( application_name : nil )
138
138
end
139
139
140
+ def test_default_tag_behavior
141
+ ActiveRecord ::QueryLogs . tags = [ :application , :foo ]
142
+ ActiveRecord ::QueryLogs . set_context ( foo : "bar" ) do
143
+ assert_sql ( %r{/\* application:active_record,foo:bar\* /} ) do
144
+ Dashboard . first
145
+ end
146
+ end
147
+ assert_sql ( %r{/\* application:active_record\* /} ) do
148
+ Dashboard . first
149
+ end
150
+ end
151
+
140
152
def test_inline_tags_only_affect_block
141
153
# disable regular comment tags
142
154
ActiveRecord ::QueryLogs . tags = [ ]
You can’t perform that action at this time.
0 commit comments