Skip to content
Open
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
16 changes: 2 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ jobs:
fail-fast: true
matrix:
rails-version:
- "7.0"
- "7.1"
- "7.2"
ruby-version:
- "3.1"
- "3.3"
- "3.4"
solidus-branch:
- "v4.1"
- "v4.2"
- "v4.3"
- "v4.4"
database:
Expand All @@ -41,16 +38,7 @@ jobs:
exclude:
- rails-version: "7.2"
solidus-branch: "v4.3"
- rails-version: "7.2"
solidus-branch: "v4.2"
- rails-version: "7.2"
solidus-branch: "v4.1"
- rails-version: "7.1"
solidus-branch: "v4.2"
- rails-version: "7.1"
solidus-branch: "v4.1"
- ruby-version: "3.4"
rails-version: "7.0"

steps:
- uses: actions/checkout@v4
- name: Run extension tests
Expand Down
84 changes: 0 additions & 84 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,2 @@
require:
- solidus_dev_support/rubocop

AllCops:
NewCops: disable
TargetRubyVersion: '3.0'
Exclude:
- sandbox/**/*
- dummy-app/**/*
- spec/dummy/**/*
- vendor/bundle/**/*

Layout/FirstArgumentIndentation:
EnforcedStyle: consistent

Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Naming/VariableNumber:
Enabled: false

# We use this extensively, the alternatives are not viable or desirable.
RSpec/AnyInstance:
Enabled: false

# No need to make the code more complex for no real gain.
RSpec/MessageSpies:
Enabled: false

# Let's consider legitimate to have multiple expectations within an example.
RSpec/MultipleExpectations:
Enabled: false

# Allow to use subject as is, no big deal.
RSpec/NamedSubject:
Enabled: false

# Let's set this to some really exagerate value.
RSpec/NestedGroups:
Max: 8

# We don't use the FactoryBot mixin
RSpec/FactoryBot/SyntaxMethods:
Enabled: false

RSpec/VerifiedDoubles:
# Sometimes you really need an "anything" double
IgnoreSymbolicNames: true

Style/FrozenStringLiteralComment:
Exclude:
- spec/**/*
- db/migrate/**/*
- bin/**/*

Style/ExplicitBlockArgument:
Exclude:
- lib/solidus_braintree/request_protection.rb

Rails/SkipsModelValidations:
Exclude:
- db/migrate/**/*

Rails/ReflectionClassName:
Exclude:
- app/models/solidus_braintree/customer.rb
- app/models/solidus_braintree/source.rb

RSpec/MultipleMemoizedHelpers:
Exclude:
- spec/models/solidus_braintree/transaction_import_spec.rb
- spec/models/solidus_braintree/response_spec.rb
- spec/models/solidus_braintree/gateway_spec.rb
- spec/controllers/solidus_braintree/client_tokens_controller_spec.rb
- spec/system/frontend/braintree_credit_card_checkout_spec.rb
- spec/system/frontend/paypal_checkout_spec.rb

