-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥗🥔✨
Marketplace
: add order_by
and delivery_window
to `DeliveryA…
…rea` (#1371) - #1185 In order to support different timing for different `DeliveryArea`s, we've given them `delivery_window` and `order_by` fields. These fields will be used to communicate on the `Cart#show` and `Order#show` screens what the timing expectations are for particular orders. Example: - Catering orders for Lions Dance Cafe can be placed any time and delivered anytime, but - Dinner orders must be placed the same day by 3pm ### After   
- Loading branch information
Showing
12 changed files
with
112 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
delivery | ||
<%- if window.time_like? %> | ||
<%= l(window.value, format: :day_month_date_hour_minute) %> | ||
at <%= l(window.value, format: :day_month_date_hour_minute) %> | ||
<%- elsif window.blank? %> | ||
at your chosen time | ||
<%- else %> | ||
<%= window.value %> | ||
for <%= window.value %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<%= form_with(model: delivery_area.location) do |delivery_area_form| %> | ||
<%= render "text_field", attribute: :label, form: delivery_area_form %> | ||
<%= render "money_field", attribute: :price, form: delivery_area_form, required: true, step: 0.01, min: 0 %> | ||
<%= render "text_field", attribute: :order_by, form: delivery_area_form %> | ||
<%= render "text_field", attribute: :delivery_window, form: delivery_area_form %> | ||
|
||
<%= delivery_area_form.submit %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
db/migrate/20230416172045_add_order_by_and_delivery_window_to_marketplace_delivery_areas.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AddOrderByAndDeliveryWindowToMarketplaceDeliveryAreas < ActiveRecord::Migration[7.0] | ||
def change | ||
safety_assured do | ||
change_table :marketplace_delivery_areas, bulk: true do |t| | ||
t.string :delivery_window, default: nil | ||
t.string :order_by, default: nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
spec/furniture/marketplace/delivery_area_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Marketplace::DeliveryAreaComponent, type: :component do | ||
subject(:output) { render_inline(component) } | ||
|
||
let(:operator) { create(:person, operator: true) } | ||
|
||
let(:component) { described_class.new(delivery_area: delivery_area, current_person: operator) } | ||
let(:delivery_area) { create(:marketplace_delivery_area) } | ||
|
||
it { is_expected.to have_content(delivery_area.label) } | ||
it { is_expected.to have_content(controller.view_context.humanized_money_with_symbol(delivery_area.price)) } | ||
|
||
it { is_expected.to have_selector("a[href='#{polymorphic_path(delivery_area.location)}'][data-turbo=true][data-turbo-stream=true][data-turbo-method=delete][data-method=delete][data-confirm='#{I18n.t("destroy.confirm")}']") } | ||
it { is_expected.to have_selector("a[href='#{polymorphic_path(delivery_area.location(:edit))}'][data-turbo=true][data-turbo-method=get][data-turbo-stream=true]") } | ||
|
||
context "when `#delivery_window` is empty" do | ||
it { is_expected.to have_content "at your chosen time" } | ||
end | ||
|
||
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}" } | ||
end | ||
|
||
context "when #order_by is blank" do | ||
it { is_expected.not_to have_content "Place orders by" } | ||
end | ||
|
||
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}" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters