Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/solidus_stripe/payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class PaymentMethod < ::Spree::PaymentMethod
preference :api_key, :string
preference :publishable_key, :string

validates :available_to_admin, inclusion: { in: [false] }

def partial_name
"stripe"
end
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ en:
models:
solidus_stripe/payment_source: Solidus Stripe Payment Source
solidus_stripe/payment_method: Solidus Stripe Payment Method
errors:
models:
solidus_stripe/payment_method:
attributes:
available_to_admin:
inclusion: "is not allowed for the Stripe payment method"
1 change: 1 addition & 0 deletions lib/solidus_stripe/testing_support/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
factory :stripe_payment_method, class: 'SolidusStripe::PaymentMethod' do
type { "SolidusStripe::PaymentMethod" }
name { "Stripe Payment Method" }
available_to_admin { false }
preferences {
{
api_key: SecureRandom.hex(8),
Expand Down
10 changes: 10 additions & 0 deletions spec/models/solidus_stripe/payment_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@
it 'has a working factory' do
expect(create(:stripe_payment_method)).to be_valid
end

it "doesn't allow available_to_admin" do
record = described_class.new(available_to_admin: true)

record.valid?

expect(
record.errors.added?(:available_to_admin, :inclusion, value: true)
).to be(true)
end
end