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

Fixing new promotion system readme with migration notice and fixing some typos and wording #6105

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
b8639fe
Post-creation chores after new v4.4 patch branch
tvdeyen Nov 12, 2024
4b5beac
Merge pull request #5913 from solidusio/github-actions/11795945831-1-…
tvdeyen Nov 12, 2024
9e4e06e
Move Line Item Actions to solidus_legacy_promotions
mamhoff Nov 13, 2024
5d8025b
Remove rails binstub from built gems
tvdeyen Nov 14, 2024
7202221
Merge pull request #5919 from solidusio/backport/v4.4/pr-5916
tvdeyen Nov 14, 2024
84d36bf
Merge pull request #5922 from solidusio/backport/v4.4/pr-5917
tvdeyen Nov 14, 2024
b51e497
Backend Menu: Fix "Promotions" items
tvdeyen Nov 14, 2024
9e721bd
Fix file location of spree/line_item_action.rb
mamhoff Nov 14, 2024
9fc4941
Merge pull request #5924 from solidusio/backport/v4.4/pr-5921
tvdeyen Nov 14, 2024
287b995
Merge pull request #5925 from solidusio/backport/v4.4/pr-5923
tvdeyen Nov 14, 2024
6579041
Fix component translation scopes
mamhoff Nov 15, 2024
5ce0c99
Merge pull request #5930 from solidusio/backport/v4.4/pr-5927
tvdeyen Nov 15, 2024
0f5d280
Use new global variables stylesheet in legacy promotions
mamhoff Nov 15, 2024
d5df47c
Feat(Admin): Dynamic routing proxies
mamhoff Nov 15, 2024
b9abfce
Merge pull request #5935 from solidusio/backport/v4.4/pr-5932
tvdeyen Nov 18, 2024
f612c1f
Merge pull request #5937 from solidusio/backport/v4.4/pr-5933
tvdeyen Nov 18, 2024
f1f90fd
Fix(Admin menus): Stable promotion menu items
mamhoff Nov 15, 2024
c68a679
Feat(SolidusPromotions): Allow viewing both promotion systems
mamhoff Nov 15, 2024
ce6256e
Merge pull request #5938 from solidusio/backport/v4.4/pr-5934
tvdeyen Nov 18, 2024
7849f23
Prepare release for Solidus v4.4.1
tvdeyen Nov 18, 2024
cb44676
Merge pull request #5939 from solidusio/github-actions/11891552738-1-…
tvdeyen Nov 18, 2024
11d5d60
Post-release chores after having released Solidus v4.4.1
tvdeyen Nov 18, 2024
d78a0cd
Fix release task
tvdeyen Nov 12, 2024
8a171b3
Merge pull request #5940 from solidusio/github-actions/11891611808-1-…
tvdeyen Nov 18, 2024
79fc8e1
Include solidus_legacy_promotions in release task
mamhoff Nov 19, 2024
c1f668e
Merge pull request #5942 from solidusio/backport/v4.4/pr-5941
tvdeyen Nov 19, 2024
26a7442
Fix spacing at top of OrderShipping#ship method
adammathys Nov 27, 2024
b2eff15
Merge pull request #5974 from solidusio/backport/v4.4/pr-5954
tvdeyen Dec 2, 2024
f9d7587
Backend: Add missing error translation
mamhoff Dec 2, 2024
1fc456f
Merge pull request #5986 from solidusio/backport/v4.4/pr-5979
tvdeyen Dec 3, 2024
349eb76
Test app task: Allow passing in user class
mamhoff Dec 1, 2024
0519828
Merge pull request #5961 from solidusio/backport/v4.4/pr-5956
tvdeyen Dec 3, 2024
29692af
test: Wait for modal to open before testing its content
tvdeyen Dec 3, 2024
c1b5ad2
test: Do not wait 30 seconds for a test to fail
tvdeyen Dec 3, 2024
8ce84be
Merge pull request #5994 from solidusio/backport/v4.4/pr-5993
tvdeyen Dec 3, 2024
80a8319
Add show all results to en.yml
fthobe Dec 3, 2024
ea8ea89
Merge pull request #5996 from solidusio/backport/v4.4/pr-5988
tvdeyen Dec 4, 2024
ecd8124
Do not constantize Spree.user_class in UserClassHandle
mamhoff Dec 4, 2024
8fea128
Wait for modal before testing its content
MadelineCollier Dec 4, 2024
b5f5e0a
Merge pull request #6005 from solidusio/backport/v4.4/pr-5998
MadelineCollier Dec 4, 2024
6f3802d
Use Order#email to show the order's email in new admin
softr8 Jan 15, 2024
6651914
Merge pull request #6006 from solidusio/backport/v4.4/pr-5596
tvdeyen Dec 4, 2024
da7a72d
Merge pull request #6004 from solidusio/backport/v4.4/pr-5999
tvdeyen Dec 4, 2024
a4677fa
tests: Give dialogs a little more time to open
tvdeyen Dec 5, 2024
bfdf4bb
Merge pull request #6012 from solidusio/backport/v4.4/pr-6010
tvdeyen Dec 5, 2024
6c75834
tests: Give even more dialogs more time to open in tests
tvdeyen Dec 6, 2024
aab2646
Only set promo configuration to legacy if no other set
mamhoff Nov 15, 2024
a1038fd
Add inverse_of to Promotion#codes association
adammathys Nov 27, 2024
be96063
Fix model class for new PromotionCodesController
adammathys Nov 27, 2024
f9accde
Legacy Promotions: Remove unneeded decorator
mamhoff Nov 30, 2024
aa071f9
Fix(promotions): Validate benefits on save
mamhoff Dec 3, 2024
3683320
Add status code to benefits controller action
mamhoff Dec 3, 2024
063f673
Add pending integration spec for orders adjustments page
mamhoff Dec 5, 2024
4dc0b43
Feat(promotions): Add PromotionHandler::Coupon#can_apply?
mamhoff Dec 5, 2024
06687c6
Feat(Promotions): Implement SolidusPromotions#order_activatable?
mamhoff Dec 5, 2024
38c4e1a
Feat(Promotions): Use order_activatable in OrderAdjuster
mamhoff Dec 5, 2024
6181ee3
Merge pull request #6018 from solidusio/backport/v4.4/pr-6017
tvdeyen Dec 6, 2024
d68f0b4
Merge pull request #6019 from solidusio/backport/v4.4/pr-5928
tvdeyen Dec 6, 2024
b8b0b91
Add `#authorization_subject` to Promotions controllers
mamhoff Nov 19, 2024
7eb5178
Fix admin promotions controller
mamhoff Nov 19, 2024
0f48e0a
Merge pull request #6022 from solidusio/backport/v4.4/pr-5955
tvdeyen Dec 6, 2024
816bc66
Merge pull request #6021 from solidusio/backport/v4.4/pr-5953
tvdeyen Dec 6, 2024
2f82f59
Merge pull request #6023 from solidusio/backport/v4.4/pr-5981
tvdeyen Dec 6, 2024
099fc05
Merge pull request #6024 from solidusio/backport/v4.4/pr-6013
tvdeyen Dec 6, 2024
341cb1f
Merge pull request #6020 from solidusio/backport/v4.4/pr-5943
tvdeyen Dec 6, 2024
a02c478
Prepare release for Solidus v4.4.2
kennyadsl Dec 9, 2024
461a671
Merge pull request #6028 from solidusio/github-actions/12236877460-1-…
kennyadsl Dec 9, 2024
8380086
Post-release chores after having released Solidus v4.4.2
kennyadsl Dec 9, 2024
e331fa0
Merge pull request #6029 from solidusio/github-actions/12237663542-1-…
tvdeyen Dec 11, 2024
30dcf9e
[SolidusAdmin] Fix mock_component helper
mamhoff Jan 3, 2025
d9da7dd
CI: Lint code on GH actions
tvdeyen Jan 9, 2025
9e59442
Merge pull request #6069 from solidusio/backport/v4.4/pr-6064
tvdeyen Jan 15, 2025
f2a27ae
Fix preferences serialization compatibility with Rails version check
swamp09 Jan 20, 2025
329d598
Merge pull request #6086 from solidusio/backport/v4.4/pr-6083
tvdeyen Jan 22, 2025
12a721a
Updated readme.md of promotion calculation with link to migration guide
fthobe Feb 7, 2025
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
22 changes: 0 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,6 @@ commands:
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'

