Skip to content

Commit

Permalink
Merge branch 'master' into improve-psp-switching-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-landa authored Sep 7, 2021
2 parents 29041b6 + ea200df commit fb03992
Show file tree
Hide file tree
Showing 293 changed files with 5,151 additions and 1,505 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ executors:
<<: *environment
DB: mysql
DB_HOST: 127.0.0.1
DB_USERNAME: root
docker:
- image: *image
- image: circleci/mysql:5.7-ram
Expand Down Expand Up @@ -114,6 +115,7 @@ jobs:
parallelism: *parallelism
environment:
RAILS_VERSION: '~> 6.0.0'
DISABLE_ACTIVE_STORAGE: true
steps:
- setup
- test
Expand All @@ -123,6 +125,7 @@ jobs:
parallelism: *parallelism
environment:
RAILS_VERSION: '~> 5.2.0'
DISABLE_ACTIVE_STORAGE: true
steps:
- setup
- test
Expand Down
1 change: 1 addition & 0 deletions .dockerdev/.psqlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\set HISTFILE ~/history/psql_history
57 changes: 57 additions & 0 deletions .dockerdev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION-slim-buster

ARG PG_VERSION
ARG MYSQL_VERSION
ARG NODE_VERSION
ARG BUNDLER_VERSION

RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
build-essential \
gnupg2 \
curl \
git \
imagemagick \
libmariadb-dev \
sqlite3 \
libsqlite3-dev \
chromium \
chromium-driver \
&& rm -rf /var/cache/apt/lists/*

RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' $PG_VERSION > /etc/apt/sources.list.d/pgdg.list

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C718D3B5072E1F5 \
&& echo "deb http://repo.mysql.com/apt/debian/ buster mysql-"$MYSQL_VERSION > /etc/apt/sources.list.d/mysql.list

RUN curl -sSL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -

RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
libpq-dev \
postgresql-client-$PG_VERSION \
mysql-client \
nodejs \
&& rm -rf /var/lib/apt/lists/*

ENV APP_USER=solidus_user \
LANG=C.UTF-8 \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3
ENV GEM_HOME=/home/$APP_USER/gems
ENV APP_HOME=/home/$APP_USER/app
ENV PATH=$PATH:$GEM_HOME/bin

RUN useradd -ms /bin/bash $APP_USER

RUN gem update --system \
&& gem install bundler:$BUNDLER_VERSION \
&& chown -R $APP_USER:$(id -g $APP_USER) /home/$APP_USER/gems

USER $APP_USER

RUN mkdir -p /home/$APP_USER/history

WORKDIR /home/$APP_USER/app
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: Feature request
url: https://github.com/solidusio/solidus/discussions?discussions_q=category%3AIdeas
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ tags
node_modules
yarn.lock
package-lock.json
.env
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
- 'sandbox/**/*'
- '**/templates/**/*'
- 'guides/node_modules/**/*'
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5

# Sometimes I believe this reads better
# This also causes spacing issues on multi-line fixes
Expand Down
210 changes: 209 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ group :backend, :frontend, :core, :api do
# and https://github.com/rails/sprockets-rails/issues/369
gem 'sprockets', '~> 3'

# Temporary locking money to 6.13.8.
# See https://github.com/solidusio/solidus/issues/3903
gem 'money', '<= 6.13.8'

platforms :ruby do
case ENV['DB']
when /mysql/
if /mysql/.match?(ENV['DB']) || ENV['DB_ALL']
gem 'mysql2', '~> 0.5.0', require: false
when /postgres/
end
if /postgres/.match?(ENV['DB']) || ENV['DB_ALL']
gem 'pg', '~> 1.0', require: false
else
end
if ENV['DB_ALL'] || !/mysql|postgres/.match?(ENV['DB'])
gem 'sqlite3', require: false
gem 'fast_sqlite', require: false
end
Expand Down
106 changes: 65 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ As a community-driven project, Solidus relies on funds and time donated by devel
### Main Contributor & Director
At present, Nebulab is the main code contributor and director of Solidus, providing technical guidance and coordinating community efforts and activities.

