Skip to content

Commit c1a46cd

Browse files
committed
Merge pull request #239 from berg/fix-tags-scope
Don't mutate configuration tags hash on event creation
2 parents a941de6 + c12ea67 commit c1a46cd

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/raven/event.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def initialize(options = {}, &block)
5252
@extra = options[:extra] || {}
5353
@extra.merge!(context.extra)
5454

55-
@tags = @configuration.tags
55+
@tags = {}
56+
@tags.merge!(@configuration.tags)
5657
@tags.merge!(options[:tags] || {})
5758
@tags.merge!(context.tags)
5859

spec/raven/event_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,31 @@
200200
end
201201
end
202202

203+
context 'configuration tags unspecified' do
204+
it 'should not persist tags between unrelated events' do
205+
config = Raven::Configuration.new
206+
207+
Raven::Event.new(
208+
:level => 'warning',
209+
:logger => 'foo',
210+
:tags => {
211+
'foo' => 'bar'
212+
},
213+
:server_name => 'foo.local',
214+
:configuration => config
215+
)
216+
217+
hash = Raven::Event.new(
218+
:level => 'warning',
219+
:logger => 'foo',
220+
:server_name => 'foo.local',
221+
:configuration => config
222+
).to_hash
223+
224+
expect(hash['tags']).to eq({})
225+
end
226+
end
227+
203228
describe '.initialize' do
204229
it 'should not touch the env object for an ignored environment' do
205230
Raven.configure(true) do |config|

0 commit comments

Comments
 (0)