Fix specs
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Run unit tests / copyright_notice (pull_request) Successful in 1m50s
				
			
		
			
				
	
				Run unit tests / rubocop (pull_request) Failing after 2m12s
				
			
		
			
				
	
				Run unit tests / check-licenses (pull_request) Successful in 2m50s
				
			
		
			
				
	
				Run unit tests / unit_tests (pull_request) Successful in 3m48s
				
			
		
			
				
	
				Run unit tests / build-static-assets (pull_request) Successful in 1h45m6s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Run unit tests / copyright_notice (pull_request) Successful in 1m50s
				
			Run unit tests / rubocop (pull_request) Failing after 2m12s
				
			Run unit tests / check-licenses (pull_request) Successful in 2m50s
				
			Run unit tests / unit_tests (pull_request) Successful in 3m48s
				
			Run unit tests / build-static-assets (pull_request) Successful in 1h45m6s
				
			This commit is contained in:
		
							parent
							
								
									12174b6f20
								
							
						
					
					
						commit
						78ab27a697
					
				| @ -6,24 +6,24 @@ require 'rails_helper' | |||||||
| 
 | 
 | ||||||
| module Tables | module Tables | ||||||
|   RSpec.describe Distribution do |   RSpec.describe Distribution do | ||||||
|     describe '#save!' do |     let(:tables_arrangement) { TablesArrangement.create! } | ||||||
|        |  | ||||||
|       around do |example| |  | ||||||
|         ActsAsTenant.with_tenant(create(:wedding)) do |  | ||||||
|           example.run |  | ||||||
|         end |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|  |     around do |example| | ||||||
|  |       ActsAsTenant.with_tenant(create(:wedding)) do | ||||||
|  |         example.run | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|  |     describe '#save!' do | ||||||
|       let(:people) { create_list(:guest, 2, status: :invited) } |       let(:people) { create_list(:guest, 2, status: :invited) } | ||||||
|       let(:distribution) do |       let(:distribution) do | ||||||
|         described_class.new(min_per_table: 5, max_per_table: 10).tap{|d| d.random_distribution(people)} |         described_class.new(min_per_table: 5, max_per_table: 10, tables_arrangement_id: tables_arrangement.id) | ||||||
|  |                        .tap { |d| d.random_distribution(people) } | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       context 'when tables_arrangement_id is nil' do |       context 'when tables_arrangement_id is nil' do | ||||||
| 
 |         it { expect { distribution.save! }.to change(TablesArrangement, :count).by(1) } | ||||||
| 
 |         it { expect { distribution.save! }.to change(Seat, :count).by(2) } | ||||||
|         it { expect { distribution.save! }.to change { TablesArrangement.count }.by(1) } |  | ||||||
|         it { expect { distribution.save! }.to change { Seat.count }.by(2) } |  | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       context 'when tables_arrangement_id is set' do |       context 'when tables_arrangement_id is set' do | ||||||
| @ -34,13 +34,15 @@ module Tables | |||||||
|           distribution.tables_arrangement_id = existing_arrangement.id |           distribution.tables_arrangement_id = existing_arrangement.id | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it { expect { distribution.save! }.not_to change { TablesArrangement.count } } |         it { expect { distribution.save! }.not_to(change(TablesArrangement, :count)) } | ||||||
|         it { expect { distribution.save! }.to change { Seat.count }.by(1) } |         it { expect { distribution.save! }.to change(Seat, :count).by(1) } | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     describe '#random_distribution' do |     describe '#random_distribution' do | ||||||
|       subject(:distribution) { described_class.new(min_per_table: 5, max_per_table: 10) } |       subject(:distribution) do | ||||||
|  |         described_class.new(min_per_table: 5, max_per_table: 10, tables_arrangement_id: tables_arrangement.id) | ||||||
|  |       end | ||||||
| 
 | 
 | ||||||
|       context 'when there are fewer people than the minimum per table' do |       context 'when there are fewer people than the minimum per table' do | ||||||
|         it 'creates one table' do |         it 'creates one table' do | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ module Tables | |||||||
| 
 | 
 | ||||||
