Fix failing spec with table reorder, lambda-fy scopes that use time

This commit is contained in:
Rohan Mitchell
2013-11-22 14:00:04 +11:00
parent 94c33e5f45
commit 4898460132
2 changed files with 21 additions and 10 deletions

View File

@@ -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|

View File

@@ -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