jobs:
lint_code:
docker:
- image: cimg/ruby:3.2-node
environment:
BUNDLE_ONLY: "lint"
ESLINT_USE_FLAT_CONFIG: false
steps:
- checkout
- run: "bundle install"
- run:
name: Check Ruby
command: "bin/rake lint:rb"
- run:
name: Check ERB
command: "bin/rake lint:erb"
- run:
name: Check JavaScript
command: "bin/rake lint:js"
- store_test_results:
path: test-results

solidus_installer:
executor:
name: sqlite
Expand Down Expand Up @@ -362,7 +341,6 @@ jobs:
workflows:
build:
jobs:
- lint_code
- solidus_installer
- test_solidus_with_coverage # Only test with coverage support with the default versions

Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Lint

on: [pull_request]

concurrency:
group: lint-${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

permissions:
contents: read

env:
BUNDLE_ONLY: "lint"

jobs:
ruby:
name: Check Ruby
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Lint Ruby files
run: bin/rake lint:rb
- name: Store test results
uses: actions/upload-artifact@v4
with:
name: rubocop-results
path: test-results

erb:
name: Check ERB
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Lint ERB files
run: bin/rake lint:erb

javascript:
name: Check JavaScript
runs-on: ubuntu-22.04
env:
ESLINT_USE_FLAT_CONFIG: false
steps:
- uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Lint JS files
run: bin/rake lint:js
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
## Solidus v4.4.2 (2024-12-09)

<!-- Please, don't edit manually. The content is automatically generated. -->

## Solidus Core

* [v4.4] [FIX] Remove spacing at top of OrderShipping#ship method by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5974
* [v4.4] Backend: Add missing error translation by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5986
* [v4.4] Test app task: Allow passing in user class by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5961
* [v4.4] Add show all results to en.yml by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5996
* [v4.4] Do not constantize Spree.user_class in UserClassHandle by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6004

## Solidus Admin

* [v4.4] test: Wait for modal to open before testing its content by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5994
* [v4.4] [specs] Wait for modal before testing its content by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6005
* [v4.4] Use Order#email to show the order&#x27;s email in new admin by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6006
* [v4.4] tests: Give even more dialogs more time to open in tests by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6018

## Solidus Backend

* [v4.4] Backend: Add missing error translation by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5986

## Solidus Promotions

* [v4.4] test: Wait for modal to open before testing its content by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5994
* [v4.4] [FIX] A few small tweaks for the new promotion admin by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6021
* [v4.4] Fix(promotions): Validate benefits on save by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6023
* [v4.4] Add can apply to promotions by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6024
* [v4.4] Fix admin promotions controller by @github-actions[bot] in https://github.com/solidusio/solidus/pull/6020

**Full Changelog**: https://github.com/solidusio/solidus/compare/v4.4.1...v4.4.2


## Solidus v4.4.1 (2024-11-18)

<!-- Please, don't edit manually. The content is automatically generated. -->

## Solidus Core

* [v4.4] Move Line Item Actions to solidus_legacy_promotions by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5919
* [v4.4] Remove rails binstubs from built gems by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5922

## Solidus Admin

* [v4.4] Remove rails binstubs from built gems by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5922
* [v4.4] Fix component translation scopes by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5930
* [v4.4] Feat(Admin): Dynamic routing proxies by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5937

## Solidus Backend

* [v4.4] Remove rails binstubs from built gems by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5922

## Solidus API

* [v4.4] Remove rails binstubs from built gems by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5922

## Solidus Promotions

* [v4.4] Fix component translation scopes by @github-actions[bot] in https://github.com/solidusio/solidus/pull/5930
* [v4.4] Better promotion menus by @tvdeyen in https://github.com/solidusio/solidus/pull/5938

**Full Changelog**: https://github.com/solidusio/solidus/compare/v4.4.0...v4.4.1


## Solidus v4.4.0 (2024-11-12)

<!-- Please, don't edit manually. The content is automatically generated. -->
Expand Down
22 changes: 18 additions & 4 deletions admin/app/components/solidus_admin/base_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def missing_translation(key, options)
end
end

def self.i18n_scope
@i18n_scope ||= name.underscore.tr("/", ".")
end

def self.stimulus_id
@stimulus_id ||= name.underscore
.sub(/^solidus_admin\/(.*)\/component$/, '\1')
Expand All @@ -34,12 +38,22 @@ def self.stimulus_id

delegate :stimulus_id, to: :class

def spree
@spree ||= Spree::Core::Engine.routes.url_helpers
class << self
private

def engines_with_routes
Rails::Engine.subclasses.map(&:instance).reject do |engine|
engine.routes.empty?
end
end
end

def solidus_admin
@solidus_admin ||= SolidusAdmin::Engine.routes.url_helpers
# For each engine with routes, define a method that returns the routes proxy.
# This allows us to use the routes in the context of a component class.
engines_with_routes.each do |engine|
define_method(engine.engine_name) do
engine.routes.url_helpers
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<li class="group <%= "active" if active? %>">
<a
href="<%= path %>"
aria-current="<%= @item.current?(@url_helpers, @fullpath) ? "page" : "false" %>"
aria-current="<%= @item.current?(self, @fullpath) ? "page" : "false" %>"
class="
flex gap-3 items-center
py-1 px-3 rounded
Expand All @@ -20,7 +20,7 @@

<% if @item.children? %>
<ul class="flex flex-col gap-0.5 pt-0.5 <%= "hidden" unless active? %>">
<%= render self.class.with_collection(@item.children, url_helpers: @url_helpers, fullpath: @fullpath) %>
<%= render self.class.with_collection(@item.children, fullpath: @fullpath) %>
</ul>
<% end %>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ class SolidusAdmin::Layout::Navigation::Item::Component < SolidusAdmin::BaseComp

# @param item [SolidusAdmin::MenuItem]
# @param fullpath [String] the current path
# @param url_helpers [#solidus_admin, #spree] context for generating paths
def initialize(
item:,
fullpath: "#",
url_helpers: Struct.new(:spree, :solidus_admin).new(spree, solidus_admin)
fullpath: "#"
)
@item = item
@url_helpers = url_helpers
@fullpath = fullpath
end

def path
@item.path(@url_helpers)
@item.path(self)
end

def active?
@item.active?(@url_helpers, @fullpath)
@item.active?(self, @fullpath)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def customer_column
col: { class: "w-[400px]" },
header: :customer,
data: ->(order) do
customer_email = order.user&.email
customer_email = order.email
content_tag :div, String(customer_email)
end
}
Expand Down
12 changes: 3 additions & 9 deletions admin/lib/solidus_admin/testing_support/component_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ module ComponentHelpers
# "Rendered"
# end
# end
def mock_component(&definition)
location = caller(1, 1).first
component_class = Class.new(SolidusAdmin::BaseComponent)
# ViewComponent will complain if we don't fake a class name:
# @see https://github.com/ViewComponent/view_component/blob/5decd07842c48cbad82527daefa3fe9c65a4226a/lib/view_component/base.rb#L371
component_class.define_singleton_method(:name) { "Foo" }
component_class.define_singleton_method(:to_s) { "#{name} (#{location})" }
component_class.class_eval(&definition) if definition
component_class
def mock_component(class_name = "Foo::Component", &definition)
component_class = stub_const(class_name, Class.new(described_class, &definition))
component_class.new
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion admin/solidus_admin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.metadata["changelog_uri"] = "https://github.com/solidusio/solidus/releases?q=%22solidus_admin%2Fv0%22&expanded=true"

