mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Fix failing spec with table reorder, lambda-fy scopes that use time
This commit is contained in:
@@ -27,9 +27,9 @@ class OrderCycle < ActiveRecord::Base
|
||||
joins(:exchanges).merge(Exchange.outgoing).where('exchanges.receiver_id = ?', distributor)
|
||||
}
|
||||
|
||||
scope :soonest_closing, active.order('order_cycles.orders_close_at ASC')
|
||||
scope :most_recently_closed, closed.order('order_cycles.orders_close_at DESC')
|
||||
scope :soonest_opening, upcoming.order('order_cycles.orders_open_at ASC')
|
||||
scope :soonest_closing, lambda { active.order('order_cycles.orders_close_at ASC') }
|
||||
scope :most_recently_closed, lambda { closed.order('order_cycles.orders_close_at DESC') }
|
||||
scope :soonest_opening, lambda { upcoming.order('order_cycles.orders_open_at ASC') }
|
||||
|
||||
|
||||
scope :managed_by, lambda { |user|
|
||||
|
||||
@@ -347,19 +347,30 @@ feature %q{
|
||||
|
||||
scenario "updating many order cycle opening/closing times at once" do
|
||||
# Given three order cycles
|
||||
3.times { create(:order_cycle) }
|
||||
oc1 = create(:order_cycle)
|
||||
oc2 = create(:order_cycle)
|
||||
oc3 = create(:order_cycle)
|
||||
|
||||
# When I go to the order cycles page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
|
||||
# And I fill in some new opening/closing times and save them
|
||||
fill_in 'order_cycle_set_collection_attributes_0_orders_open_at', :with => '2012-12-01 12:00:00'
|
||||
fill_in 'order_cycle_set_collection_attributes_0_orders_close_at', :with => '2012-12-01 12:00:01'
|
||||
fill_in 'order_cycle_set_collection_attributes_1_orders_open_at', :with => '2012-12-01 12:00:02'
|
||||
fill_in 'order_cycle_set_collection_attributes_1_orders_close_at', :with => '2012-12-01 12:00:03'
|
||||
fill_in 'order_cycle_set_collection_attributes_2_orders_open_at', :with => '2012-12-01 12:00:04'
|
||||
fill_in 'order_cycle_set_collection_attributes_2_orders_close_at', :with => '2012-12-01 12:00:05'
|
||||
within("tr.order-cycle-#{oc1.id}") do
|
||||
all('input').first.set '2012-12-01 12:00:00'
|
||||
all('input').last.set '2012-12-01 12:00:01'
|
||||
end
|
||||
|
||||
within("tr.order-cycle-#{oc2.id}") do
|
||||
all('input').first.set '2012-12-01 12:00:02'
|
||||
all('input').last.set '2012-12-01 12:00:03'
|
||||
end
|
||||
|
||||
within("tr.order-cycle-#{oc3.id}") do
|
||||
all('input').first.set '2012-12-01 12:00:04'
|
||||
all('input').last.set '2012-12-01 12:00:05'
|
||||
end
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
# Then my times should have been saved
|
||||
|
||||
Reference in New Issue
Block a user