FactoryBot.define do
	factory :licitacao_lote, class: 'Licitacao::Lote' do
		projeto_id {
			FactoryBot.create(:licitacao_projeto, :por_lote, status: :em_sessao).id
		}
		lances_abertos {true}
		criterio_de_julgamento {'menor_preco'}

		trait :melhor_tecnica do
			criterio_de_julgamento {'melhor_tecnica'}
		end

		trait :tecnica_e_preco do
			criterio_de_julgamento {'tecnica_e_preco'}
		end

		trait :completo do
			after(:create) do |lote|
				FactoryBot.create_list(:licitacao_item_do_lote, 2, lote_id: lote.id)
				lote.processo.pessoas_do_projeto.each do |pessoa_do_projeto|
					pessoa_do_projeto.send(:cria_pessoas_do_lote)
					lote.reload.itens_do_lote.each do |il|
						FactoryBot.create(:item_do_projeto_por_pessoa, item_do_lote_id: il.id, pessoa_do_projeto_id: pessoa_do_projeto.id, final: false)
					end
				end
			end
		end
	end
end