s.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(spec|script)/})
f.match(%r{^(spec|bin)/})
end + ["app/assets/builds/solidus_admin/tailwind.css"]

s.required_ruby_version = '>= 3.1.0'
Expand Down
7 changes: 3 additions & 4 deletions admin/spec/components/solidus_admin/base_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def call
icon_tag("user-line")
end
end.new
end

render_inline(component)

Expand Down Expand Up @@ -42,7 +42,7 @@ def call

describe ".stimulus_id" do
it "returns the stimulus id for the component" do
stub_const("SolidusAdmin::Foo::Bar::Component", Class.new(described_class))
mock_component("SolidusAdmin::Foo::Bar::Component") { erb_template "" }

expect(SolidusAdmin::Foo::Bar::Component.stimulus_id).to eq("foo--bar")
expect(SolidusAdmin::Foo::Bar::Component.new.stimulus_id).to eq("foo--bar")
Expand All @@ -55,8 +55,7 @@ def call

allow(Rails.logger).to receive(:debug) { debug_logs << _1 }

component_class = stub_const("Foo::Component", Class.new(described_class){ erb_template "" })
component = component_class.new
component = mock_component { erb_template "" }
render_inline(component)
translation = component.translate("foo.bar.baz")

Expand Down
12 changes: 6 additions & 6 deletions admin/spec/features/adjustment_reasons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
before do
visit "/admin/adjustment_reasons#{query}"
click_on "Add new"
expect(page).to have_selector("dialog", wait: 5)
expect(page).to have_content("New Adjustment Reason")
expect(page).to be_axe_clean
end