Rails/ApplicationRecord:
Exclude:
- db/migrate/*
24 changes: 12 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', branch: branch
branch = ENV.fetch("SOLIDUS_BRANCH", "main")
gem "solidus", github: "solidusio/solidus", branch: branch

gem 'rails', "~> #{ENV.fetch('RAILS_VERSION', '7.0')}"
gem "rails", "~> #{ENV.fetch("RAILS_VERSION", "7.0")}"

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'
gem "solidus_auth_devise"

case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
case ENV.fetch("DB", nil)
when "mysql"
gem "mysql2"
when "postgresql"
gem "pg"
else
gem 'sqlite3'
gem "sqlite3"
end

gemspec
Expand All @@ -27,4 +27,4 @@ gemspec
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
12 changes: 6 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'solidus_dev_support/rake_tasks'
require "bundler/gem_tasks"
require "solidus_dev_support/rake_tasks"
SolidusDevSupport::RakeTasks.install

task :default do
require 'bundler'
require "bundler"
Bundler.with_unbundled_env do
sh 'bin/rspec'
sh "bin/rspec"
end
end

CLOBBER.include('dummy-app')
CLOBBER.include('sandbox')
CLOBBER.include("dummy-app")
CLOBBER.include("sandbox")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module SolidusBraintree
module SpreeUserDecorator
def self.prepended(base)
base.has_one :braintree_customer, class_name: 'SolidusBraintree::Customer', inverse_of: :user
base.has_one :braintree_customer, class_name: "SolidusBraintree::Customer", inverse_of: :user
end

::Spree.user_class.prepend self
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/solidus_braintree/braintree_admin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module SolidusBraintree
module BraintreeAdminHelper
# Returns a link to the Braintree web UI for the given Braintree payment
def braintree_transaction_link(payment)
environment = payment.payment_method.preferred_environment == 'sandbox' ? 'sandbox' : 'www'
environment = (payment.payment_method.preferred_environment == "sandbox") ? "sandbox" : "www"
merchant_id = payment.payment_method.preferred_merchant_id
response_code = payment.response_code

Expand All @@ -14,9 +14,9 @@ def braintree_transaction_link(payment)
link_to(
response_code,
"https://#{environment}.braintreegateway.com/merchants/#{merchant_id}/transactions/#{response_code}",
title: 'Show payment on Braintree',
target: '_blank',
rel: 'noopener'
title: "Show payment on Braintree",
target: "_blank",
rel: "noopener"
)
end
end
Expand Down
68 changes: 34 additions & 34 deletions app/models/solidus_braintree/avs_result.rb
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# frozen_string_literal: true

require 'active_merchant/billing/avs_result'
require "active_merchant/billing/avs_result"

module SolidusBraintree
class AVSResult < ActiveMerchant::Billing::AVSResult
# Mapping took from ActiveMerchant::Billing::BraintreeBlueGateway
AVS_MAPPING = {
'M' => {
'M' => 'M',
'N' => 'A',
'U' => 'B',
'I' => 'B',
'A' => 'B'
"M" => {
"M" => "M",
"N" => "A",
"U" => "B",
"I" => "B",
"A" => "B"
},
'N' => {
'M' => 'Z',
'N' => 'C',
'U' => 'C',
'I' => 'C',
'A' => 'C'
"N" => {
"M" => "Z",
"N" => "C",
"U" => "C",
"I" => "C",
"A" => "C"
},
'U' => {
'M' => 'P',
'N' => 'N',
'U' => 'I',
'I' => 'I',
'A' => 'I'
"U" => {
"M" => "P",
"N" => "N",
"U" => "I",
"I" => "I",
"A" => "I"
},
'I' => {
'M' => 'P',
'N' => 'C',
'U' => 'I',
'I' => 'I',
'A' => 'I'
"I" => {
"M" => "P",
"N" => "C",
"U" => "I",
"I" => "I",
"A" => "I"
},
'A' => {
'M' => 'P',
'N' => 'C',
'U' => 'I',
'I' => 'I',
'A' => 'I'
"A" => {
"M" => "P",
"N" => "C",
"U" => "I",
"I" => "I",
"A" => "I"
},
'B' => {
'B' => 'B'
"B" => {
"B" => "B"
},
nil => { nil => nil }
nil => {nil => nil}
}.freeze

class << self
Expand Down
2 changes: 1 addition & 1 deletion app/models/solidus_braintree/base_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module SolidusBraintree
def self.table_name_prefix
'solidus_paypal_braintree_'
"solidus_paypal_braintree_"
end

class BaseRecord < ::Spree::Base
Expand Down
22 changes: 11 additions & 11 deletions app/models/solidus_braintree/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
module SolidusBraintree
class Configuration < BaseRecord
PAYPAL_BUTTON_PREFERENCES = {
color: { availables: %w[gold blue silver white black], default: 'white' },
shape: { availables: %w[pill rect], default: 'rect' },
label: { availables: %w[checkout credit pay buynow paypal installment], default: 'checkout' },
tagline: { availables: %w[true false], default: 'false' },
layout: { availables: %w[horizontal vertical], default: 'horizontal' },
messaging: { availables: %w[true false], default: 'false' }
color: {availables: %w[gold blue silver white black], default: "white"},
shape: {availables: %w[pill rect], default: "rect"},
label: {availables: %w[checkout credit pay buynow paypal installment], default: "checkout"},
tagline: {availables: %w[true false], default: "false"},
layout: {availables: %w[horizontal vertical], default: "horizontal"},
messaging: {availables: %w[true false], default: "false"}
}.freeze

include ::Spree::Preferences::Persistable

belongs_to :store, class_name: 'Spree::Store', optional: false
belongs_to :store, class_name: "Spree::Store", optional: false

# Preferences for Paypal button
PAYPAL_BUTTON_PREFERENCES.each do |name, desc|
preference_name = "paypal_button_#{name}".to_sym
attribute_name = "preferred_#{preference_name}".to_sym
preference_name = :"paypal_button_#{name}"
attribute_name = :"preferred_#{preference_name}"

preference preference_name, :string, default: desc[:default]

validates attribute_name, inclusion: desc[:availables]
end

preference :venmo_button_color, :preference_select, default: 'blue'
preference :venmo_button_width, :preference_select, default: '320'
preference :venmo_button_color, :preference_select, default: "blue"
preference :venmo_button_width, :preference_select, default: "320"

def preferred_venmo_button_color_options
[["Blue", "blue"], ["White", "white"]]
Expand Down
Loading
Loading