Skip to content

Commit e3c7ad8

Browse files
committed
Sometimes tests encode unreal situations
* mutant signalled some unhandled mutations around key.to_s * which lead to the investigation that we should not need key.to_s at all * the reason we have to do it is because of the tests, transformation tested on their own do not pass through SymbolizeMetadaKeys which is part of every mapper — when such transformation is not present as part of the pipeline the keys wound not be symbols: thus the key.to_s fallback
1 parent 0e0c4f7 commit e3c7ad8

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ruby_event_store/lib/ruby_event_store/mappers/transformation/preserve_types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def restore_type(argument, type)
143143
case type
144144
when Hash
145145
argument.reduce({}) do |hash, (key, value)|
146-
key_type, value_type = type.fetch(key.to_sym) { type.fetch(key.to_s) }
146+
key_type, value_type = type.fetch(key.to_sym)
147147
hash.merge(restore_type(key, key_type) => restore_type(value, value_type))
148148
end
149149
when Array

ruby_event_store/spec/mappers/transformation/preserve_types_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module Transformation
3535
valid_at: time,
3636
)
3737
end
38+
3839
let(:dump_of_record) do
3940
Record.new(
4041
event_id: uuid,
@@ -337,16 +338,14 @@ module Transformation
337338
event_id: uuid,
338339
metadata: {
339340
},
340-
data: {
341-
active_support_time_with_zone: active_support_time_with_zone,
342-
},
341+
data: active_support_time_with_zone,
343342
event_type: "TestEvent",
344343
timestamp: nil,
345344
valid_at: nil,
346345
)
347346

348347
expect(transformation.dump(record).metadata[:types]).to eq(
349-
{ data: { "active_support_time_with_zone" => %w[Symbol ActiveSupport::TimeWithZone] }, metadata: {} },
348+
{ data: "ActiveSupport::TimeWithZone", metadata: {} },
350349
)
351350
expect(transformation.load(transformation.dump(record))).to eq(record)
352351
ensure

0 commit comments

Comments
 (0)