Skip to content
Draft
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
35 changes: 0 additions & 35 deletions .circleci/config.yml

This file was deleted.

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
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Test

on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 0 * * 4" # every Thursday
workflow_call:

permissions:
contents: read

jobs:
rspec:
uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ pkg
*.swp
spec/dummy
spec/examples.txt
/sandbox
.rvmrc
.ruby-version
.ruby-gemset
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--color
--format progress
--require spec_helper
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require:
- solidus_dev_support/rubocop

inherit_from: .rubocop_todo.yml
AllCops:
NewCops: disable
15 changes: 12 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
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_globalize', github: 'solidusio-contrib/solidus_globalize'

case ENV['DB']
case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
Expand All @@ -26,5 +32,8 @@ end
gemspec

# Use a local Gemfile to include development dependencies that might not be
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
# relevant for the project or for other contributors, e.g. pry-byebug.
#
# 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'
137 changes: 64 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# Product Assembly
# Solidus Product Assembly

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

Create a product which is composed of other products.

## Installation

Add the following line to your `Gemfile`:
Add solidus_product_assembly to your Gemfile:

```ruby
gem 'solidus_product_assembly', github: 'solidusio-contrib/solidus_product_assembly', branch: 'master'
gem 'solidus_product_assembly'
```

Run bundle install as well as the extension intall command to copy and run migrations and
append solidus_product_assembly to your js manifest file:
Bundle your dependencies and run the installation generator:

bundle install
rails g solidus_product_assembly:install
```shell
bin/rails generate solidus_product_assembly:install
```

## Use
## Usage

To build a bundle (assembly product) you'd need to first check the "Can be part"
flag on each product you want to be part of the bundle. Then create a product
Expand All @@ -30,85 +31,75 @@ That means you essentially have a product composed of other products. From a
customer perspective it's like they are paying a single amount for a collection
of products.

## Releasing a new version
## Development

### Testing the extension

#### 1. Bump gem version and push to RubyGems
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`.

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

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:
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run

```bash
gem bump --version minor --tag --release
```shell
bundle exec rubocop
```

This command will:
When testing your application's integration with this extension you may use its factories.
Simply add this require statement to your `spec/spec_helper.rb`:

- 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
```ruby
require 'solidus_product_assembly/testing_support/factories'
```

Or you can run these commands individually:
Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
factories along with this extension's factories using this statement:

```bash
gem bump --version minor
gem tag
gem release
```ruby
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusProductAssembly::Engine)
```

#### 2. Publish the updated CHANGELOG
### Running the sandbox

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`.

Here's an example:

After the release is done we can generate the updated CHANGELOG
using
[github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator)
by running the following command:
```
$ 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
```

### Updating the changelog

```bash
bundle exec github_changelog_generator solidusio/solidus_auth_devise --token YOUR_GITHUB_TOKEN
git commit -am 'Update CHANGELOG'
git push upstream master
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.

## Contributing

Spree is an open source project and we encourage contributions. Please see the [Community Guidelines][1] before contributing.

In the spirit of [free software][2], **everyone** is encouraged to help improve this project.

Here are some ways *you* can contribute:

* by using prerelease versions
* by reporting [bugs][3]
* by suggesting new features
* by writing translations
* by writing or editing documentation
* by writing specifications
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
* by refactoring code
* by resolving [issues][3]
* by reviewing patches

Starting point:

* Fork the repo
* Clone your repo
* Run `bundle install`
* Run `bundle exec rake test_app` to create the test application in `spec/test_app`
* Make your changes
* Ensure specs pass by running `bundle exec rspec spec`
* Submit your pull request

Copyright (c) 2014 [Spree Commerce Inc.][4] and [contributors][5], released under the [New BSD License][6]

[1]: https://solidus.io/community-guidelines/
[2]: http://www.fsf.org/licensing/essays/free-sw.html
[3]: https://github.com/spree/spree-product-assembly/issues
[4]: https://github.com/spree
[5]: https://github.com/spree/spree-product-assembly/graphs/contributors
[6]: https://github.com/spree/spree-product-assembly/blob/master/LICENSE.md
Spree is an open source project and we encourage contributions. Please see the [Community Guidelines](https://solidus.io/community-guidelines/) before contributing.

In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.

## License

Copyright (c) 2014 [Spree Commerce Inc.](https://github.com/spree) and [contributors](https://github.com/spree/spree-product-assembly/graphs/contributors), released under the [New BSD License](LICENSE)
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ def self.prepended(base)

scope :individual_saled, -> { where(individual_sale: true) }

scope :search_can_be_part, ->(query){
not_deleted.available.joins(:master)
.where(arel_table["name"].matches("%#{query}%").or(::Spree::Variant.arel_table["sku"].matches("%#{query}%")))
.where(can_be_part: true)
.limit(30)
}
if defined?(SolidusGlobalize)
scope :search_can_be_part, ->(query){
not_deleted.available.joins(:master)
.joins(:translations)
.where(
::Spree::Product::Translation.arel_table["name"].matches(query)
.or(::Spree::Variant.arel_table["sku"].matches(query))
)
.where(can_be_part: true)
.limit(30)
}
else
scope :search_can_be_part, ->(query){
not_deleted.available.joins(:master)
.where(arel_table["name"].matches(query).or(::Spree::Variant.arel_table["sku"].matches(query)))
.where(can_be_part: true)
.limit(30)
}
end

validate :assembly_cannot_be_part, if: :assembly?
end
Expand Down
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_product_assembly/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
7 changes: 7 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rake", "rake")
Loading
Loading