Skip to content

Commit 335b910

Browse files
committed
Some test fixes and cleanup
1 parent 7373fe2 commit 335b910

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

app/actions/manifest_route_update.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ def find_or_create_valid_route(app, manifest_route, user_audit_info)
9595
elsif !route.available_in_space?(app.space)
9696
raise InvalidRoute.new('Routes cannot be mapped to destinations in different spaces')
9797
elsif manifest_route[:options]
98-
# remove nil values from options
99-
manifest_route[:options] = manifest_route[:options].compact
10098
message = RouteUpdateMessage.new({
10199
'options' => manifest_route[:options]
102100
})

app/actions/route_create.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def create(message:, space:, domain:, manifest_triggered: false)
2020
)
2121

2222
Route.db.transaction do
23-
route.save(raise_on_failure: true)
23+
route.save
2424

2525
MetadataUpdate.update(route, message)
2626
end

app/actions/route_update.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class Error < StandardError
66
def update(route:, message:)
77

88
Route.db.transaction do
9-
route.options = route.options.symbolize_keys.merge(message.options).compact if message.requested?(:options)
10-
route.save(raise_on_failure: true)
9+
route.options = route.options.symbolize_keys.merge(message.options) if message.requested?(:options)
10+
route.save
1111
MetadataUpdate.update(route, message)
1212
end
1313

app/models/runtime/route.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def options_with_serialization=(opts)
7878
cleaned_opts = remove_hash_options_for_non_hash_loadbalancing(opts)
7979
rounded_opts = round_hash_balance_to_one_decimal(cleaned_opts)
8080
normalized_opts = normalize_hash_balance_to_string(rounded_opts)
81+
# Remove nil values after all processing
82+
normalized_opts = normalized_opts.compact if normalized_opts.is_a?(Hash)
8183
self.options_without_serialization = Oj.dump(normalized_opts)
8284

8385
logger.error("CRITICAL: options_with_serialization= setter completed", normalized_opts: normalized_opts.inspect, json: self.options_without_serialization.inspect)
@@ -330,7 +332,7 @@ def validate_total_reserved_route_ports
330332
def validate_route_options
331333
return if options.blank?
332334

333-
route_options = options.is_a?(Hash) ? options : options.deep_symbolize_keys
335+
route_options = options.is_a?(Hash) ? options : options.symbolize_keys
334336
loadbalancing = route_options[:loadbalancing] || route_options['loadbalancing']
335337

336338
return if loadbalancing != 'hash'

spec/unit/messages/validators_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ def self.enabled?(flag_name, **)
708708
it 'does not allow hash_balance between 0 and 1.1' do
709709
message = OptionsMessage.new({ options: { hash_balance: 0.5 } })
710710
expect(message).not_to be_valid
711-
expect(message.errors.full_messages).to include('Options Hash balance must be either 0 or greater than or equal to 1.1')
711+
expect(message.errors.full_messages).to include('Options Hash balance must be either 0 or between 1.1 and 10.0')
712712
end
713713

714714
it 'allows numeric string hash_balance' do

0 commit comments

Comments
 (0)