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

Appland v2.10.2 #13

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
42415ff
Bump Solidus to 2.10.0
kennyadsl Jan 15, 2020
729c816
Fix in_taxons scope when taxon is an ActiveRecord::Base
kennyadsl May 11, 2020
d7dfcc5
Bump Solidus to 2.10.1
kennyadsl May 14, 2020
d3b9c93
Fix admin user factory
filippoliverani Feb 14, 2020
d6b9d84
Replace http method in api doc
SamuelMartini Feb 27, 2020
7a22106
Replace wrong key and add parameters in product taxons endpoint doc
SamuelMartini Feb 26, 2020
2b35370
Generate stoplight doc on version with multiple digits
kennyadsl May 21, 2020
2ef0737
Merge pull request #3631 from nebulab/kennyadsl/fix-doc-generation-mu…
aldesantis May 22, 2020
d7e8780
Frontend: Try to add a coupon code only when updating checkouts
kennyadsl Jul 8, 2020
6f0dbd8
Frontend: Update checkout controller specs params
kennyadsl Jul 8, 2020
8d24125
API: normalize payment source parameters
kennyadsl Jul 8, 2020
0332b80
API: Add specs for shipments recalculation on order updates
kennyadsl Jul 8, 2020
3f14233
API: improve checkout specs with the correct state
kennyadsl Jul 8, 2020
576c88c
Add split strong parameters for checkouts
kennyadsl Jul 8, 2020
cde87a3
Frontend: Only permit attributes for the current checkout step
kennyadsl Jul 8, 2020
8eceb9c
API: Only permit attributes for the current checkout step
kennyadsl Jul 8, 2020
aabc9cb
Refresh taxons associations in taxon promo rule specs
kennyadsl Jul 9, 2020
79202e4
Merge pull request #3694 from nebulab/v2.10-fix-taxons-specs
kennyadsl Jul 10, 2020
77793cc
Merge pull request from GHSA-3mvg-rrrw-m7ph
kennyadsl Jul 16, 2020
b3578b0
Permit passing an address via payment source parameters
kennyadsl Jul 16, 2020
d0c6b12
Merge pull request #3712 from nebulab/v2.10-permit_address-source
kennyadsl Jul 16, 2020
4f986d6
Bump Solidus to 2.10.2
kennyadsl Jul 16, 2020
84a2755
travis
jaredKreppein Sep 3, 2020
2c140a8
travis
jaredKreppein Sep 3, 2020
7d45b06
sym links
jaredKreppein Sep 3, 2020
8e8de8c
fixed appmap paths
jaredKreppein Sep 3, 2020
3cd1b5d
add chromedriver to travis
jaredKreppein Sep 3, 2020
860f80b
modified travis for chromedriver
jaredKreppein Sep 3, 2020
9cb5811
travis
jaredKreppein Sep 3, 2020
54dc75e
selenium for travis
jaredKreppein Sep 4, 2020
9c1ba64
travis
jaredKreppein Sep 4, 2020
489574f
add 'bundle install' to travis
jaredKreppein Sep 4, 2020
6b7ee94
only test 'backend'
jaredKreppein Sep 4, 2020
002355e
add timeout for test
jaredKreppein Sep 4, 2020
ecf14be
add timeout for test
jaredKreppein Sep 4, 2020
06592e7
add timeout for test
jaredKreppein Sep 4, 2020
4561904
add timeout for test
jaredKreppein Sep 4, 2020
9f67252
travis
jaredKreppein Sep 4, 2020
ba493a8
travis
jaredKreppein Sep 4, 2020
ff84809
travis
jaredKreppein Sep 4, 2020
86a63fc
travis
jaredKreppein Sep 4, 2020
654336b
travis
jaredKreppein Sep 4, 2020
d629751
travis
jaredKreppein Sep 4, 2020
6845174
new travis config
jaredKreppein Sep 14, 2020
b5bff5e
updated travis.yml and add 'appmap/railtie'
jaredKreppein Sep 18, 2020
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ workflows:
- persist_version:
filters:
branches:
only: /master|v\d\.\d/
only: /master|v\d\.\d+/
- postgres
- mysql
- postgres_rails52
Expand Down
50 changes: 50 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Turn on validation, so we can use import:
version: ~> 1.0

import:
- land-of-apps/land-of-apps:travis/ruby-imports.yml

addons:
apt:
packages:
- parallel

