Update some comments in Enterprise and OrderCycle models

This commit is contained in:
Kristina Lim
2019-05-06 18:35:01 +08:00
parent 4430c88a95
commit c0a5bcce92
2 changed files with 3 additions and 8 deletions

View File

@@ -94,10 +94,8 @@ class Enterprise < ActiveRecord::Base
select('DISTINCT enterprises.*')
}
scope :not_ready_for_checkout, lambda {
# When ready_for_checkout is empty, ActiveRecord generates the SQL:
# id NOT IN (NULL)
# I would have expected this to return all rows, but instead it returns none. But we want to
# return all rows when there are no enterprises ready for checkout.
# When ready_for_checkout is empty, return all rows when there are no enterprises ready for
# checkout.
ready_enterprises = Enterprise.ready_for_checkout
ready_enterprises.present? ? where("id NOT IN (?)", ready_enterprises) : where("TRUE")
}

View File

@@ -9,7 +9,7 @@ class OrderCycle < ActiveRecord::Base
has_many :exchanges, :dependent => :destroy
# These scope names are prepended with "cached_" because there are existing accessor methods
# :incoming_exchanges and :outgoing_exchanges. Future work can be done to name these properly.
# :incoming_exchanges and :outgoing_exchanges.
has_many :cached_incoming_exchanges, conditions: { incoming: true }, class_name: "Exchange"
has_many :cached_outgoing_exchanges, conditions: { incoming: false }, class_name: "Exchange"
@@ -18,9 +18,6 @@ class OrderCycle < ActiveRecord::Base
has_and_belongs_to_many :schedules, join_table: 'order_cycle_schedules'
# TODO: DRY the incoming/outgoing clause used in several cases below
# See Spree::Product definition, scopes variants and variants_including_master
# This will require these accessors to be renamed
attr_accessor :incoming_exchanges, :outgoing_exchanges
validates_presence_of :name, :coordinator_id