Skip to content

Commit

Permalink
Merge branch 'main' into journal/entry-summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
zspencer authored Feb 3, 2024
2 parents b496f05 + 3dd918e commit 3b1347e
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 91 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ gem "tzinfo-data", "~> 1.2021", platforms: %i[mingw mswin x64_mingw jruby]
# Performance Optimization
#
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", "~> 1.17", require: false
gem "bootsnap", "~> 1.18", require: false

# Permissions and policies
gem "pundit", "~> 2.3"
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
apimatic_core (0.3.4)
apimatic_core_interfaces (~> 0.2.0)
Expand Down Expand Up @@ -134,15 +134,15 @@ GEM
bindex (0.8.1)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bootsnap (1.17.1)
bootsnap (1.18.3)
msgpack (~> 1.2)
builder (3.2.4)
byebug (11.1.3)
capybara (3.39.2)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
Expand Down Expand Up @@ -372,7 +372,7 @@ GEM
redcarpet (3.6.0)
redis-client (0.19.1)
connection_pool
regexp_parser (2.8.3)
regexp_parser (2.9.0)
reline (0.4.2)
io-console (~> 0.5)
rexml (3.2.6)
Expand Down Expand Up @@ -545,7 +545,7 @@ DEPENDENCIES
bcrypt (~> 3.1.20)
better_errors
binding_of_caller
bootsnap (~> 1.17)
bootsnap (~> 1.18)
capybara
cssbundling-rails
decent_exposure (~> 3.0)
Expand Down
16 changes: 10 additions & 6 deletions app/furniture/marketplace/menu/product_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<%= render CardComponent.new(dom_id: dom_id(product)) do |card| %>
<%- card.with_header(variant: :no_padding) do %>
<% if product.photo.present? %>

<% if product.photo.present? %>
<%- card.with_header(variant: :no_padding) do %>
<figure>
<%= image_tag hero_image, class: "rounded-t-lg w-full" %>
<figcaption class="px-2 pt-4 sm:px-4">
<h3><%= name %></h3>
<%= render Marketplace::Product::TitleComponent.new(product:) %>
</figcaption>
</figure>
<%- else %>
<h3 class="px-4"><%= name %></h3>
<%- end %>
<%- else %>
<%- card.with_header do %>
<%= render Marketplace::Product::TitleComponent.new(product:) %>
<% end %>
<%- end %>
<% end %>


<div class="text-sm italic">
<%= description %>
Expand Down
2 changes: 2 additions & 0 deletions app/furniture/marketplace/product/title_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h3><%= name %></h3>
<p class="text-sm">Serves <%= servings %></p>
10 changes: 10 additions & 0 deletions app/furniture/marketplace/product/title_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Marketplace
class Product::TitleComponent < Component
attr_accessor :product
delegate :servings, :name, to: :product

def initialize(product:)
self.product = product
end
end
end
12 changes: 7 additions & 5 deletions app/furniture/marketplace/product_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<%= render CardComponent.new(dom_id: dom_id(product)) do |card| %>
<%- card.with_header(variant: :no_padding) do %>
<% if product.photo.present? %>
<% if product.photo.present? %>
<%- card.with_header(variant: :no_padding) do %>
<figure>
<%= image_tag hero_image, class: "rounded-t-lg w-full" %>
<figcaption class="px-2 pt-4 sm:px-4">
<h3><%= name %></h3>
<%= render Marketplace::Product::TitleComponent.new(product:) %>
<%- if product.archived? %>
<span class="italic">(archived)</span>
<%- end %>
</figcaption>
</figure>
<%- else %>
<h3 class="px-4"><%= name %></h3>
<% end %>
<%- else %>
<%- card.with_header do %>
<%= render Marketplace::Product::TitleComponent.new(product:) %>
<%- end %>
<%- end %>

<div class="text-sm italic">
Expand Down
2 changes: 1 addition & 1 deletion app/furniture/marketplace/product_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Marketplace
class ProductPolicy < Policy
alias_method :product, :object
def permitted_attributes(_params = nil)
%i[name description price_cents price_currency price photo restore] + [tax_rate_ids: []]
%i[name description price_cents price_currency price photo restore servings] + [tax_rate_ids: []]
end

def update?
Expand Down
2 changes: 2 additions & 0 deletions app/furniture/marketplace/products/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<%= form_with model: product.location do |f| %>
<%= render "text_field", { attribute: :name, form: f} %>
<%= render "text_area", { attribute: :description, form: f} %>
<%= render "number_field", { attribute: :servings, form: f, min: 0, step: 1} %>

