Use average discomfort instead of sum #109
@ -8,7 +8,7 @@ module Tables
|
|||||||
end
|
end
|
||||||
|
|
||||||
def calculate
|
def calculate
|
||||||
table_size_penalty + cohesion_penalty
|
table_size_penalty + 10 * (cohesion_penalty * 1.0 / table.size)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -10,6 +10,19 @@ module Tables
|
|||||||
let(:work) { create(:group, name: 'work') }
|
let(:work) { create(:group, name: 'work') }
|
||||||
let(:school) { create(:group, name: 'school') }
|
let(:school) { create(:group, name: 'school') }
|
||||||
|
|
||||||
|
describe '#calculate' do
|
||||||
|
before do
|
||||||
|
allow(calculator).to receive(:table_size_penalty).and_return(2)
|
||||||
|
allow(calculator).to receive(:cohesion_penalty).and_return(3)
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:table) { Table.new(create_list(:guest, 6)) }
|
||||||
|
|
||||||
|
it 'returns the sum of the table size penalty and the average cohesion penalty' do
|
||||||
|
expect(calculator.calculate).to eq(2 + 10 * 3 / 6.0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#table_size_penalty' do
|
describe '#table_size_penalty' do
|
||||||
before do
|
before do
|
||||||
table.min_per_table = 5
|
table.min_per_table = 5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user