Skip to content

Instantly share code, notes, and snippets.

View kenton's full-sized avatar

Kenton Newby kenton

View GitHub Profile

For RS-2265, a ReturnAuth should allow selection of a warehouse, defaulting to SF

My intended workflow would have been something like this:

  • add a warehouse_id column to ReturnAuthorizations
  • include spec for validations that a ReturnAuth marked as "accepted" has to have a warehouse_id present
  • ReturnAuthorization#process_return calls ReturnAuthorization#return_inventory_units
  • ReturnAuthorization#return_inventory_units calls InventoryUnit#return! on each of the ReturnAuth's inventory_units
  • InventoryUnit#return! is a state transition that has a callback function, InventoryUnit#restock_variants
  • InventoryUnit#restock_variants increments the variant count to restock that item
  • This should also be where the warehouse is set for that variant, but you need to be able to pass in the warehouse object to the #return! method used for the state transition. This can be done with a block, but requries reimplementing the state machine found in Spree::InventoryUnit in the spree/trr-deploy branch.
<div class="box" data-hook="admin_users_index_search">
<h3>Search</h3>
<form accept-charset="UTF-8" action="/admin/users" class="spree/user_search" id="spree/user_search" method="get">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="&#x2713;" />
</div>
<p>
Email<br><input id="q_email_cont" name="q[email_cont]" size="18" type="text" />
</p>
<div data-hook="admin_users_index_search_buttons">
# getting this json format in the response
[{"product":{"id":160,"name":"3.1 Phillip Lim Dress"}},{"product":{"id":161,"name":"3.1 Phillip Lim Skirt"}},{"product":{"id":178,"name":"3.1 Phillip Lim Dress"}},{"product":{"id":175,"name":"3.1 Phillip Lim Dress"}},{"product":{"id":156,"name":"3.1 Phillip Lim Wool Dress"}},{"product":{"id":158,"name":"3.1 Phillip Lim Plaid Skirt"}},{"product":{"id":159,"name":"3.1 Phillip Lim Silk Pants"}},{"product":{"id":162,"name":"3.1 Phillip Lim Woven Blazer"}},{"product":{"id":163,"name":"3.1 Phillip Lim Strapless Dress"}},{"product":{"id":164,"name":"3.1 Phillip Lim Tiered Skirt"}},{"product":{"id":166,"name":"3.1 Phillip Lim Shift Dress"}},{"product":{"id":167,"name":"3.1 Phillip Lim Beaded Tee"}},{"product":{"id":168,"name":"3.1 Phillip Lim Silk Dress"}},{"product":{"id":171,"name":"3.1 Phillip Lim Shearling Jacket"}},{"product":{"id":172,"name":"3.1 Phillip Lim Printed Sweater"}}]
# need this format in the response
[{"id":156,"name":"3.1 Phillip Lim Wool Dress"},{"id":15
Spree::Sunspot::Setup.configure do
searchable auto_index: true,
auto_remove: true,
include: [:variants],
if: ->(prod) { prod.in_active_flash_sale_now? } do
text :name, boost: 2.0
text :description, boost: 1.2
<!-- current implementation -->
<fieldType name="text" class="solr.TextField" omitNorms="false">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<!--<filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="true"/>-->
</analyzer>
{"products"=>
[{"id"=>2166,
"permalink"=>"jil-sander-coat",
"name"=>"Jil Sander Coat",
"variants"=>
[{"id"=>4341,
"price"=>"295.0",
"sku"=>"JIL01550",
"size_hash"=>{"name"=>"clothing-size", "value"=>"S", "id"=>18},
"on_hand"=>0}],
{"products"=>
[{"id"=>1603,
"permalink"=>"giuseppe-zanotti-platform-pump-1",
"name"=>"Giuseppe Zanotti Platform Pump",
"variants"=>
[{"id"=>3215,
"price"=>"175.0",
"sku"=>"GIU01363",
"size_hash"=>{},
"on_hand"=>0}],
"filters"=>
["Booties",
"Dresses",
"Handbags",
"Outerwear",
"Shoes",
"Tops",
"Women's Clothing"],
{"id"=>1610,
"permalink"=>"givenchy-sandal",
"name"=>"Givenchy Sandal",
"variants"=>
[{"id"=>3229,
"price"=>"95.0",
"sku"=>"GIV01310",
"size_hash"=>{"name"=>"shoes-size", "value"=>"7.5", "id"=>4},
"on_hand"=>0}],
"taxons"=>[{"id"=>65, "name"=>"Sandals"}],
Finished in 23 minutes 33.49 seconds
465 examples, 2 failures, 11 pending
Failed examples:
rspec ./spec/requests/flash_sales_spec.rb:97 # FlashSales checking pagination paginates products
rspec ./spec/requests/flash_sales_spec.rb:122 # FlashSales checking pagination lets user navigate with next and previous links work (also 2nd page test)
Finished in 23 minutes 33.49 seconds
465 examples, 2 failures, 11 pending