# script: |
# run_tests() (
# cd $1
# # Use -f doc so we get regular output and keep Travis happy
# APPMAP=true bundle exec rspec -f doc || true
# )
# export -f run_tests
# echo 'api backend core frontend' | parallel -j3 --will-cite --line-buffer -d ' ' run_tests

env:
global:
- EXTRA_APPMAPS="*/tmp/appmap/rspec"

jobs:
include:
- stage: test
workspaces:
create:
name: appmaps
paths:
- "$EXTRA_APPMAPS"
script: |
run_tests() (
cd $1
# Use -f doc so we get regular output and keep Travis happy
APPMAP=true bundle exec rspec -f doc || true
)
export -f run_tests
echo 'api backend core frontend' | parallel --will-cite --line-buffer -d ' ' run_tests
after_script:
- true
- stage: upload
workspaces:
use:
- appmaps
install:
- true
script:
- true
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source 'https://rubygems.org'
group :backend, :frontend, :core, :api do
gemspec require: false

gem 'appmap', github: 'applandinc/appmap-ruby', branch: 'master'

rails_version = ENV['RAILS_VERSION'] || '~> 6.0.0'
gem 'rails', rails_version, require: false

Expand Down
21 changes: 17 additions & 4 deletions api/app/controllers/spree/api/checkouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,24 @@ def user_id
end

def update_params
if update_params = massaged_params[:order]
update_params.permit(permitted_checkout_attributes)
state = @order.state
case state.to_sym
when :cart, :address
massaged_params.fetch(:order, {}).permit(
permitted_checkout_address_attributes
)
when :delivery
massaged_params.require(:order).permit(
permitted_checkout_delivery_attributes
)
when :payment
massaged_params.require(:order).permit(
permitted_checkout_payment_attributes
)
else
# We current allow update requests without any parameters in them.
{}
massaged_params.fetch(:order, {}).permit(
permitted_checkout_confirm_attributes
)
end
end

Expand Down
8 changes: 7 additions & 1 deletion api/app/controllers/spree/api/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ def order_params
end

def normalize_params
params[:order][:payments_attributes] = params[:order].delete(:payments) if params[:order][:payments]
if params[:order][:payments]
payments_params = params[:order].delete(:payments)
params[:order][:payments_attributes] = payments_params.map do |payment_params|
payment_params[:source_attributes] = payment_params.delete(:source) if payment_params[:source].present?
payment_params
end
end
params[:order][:shipments_attributes] = params[:order].delete(:shipments) if params[:order][:shipments]
params[:order][:line_items_attributes] = params[:order].delete(:line_items) if params[:order][:line_items]
params[:order][:ship_address_attributes] = params[:order].delete(:ship_address) if params[:order][:ship_address].present?
Expand Down
1 change: 1 addition & 0 deletions api/appmap.yml
9 changes: 6 additions & 3 deletions api/openapi/api.oas2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ paths:
- Variants
security:
- api-key: []
post:
put:
responses:
'200':
description: ''
Expand Down Expand Up @@ -4264,7 +4264,7 @@ paths:
type: string
required: true
'/shipments/{shipment_number}/select_shipping_method':
get:
put:
responses:
'200':
description: ''
Expand Down Expand Up @@ -4553,10 +4553,13 @@ paths:
- Products
parameters:
- in: query
name: taxon_id
name: id
type: integer
- $ref: '#/parameters/page'
- $ref: '#/parameters/per_page'
- type: boolean
in: query
name: simple
security:
- api-key: []
schemes:
Expand Down
38 changes: 33 additions & 5 deletions api/spec/requests/spree/api/checkouts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ module Spree
end

describe 'setting the payment amount' do
let(:order) { create(:order_with_line_items, state: :payment) }
let(:params) do
{
order_token: order.guest_token,
Expand Down Expand Up @@ -322,17 +323,44 @@ module Spree
end
end

it "cannot update attributes of another step" do
order.update_column(:state, "payment")

params = {
order_token: order.guest_token,
order: {
payments_attributes: [
{
payment_method_id: @payment_method.id.to_s,
source_attributes: attributes_for(:credit_card)
}
],
ship_address_attributes: {
zipcode: 'MALICIOUS ZIPCODE'
}
}
}
expect do
put spree.api_checkout_path(order), params: params
end.not_to change { order.reload.ship_address.zipcode }
expect(response.status).to eq(200)
end

it "returns the order if the order is already complete" do
order.update_columns(completed_at: Time.current, state: 'complete')
put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token }
assert_unauthorized!
end

