-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11418 from spree/feature/subscriber-validations
Add Webhooks::Subscriber check_uri_path validation
- Loading branch information
Showing
26 changed files
with
596 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
api/app/serializers/spree/api/v2/platform/asset_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Platform | ||
class AssetSerializer < BaseSerializer | ||
include ResourceSerializerConcern | ||
|
||
belongs_to :viewable, polymorphic: true | ||
end | ||
end | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
api/app/serializers/spree/api/v2/platform/property_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Platform | ||
class PropertySerializer < BaseSerializer | ||
include ResourceSerializerConcern | ||
end | ||
end | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
api/app/serializers/spree/api/v2/platform/prototype_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Platform | ||
class PrototypeSerializer < BaseSerializer | ||
include ResourceSerializerConcern | ||
|
||
has_many :properties | ||
has_many :option_types | ||
has_many :taxons | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
api/app/serializers/spree/api/v2/platform/reimbursement_credit_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Platform | ||
class ReimbursementCreditSerializer < BaseSerializer | ||
end | ||
end | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
api/app/serializers/spree/api/v2/platform/role_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Platform | ||
class RoleSerializer < BaseSerializer | ||
include ResourceSerializerConcern | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
api/app/serializers/spree/api/v2/platform/stock_transfer_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Platform | ||
class StockTransferSerializer < BaseSerializer | ||
include ResourceSerializerConcern | ||
|
||
belongs_to :destination_location, serializer: :stock_location | ||
belongs_to :source_location, serializer: :stock_location | ||
has_many :stock_movements | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
api/spec/serializers/spree/api/v2/platform/asset_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::Api::V2::Platform::AssetSerializer do | ||
include_context 'API v2 serializers params' | ||
|
||
subject { described_class.new(resource, params: serializer_params).serializable_hash } | ||
|
||
let(:viewable) { create(:variant) } | ||
let(:type) { :asset } | ||
let(:resource) { create(type, viewable: viewable) } | ||
|
||
it do | ||
expect(subject).to eq( | ||
data: { | ||
id: resource.id.to_s, | ||
attributes: { | ||
viewable_type: resource.viewable_type, | ||
attachment_height: resource.attachment_height, | ||
attachment_file_size: resource.attachment_file_size, | ||
position: resource.position, | ||
attachment_content_type: resource.attachment_content_type, | ||
attachment_file_name: resource.attachment_file_name, | ||
type: resource.type, | ||
attachment_updated_at: resource.attachment_updated_at, | ||
alt: resource.alt, | ||
created_at: resource.created_at, | ||
updated_at: resource.updated_at | ||
}, | ||
relationships: { | ||
viewable: { | ||
data: { | ||
id: viewable.id.to_s, | ||
type: :variant | ||
} | ||
} | ||
}, | ||
type: type | ||
} | ||
) | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
api/spec/serializers/spree/api/v2/platform/property_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::Api::V2::Platform::PropertySerializer do | ||
include_context 'API v2 serializers params' | ||
|
||
subject { described_class.new(resource, params: serializer_params).serializable_hash } | ||
|
||
let(:type) { :property } | ||
let(:resource) { create(type) } | ||
|
||
it do | ||
expect(subject).to eq( | ||
data: { | ||
id: resource.id.to_s, | ||
type: type, | ||
attributes: { | ||
name: resource.name, | ||
presentation: resource.presentation, | ||
created_at: resource.created_at, | ||
updated_at: resource.updated_at, | ||
filterable: resource.filterable, | ||
filter_param: resource.filter_param | ||
} | ||
} | ||
) | ||
end | ||
end |
47 changes: 47 additions & 0 deletions
47
api/spec/serializers/spree/api/v2/platform/prototype_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::Api::V2::Platform::PrototypeSerializer do | ||
include_context 'API v2 serializers params' | ||
|
||
subject { described_class.new(resource, params: serializer_params).serializable_hash } | ||
|
||
let(:property) { create(:property) } | ||
let(:option_type) { create(:option_type) } | ||
let(:resource) { create(type, properties: [property], option_types: [option_type], taxons: [taxon]) } | ||
let(:taxon) { create(:taxon) } | ||
let(:type) { :prototype } | ||
|
||
it do | ||
expect(subject).to eq( | ||
data: { | ||
id: resource.id.to_s, | ||
attributes: { | ||
name: resource.name, | ||
created_at: resource.created_at, | ||
updated_at: resource.updated_at | ||
}, | ||
relationships: { | ||
properties: { | ||
data: [{ | ||
id: property.id.to_s, | ||
type: :property | ||
}] | ||
}, | ||
option_types: { | ||
data: [{ | ||
id: option_type.id.to_s, | ||
type: :option_type | ||
}] | ||
}, | ||
taxons: { | ||
data: [{ | ||
id: taxon.id.to_s, | ||
type: :taxon | ||
}] | ||
} | ||
}, | ||
type: type | ||
} | ||
) | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
api/spec/serializers/spree/api/v2/platform/refund_reason_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::Api::V2::Platform::RefundReasonSerializer do | ||
include_context 'API v2 serializers params' | ||
|
||
subject { described_class.new(resource, params: serializer_params).serializable_hash } | ||
|
||
let(:type) { :refund_reason } | ||
let(:resource) { create(type) } | ||
|
||
it do | ||
expect(subject).to eq( | ||
data: { | ||
id: resource.id.to_s, | ||
attributes: { | ||
name: resource.name, | ||
active: resource.active, | ||
mutable: resource.mutable, | ||
created_at: resource.created_at, | ||
updated_at: resource.updated_at | ||
}, | ||
type: type | ||
} | ||
) | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
api/spec/serializers/spree/api/v2/platform/reimbursement_credit_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'spec_helper' | ||
|
||
describe Spree::Api::V2::Platform::ReimbursementCreditSerializer do | ||
include_context 'API v2 serializers params' | ||
|
||
subject { described_class.new(resource, params: serializer_params).serializable_hash } | ||
|
||
let(:type) { :reimbursement_credit } | ||
let(:resource) { create(type, creditable: create(:store_credit)) } | ||
|
||
it do | ||
expect(subject).to eq( | ||
data: { | ||
id: resource.id.to_s, | ||
type: type | ||
} | ||
) | ||
end | ||
end |
Oops, something went wrong.