mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge branch 'master' into bugfix
This commit is contained in:
@@ -10,21 +10,29 @@ FactoryGirl.define do
|
||||
|
||||
after(:create) do |oc|
|
||||
# Suppliers
|
||||
supplier1 = create(:supplier_enterprise)
|
||||
supplier2 = create(:supplier_enterprise)
|
||||
|
||||
# Incoming Exchanges
|
||||
ex1 = create(:exchange, :order_cycle => oc, :incoming => true,
|
||||
:sender => create(:supplier_enterprise), :receiver => oc.coordinator)
|
||||
:sender => supplier1, :receiver => oc.coordinator)
|
||||
ex2 = create(:exchange, :order_cycle => oc, :incoming => true,
|
||||
:sender => create(:supplier_enterprise), :receiver => oc.coordinator)
|
||||
:sender => supplier2, :receiver => oc.coordinator)
|
||||
ExchangeFee.create!(exchange: ex1,
|
||||
enterprise_fee: create(:enterprise_fee, enterprise: ex1.sender))
|
||||
ExchangeFee.create!(exchange: ex2,
|
||||
enterprise_fee: create(:enterprise_fee, enterprise: ex2.sender))
|
||||
|
||||
# Distributors
|
||||
#Distributors
|
||||
distributor1 = create(:distributor_enterprise)
|
||||
distributor2 = create(:distributor_enterprise)
|
||||
|
||||
# Outgoing Exchanges
|
||||
ex3 = create(:exchange, :order_cycle => oc, :incoming => false,
|
||||
:sender => oc.coordinator, :receiver => create(:distributor_enterprise),
|
||||
:sender => oc.coordinator, :receiver => distributor1,
|
||||
:pickup_time => 'time 0', :pickup_instructions => 'instructions 0')
|
||||
ex4 = create(:exchange, :order_cycle => oc, :incoming => false,
|
||||
:sender => oc.coordinator, :receiver => create(:distributor_enterprise),
|
||||
:sender => oc.coordinator, :receiver => distributor2,
|
||||
:pickup_time => 'time 1', :pickup_instructions => 'instructions 1')
|
||||
ExchangeFee.create!(exchange: ex3,
|
||||
enterprise_fee: create(:enterprise_fee, enterprise: ex3.receiver))
|
||||
|
||||
@@ -113,7 +113,7 @@ feature %q{
|
||||
let!(:supplier1) { order_cycle1.suppliers.first }
|
||||
let!(:supplier2) { order_cycle1.suppliers.last }
|
||||
let!(:distributor1) { order_cycle1.distributors.first }
|
||||
let!(:distributor2) { order_cycle1.distributors.last }
|
||||
let!(:distributor2) { order_cycle1.distributors.reject{ |d| d == distributor1 }.last } # ensure d1 != d2
|
||||
let(:product) { order_cycle1.products.first }
|
||||
|
||||
before(:each) do
|
||||
|
||||
@@ -3,20 +3,15 @@ RSpec::Matchers.define :have_table_row do |row|
|
||||
match_for_should do |node|
|
||||
@row = row
|
||||
|
||||
false_on_timeout_error do
|
||||
wait_until { rows_under(node).include? row }
|
||||
end
|
||||
node.has_selector? "tr", text: row.join(" ").strip # Check for appearance
|
||||
rows_under(node).include? row # Robust check of columns
|
||||
end
|
||||
|
||||
match_for_should_not do |node|
|
||||
@row = row
|
||||
|
||||
false_on_timeout_error do
|
||||
# Without this sleep, we trigger capybara's wait when looking up the table, for the full
|
||||
# period of default_wait_time.
|
||||
sleep 0.1
|
||||
wait_until { !rows_under(node).include? row }
|
||||
end
|
||||
node.has_no_selector? "tr", text: row.join(" ").strip # Check for appearance
|
||||
!rows_under(node).include? row # Robust check of columns
|
||||
end
|
||||
|
||||
failure_message_for_should do |text|
|
||||
@@ -27,17 +22,7 @@ RSpec::Matchers.define :have_table_row do |row|
|
||||
"expected not to find table row #{@row}"
|
||||
end
|
||||
|
||||
|
||||
def rows_under(node)
|
||||
node.all('tr').map { |tr| tr.all('th, td').map(&:text) }
|
||||
end
|
||||
|
||||
def false_on_timeout_error
|
||||
yield
|
||||
rescue TimeoutError
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user