Skip to content

Commit

Permalink
Freeze config on operation config
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Jul 8, 2024
1 parent ea12778 commit d660733
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module WhiteLabel

it 'uses config from options' do
operation_config = { endpoint: 'https://example.com' }
expect_any_instance_of(Config).to receive(:freeze)
expect_any_instance_of(Config)
.to receive(:merge).with(operation_config)
.and_call_original
Expand Down
2 changes: 2 additions & 0 deletions hearth/lib/hearth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize_config(options, config_class)
config.plugins.each { |p| p.call(config) }
config.interceptors.concat(client_interceptors)
config.validate!
config.freeze
config
end

Expand All @@ -55,6 +56,7 @@ def operation_config(options)
operation_plugins&.each { |p| p.call(config) }
config.interceptors.concat(operation_interceptors)
config.validate!
config.freeze
config
end

Expand Down
8 changes: 8 additions & 0 deletions hearth/spec/hearth/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def read_before_signing(*args); end
client = Test::Client.new(interceptors: [interceptor])
expect(client.config.interceptors.to_a).to include(interceptor)
end

it 'freezes config' do
expect(subject.config.frozen?).to be(true)
end
end

describe '#inspect' do
Expand Down Expand Up @@ -130,6 +134,10 @@ def read_before_signing(*args); end
config = subject.operation({}, interceptors: [interceptor])
expect(config.interceptors.to_a).to eq([interceptor])
end

it 'freezes config' do
expect(subject.operation.frozen?).to be(true)
end
end

describe '#output_stream' do
Expand Down

0 comments on commit d660733

Please sign in to comment.