Skip to content

Commit

Permalink
🧹 Marketplace: Remove Controller#update and unused .settings
Browse files Browse the repository at this point in the history
- #1511

Now that the `Marketplace` no longer has any user modifiable attributes,
I got rid of all the leftovers.
  • Loading branch information
zspencer committed Jul 6, 2023
1 parent 14d6ce1 commit dc90b70
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 46 deletions.
1 change: 0 additions & 1 deletion app/furniture/marketplace/marketplace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Marketplace < Furniture

has_many :notification_methods, inverse_of: :marketplace, dependent: :destroy

setting :notify_emails
setting :stripe_account
alias_method :vendor_stripe_account, :stripe_account
setting :stripe_webhook_endpoint
Expand Down
4 changes: 0 additions & 4 deletions app/furniture/marketplace/marketplace_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

class Marketplace
class MarketplacePolicy < Policy
def permitted_attributes(_params)
[:delivery_fee, :notify_emails, :delivery_window, :order_by]
end

alias_method :marketplace, :object
def show?
true
Expand Down
13 changes: 0 additions & 13 deletions app/furniture/marketplace/marketplaces_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@ def edit
marketplace
end

def update
if marketplace.update(marketplace_params)
redirect_to marketplace.location(:edit), notice: t(".success")
else
flash[:alert] = t(".failure")
render :edit, status: :unprocessable_entity
end
end

helper_method def marketplace
authorize(Marketplace.find(params[:id]))
end

def marketplace_params
policy(Marketplace).permit(params.require(:marketplace))
end
end
end
2 changes: 1 addition & 1 deletion app/furniture/marketplace/order/received_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Marketplace
class Order
class ReceivedMailer < Mailer
def to
order.marketplace.notify_emails.split(",") + order.marketplace.notification_methods.map(&:contact_location)
order.marketplace.notification_methods.map(&:contact_location)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/furniture/marketplace/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Marketplace
class Routes
def self.append_routes(router)
router.resources :marketplaces, only: [:show, :edit, :update], module: "marketplace" do
router.resources :marketplaces, only: [:show, :edit], module: "marketplace" do
router.resources :carts, only: [] do
router.resources :cart_products
router.resource :checkout, only: [:show, :create]
Expand Down
5 changes: 0 additions & 5 deletions spec/factories/furniture/marketplace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
tax_rates { Array.new(tax_rate_quantity) { association(:marketplace_tax_rate) } }
end

trait :with_notify_emails do
notify_emails { Array.new((1..3).to_a.sample) { Faker::Internet.email }.join(",") }
end

trait :with_delivery_areas do
transient do
delivery_area_quantity { 1 }
Expand All @@ -52,7 +48,6 @@
trait :full do
with_tax_rates
with_delivery_areas
with_notify_emails
end

trait :ready_for_shopping do
Expand Down
12 changes: 0 additions & 12 deletions spec/furniture/marketplace/marketplaces_controller_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@
end
end

describe "#update" do
before { sign_in(space, member) }

it "updates the attributes" do
marketplace_attributes = attributes_for(:marketplace, notify_emails: "[email protected]")
put polymorphic_path(marketplace.location), params: {marketplace: marketplace_attributes}
marketplace.reload

expect(marketplace.notify_emails).to eq(marketplace_attributes[:notify_emails])
end
end

describe "#show" do
it "does not show guests the edit button" do
get polymorphic_path(marketplace.location)
Expand Down
14 changes: 5 additions & 9 deletions spec/furniture/marketplace/order/received_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
require "rails_helper"

RSpec.describe Marketplace::Order::ReceivedMailer, type: :mailer do
let(:marketplace) { create(:marketplace, notify_emails: "[email protected],[email protected]") }
let(:marketplace) { create(:marketplace) }
let(:order) { build(:marketplace_order, placed_at: 1.hour.ago, marketplace: marketplace) }

describe "#notification" do
subject(:notification) { described_class.notification(order) }

it { is_expected.to be_to(marketplace.notify_emails.split(",")) }

context "when the marketplace has a order notification contact location" do
before do
marketplace.notification_methods.create(contact_location: "[email protected]")
end

it { is_expected.to be_to(marketplace.notify_emails.split(",") + marketplace.notification_methods.map(&:contact_location)) }
before do
marketplace.notification_methods.create(contact_location: "[email protected]")
end

it { is_expected.to be_to(marketplace.notification_methods.map(&:contact_location)) }

it { is_expected.to have_subject(t(".notification.subject", marketplace_name: order.marketplace_name, order_id: order.id)) }

specify do
Expand Down

0 comments on commit dc90b70

Please sign in to comment.