Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gem with the latest dev_support #97

Merged
merged 3 commits into from
Jan 25, 2021
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
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ jobs:
executor: solidusio_extensions/mysql
steps:
- solidusio_extensions/run-tests
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql

"Weekly run specs against master":
triggers:
- schedule:
Expand Down
2 changes: 1 addition & 1 deletion .gem_release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bump:
recurse: false
file: 'lib/solidus_stripe/version.rb'
message: Bump Solidus Stripe to %{version}
message: Bump SolidusStripe to %{version}
tag: true
8 changes: 4 additions & 4 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
daysUntilClose: false
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
recent activity. It might be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
closeComment: false
2 changes: 2 additions & 0 deletions .github_changelog_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
issues=false
exclude-labels=infrastructure
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
.DS_Store
.idea
.project
.ruby-version
.rvmrc
.sass-cache
coverage
Gemfile.lock
Expand All @@ -17,3 +15,6 @@ pkg
spec/dummy
spec/examples.txt
/sandbox
.rvmrc
.ruby-version
.ruby-gemset
4 changes: 1 addition & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ require:
- solidus_dev_support/rubocop

AllCops:
Exclude:
- sandbox/**/*
- spec/dummy/**/*
NewCops: disable
12 changes: 3 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# 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', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch
gem 'solidus', github: 'solidusio/solidus', branch: branch

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
# See https://github.com/bundler/bundler/issues/6677
gem 'rails', '>0.a'

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

case ENV['DB']
when 'mysql'
Expand All @@ -23,12 +23,6 @@ else
gem 'sqlite3'
end

group :development, :test do
gem "pry-rails"
gem "ffaker"
gem "rails-controller-testing"
end

gemspec

# Use a local Gemfile to include development dependencies that might not be
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2014 Spree Commerce Inc. and other contributors.
Copyright (c) 2020 Solidus Team and other contributors.
Copyright (c) 2021 Solidus Team and other contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand All @@ -10,7 +10,7 @@ are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Spree nor the names of its contributors may be used to
* Neither the name Solidus nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

Expand Down
80 changes: 47 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Solidus Stripe
===============
# Solidus Stripe

