-
-
Notifications
You must be signed in to change notification settings - Fork 724
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 #12960 from mkllnk/dfc-link-backorder
Store link to open backorder
- Loading branch information
Showing
21 changed files
with
290 additions
and
105 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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
db/migrate/20241030023153_add_subject_to_semantic_links.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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
# rails g migration AddSubjectToSemanticLinks subject:references{polymorphic} | ||
# | ||
# We want to add links to Exchanges as well as Variants. | ||
# The word subject comes from the triple structure of the Semantic Web: | ||
# | ||
# Subject predicate object (variant has linke URL) | ||
class AddSubjectToSemanticLinks < ActiveRecord::Migration[7.0] | ||
def change | ||
# We allow `null` until we filled the new columns with existing data. | ||
add_reference :semantic_links, :subject, polymorphic: true, null: true | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20241030025540_copy_subject_on_semantic_links.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 @@ | ||
# frozen_string_literal: true | ||
|
||
class CopySubjectOnSemanticLinks < ActiveRecord::Migration[7.0] | ||
def up | ||
execute <<~SQL.squish | ||
UPDATE semantic_links SET | ||
subject_id = variant_id, | ||
subject_type = 'Spree::Variant' | ||
SQL | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class ChangeNullOnSemanticLinks < ActiveRecord::Migration[7.0] | ||
def change | ||
change_column_null :semantic_links, :subject_id, false | ||
change_column_null :semantic_links, :subject_type, false | ||
|
||
change_column_null :semantic_links, :variant_id, true | ||
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
215 changes: 125 additions & 90 deletions
215
spec/fixtures/vcr_cassettes/FdcBackorderer/creates_finds_and_updates_orders.yml
Large diffs are not rendered by default.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
spec/migrations/20241030025540_copy_subject_on_semantic_links_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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require_relative '../../db/migrate/20241030025540_copy_subject_on_semantic_links' | ||
|
||
RSpec.describe CopySubjectOnSemanticLinks do | ||
describe "#up" do | ||
let(:original_variant) { create(:variant) } | ||
let(:dummy_variant) { create(:variant) } | ||
|
||
it "copies the original data" do | ||
link = SemanticLink.create!( | ||
subject: dummy_variant, # This would be NULL when migration runs. | ||
semantic_id: "some-url", | ||
) | ||
SemanticLink.update_all("variant_id = #{original_variant.id}") | ||
|
||
expect { subject.up }.to change { | ||
link.reload.subject | ||
}.from(dummy_variant).to(original_variant) | ||
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
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 |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
let(:user) { build(:user, email: "[email protected]") } | ||
let(:order) { build(:order, user:) } | ||
|
||
it { is_expected.to have_one :exchange } | ||
it { is_expected.to have_many :semantic_links } | ||
|
||
describe "#errors" do | ||
it "provides friendly error messages" do | ||
order.ship_address = Spree::Address.new | ||
|
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