<%= render "money_field", { attribute: :price, form: f, min: 0, step: 0.01} %>
<%= render "collection_check_boxes", { attribute: :tax_rate_ids, collection: bazaar.tax_rates, value_method: :id, text_method: :label, form: f} %>
<%- if product.photo.present? %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MarketplaceAddServingsToProducts < ActiveRecord::Migration[7.1]
def change
add_column :marketplace_products, :servings, :integer, null: true
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_01_29_014151) do
ActiveRecord::Schema[7.1].define(version: 2024_02_01_014607) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -210,6 +210,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "discarded_at"
t.integer "servings"
t.index ["discarded_at"], name: "index_marketplace_products_on_discarded_at"
t.index ["marketplace_id"], name: "index_marketplace_products_on_marketplace_id"
end
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@hotwired/turbo-rails": "^7.3.0",
"@rails/actioncable": "^7.1.3",
"@rails/activestorage": "^7.1.3",
"@sentry/browser": "^7.98.0",
"@sentry/browser": "^7.99.0",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@webpack-cli/serve": "^2.0.5",
Expand Down
32 changes: 32 additions & 0 deletions spec/furniture/marketplace/selling_products_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@
sign_in(space.members.first, space)
end

# @see https://github.com/zinc-collective/convene/issues/2168
describe "Listing Products for Sale" do
it "Adds the Product to the Menu" do # rubocop:disable RSpec/ExampleLength
visit(polymorphic_path(marketplace.location(child: :products)))
click_link("Add a Product")

fill_in("Name", with: "A Delicious Apple")

description = <<~DESC.gsub("\n", "")
A red Apple, grown in the an Orchard
Made with a Trunk.
DESC

fill_in("Description", with: description)
fill_in("Price", with: "10.00")
fill_in("Servings", with: 4)

expect { click_button("Create") }.to change(marketplace.products, :count).by(1)

created_product = marketplace.products.last

visit(polymorphic_path(marketplace.room.location))

within("##{dom_id(created_product)}") do
expect(page).to have_content("A Delicious Apple")
expect(page).to have_content(description)
expect(page).to have_content("$10.00")
expect(page).to have_content("Serves 4")
end
end
end

describe "Archiving Products" do
before do
cart.cart_products.create(product:, quantity: 1)
Expand Down
140 changes: 70 additions & 70 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -380,76 +380,76 @@
dependencies:
spark-md5 "^3.0.1"

"@sentry-internal/feedback@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.98.0.tgz#2dabbdc060dca49e79536ae99a9bd55f9c6f806f"
integrity sha512-t/mATvwkLcQLKRlx8SO5vlUjaadF6sT3lfR0PdWYyBy8qglbMTHDW4KP6JKh1gdzTVQGnwMByy+/4h9gy4AVzw==
dependencies:
"@sentry/core" "7.98.0"
"@sentry/types" "7.98.0"
"@sentry/utils" "7.98.0"

"@sentry-internal/replay-canvas@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-7.98.0.tgz#108160c49f714a6021368fd60e08b7291fe44450"
integrity sha512-vAR6KIycyazaY9HwxG5UONrPTe8jeKtZr6k04svPC8OvcoI0xF+l1jMEYcarffuzKpZlPfssYb5ChHtKuXCB+Q==
dependencies:
"@sentry/core" "7.98.0"
"@sentry/replay" "7.98.0"
"@sentry/types" "7.98.0"
"@sentry/utils" "7.98.0"

"@sentry-internal/tracing@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.98.0.tgz#812ef7fce6b64794784f3279c66bc6b5cfd29d7f"
integrity sha512-FnhD2uMLIAJvv4XsYPv3qsTTtxrImyLxiZacudJyaWFhxoeVQ8bKKbWJ/Ar68FAwqTtjXMeY5evnEBbRMcQlaA==
dependencies:
"@sentry/core" "7.98.0"
"@sentry/types" "7.98.0"
"@sentry/utils" "7.98.0"

"@sentry/browser@^7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.98.0.tgz#f249e6e38351de4cea1142f498e1169006e5dd76"
integrity sha512-/MzTS31N2iM6Qwyh4PSpHihgmkVD5xdfE5qi1mTlwQZz5Yz8t7MdMriX8bEDPlLB8sNxl7+D6/+KUJO8akX0nQ==
dependencies:
"@sentry-internal/feedback" "7.98.0"
"@sentry-internal/replay-canvas" "7.98.0"
"@sentry-internal/tracing" "7.98.0"
"@sentry/core" "7.98.0"
"@sentry/replay" "7.98.0"
"@sentry/types" "7.98.0"
"@sentry/utils" "7.98.0"

"@sentry/core@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.98.0.tgz#e4f5353bc3986e510b8dd2507355787440d6e25d"
integrity sha512-baRUcpCNGyk7cApQHMfqEZJkXdvAKK+z/dVWiMqWc5T5uhzMnPE8/gjP1JZsMtJSQ8g5nHimBdI5TwOyZtxPaA==
dependencies:
"@sentry/types" "7.98.0"
"@sentry/utils" "7.98.0"

"@sentry/replay@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.98.0.tgz#21ba96d501260c1a33bc1af445f5cfbe02d0ba30"
integrity sha512-CQabv/3KnpMkpc2TzIquPu5krpjeMRAaDIO0OpTj5SQeH2RqSq3fVWNZkHa8tLsADxcfLFINxqOg2jd1NxvwxA==
dependencies:
"@sentry-internal/tracing" "7.98.0"
"@sentry/core" "7.98.0"
"@sentry/types" "7.98.0"
"@sentry/utils" "7.98.0"

