Skip to content

Commit

Permalink
Merge branch 'main' into create-edit-product-property
Browse files Browse the repository at this point in the history
  • Loading branch information
Astr0surf3r authored Nov 13, 2024
2 parents 23c1b84 + b1a3796 commit 5d14ec2
Show file tree
Hide file tree
Showing 18 changed files with 295 additions and 50 deletions.
3 changes: 3 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ changelog:
- title: Solidus Sample
labels:
- "changelog:solidus_sample"
- title: Solidus Promotions
labels:
- "changelog:solidus_promotions"
207 changes: 207 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions backend/app/controllers/spree/admin/dashboards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
module Spree
module Admin
class DashboardsController < BaseController
before_action :deprecate
def deprecate
Spree.deprecator.warn "The #{self.class.name} is deprecated. If you still use dashboards, please copy all controllers and views from solidus_backend to your application."
end
end
end
end
1 change: 1 addition & 0 deletions backend/app/views/spree/admin/dashboards/home.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<%# Placeholder view for a home dashboard %>
<p><%= Spree.deprecator.warn "The Home view is deprecated, If you still use dashboards, please copy all controllers and views from solidus_backend to your application." %></p>
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CannotRebuildShipments < StandardError; end
go_to_state :confirm
end

self.allowed_ransackable_associations = %w[shipments user order_promotions promotions bill_address ship_address line_items]
self.allowed_ransackable_associations = %w[shipments user bill_address ship_address line_items]
self.allowed_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total store_id]

attr_reader :coupon_code
Expand Down
4 changes: 3 additions & 1 deletion core/db/default/spree/return_reasons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Spree::ReturnReason.find_or_create_by(name: 'Better price available')
Spree::ReturnReason.find_or_create_by(name: 'Missed estimated delivery date')
Spree::ReturnReason.find_or_create_by(name: 'Missing parts or accessories')
Spree::ReturnReason.find_or_create_by(name: 'Damaged/Defective')
Spree::ReturnReason.find_or_create_by(name: 'Damaged during transport')
Spree::ReturnReason.find_or_create_by(name: 'Defective within warranty period')
Spree::ReturnReason.find_or_create_by(name: 'Other defects or damages')
Spree::ReturnReason.find_or_create_by(name: 'Different from what was ordered')
Spree::ReturnReason.find_or_create_by(name: 'Different from description')
Spree::ReturnReason.find_or_create_by(name: 'No longer needed/wanted')
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
apply 'https://github.com/solidusio/solidus_starter_frontend/raw/rails-7.2/template.rb'
apply 'https://github.com/solidusio/solidus_starter_frontend/raw/main/template.rb'
4 changes: 2 additions & 2 deletions core/lib/spree/core/version.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

module Spree
VERSION = "4.4.0.dev"
VERSION = "4.5.0.dev"

def self.solidus_version
VERSION
end

def self.previous_solidus_minor_version
'4.3'
'4.4'
end

def self.solidus_gem_version
Expand Down
2 changes: 2 additions & 0 deletions core/lib/spree/permission_sets/dashboard_display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def category
end

def activate!
Spree.deprecator.warn "The #{self.class.name} module is deprecated. " \
"If you still use dashboards, please copy all controllers and views from #{self.class.name} to your application."
can [:admin, :home], :dashboards
end
end
Expand Down
6 changes: 6 additions & 0 deletions core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
let(:user) { create(:user, email: "[email protected]") }
let(:order) { create(:order, user:, store:) }

describe ".ransackable_associations" do
subject { described_class.ransackable_associations }

it { is_expected.to contain_exactly("user", "line_items", "shipments", "bill_address", "ship_address") }
end

context '#store' do
it { is_expected.to respond_to(:store) }

Expand Down
36 changes: 0 additions & 36 deletions core/spec/models/spree/permission_sets/dashboard_display_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
NODE_VERSION: 20
MYSQL_VERSION: "8.0"
BUNDLER_VERSION: 2
image: solidus-4.4.0.dev
image: solidus-4.5.0.dev
command: bash -c "(bundle check || bundle) && bash -c 'echo Container initialized, see README.md for further steps.' && tail -f /dev/null"
environment:
CAPYBARA_DRIVER: selenium_chrome_headless_docker_friendly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

module SolidusLegacyPromotions
module SpreeOrderDecorator
module ClassMethods
def allowed_ransackable_associations
super + ["promotions", "order_promotions"]
end
end

def self.prepended(base)
base.has_many :order_promotions, class_name: 'Spree::OrderPromotion', dependent: :destroy
base.has_many :promotions, through: :order_promotions
Expand All @@ -17,5 +23,6 @@ def shipping_discount
end