[![CircleCI](https://circleci.com/gh/solidusio/solidus_stripe.svg?style=svg)](https://circleci.com/gh/solidusio/solidus_stripe)
[![CircleCI](https://circleci.com/gh/solidusio/solidus_stripe.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_stripe)
[![codecov](https://codecov.io/gh/solidusio/solidus_stripe/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_stripe)

Stripe Payment Method for Solidus. It works as a wrapper for the ActiveMerchant Stripe gateway.

Expand All @@ -21,7 +21,6 @@ Then run from the command line:
```shell
bundle install
bundle exec rails g solidus_stripe:install
bundle exec rails db:migrate
```

Usage
Expand Down Expand Up @@ -259,53 +258,68 @@ SolidusStripe.Payment.prototype.elementsBaseOptions = function () {
};
```


Migrating from solidus_gateway
------------------------------
## Migrating from solidus_gateway

If you were previously using `solidus_gateway` gem you might want to
check out our [Wiki page](https://github.com/solidusio/solidus_stripe/wiki/Migrating-from-solidus_gateway)
that describes how to handle this migration.

Testing
-------
## Development

### Testing the extension

Then just run the following to automatically build a dummy app if necessary and
run the tests:
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
`bin/rake extension:test_app`.

```shell
bundle exec rake
bin/rake
```

Releasing
---------
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run

We use [gem-release](https://github.com/svenfuchs/gem-release) to release this
extension with ease.
```shell
bundle exec rubocop
```

Supposing you are on the master branch and you are working on a fork of this
extension, `upstream` is the main remote and you have write access to it, you
can simply run:
When testing your application's integration with this extension you may use its factories.
Simply add this require statement to your spec_helper:

```
gem bump --version minor --tag --release --remote upstream
```ruby
require '<%= file_name %>/factories'
```

This command will:
### Running the sandbox

- bump the gem version to the next minor (changing the `version.rb` file)
- commit the change and push it to upstream master
- create a git tag
- push the tag to the upstream remote
- release the new version on RubyGems
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
`sandbox/bin/rails`.

Or you can run these commands individually:
Here's an example:

```
gem bump --version minor --remote upstream
gem tag --remote upstream
gem release
$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop
```

Copyright (c) 2020 Spree Commerce Inc., released under the New BSD License
Copyright (c) 2020 Solidus Team, released under the New BSD License
### Updating the changelog

Before and after releases the changelog should be updated to reflect the up-to-date status of
the project:

```shell
bin/rake changelog
git add CHANGELOG.md
git commit -m "Update the changelog"
```

### Releasing new versions

Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.

## License
Copyright (c) 2014 Spree Commerce Inc., released under the New BSD License
Copyright (c) 2021 Solidus Team, released under the New BSD License
16 changes: 4 additions & 12 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/usr/bin/env ruby

# frozen_string_literal: true

app_root = 'spec/dummy'

unless File.exist? "#{app_root}/bin/rails"
system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
warn "Automatic creation of the dummy app failed"
exit 1
end
if %w[g generate].include? ARGV.first
exec "#{__dir__}/rails-engine", *ARGV
else
exec "#{__dir__}/rails-sandbox", *ARGV
end

Dir.chdir app_root
exec 'bin/rails', *ARGV
13 changes: 13 additions & 0 deletions bin/rails-engine
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/solidus_stripe/engine', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require 'rails/all'
require 'rails/engine/commands'
16 changes: 16 additions & 0 deletions bin/rails-sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby

app_root = 'sandbox'

unless File.exist? "#{app_root}/bin/rails"
warn 'Creating the sandbox app...'
Dir.chdir "#{__dir__}/.." do
system "#{__dir__}/sandbox" or begin
warn 'Automatic creation of the sandbox app failed'
exit 1
end
end
end

Dir.chdir app_root
exec 'bin/rails', *ARGV
2 changes: 2 additions & 0 deletions bin/sandbox
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ unbundled bundle exec rails generate spree:install \
--user_class=Spree::User \
--enforce_available_locales=true \
--with-authentication=false \
--payment-method=none \
$@

unbundled bundle exec rails generate solidus:auth:install
unbundled bundle exec rails generate ${extension_name}:install

echo
echo "🚀 Sandbox app successfully created for $extension_name!"
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.

en:
hello: Hello world
6 changes: 1 addition & 5 deletions lib/generators/solidus_stripe/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ def add_javascripts
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_stripe\n"
end

def add_migrations
run 'bundle exec rake railties:install:migrations FROM=solidus_stripe'
end

def add_migrations
run 'bin/rails railties:install:migrations FROM=solidus_stripe'
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
if run_migrations
run 'bin/rails db:migrate'
else
Expand Down
10 changes: 5 additions & 5 deletions lib/solidus_stripe.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "active_merchant"
require "solidus_core"
require "solidus_support"
require "solidus_stripe/engine"
require "solidus_stripe/version"
require 'active_merchant'

require 'solidus_stripe/configuration'
require 'solidus_stripe/version'
require 'solidus_stripe/engine'
21 changes: 21 additions & 0 deletions lib/solidus_stripe/configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module SolidusStripe
class Configuration
# Define here the settings for this extensions, e.g.:
#
# attr_accessor :my_setting
end

class << self
def configuration
@configuration ||= Configuration.new
end

alias config configuration

def configure
yield configuration
end
end
end
15 changes: 2 additions & 13 deletions lib/solidus_stripe/engine.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spree/core'
require 'solidus_core'
require 'solidus_support'

module SolidusStripe
class Engine < Rails::Engine
Expand All @@ -15,18 +16,6 @@ class Engine < Rails::Engine
g.test_framework :rspec
end

if SolidusSupport.backend_available?
paths["app/views"] << "lib/views/backend"
end

if SolidusSupport.frontend_available?
paths["app/views"] << "lib/views/frontend"
end

if SolidusSupport.api_available?
paths["app/views"] << "lib/views/api"
end

initializer "spree.payment_method.add_stripe_credit_card", after: "spree.register.payment_methods" do |app|
app.config.spree.payment_methods << "Spree::PaymentMethod::StripeCreditCard"
end
Expand Down
Loading