Merge branch 'master' into buu/add-product-images-11065

This commit is contained in:
Rachel Arnould
2024-01-25 16:32:45 +01:00
committed by GitHub
23 changed files with 62 additions and 46 deletions

View File

@@ -0,0 +1,39 @@
# frozen_string_literal: true
class RenameOffendingMigrations < ActiveRecord::Migration[7.0]
MIGRATION_IDS = {
'20231002000136871': "20231002000136",
'20231002000136872': "20231002000137",
'20231002000136876': "20231002000138",
'20231002000136877': "20231002000139",
'20231002000136879': "20231002000140",
'20231002000136926': "20231002000141",
'20231002000136952': "20231002000142",
'20231002000136955': "20231002000143",
'20231002000136959': "20231002000144",
'20231002000136976': "20231002000145",
'20231002000137115': "20231002000146",
'20231002000137116': "20231002000147",
'20231003000823494': "20231003000823",
}.freeze
def up
MIGRATION_IDS.each do |bad_id, good_id|
execute <<~SQL.squish
UPDATE schema_migrations
SET version='#{good_id}'
WHERE version='#{bad_id}'
SQL
end
end
def down
MIGRATION_IDS.each do |bad_id, good_id|
execute <<~SQL.squish
UPDATE schema_migrations
SET version='#{bad_id}'
WHERE version='#{good_id}'
SQL
end
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 20231003000823494) do
ActiveRecord::Schema[7.0].define(version: 2024_01_15_022359) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"

View File

@@ -36,7 +36,7 @@
"stimulus": "^3.2.2",
"stimulus-flatpickr": "^1.4.0",
"stimulus_reflex": "3.5.0-rc3",
"tom-select": "^2.2.3",
"tom-select": "^2.3.1",
"trix": "^2.0.8",
"webpack": "~4"
},

View File

@@ -60,11 +60,6 @@ RSpec.describe "Database" do
puts migrations.join("\n")
puts "\nTo disable this warning, add the class name(s) of the model(s) to models_todo " \
"in #{__FILE__}"
return if ENV.fetch("OFN_WRITE_FOREIGN_KEY_MIGRATIONS", false)
puts "Migrations have not been written to disk. To write migrations to disk, please " \
"add OFN_WRITE_FOREIGN_KEY_MIGRATIONS=true to the file .env.test.local"
end
def process_association(model_class, association)
@@ -104,9 +99,6 @@ RSpec.describe "Database" do
migration_name = "add_foreign_key_to_#{model_class.table_name}_" \
"#{foreign_key_table_name}_#{foreign_key_column}"
migration_class_name = migration_name.camelize
millisecond_timestamp = generate_timestamp
migration_file_name = "db/migrate/#{millisecond_timestamp}_" \
"#{migration_name}.rb"
orphaned_records_query = generate_orphaned_records_query(model_class, foreign_key_table_name,
foreign_key_column)
@@ -122,11 +114,6 @@ RSpec.describe "Database" do
end
MIGRATION
if ENV.fetch("OFN_WRITE_FOREIGN_KEY_MIGRATIONS", false)
File.open(migration_file_name, 'w') do |file|
file.puts migration
end
end
migration
end
@@ -140,20 +127,4 @@ RSpec.describe "Database" do
# AND #{model_class.table_name}.#{foreign_key_column} IS NOT NULL
SQL
end
# Generates a unique timestamp.
#
# We may create multiple migrations within the same second, maybe even millisecond.
# So we add precision to milliseconds and increment on conflict.
def generate_timestamp
@last_creation_time ||= Time.new.utc(0)
creation_time = Time.now.utc
if creation_time <= @last_creation_time
creation_time += 0.001.seconds
end
@last_creation_time = creation_time
creation_time.utc.strftime('%Y%m%d%H%M%S%L')
end
end

View File

@@ -100,8 +100,15 @@ module WebHelper
def tomselect_search_and_select(value, options)
tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper")
tomselect_wrapper.find(".ts-control").click
tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').set(value)
# Use send_keys as setting the value directly doesn't trigger the search
tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').send_keys(value)
tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click
end
def tomselect_select(value, options)
tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper")
tomselect_wrapper.find(".ts-control").click
tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click
end

View File

@@ -1074,19 +1074,18 @@ describe '
end
describe "searching customers" do
def serching_for_customers
def searching_for_customers
# opens the customer dropdown
find(".items-placeholder").click
# sets the query name
find(".dropdown-input").set("John")
find(".dropdown-input").send_keys("John")
within(".customer-details") do
expect(page).to have_content("John Doe")
expect(page).to have_content(customer.email.to_s)
end
# sets the query email
find(".dropdown-input").set("maura@smith.biz")
find(".dropdown-input").send_keys("maura@smith.biz")
within(".customer-details") do
expect(page).to have_content("John Doe")
expect(page).to have_content(customer.email.to_s)
@@ -1103,7 +1102,7 @@ describe '
end
it "finds a customer by name" do
serching_for_customers
searching_for_customers
end
end
@@ -1117,7 +1116,7 @@ describe '
end
it "finds a customer by name" do
serching_for_customers
searching_for_customers
end
end
end

View File

@@ -934,8 +934,8 @@ describe '
fill_in "Order number", with: "R123456"
tomselect_multiselect order_cycle.name, from: 'q[order_cycle_id_in][]'
tomselect_multiselect distributor.name, from: 'q[distributor_id_in][]'
tomselect_search_and_select shipping_method.name, from: 'shipping_method_id'
tomselect_search_and_select "complete", from: 'q[state_eq]'
tomselect_select shipping_method.name, from: 'shipping_method_id'
tomselect_select "complete", from: 'q[state_eq]'
fill_in "Email", with: user.email
fill_in "First name begins with", with: "J"
fill_in "Last name begins with", with: "D"

View File

@@ -233,7 +233,7 @@ describe 'Subscriptions' do
before do
visit admin_subscriptions_path
page.find("#new-subscription").click
tomselect_search_and_select shop.name, from: "subscription[shop_id]"
tomselect_select shop.name, from: "subscription[shop_id]"
click_button "Continue"
end

View File

@@ -183,7 +183,7 @@ describe 'Subscriptions' do
before do
visit admin_subscriptions_path
page.find("#new-subscription").click
tomselect_search_and_select shop.name, from: "subscription[shop_id]"
tomselect_select shop.name, from: "subscription[shop_id]"
click_button "Continue"
end

View File

@@ -8768,10 +8768,10 @@ toidentifier@1.0.1:
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35"
integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==
tom-select@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/tom-select/-/tom-select-2.2.3.tgz#858acca2dcec1dbe1a94a3f4c944384e166a4f40"
integrity sha512-VMhRdFlugLGdnNZsP5r8sHKtyvWekIbtr53uoKONMzM+JSBWgy5pV9F+iZ2LTEbzIQI0efIwZ7I6h+wzZoM/zQ==
tom-select@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/tom-select/-/tom-select-2.3.1.tgz#df338d9082874cd0bceb3bee87ed0184447c47f1"
integrity sha512-QS4vnOcB6StNGqX4sGboGXL2fkhBF2gIBB+8Hwv30FZXYPn0CyYO8kkdATRvwfCTThxiR4WcXwKJZ3cOmtI9eg==
dependencies:
"@orchidjs/sifter" "^1.0.3"
"@orchidjs/unicode-variants" "^1.0.4"