solidus_support_devise_token_auth 0.2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4b2b75f0d9269430dcfe6b2fcc4e6f3f8dc43263087195f444fcf52c020be4ec
4
+ data.tar.gz: b3cb51126b8f0b3e2d27906dc5c4cc542865af388404a9954c7aa7c605ecb992
5
+ SHA512:
6
+ metadata.gz: '09de15d30a40e69ed54d7c7d01a4d234ab365da63478a2a7716c3e5001896020fd1ae40f5318206dde593e34df75a1c8abb8a6cc247c899352c9d965956acdce'
7
+ data.tar.gz: 27abce0777640719c1e37d2b2398bb2a2d9a26d5184bce69c36dd0db6cb342d957c2259e7a24042f4e689603b23818e51ea4e2d6261e81010748505ebf5c6013
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /log/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Metrics/BlockLength:
2
+ ExcludedMethods: ['describe', 'context']
3
+
4
+ Metrics/LineLength:
5
+ Max: 100
6
+
7
+ Style/Documentation:
8
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
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=v2.2
14
+ - SOLIDUS_BRANCH=v2.3
15
+ - SOLIDUS_BRANCH=v2.4
16
+ - SOLIDUS_BRANCH=v2.5
17
+ - SOLIDUS_BRANCH=v2.6
18
+ - SOLIDUS_BRANCH=v2.7
19
+ - SOLIDUS_BRANCH=master
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
9
+ gem 'solidus_core_devise_token_auth', github: 'skycocker/solidus_devise_token_auth', branch: branch
10
+
11
+ # Specify your gem's dependencies in solidus_support.gemspec
12
+ gemspec
13
+
14
+ gem 'sprockets-rails'
15
+ gem 'sqlite3'
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # SolidusSupport
2
+
3
+ This gem holds some common functionality for Solidus Extensions.
4
+
5
+ It has some utilities to make it easier to support multiple versions of Solidus.
6
+
7
+ ## Usage
8
+
9
+ ### `SolidusSupport::Migration`
10
+
11
+ Rails >= 5 introduced the concept of specifying what rails version your migration was written for, like `ActiveRecord::Migration[5.0]`.
12
+ Not specifying a version is deprecated in Rails 5.0 and removed in rails 5.1.
13
+ This wasn't backported to Rails 4.2, but Rails 4.2 _is_ Rails 4.2. So we provide this helper.
14
+
15
+ ``` ruby
16
+ # On Rails 4.2
17
+ SolidusSupport::Migration[4.2] # returns `ActiveRecord::Migration`
18
+ SolidusSupport::Migration[5.0] # errors
19
+
20
+ # On Rails 5.0
21
+ SolidusSupport::Migration[4.2] # same as `ActiveRecord::Migration[4.2]`
22
+ SolidusSupport::Migration[5.0] # same as `ActiveRecord::Migration[5.0]`
23
+ ```
24
+
25
+ There's no reason to use `SolidusSupport::Migration[5.0]` over `ActiveRecord::Migration[5.0]`, but it is provided.
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
+
63
+ ## Development
64
+
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.
66
+
67
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/solidusio/solidus_support.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+
3
+ begin
4
+ require 'rubocop/rake_task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RuboCop::RakeTask.new
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: %i[rubocop spec]
11
+ end
@@ -0,0 +1,56 @@
1
+ require 'solidus_support/version'
2
+ require 'solidus_support/migration'
3
+ require 'solidus_core'
4
+
5
+ module SolidusSupport
6
+ class << self
7
+ def solidus_gem_version
8
+ if Spree.respond_to?(:solidus_gem_version)
9
+ Spree.solidus_gem_version
10
+ elsif Spree.respond_to?(:gem_version)
11
+ # 1.1 doesn't have solidus_gem_version
12
+ Gem::Version.new(Spree.solidus_version)
13
+ else
14
+ # 1.0 doesn't have gem_version
15
+ Gem::Specification.detect { |x| x.name == 'solidus_core' }.version
16
+ end
17
+ end
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
+
24
+ def payment_source_parent_class
25
+ if new_gateway_code?
26
+ Spree::PaymentSource
27
+ else
28
+ Spree::Base
29
+ end
30
+ end
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
+
44
+ def frontend_available?
45
+ defined?(Spree::Frontend::Engine)
46
+ end
47
+
48
+ def backend_available?
49
+ defined?(Spree::Backend::Engine)
50
+ end
51
+
52
+ def api_available?
53
+ defined?(Spree::Api::Engine)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,36 @@
1
+ # A basic feature_helper to be included as the starting point for extensions
2
+ #
3
+ # Can be required from an extension's spec/feature_helper.rb
4
+ #
5
+ # require 'solidus_support/extension/feature_helper'
6
+ #
7
+
8
+ require 'solidus_support/extension/rails_helper'
9
+
10
+ require 'capybara-screenshot/rspec'
11
+ require 'capybara/poltergeist'
12
+
13
+ Capybara.register_driver :poltergeist do |app|
14
+ Capybara::Poltergeist::Driver.new(app, js_errors: true, timeout: 90)
15
+ end
16
+
17
+ Capybara.javascript_driver = :poltergeist
18
+ Capybara.default_max_wait_time = 10
19
+
20
+ require 'spree/testing_support/capybara_ext'
21
+
22
+ RSpec.configure do |config|
23
+ config.when_first_matching_example_defined(type: :feature) do
24
+ config.before :suite do
25
+ # Preload assets
26
+ if Rails.application.respond_to?(:precompiled_assets)
27
+ Rails.application.precompiled_assets
28
+ else
29
+ # For older sprockets 2.x
30
+ Rails.application.config.assets.precompile.each do |asset|
31
+ Rails.application.assets.find_asset(asset)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,43 @@
1
+ # A basic rails_helper to be included as the starting point for extensions
2
+ #
3
+ # Can be required from an extension's spec/rails_helper.rb
4
+ #
5
+ # require 'solidus_support/extension/rails_helper'
6
+ #
7
+
8
+ require 'solidus_support/extension/spec_helper'
9
+
10
+ require 'rspec/rails'
11
+ require 'database_cleaner'
12
+ require 'ffaker'
13
+
14
+ require 'spree/testing_support/authorization_helpers'
15
+ require 'spree/testing_support/factories'
16
+ require 'spree/testing_support/url_helpers'
17
+ require 'spree/testing_support/preferences'
18
+
19
+ RSpec.configure do |config|
20
+ config.include FactoryBot::Syntax::Methods
21
+
22
+ # visit spree.admin_path
23
+ # current_path.should eql(spree.products_path)
24
+ config.include Spree::TestingSupport::UrlHelpers
25
+
26
+ config.include Spree::TestingSupport::Preferences
27
+
28
+ config.before :suite do
29
+ DatabaseCleaner.clean_with :truncation
30
+ end
31
+
32
+ # Around each spec check if it is a Javascript test and switch between using
33
+ # database transactions or not where necessary.
34
+ config.around(:each) do |example|
35
+ DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
36
+
37
+ DatabaseCleaner.cleaning do
38
+ reset_spree_preferences
39
+
40
+ example.run
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ # A basic spec_helper to be included as the starting point for extensions
2
+ #
3
+ # Can be required from an extension's spec/spec_helper.rb
4
+ #
5
+ # require 'solidus_support/extension/spec_helper'
6
+ #
7
+
8
+ RSpec.configure do |config|
9
+ config.filter_run focus: true
10
+ config.run_all_when_everything_filtered = true
11
+
12
+ config.mock_with :rspec
13
+ config.color = true
14
+
15
+ config.fail_fast = ENV['FAIL_FAST'] || false
16
+ config.order = 'random'
17
+
18
+ Kernel.srand config.seed
19
+ end
@@ -0,0 +1,15 @@
1
+ module SolidusSupport
2
+ module Migration
3
+ def self.[](version)
4
+ if Rails.gem_version >= Gem::Version.new('5.x')
5
+ ActiveRecord::Migration[version]
6
+ else
7
+ # Rails < 5 doesn't support specifying rails version of migrations, but
8
+ # it _is_ rails 4.2, so we can use that when requested.
9
+ return ActiveRecord::Migration if version.to_s == '4.2'
10
+
11
+ raise ArgumentError, "Unknown migration version '#{version}'; expected one of '4.2'"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module SolidusSupport
2
+ VERSION = '0.2.2.0'.freeze
3
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'solidus_support/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'solidus_support_devise_token_auth'
9
+ spec.version = SolidusSupport::VERSION
10
+ spec.authors = ['John Hawthorn', 'Michał Siwek (skycocker)']
11
+ spec.email = ['john@stembolt.com', 'mike21@aol.pl']
12
+
13
+ spec.summary = 'A common functionality for solidus extensions (devise_token_auth revised version)'
14
+ spec.description = 'Collection of common functionality for solidus extensions'
15
+ spec.homepage = 'https://github.com/skycocker/solidus_support'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.14'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rspec-rails', '~> 3.7'
23
+ spec.add_development_dependency 'rubocop'
24
+ spec.add_development_dependency 'rubocop-rspec'
25
+ spec.add_development_dependency 'solidus_core_devise_token_auth'
26
+ 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
@@ -0,0 +1,2 @@
1
+ require_relative 'support/dummy_app'
2
+ require 'solidus_support/extension/spec_helper'
@@ -0,0 +1,19 @@
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', __dir__)
15
+ config.active_record.sqlite3.represent_boolean_as_integer = true
16
+ end
17
+ end
18
+
19
+ DummyApp::Application.initialize!
@@ -0,0 +1,4 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: ':memory:'
4
+ timeout: 10000
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_support_devise_token_auth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2.0
5
+ platform: ruby
6
+ authors:
7
+ - John Hawthorn
8
+ - Michał Siwek (skycocker)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2018-10-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.14'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.14'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec-rails
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop-rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: solidus_core_devise_token_auth
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: Collection of common functionality for solidus extensions
99
+ email:
100
+ - john@stembolt.com
101
+ - mike21@aol.pl
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".rubocop.yml"
109
+ - ".travis.yml"
110
+ - Gemfile
111
+ - README.md
112
+ - Rakefile
113
+ - lib/solidus_support.rb
114
+ - lib/solidus_support/extension/feature_helper.rb
115
+ - lib/solidus_support/extension/rails_helper.rb
116
+ - lib/solidus_support/extension/spec_helper.rb
117
+ - lib/solidus_support/migration.rb
118
+ - lib/solidus_support/version.rb
119
+ - solidus_support.gemspec
120
+ - spec/solidus_support_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/support/dummy_app.rb
123
+ - spec/support/dummy_app/database.yml
124
+ homepage: https://github.com/skycocker/solidus_support
125
+ licenses: []
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.7.6
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: A common functionality for solidus extensions (devise_token_auth revised
147
+ version)
148
+ test_files: []