Spree::Order.prepend(self)
Spree::Order.singleton_class.prepend self::ClassMethods
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

namespace :solidus_legacy_promotions do
desc "Delete ineligible adjustments"
task delete_ineligible_adjustments: :environment do
Spree::Adjustment.where(eligible: false).delete_all
end
end
6 changes: 6 additions & 0 deletions legacy_promotions/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
it { is_expected.to respond_to(:order_promotions) }
it { is_expected.to respond_to(:promotions) }

describe ".ransackable_associations" do
subject { described_class.ransackable_associations }

it { is_expected.to include("promotions", "order_promotions") }
end

context "#apply_shipping_promotions" do
let(:order) { build(:order) }

Expand Down
44 changes: 39 additions & 5 deletions promotions/MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Migrating from Solidus' promotion system to SolidusPromotions
# Migrating from `solidus_legacy_promotions` to `solidus_promotions`

The system is designed to completely replace the Solidus promotion system. Follow these steps to migrate your store to the gem:
The system is designed to completely replace the legacy promotion system. This guide shows you how
to run both systems side-by-side, migrate your store's configuration to the `solidus_promotions`, and
finally remove the dependency on `solidus_legacy_promotions`.

Follow these steps to migrate your store to the gem:

## Install solidus_promotions

Expand All @@ -17,9 +21,9 @@ bundle install
bundle exec rails generate solidus_promotions:install
```

This will install the extension. It will add new tables, and new routes. It will also generate an initializer in `config/initializers/solidus_promotions.rb`.
This will install the extension. It will add new tables, and new routes. It will also change your initializer in `config/initializers/spree.rb`.

For the time being, comment out the following lines:
For the time being, leave the following lines commented out:

```rb
# Make sure we use Spree::SimpleOrderContents
Expand Down Expand Up @@ -88,7 +92,7 @@ Stores that have a custom coupon codes controller, such as Solidus' starter fron
If you have custom promotion rules or actions, you need to create new conditions and benefits, respectively.

> [!IMPORTANT]
> SolidusPromotions currently only supports actions that discount line items and shipments, as well as creating discounted line items. If you have actions that create order-level adjustments, we currently have no support for that.
> SolidusPromotions only supports actions that discount line items and shipments, as well as creating discounted line items. If you have actions that create order-level adjustments, we have no support for that.
In our experience, using the three actions can do almost all the things necessary, since they are customizable using calculators.

Expand Down Expand Up @@ -148,3 +152,33 @@ require 'my_promotion_map'

SolidusPromotions::PromotionMigrator.new(MY_PROMOTION_MAP).call
```

## Removing `solidus_legacy_promotions`

Once your store runs on `solidus_promotions`, you can now drop the dependency on `solidus_legacy_promotions`.
In order to do so, first make sure you have no ineligible promotion adjustments left in your database:

```rb
>> Spree::Adjustment.where(eligible: false)
=> 0
>>
```

If you still have ineligible adjustments in your database, run the following command:

```sh
bundle exec rails solidus_legacy_promotions:delete_ineligible_adjustments
```

Now you can safely remove `solidus_legacy_promotions` from your `Gemfile`. If your store depends on the whole `solidus` suite,
replace that dependency declaration in the `Gemfile` with the individual gems:

```diff
# Gemfile
- gem 'solidus', '~> 4,4'
+ gem 'solidus_core', '~> 4.4'
+ gem 'solidus_api', '~> 4.4'
+ gem 'solidus_backend', '~> 4.4'
+ gem 'solidus_admin', '~> 4.4'
+ gem 'solidus_promotions', '~> 4.4'
```
2 changes: 1 addition & 1 deletion tasks/releasing.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'bundler/gem_tasks'

SOLIDUS_GEM_NAMES = %w[core api backend sample]
SOLIDUS_GEM_NAMES = %w[core api backend sample promotions]

%w[build install].each do |task_name|
desc "Run rake #{task} for each Solidus gem"
Expand Down
5 changes: 3 additions & 2 deletions tasks/testing.rake
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ def subproject_task(project, task, title: project, task_name: nil)
end

%w[spec db:drop db:create db:migrate db:reset].each do |task|
%w(api backend core frontend sample).each do |project|
solidus_gem_names = %w[core api backend sample promotions]
solidus_gem_names.each do |project|
desc "Run specs for #{project}" if task == 'spec'
subproject_task(project, task)
end

desc "Run rake #{task} for each Solidus engine"
task task => %w(api backend core frontend sample).map { |p| "#{task}:#{p}" }
task task => solidus_gem_names.map { |p| "#{task}:#{p}" }
end

desc "Run backend JS specs"
Expand Down

0 comments on commit 5d14ec2

Please sign in to comment.