it "opens a modal" do
expect(page).to have_selector("dialog")
it "closing the modal keeps query params" do
within("dialog") { click_on "Cancel" }
expect(page).not_to have_selector("dialog")
expect(page).not_to have_selector("dialog", wait: 5)
expect(page.current_url).to include(query)
end

Expand Down Expand Up @@ -69,14 +69,14 @@
Spree::AdjustmentReason.create(name: "Good Reason", code: 5999)
visit "/admin/adjustment_reasons#{query}"
find_row("Good Reason").click
expect(page).to have_selector("dialog", wait: 5)
expect(page).to have_content("Edit Adjustment Reason")
expect(page).to be_axe_clean
end

it "opens a modal" do
expect(page).to have_selector("dialog")
it "closing the modal keeps query params" do
within("dialog") { click_on "Cancel" }
expect(page).not_to have_selector("dialog")
expect(page).not_to have_selector("dialog", wait: 5)
expect(page.current_url).to include(query)
end

Expand Down
1 change: 1 addition & 0 deletions admin/spec/features/orders/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
visit "/admin/orders"
click_on "In Progress"

expect(page).to have_content("admin@example.com")
expect(page).to have_content("R123456789")
expect(page).to have_content("$19.99")
expect(page).to be_axe_clean
Expand Down
10 changes: 5 additions & 5 deletions admin/spec/features/orders/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
expect(page).to have_content("Order R123456789")
open_customer_menu
click_on "Edit billing address"
expect(page).to have_css("dialog", wait: 30)
expect(page).to have_css("dialog", wait: 5)

