solidus_support 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +23 -0
- data/Gemfile +4 -1
- data/README.md +36 -1
- data/lib/solidus_support.rb +18 -1
- data/lib/solidus_support/extension/feature_helper.rb +1 -1
- data/lib/solidus_support/extension/rails_helper.rb +1 -1
- data/lib/solidus_support/extension/spec_helper.rb +1 -1
- data/lib/solidus_support/version.rb +1 -1
- data/solidus_support.gemspec +2 -0
- data/spec/solidus_support_spec.rb +41 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/dummy_app.rb +18 -0
- data/spec/support/dummy_app/database.yml +4 -0
- metadata +37 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6337566230395848b49403c4b56e36c77e145a4b622c08e144021b8fbf86e1
|
4
|
+
data.tar.gz: 6a89880916b4420dd0faafa0542d33da84e0ae95ee5193402441af91a96d3799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c202ec470b49983809717d7f9e8633e0a086bd1e782410aa0f221fd444e23842842f112fea46da313f23e66aba3a28ee0a9560b3c227b0f412c41ad129ce597
|
7
|
+
data.tar.gz: 6c03785d6c92023a8d9fe6b3e1fc5d12867c712fce458f7bf33417918ee4f814b91428ecae72593dbc30317e25cb70902780afb2693b10b4ee155e602e4b071d
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
dist: trusty
|
4
|
+
cache:
|
5
|
+
bundler: true
|
6
|
+
before_install:
|
7
|
+
- "gem install bundler --pre"
|
8
|
+
- "bundler -v"
|
9
|
+
rvm:
|
10
|
+
- 2.4.2
|
11
|
+
env:
|
12
|
+
matrix:
|
13
|
+
- SOLIDUS_BRANCH=v1.0
|
14
|
+
- SOLIDUS_BRANCH=v1.1
|
15
|
+
- SOLIDUS_BRANCH=v1.2
|
16
|
+
- SOLIDUS_BRANCH=v1.3
|
17
|
+
- SOLIDUS_BRANCH=v1.4
|
18
|
+
- SOLIDUS_BRANCH=v2.0
|
19
|
+
- SOLIDUS_BRANCH=v2.1
|
20
|
+
- SOLIDUS_BRANCH=v2.2
|
21
|
+
- SOLIDUS_BRANCH=v2.3
|
22
|
+
- SOLIDUS_BRANCH=v2.4
|
23
|
+
- SOLIDUS_BRANCH=master
|
data/Gemfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
4
|
-
gem '
|
4
|
+
gem 'solidus_core', github: 'solidusio/solidus', branch: branch
|
5
5
|
|
6
6
|
# Specify your gem's dependencies in solidus_support.gemspec
|
7
7
|
gemspec
|
8
|
+
|
9
|
+
gem 'sqlite3'
|
10
|
+
gem 'sprockets-rails'
|
data/README.md
CHANGED
@@ -24,6 +24,42 @@ SolidusSupport::Migration[5.0] # same as `ActiveRecord::Migration[5.0]`
|
|
24
24
|
|
25
25
|
There's no reason to use `SolidusSupport::Migration[5.0]` over `ActiveRecord::Migration[5.0]`, but it is provided.
|
26
26
|
|
27
|
+
### Testing Helpers
|
28
|
+
|
29
|
+
This gem provides some useful helpers for RSpec to setup an extension's test
|
30
|
+
environment easily.
|
31
|
+
|
32
|
+
Into your extension's spec/spec_helper.rb:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require "solidus_support/extension/feature_helper"
|
36
|
+
```
|
37
|
+
|
38
|
+
This helper loads configuration needed to run extensions feature specs
|
39
|
+
correctly, setting up Capybara and configuring Rails test application
|
40
|
+
to precompile assets before the first feature spec.
|
41
|
+
|
42
|
+
This helper requires the `rails_helper`, also provided by this gem and
|
43
|
+
requireable as a stand-alone helper.
|
44
|
+
|
45
|
+
By doing:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require "solidus_support/extension/rails_helper"
|
49
|
+
```
|
50
|
+
|
51
|
+
extension's test suite will have all Rails related tests configuration,
|
52
|
+
like authorization helpers, Solidus core factories, url helpers, and
|
53
|
+
other helpers to easily work with Solidus Config.
|
54
|
+
|
55
|
+
This `rails_helper` in turn requires the basic `spec_helper`, which is
|
56
|
+
responsible to load a basic RSpec configuration, which could be needed
|
57
|
+
in all extensions. It is also requireable as a stand-alone helper with:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require "solidus_support/extension/spec_helper"
|
61
|
+
```
|
62
|
+
|
27
63
|
## Development
|
28
64
|
|
29
65
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -33,4 +69,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
33
69
|
## Contributing
|
34
70
|
|
35
71
|
Bug reports and pull requests are welcome on GitHub at https://github.com/solidusio/solidus_support.
|
36
|
-
|
data/lib/solidus_support.rb
CHANGED
@@ -16,14 +16,31 @@ module SolidusSupport
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def new_gateway_code?
|
20
|
+
first_version_with_new_gateway_code = Gem::Requirement.new('>= 2.3')
|
21
|
+
first_version_with_new_gateway_code.satisfied_by?(solidus_gem_version)
|
22
|
+
end
|
23
|
+
|
19
24
|
def payment_source_parent_class
|
20
|
-
if
|
25
|
+
if new_gateway_code?
|
21
26
|
Spree::PaymentSource
|
22
27
|
else
|
23
28
|
Spree::Base
|
24
29
|
end
|
25
30
|
end
|
26
31
|
|
32
|
+
def payment_method_parent_class(credit_card: false)
|
33
|
+
if new_gateway_code?
|
34
|
+
if credit_card
|
35
|
+
Spree::PaymentMethod::CreditCard
|
36
|
+
else
|
37
|
+
Spree::PaymentMethod
|
38
|
+
end
|
39
|
+
else
|
40
|
+
Spree::Gateway
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
27
44
|
def frontend_available?
|
28
45
|
defined?(Spree::Frontend::Engine)
|
29
46
|
end
|
data/solidus_support.gemspec
CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
+
spec.add_development_dependency "solidus_core"
|
19
20
|
spec.add_development_dependency "bundler", "~> 1.14"
|
20
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec-rails", "~> 3.7"
|
21
23
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
RSpec.describe SolidusSupport do
|
2
|
+
describe '.payment_method_parent_class' do
|
3
|
+
subject { described_class.payment_method_parent_class(credit_card: credit_card) }
|
4
|
+
|
5
|
+
let(:credit_card) { nil }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow(described_class).to receive(:solidus_gem_version) do
|
9
|
+
Gem::Version.new(solidus_version)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'For Solidus < 2.3' do
|
14
|
+
let(:solidus_version) { '2.2.1' }
|
15
|
+
|
16
|
+
it { is_expected.to eq(Spree::Gateway) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'For Solidus >= 2.3' do
|
20
|
+
let(:solidus_version) { '2.3.1' }
|
21
|
+
|
22
|
+
it { is_expected.to eq(Spree::PaymentMethod) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with credit_card: true' do
|
26
|
+
let(:credit_card) { true }
|
27
|
+
|
28
|
+
context 'For Solidus < 2.3' do
|
29
|
+
let(:solidus_version) { '2.2.1' }
|
30
|
+
|
31
|
+
it { is_expected.to eq(Spree::Gateway) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'For Solidus >= 2.3' do
|
35
|
+
let(:solidus_version) { '2.3.1' }
|
36
|
+
|
37
|
+
it { is_expected.to eq(Spree::PaymentMethod::CreditCard) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = '1'
|
3
|
+
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
require 'rails'
|
7
|
+
require 'solidus_core'
|
8
|
+
|
9
|
+
Bundler.require(:default, :test)
|
10
|
+
|
11
|
+
module DummyApp
|
12
|
+
class Application < ::Rails::Application
|
13
|
+
config.eager_load = false
|
14
|
+
config.paths["config/database"] = File.expand_path('../dummy_app/database.yml', __FILE__)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
DummyApp::Application.initialize!
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: solidus_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.7'
|
41
69
|
description: Collection of common functionality for solidus extensions
|
42
70
|
email:
|
43
71
|
- john@stembolt.com
|
@@ -46,6 +74,8 @@ extensions: []
|
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
76
|
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
49
79
|
- Gemfile
|
50
80
|
- README.md
|
51
81
|
- Rakefile
|
@@ -56,6 +86,10 @@ files:
|
|
56
86
|
- lib/solidus_support/migration.rb
|
57
87
|
- lib/solidus_support/version.rb
|
58
88
|
- solidus_support.gemspec
|
89
|
+
- spec/solidus_support_spec.rb
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- spec/support/dummy_app.rb
|
92
|
+
- spec/support/dummy_app/database.yml
|
59
93
|
homepage: https://solidus.io
|
60
94
|
licenses: []
|
61
95
|
metadata: {}
|
@@ -75,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
109
|
version: '0'
|
76
110
|
requirements: []
|
77
111
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.7.
|
112
|
+
rubygems_version: 2.7.3
|
79
113
|
signing_key:
|
80
114
|
specification_version: 4
|
81
115
|
summary: A common functionality for solidus extensions
|