"@sentry/types@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.98.0.tgz#6a88bf60679aea88ac6cba4d1517958726c2bafb"
integrity sha512-pc034ziM0VTETue4bfBcBqTWGy4w0okidtoZJjGVrYAfE95ObZnUGVj/XYIQ3FeCYWIa7NFN2MvdsCS0buwivQ==

"@sentry/utils@7.98.0":
version "7.98.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.98.0.tgz#54355a197f7f71a6d17354a3d043022df402b502"
integrity sha512-0/LY+kpHxItVRY0xPDXPXVsKRb95cXsGSQf8sVMtfSjz++0bLL1U4k7PFz1c5s2/Vk0B8hS6duRrgMv6dMIZDw==
dependencies:
"@sentry/types" "7.98.0"
"@sentry-internal/feedback@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.99.0.tgz#c3fec1500cb24c9a5e09479d478fddca909477da"
integrity sha512-exIO1o+bE0MW4z30FxC0cYzJ4ZHSMlDPMHCBDPzU+MWGQc/fb8s58QUrx5Dnm6HTh9G3H+YlroCxIo9u0GSwGQ==
dependencies:
"@sentry/core" "7.99.0"
"@sentry/types" "7.99.0"
"@sentry/utils" "7.99.0"

"@sentry-internal/replay-canvas@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-7.99.0.tgz#d6ba7eec7ab2f7210a7deb6daa4dd82f7b1e9e29"
integrity sha512-PoIkfusToDq0snfl2M6HJx/1KJYtXxYhQplrn11kYadO04SdG0XGXf4h7wBTMEQ7LDEAtQyvsOu4nEQtTO3YjQ==
dependencies:
"@sentry/core" "7.99.0"
"@sentry/replay" "7.99.0"
"@sentry/types" "7.99.0"
"@sentry/utils" "7.99.0"

"@sentry-internal/tracing@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.99.0.tgz#ad13f8343444ecf7323a4220d4e57a55166565d7"
integrity sha512-z3JQhHjoM1KdM20qrHwRClKJrNLr2CcKtCluq7xevLtXHJWNAQQbafnWD+Aoj85EWXBzKt9yJMv2ltcXJ+at+w==
dependencies:
"@sentry/core" "7.99.0"
"@sentry/types" "7.99.0"
"@sentry/utils" "7.99.0"

"@sentry/browser@^7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.99.0.tgz#3e78beb490d141c988038ea902689a1e9171c6cf"
integrity sha512-bgfoUv3wkwwLgN5YUOe0ibB3y268ZCnamZh6nLFqnY/UBKC1+FXWFdvzVON/XKUm62LF8wlpCybOf08ebNj2yg==
dependencies:
"@sentry-internal/feedback" "7.99.0"
"@sentry-internal/replay-canvas" "7.99.0"
"@sentry-internal/tracing" "7.99.0"
"@sentry/core" "7.99.0"
"@sentry/replay" "7.99.0"
"@sentry/types" "7.99.0"
"@sentry/utils" "7.99.0"

"@sentry/core@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.99.0.tgz#6881aae5ac1436637b3d88e0b12df4ab56016c5f"
integrity sha512-vOAtzcAXEUtS/oW7wi3wMkZ3hsb5Ch96gKyrrj/mXdOp2zrcwdNV6N9/pawq2E9P/7Pw8AXw4CeDZztZrjQLuA==
dependencies:
"@sentry/types" "7.99.0"
"@sentry/utils" "7.99.0"

"@sentry/replay@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.99.0.tgz#c63f2bd79a791538ba54bcd91f02379dc4d5c1cc"
integrity sha512-gyN/I2WpQrLAZDT+rScB/0jnFL2knEVBo8U8/OVt8gNP20Pq8T/rDZKO/TG0cBfvULDUbJj2P4CJryn2p/O2rA==
dependencies:
"@sentry-internal/tracing" "7.99.0"
"@sentry/core" "7.99.0"
"@sentry/types" "7.99.0"
"@sentry/utils" "7.99.0"

"@sentry/types@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.99.0.tgz#bba7a514abab445026ee42f40f92f81275a6deba"
integrity sha512-94qwOw4w40sAs5mCmzcGyj8ZUu/KhnWnuMZARRq96k+SjRW/tHFAOlIdnFSrt3BLPvSOK7R3bVAskZQ0N4FTmA==

"@sentry/utils@7.99.0":
version "7.99.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.99.0.tgz#ef96c3b59e23c79f3ef500db508234a48fa1cfbe"
integrity sha512-cYZy5WNTkWs5GgggGnjfGqC44CWir0pAv4GVVSx0fsup4D4pMKBJPrtub15f9uC+QkUf3vVkqwpBqeFxtmJQTQ==
dependencies:
"@sentry/types" "7.99.0"

"@sindresorhus/merge-streams@^1.0.0":
version "1.0.0"
Expand Down

0 comments on commit 3b1347e

Please sign in to comment.