18F/micropurchase

View on GitHub
app/models/rules/reverse_auction.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Rules::ReverseAuction < Rules::BaseRules
  def winning_bid
    auction.lowest_bid || NullBid.new
  end

  def highlighted_bid(_user)
    winning_bid
  end

  def veiled_bids(_user)
    auction.bids.order(created_at: :desc)
  end

  def max_allowed_bid
    if auction.lowest_bid.is_a?(NullBid) || auction.lowest_bid.nil?
      auction.start_price - PlaceBid::BID_INCREMENT
    else
      auction.lowest_bid.amount - PlaceBid::BID_INCREMENT
    end
  end

  def show_bids?
    true
  end

  def rules_label
    'Reverse'
  end

  def rules_route
    'auctions_rules_reverse'
  end
end