Skip to content

Commit

Permalink
🥗 Marketplace: Woops, both Delivery patches worked independently.…
Browse files Browse the repository at this point in the history
….. (#1378)

- #1325

I suppose this is why the "Prevent Merging unless Branch is Up To Date
With Upstream" button is a thing...

This should fix the main branch, but I'm curious about what people think
about adding constraints to not allow merging branches that are behind
main?
  • Loading branch information
zspencer authored Apr 17, 2023
2 parents af63625 + 8b5de33 commit 73b5579
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<%- if cart.marketplace.order_by.present? && cart.marketplace.delivery_window.present? %>
Orders placed <%= cart.marketplace.order_by %>
are delivered <%= cart.marketplace.delivery_window %>
<%- elsif cart.marketplace.order_by.blank? && cart.marketplace.delivery_window.present? %>
Orders are delivered <%= cart.marketplace.delivery_window %>
<%- elsif cart.delivery_window.present? && cart.marketplace.order_by.present? %>
Place orders <%= cart.marketplace.order_by %> to ensure an on-time delivery for <%= render(cart.delivery_window) %>
<%- if order_by.present? && delivery_window.present? %>
Orders placed <%= order_by %>
are delivered <%= delivery_window %>
<%- elsif order_by.blank? && delivery_window.present? %>
Orders are delivered <%= delivery_window %>
<%- elsif order_by.present? && delivery_window.blank? && cart.delivery_window.blank? %>
Order <%= order_by %>
<%- elsif cart.delivery_window.present? && order_by.present? %>
Order <%= order_by %> to ensure an on-time delivery for <%= render(cart.delivery_window) %>
<%- elsif cart.delivery_window.present? %>
Delivering at <%= render(cart.delivery_window) %>
<%- else %>
Delivers at your chosen time
<%- end %>
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
class Marketplace
class Cart
class DeliveryExpectationsComponent < ApplicationComponent
attr_accessor :cart
attr_accessor :cart, :delivery_window, :order_by

def initialize(cart:, **kwargs)
def initialize(cart:, order_by: cart.marketplace.order_by,
delivery_window: cart.marketplace.delivery_window, **kwargs)
super(**kwargs)

self.cart = cart
self.delivery_window = delivery_window
self.order_by = order_by
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions app/furniture/marketplace/delivery/windows/_window.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
delivery
<%- if window.time_like? %>
at <%= l(window.value, format: :day_month_date_hour_minute) %>
<%= l(window.value, format: :day_month_date_hour_minute) %>
<%- elsif window.blank? %>
at your chosen time
your chosen time
<%- else %>
for <%= window.value %>
<%= window.value %>
<%- end %>
5 changes: 1 addition & 4 deletions app/furniture/marketplace/delivery_area_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

<div class="grow flex flex-col justify-between">
<div class="text-sm">
<%- if order_by.present? %>
Place orders by <%= order_by %> to ensure an on-time
<%- end %>
<%= render(delivery_window) %>
<%= render Marketplace::Cart::DeliveryExpectationsComponent.new(order_by: delivery_area.order_by, delivery_window: delivery_area.delivery_window, cart: example_cart) %>
</div>

<div class="text-right mt-3 italic">
Expand Down
4 changes: 4 additions & 0 deletions app/furniture/marketplace/delivery_area_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def price
helpers.humanized_money_with_symbol(delivery_area.price)
end

def example_cart
delivery_area.marketplace.carts.new
end

delegate :order_by, to: :delivery_area

def delivery_window
Expand Down
6 changes: 3 additions & 3 deletions spec/furniture/marketplace/delivery_area_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
it { is_expected.to have_content "at your chosen time" }
end

context "when `#delivery_window`` is a string" do
context "when `#delivery_window` is a string" do
let(:delivery_area) { create(:marketplace_delivery_area, delivery_window: "dinnertime same day") }

it { is_expected.to have_content "for #{delivery_area.delivery_window}" }
it { is_expected.to have_content delivery_area.delivery_window }
end

context "when #order_by is blank" do
Expand All @@ -31,6 +31,6 @@
context "when `#order_by` is set" do
let(:delivery_area) { create(:marketplace_delivery_area, order_by: "noon") }

it { is_expected.to have_content "by #{delivery_area.order_by}" }
it { is_expected.to have_content delivery_area.order_by }
end
end

0 comments on commit 73b5579

Please sign in to comment.