[![Nebulab](https://nebulab.it/assets/images/public/logo.svg)](https://nebulab.it/)
[![Nebulab](https://nebulab.com/assets/img/logo-nebulab_black.svg)](https://nebulab.com/)

### Ambassadors
Support this project by becoming a Solidus Ambassador. Your logo will show up here with a link to your website. [Become an Ambassador](https://opencollective.com/solidus).
Expand Down Expand Up @@ -103,51 +103,19 @@ Begin by making sure you have
required for Paperclip. (You can install it using [Homebrew](https://brew.sh) if
you're on a Mac.)

To add solidus, begin with a Rails 5/6 application and a database configured and
created.
To add Solidus, begin with a Rails 5.2, 6 or 6.1 application and a database
configured and created.

### Installing Solidus

<details>
<summary>For Solidus v2.11 and above</summary>
In your application's root folder run:

Add the following to your Gemfile.

```ruby
gem 'solidus'
```

Run the `bundle` command to install.

After installing gems, you'll have to run the generator to create necessary
configuration files and migrations.

```bash
bin/rails g solidus:install
```
</details>

<details>
<summary>For Solidus v2.10 and below</summary>

Add the following to your Gemfile. Skip the `solidus_auth_devise` part
if you want to use a custom authentication system.

```ruby
gem 'solidus'
gem 'solidus_auth_devise'
```

Run the `bundle` command to install.

After installing gems, you'll have to run the generator to create necessary
configuration files and migrations.

```bash
bin/rails g spree:install
```
</details>
```bash
bundle add solidus
bin/rails g solidus:install
```

And follow the prompt's instructions.
### Accessing Solidus Store

Start the Rails server with the command:
Expand Down Expand Up @@ -238,6 +206,8 @@ and/or customizations to the Solidus admin. Use at your own risk.
cd solidus
```

### Without Docker

* Install the gem dependencies

```bash
Expand All @@ -256,6 +226,60 @@ and/or customizations to the Solidus admin. Use at your own risk.
bin/setup
```

### With Docker

```bash
docker-compose up -d
```

Wait for all the gems to be installed (progress can be checked through `docker-compose logs -f app`).

You can provide the ruby version you want your image to use:

```bash
docker-compose build --build-arg RUBY_VERSION=2.6 app
docker-compose up -d
```

The rails version can be customized at runtime through `RAILS_VERSION` environment variable:

```bash
RAILS_VERSION='~> 5.0' docker-compose up -d
```

Running tests:

```bash
# sqlite
docker-compose exec app bin/rspec
# postgres
docker-compose exec app env DB=postgres bin/rspec
# mysql
docker-compose exec app env DB=mysql bin/rspec
```

Accessing the databases:

```bash
# sqlite
docker-compose exec app sqlite3 /path/to/db
# postgres
docker-compose exec app env PGPASSWORD=password psql -U root -h postgres
# mysql
docker-compose exec app mysql -u root -h mysql -ppassword
```

In order to be able to access the [sandbox application](#sandbox), just make
sure to provide the appropriate `--binding` option to `rails server`. By
default, port `3000` is exposed, but you can change it through `SANDBOX_PORT`
environment variable:

```bash
SANDBOX_PORT=4000 docker-compose up -d
docker-compose exec app bin/sandbox
docker-compose exec app bin/rails server --binding 0.0.0.0 --port 4000
```

### Sandbox

Solidus is meant to be run within the context of Rails application. You can
Expand Down
5 changes: 3 additions & 2 deletions api/app/controllers/spree/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def gateway_error(exception)
end

def parameter_missing_error(exception)
message = exception.original_message || exception.message
# use original_message to remove DidYouMean suggestions, if defined
message = exception.try(:original_message) || exception.message
render json: {
exception: message,
error: message,
Expand Down Expand Up @@ -138,7 +139,7 @@ def product_scope
end

def variants_associations
[{ option_values: :option_type }, :default_price, :images]
[{ option_values: :option_type }, :prices, :images]
end

def product_includes
Expand Down
31 changes: 30 additions & 1 deletion api/app/controllers/spree/api/customer_returns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ module Spree
module Api
class CustomerReturnsController < Spree::Api::BaseController
before_action :load_order
before_action :build_customer_return, only: [:create]
around_action :lock_order, only: [:create, :update, :destroy, :cancel]

rescue_from Spree::Order::InsufficientStock, with: :insufficient_stock_error

def create
authorize! :create, CustomerReturn
@customer_return = CustomerReturn.create(customer_return_params)

if @customer_return.save
respond_with(@customer_return, status: 201, default_template: :show)
else
Expand Down Expand Up @@ -62,6 +63,34 @@ def load_order
def customer_return_params
params.require(:customer_return).permit(permitted_customer_return_attributes)
end

def build_customer_return
customer_return_attributes = customer_return_params
return_items_params = customer_return_attributes.
delete(:return_items_attributes)

if return_items_params.is_a? ActionController::Parameters
return_items_params = return_items_params.values
Spree::Deprecation.warn(
"Passing `return_items_attributes` as a hash of hashes is \
deprecated and will be removed in future versions of Solidus."
)
end

@customer_return = CustomerReturn.new(customer_return_attributes)

@customer_return.return_items = return_items_params.map do |item_params|
return_item = if item_params[:id]
Spree::ReturnItem.find(item_params[:id])
else
Spree::ReturnItem.new
end

return_item.assign_attributes(item_params)

return_item
end
end
end
end
end
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/shipments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def mine_includes
},
variant: {
product: {},
default_price: {},
prices: {},
option_values: {
option_type: {}
}
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/taxons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def products
# Products#index does not do the sorting.
taxon = Spree::Taxon.find(params[:id])
@products = paginate(taxon.products.ransack(params[:q]).result)
@products = @products.includes(master: :default_price)
@products = @products.includes(master: :prices)

if params[:simple]
@exclude_data = {
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/variants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def variant_params
end

def include_list
[{ option_values: :option_type }, :product, :default_price, :images, { stock_items: :stock_location }]
[{ option_values: :option_type }, :product, :prices, :images, { stock_items: :stock_location }]
end
end
end
Expand Down
Loading

0 comments on commit fb03992

Please sign in to comment.