|       context 'when there are two tables with two people each' do |       context 'when there are two tables with two people each' do | ||||||
|         let(:initial_solution) do |         let(:initial_solution) do | ||||||
|           Distribution.new(min_per_table: 2, max_per_table: 2).tap do |distribution| |           Distribution.new(min_per_table: 2, max_per_table: 2, tables_arrangement_id: nil).tap do |distribution| | ||||||
|             distribution.tables << Set[:a, :b].to_table |             distribution.tables << Set[:a, :b].to_table | ||||||
|             distribution.tables << Set[:c, :d].to_table |             distribution.tables << Set[:c, :d].to_table | ||||||
|           end |           end | ||||||
| @ -35,7 +35,7 @@ module Tables | |||||||
| 
 | 
 | ||||||
|       context 'when there are two tables with three people each' do |       context 'when there are two tables with three people each' do | ||||||
|         let(:initial_solution) do |         let(:initial_solution) do | ||||||
|           Distribution.new(min_per_table: 3, max_per_table: 3).tap do |distribution| |           Distribution.new(min_per_table: 3, max_per_table: 3, tables_arrangement_id: nil).tap do |distribution| | ||||||
|             distribution.tables << Set[:a, :b, :c].to_table |             distribution.tables << Set[:a, :b, :c].to_table | ||||||
|             distribution.tables << Set[:d, :e, :f].to_table |             distribution.tables << Set[:d, :e, :f].to_table | ||||||
|           end |           end | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ module Tables | |||||||
| 
 | 
 | ||||||
|       context 'when there are two tables with two people each' do |       context 'when there are two tables with two people each' do | ||||||
|         let(:initial_solution) do |         let(:initial_solution) do | ||||||
|           Distribution.new(min_per_table: 2, max_per_table: 2).tap do |distribution| |           Distribution.new(min_per_table: 2, max_per_table: 2, tables_arrangement_id: nil).tap do |distribution| | ||||||
|             distribution.tables << Set[:a, :b].to_table |             distribution.tables << Set[:a, :b].to_table | ||||||
|             distribution.tables << Set[:c, :d].to_table |             distribution.tables << Set[:c, :d].to_table | ||||||
|           end |           end | ||||||
| @ -35,7 +35,7 @@ module Tables | |||||||
| 
 | 
 | ||||||
|       context 'when there are two tables with three people each' do |       context 'when there are two tables with three people each' do | ||||||
|         let(:initial_solution) do |         let(:initial_solution) do | ||||||
|           Distribution.new(min_per_table: 3, max_per_table: 3).tap do |distribution| |           Distribution.new(min_per_table: 3, max_per_table: 3, tables_arrangement_id: nil).tap do |distribution| | ||||||
|             distribution.tables << Set[:a, :b, :c].to_table |             distribution.tables << Set[:a, :b, :c].to_table | ||||||
|             distribution.tables << Set[:d, :e, :f].to_table |             distribution.tables << Set[:d, :e, :f].to_table | ||||||
|           end |           end | ||||||
| @ -58,7 +58,7 @@ module Tables | |||||||
| 
 | 
 | ||||||
|       context 'when there are three tables with two people each' do |       context 'when there are three tables with two people each' do | ||||||
|         let(:initial_solution) do |         let(:initial_solution) do | ||||||
|           Distribution.new(min_per_table: 2, max_per_table: 2).tap do |distribution| |           Distribution.new(min_per_table: 2, max_per_table: 2, tables_arrangement_id: nil).tap do |distribution| | ||||||
|             distribution.tables << Set[:a, :b].to_table |             distribution.tables << Set[:a, :b].to_table | ||||||
|             distribution.tables << Set[:c, :d].to_table |             distribution.tables << Set[:c, :d].to_table | ||||||
|             distribution.tables << Set[:e, :f].to_table |             distribution.tables << Set[:e, :f].to_table | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ module Tables | |||||||
|   RSpec.describe WheelSwap do |   RSpec.describe WheelSwap do | ||||||
|     context 'when the solution has three tables' do |     context 'when the solution has three tables' do | ||||||
|       let(:initial_solution) do |       let(:initial_solution) do | ||||||
|         Distribution.new(min_per_table: 3, max_per_table: 3).tap do |distribution| |         Distribution.new(min_per_table: 3, max_per_table: 3, tables_arrangement_id: nil).tap do |distribution| | ||||||
|           distribution.tables << Set[:a, :b, :c].to_table |           distribution.tables << Set[:a, :b, :c].to_table | ||||||
|           distribution.tables << Set[:d, :e, :f].to_table |           distribution.tables << Set[:d, :e, :f].to_table | ||||||
|           distribution.tables << Set[:g, :h, :i].to_table |           distribution.tables << Set[:g, :h, :i].to_table | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user