From 5b36526c599d57601afab487769254517aaceb66 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 10 Nov 2024 18:40:26 +0100 Subject: [PATCH] Increase penalty for tables under minimum capacity --- app/services/tables/discomfort_calculator.rb | 2 +- spec/services/tables/discomfort_calculator_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/tables/discomfort_calculator.rb b/app/services/tables/discomfort_calculator.rb index 9942bf0..c21796a 100644 --- a/app/services/tables/discomfort_calculator.rb +++ b/app/services/tables/discomfort_calculator.rb @@ -22,7 +22,7 @@ module Tables # def table_size_penalty case table.size - when 0...table.min_per_table then 2 * (table.min_per_table - table.size) + when 0...table.min_per_table then 5 * (table.min_per_table - table.size) when table.min_per_table..table.max_per_table then 0 else 5 * (table.size - table.max_per_table) end diff --git a/spec/services/tables/discomfort_calculator_spec.rb b/spec/services/tables/discomfort_calculator_spec.rb index eab291b..99fb3d0 100644 --- a/spec/services/tables/discomfort_calculator_spec.rb +++ b/spec/services/tables/discomfort_calculator_spec.rb @@ -49,13 +49,13 @@ module Tables context 'when the number of guests is one unit below the lower bound' do let(:table) { Table.new(create_list(:guest, 4)) } - it { expect(calculator.send(:table_size_penalty)).to eq(2) } + it { expect(calculator.send(:table_size_penalty)).to eq(5) } end context 'when the number of guests is two units below the lower bound' do let(:table) { Table.new(create_list(:guest, 3)) } - it { expect(calculator.send(:table_size_penalty)).to eq(4) } + it { expect(calculator.send(:table_size_penalty)).to eq(10) } end context 'when the number of guests is one unit above the upper bound' do