# Regression test for https://github.com/spree/spree/issues/3784
it "can update the special instructions for an order" do
instructions = "Don't drop it. (Please)"
put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token, order: { special_instructions: instructions } }
expect(json_response['special_instructions']).to eql(instructions)
context "in delivery state" do
let(:order) { create(:order_with_line_items, state: :delivery) }

# Regression test for https://github.com/spree/spree/issues/3784
it "can update the special instructions for an order" do
instructions = "Don't drop it. (Please)"
put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token, order: { special_instructions: instructions } }
expect(json_response['special_instructions']).to eql(instructions)
end
end

context "as an admin" do
Expand Down
23 changes: 23 additions & 0 deletions api/spec/requests/spree/api/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ module Spree
end

context 'creating payment' do
let!(:order) { create(:order_with_line_items) }
let(:order_params) { super().merge(payments_attributes: [{ payment_method_id: payment_method.id }]) }

context "with allowed payment method" do
Expand All @@ -166,6 +167,28 @@ module Spree
subject
}.to change { Spree::Payment.count }.by(1)
end

context 'trying to change the address' do
let(:order_params) do
super().merge(
ship_address_attributes: {
zipcode: '90100'
}
)
end

it 'changes the address' do
expect {
subject
}.to change { order.reload.ship_address.zipcode }
end

it 'invalidates the shipments' do
expect {
subject
}.to change { order.reload.shipments }.to([])
end
end
end

context "with disallowed payment method" do
Expand Down
2 changes: 2 additions & 0 deletions api/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'appmap/rspec'

if ENV["COVERAGE"]
require 'simplecov'
SimpleCov.start('rails')
Expand Down
12 changes: 12 additions & 0 deletions appmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: solidus

packages:
- path: app/controllers
- path: app/helpers
- path: app/jobs
- path: app/mailers
- path: app/models
- path: app/subscribers
- path: config
- path: db
- path: lib
1 change: 1 addition & 0 deletions backend/appmap.yml
2 changes: 2 additions & 0 deletions backend/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'appmap/rspec'

if ENV["COVERAGE"]
require 'simplecov'
SimpleCov.start('rails')
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/product/scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_taxons(*ids_or_records_or_names)
ids_or_records_or_names.flatten.map { |taxon|
case taxon
when Integer then Spree::Taxon.find_by(id: taxon)
when ActiveRecord::Base then t
when ActiveRecord::Base then taxon
when String
Spree::Taxon.find_by(name: taxon) ||
Spree::Taxon.where("#{taxons}.permalink LIKE ? OR #{taxons}.permalink = ?", "%/#{taxon}/", "#{taxon}/").first
Expand Down
1 change: 1 addition & 0 deletions core/appmap.yml
28 changes: 21 additions & 7 deletions core/lib/spree/core/controller_helpers/strong_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,30 @@ def permitted_source_attributes
end

def permitted_checkout_attributes
permitted_attributes.checkout_attributes + [
bill_address_attributes: permitted_address_attributes,
ship_address_attributes: permitted_address_attributes,
payments_attributes: permitted_payment_attributes,
shipments_attributes: permitted_shipment_attributes
]
permitted_attributes.checkout_attributes
end

def permitted_checkout_address_attributes
permitted_attributes.checkout_address_attributes
end

def permitted_checkout_delivery_attributes
permitted_attributes.checkout_delivery_attributes
end

def permitted_checkout_payment_attributes
permitted_attributes.checkout_payment_attributes
end

def permitted_checkout_confirm_attributes
permitted_attributes.checkout_confirm_attributes
end

def permitted_order_attributes
permitted_checkout_attributes + [
permitted_checkout_address_attributes +
permitted_checkout_delivery_attributes +
permitted_checkout_payment_attributes +
permitted_checkout_confirm_attributes + [
line_items_attributes: permitted_line_item_attributes
]
end
Expand Down
3 changes: 2 additions & 1 deletion core/lib/spree/core/importer/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def self.create_payments_from_params(payments_hash, order)
# spree_wombat serializes payment state as status so imported orders should fall back to status field.
payment.state = target[:state] || target[:status] || 'completed'
payment.payment_method = Spree::PaymentMethod.find_by!(name: target[:payment_method])
payment.source = create_source_payment_from_params(target[:source], payment) if target[:source]
source_attributes = target[:source] || target[:source_attributes]
payment.source = create_source_payment_from_params(source_attributes, payment) if source_attributes
payment.save!
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/core/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Spree
VERSION = "2.10.0.beta1"
VERSION = "2.10.2"

def self.solidus_version
VERSION
Expand Down
Loading