within("dialog") do
fill_in "Name", with: "John Doe"
Expand All @@ -74,7 +74,7 @@

open_customer_menu
click_on "Edit shipping address"
expect(page).to have_css("dialog", wait: 30)
expect(page).to have_css("dialog", wait: 5)

within("dialog") do
fill_in "Name", with: "Jane Doe"
Expand Down Expand Up @@ -119,18 +119,18 @@
expect(Spree::Order.last.line_items.count).to eq(0)

find("[aria-selected]", text: "Just another product").click
expect(page).to have_content("Variant added to cart successfully", wait: 30)
expect(page).to have_content("Variant added to cart successfully", wait: 5)

expect(Spree::Order.last.line_items.count).to eq(1)
expect(Spree::Order.last.line_items.last.quantity).to eq(1)

fill_in "line_item[quantity]", with: 4
expect(page).to have_content("Quantity updated successfully", wait: 30)
expect(page).to have_content("Quantity updated successfully", wait: 5)

expect(Spree::Order.last.line_items.last.quantity).to eq(4)

accept_confirm("Are you sure?") { click_on "Delete" }
expect(page).to have_content("Line item removed successfully", wait: 30)
expect(page).to have_content("Line item removed successfully", wait: 5)

expect(Spree::Order.last.line_items.count).to eq(0)
expect(page).to be_axe_clean
Expand Down
Loading