Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Address the review findings on the seller panel
Damian Legawiecaf5c4783f425
diff --git a/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rbindex 143bb6bce4..59fe22d821 100644--- a/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb@@ -66,12 +66,18 @@ module Spree# Accepting the marketplace's terms is a profile write, not an endpoint# of its own: `accept_terms: true` stamps the time, which is what the- # AcceptTerms requirement reads. Deliberately one-way — a seller- # cannot un-accept by sending `false`, since the stamp is a record- # that it happened.+ # AcceptTerms requirement reads.+ #+ # Re-stamped every time rather than only on a first acceptance: a+ # marketplace that rewrites its terms advances the requirement's+ # `terms_effective_from`, which puts everyone who accepted before+ # that date back on the checklist — and a seller who could not+ # re-accept would be stuck there with nothing to click.+ #+ # One-way all the same: sending `false` is a no-op, because the+ # stamp records that acceptance happened.def terms_attributesreturn {} unless ActiveModel::Type::Boolean.new.cast(params[:accept_terms])- return {} if current_seller.terms_accepted_at.present?{ terms_accepted_at: Time.current }enddiff --git a/spree/api/app/controllers/spree/api/v3/seller/requirement_submissions_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/requirement_submissions_controller.rbindex 1de9dcb8af..ec78b40453 100644--- a/spree/api/app/controllers/spree/api/v3/seller/requirement_submissions_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/seller/requirement_submissions_controller.rb@@ -17,12 +17,14 @@ module Spree# POST /api/v3/seller/requirements/:requirement_id/submissionsdef create+ attributes = permitted_params+result = Spree.seller_requirement_submission_create_workflow.call(seller: current_seller,requirement: @requirement,- note: params[:note],- reference: params[:reference],- file: params[:file],+ note: attributes[:note],+ reference: attributes[:reference],+ file: attributes[:file],submitted_by: try_spree_current_user)@@ -55,6 +57,13 @@ module Spreeprotected+ # What a seller may say about a requirement. `file` is a direct-upload+ # signed id, so it is a string like the rest — the bytes are already+ # in storage by the time this runs.+ def permitted_params+ params.permit(:note, :reference, :file)+ end+def read_actions%w[download]enddiff --git a/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rbindex 5a584a9afc..f8ce027c48 100644--- a/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb@@ -83,11 +83,13 @@ RSpec.describe Spree::Api::V3::Seller::ProfileController, type: :controller do# The lifecycle belongs to the operator's workflows. A seller approving# themselves would skip the mail, the payouts and every extension hook.+ # A status the seller does not already hold, so this fails if `status`+ # ever becomes permitted — sending the one they are on would pass either+ # way and prove nothing.it 'refuses to move its own status' do- patch :update, params: { status: 'approved' }, as: :json+ patch :update, params: { status: 'suspended' }, as: :json- expect(seller.reload).to be_approved # was already approved- expect(seller.status).to eq('approved')+ expect(seller.reload).to be_approvedendit 'cannot change its own settlement terms' do@@ -120,6 +122,20 @@ RSpec.describe Spree::Api::V3::Seller::ProfileController, type: :controller doexpect(seller.reload.terms_accepted_at).to be_within(1.second).of(accepted)end+ # A marketplace that rewrites its terms advances the requirement's+ # `terms_effective_from`, which puts everyone who accepted before that+ # date back on the checklist. A seller who could not re-accept would be+ # stuck there with nothing to click.+ it 'lets a seller accept revised terms' do+ seller.update!(terms_accepted_at: 1.year.ago)++ expect {+ patch :update, params: { accept_terms: true }, as: :json+ }.to change { seller.reload.terms_accepted_at }++ expect(seller.terms_accepted_at).to be_within(5.seconds).of(Time.current)+ end+it 'cannot change its own slug' dooriginal = seller.slugdiff --git a/spree/api/spec/requests/seller_invitation_flow_spec.rb b/spree/api/spec/requests/spree/api/v3/seller/invitation_flow_spec.rbsimilarity index 96%rename from spree/api/spec/requests/seller_invitation_flow_spec.rbrename to spree/api/spec/requests/spree/api/v3/seller/invitation_flow_spec.rbindex f06b0c5b1e..e4ec846a22 100644--- a/spree/api/spec/requests/seller_invitation_flow_spec.rb+++ b/spree/api/spec/requests/spree/api/v3/seller/invitation_flow_spec.rb@@ -3,7 +3,7 @@ require 'spec_helper'# End-to-end over real HTTP: the link in the email, then the two endpoints it# leads to. Unit specs cover the controller in isolation; this proves the# routes are mounted and reachable as the mail addresses them.-RSpec.describe 'seller invitation flow', type: :request do+RSpec.describe 'Seller invitation flow', type: :request dolet(:store) { @default_store }let(:seller) { create(:seller, :approved, store: store) }# Carries the seller's seeded role, exactly as `Seller::TeamController`diff --git a/spree/api/spec/requests/seller_team_management_spec.rb b/spree/api/spec/requests/spree/api/v3/seller/team_management_spec.rbsimilarity index 97%rename from spree/api/spec/requests/seller_team_management_spec.rbrename to spree/api/spec/requests/spree/api/v3/seller/team_management_spec.rbindex acc4634af2..8fef154081 100644--- a/spree/api/spec/requests/seller_team_management_spec.rb+++ b/spree/api/spec/requests/spree/api/v3/seller/team_management_spec.rb@@ -3,7 +3,7 @@ require 'spec_helper'# The team screen's whole loop over HTTP: invite, see it pending, resend,# revoke — then invite again and accept, and watch it move from the pending# list into the member list.-RSpec.describe 'seller team management', type: :request do+RSpec.describe 'Seller team management', type: :request dolet(:store) { @default_store }let(:seller) { create(:seller, :approved, store: store) }let(:owner) { create(:admin_user, :without_admin_role).tap { |u| seller.add_user(u) } }diff --git a/spree/core/spec/finders/spree/sellers/panel_url_spec.rb b/spree/core/spec/finders/spree/sellers/panel_url_spec.rbindex 7f661420d2..604720de15 100644--- a/spree/core/spec/finders/spree/sellers/panel_url_spec.rb+++ b/spree/core/spec/finders/spree/sellers/panel_url_spec.rb@@ -3,9 +3,15 @@ require 'spec_helper'RSpec.describe Spree::Sellers::PanelUrl dolet(:store) { @default_store }- after do- Spree::Config[:seller_panel_url] = nil- Spree::Config[:dashboard_url] = nil+ # Captured and put back rather than reset to nil: a suite that configured+ # either of these would silently lose it for every example after this file.+ around do |example|+ panel = Spree::Config[:seller_panel_url]+ dashboard = Spree::Config[:dashboard_url]+ example.run+ ensure+ Spree::Config[:seller_panel_url] = panel+ Spree::Config[:dashboard_url] = dashboardendit 'prefers an explicitly configured panel origin' do