-
-
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: Save stripe api key (#1009)
#831 * Use strings to access data stored in Settings * Delete leftover debugging info * Marketplace: MarketplacesController#edit Spec Just a basic "get the route, confirm it renders a template successfully for authenticated user and is a 404 when not" * Marketplace: Unit tests MarketplacePolicy#update? * Marketplace: Guests may Checkout from Marketplace We had been doing our smoke-testing with authenticated users, not guests; and then Zee broke everything by not logging in and discovering that we hadn't actually handled the Guest case well. This tests the `Marketplace::CheckoutPolicy`, as well as sprouts some Factories for creating `:marketplace_checkout`s more conveniently. * Marketplace: Streamline flow for Configuring Marketplace - Adds Breadcrumbs - Places Configure Products underneath the `marketplace/edit` view Co-authored-by: Ana <[email protected]> Co-authored-by: Naomi Quinones <[email protected]> Co-authored-by: Zee <[email protected]> Co-authored-by: Dalton <[email protected]> Co-authored-by: Kelly Hong <[email protected]>
- Loading branch information
1 parent
4b73100
commit 31c6497
Showing
14 changed files
with
137 additions
and
10 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
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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= form_with model: marketplace.location do |marketplace_form| %> | ||
<fieldset> | ||
<%= render "password_field", form: marketplace_form, attribute: :stripe_api_key %> | ||
<%= marketplace_form.submit %> | ||
</fieldset> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%- breadcrumb :edit_marketplace, marketplace %> | ||
<%= render partial: 'form', locals: { marketplace: marketplace } %> | ||
|
||
<%- if policy(marketplace.products.new).create? %> | ||
<%= link_to t('marketplace.product.index'), marketplace.location(child: :products) %> | ||
<%- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
FactoryBot.define do | ||
factory :marketplace_checkout, class: 'Marketplace::Checkout' do | ||
|
||
factory :marketplace_checkout, class: "Marketplace::Checkout" do | ||
trait :with_shopper do | ||
transient do | ||
person { nil } | ||
end | ||
|
||
shopper { build(:marketplace_shopper, person: person) } | ||
end | ||
|
||
trait :with_cart do | ||
transient do | ||
marketplace { nil } | ||
end | ||
before(:build) do |checkout, evaluator| | ||
build(:marketplace_cart, marketplace: marketplace, checkout: checkout, shopper: checkout.shopper) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Marketplace::CheckoutPolicy, type: :policy do | ||
subject { described_class } | ||
|
||
let(:membership) { create(:membership, space: marketplace.room.space) } | ||
let(:member) { membership.member } | ||
let(:non_member) { create(:person) } | ||
let(:guest) { Guest.new } | ||
|
||
let(:marketplace) { create(:marketplace) } | ||
|
||
let(:member_checkout) { build(:marketplace_checkout, :with_cart, :with_shopper, marketplace: marketplace, person: member) } | ||
let(:guest_checkout) { build(:marketplace_checkout, :with_cart, :with_shopper, marketplace: marketplace) } | ||
let(:non_member_checkout) { build(:marketplace_checkout, :with_cart, :with_shopper, marketplace: marketplace, person: non_member) } | ||
|
||
permissions :new? do | ||
it { is_expected.to permit(member, member_checkout) } | ||
it { is_expected.not_to permit(non_member, member_checkout) } | ||
it { is_expected.not_to permit(guest, member_checkout) } | ||
it { is_expected.to permit(non_member, non_member_checkout) } | ||
it { is_expected.not_to permit(member, non_member_checkout) } | ||
it { is_expected.to permit(guest, guest_checkout) } | ||
it { is_expected.not_to permit(member, guest_checkout) } | ||
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
24 changes: 24 additions & 0 deletions
24
spec/furniture/marketplace/marketplaces_controller_request_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,24 @@ | ||
require "rails_helper" | ||
RSpec.describe Marketplace::MarketplacesController, type: :request do | ||
let(:marketplace) { create(:marketplace) } | ||
let(:space) { marketplace.space } | ||
let(:membership) { create(:membership, space: space) } | ||
let(:member) { membership.member } | ||
|
||
describe "#edit" do | ||
subject(:executed_response) { | ||
get polymorphic_path(marketplace.location(:edit)) | ||
response | ||
} | ||
|
||
context "when a Member" do | ||
before { sign_in(space, member) } | ||
|
||
it { is_expected.to render_template(:edit) } | ||
end | ||
|
||
context "when unauthenticated" do | ||
it { is_expected.to be_not_found } | ||
end | ||
end | ||
end |