From 8383441f79105a06b9243c68a33839495cd29622 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 Jan 2025 10:36:22 +1100 Subject: [PATCH 1/6] List ignored files more explicitely --- .rubocop_styleguide.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 29bdef8e08..e07f27b021 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -5,8 +5,12 @@ AllCops: NewCops: enable Exclude: - bin/**/* - - db/**/* - config/**/* + - db/bad_migrations/* + - db/default/* + - db/migrate/* + - db/schema.rb + - db/seeds.rb - script/**/* - vendor/**/* - node_modules/**/* From 25a90a44f9cba3234680be97d002448ae035a1fb Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 Jan 2025 10:39:50 +1100 Subject: [PATCH 2/6] Modernise seeds file --- .rubocop_styleguide.yml | 1 - db/seeds.rb | 27 +++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index e07f27b021..385a01c68f 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -10,7 +10,6 @@ AllCops: - db/default/* - db/migrate/* - db/schema.rb - - db/seeds.rb - script/**/* - vendor/**/* - node_modules/**/* diff --git a/db/seeds.rb b/db/seeds.rb index 0da80c8929..1fedc9fc2c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,30 +1,33 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# frozen_string_literal: true + +# This file should contain all the record creation needed to seed the database +# with its default values. The data can then be loaded with the rake db:seed +# (or created alongside the db with db:setup). require 'yaml' # We need mail_configuration to create a user account, because it sends a confirmation email. MailConfiguration.apply! -puts "[db:seed] Seeding Countries" -unless Spree::Country.find_by(iso: ENV['DEFAULT_COUNTRY_CODE']) +Rails.logger.debug "[db:seed] Seeding Countries" +unless Spree::Country.find_by(iso: ENV.fetch('DEFAULT_COUNTRY_CODE', nil)) require File.join(File.dirname(__FILE__), 'default', 'countries') end -country = Spree::Country.find_by(iso: ENV['DEFAULT_COUNTRY_CODE']) -puts "Default country is #{country.to_s}" +country = Spree::Country.find_by(iso: ENV.fetch('DEFAULT_COUNTRY_CODE', nil)) +Rails.logger.debug { "Default country is #{country}" } -puts "[db:seed] Seeding states for " + country.name -states = YAML::load_file "db/default/spree/states.yml" +Rails.logger.debug { "[db:seed] Seeding states for #{country.name}" } +states = YAML.load_file "db/default/spree/states.yml" states.each do |state| - puts "State: " + state.to_s + Rails.logger.debug { "State: #{state}" } unless Spree::State.find_by(name: state['name']) - Spree::State.create!({ name: state['name'], abbr: state['abbr'], country: country }) + Spree::State.create!({ name: state['name'], abbr: state['abbr'], country: }) end end -puts "[db:seed] Seeding Zones" +Rails.logger.debug "[db:seed] Seeding Zones" require File.join(File.dirname(__FILE__), 'default', 'zones') -puts "[db:seed] Seeding Users" +Rails.logger.debug "[db:seed] Seeding Users" require File.join(File.dirname(__FILE__), 'default', 'users') DefaultStockLocation.find_or_create From 042cc238c807b4515e296acfd31cad7e86ae90d9 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 Jan 2025 10:52:34 +1100 Subject: [PATCH 3/6] Modernise db default scripts --- .rubocop_styleguide.yml | 1 - db/default/countries.rb | 679 ++++++++++++++++++++++++++-------------- db/default/users.rb | 27 +- db/default/zones.rb | 9 +- 4 files changed, 473 insertions(+), 243 deletions(-) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 385a01c68f..d83be12661 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -7,7 +7,6 @@ AllCops: - bin/**/* - config/**/* - db/bad_migrations/* - - db/default/* - db/migrate/* - db/schema.rb - script/**/* diff --git a/db/default/countries.rb b/db/default/countries.rb index 4cc00cb560..3f90a55511 100644 --- a/db/default/countries.rb +++ b/db/default/countries.rb @@ -1,229 +1,450 @@ -Spree::Country.create!([ - { name: "Chad", iso3: "TCD", iso: "TD", iso_name: "CHAD", numcode: "148" }, - { name: "Faroe Islands", iso3: "FRO", iso: "FO", iso_name: "FAROE ISLANDS", numcode: "234" }, - { name: "India", iso3: "IND", iso: "IN", iso_name: "INDIA", numcode: "356" }, - { name: "Nicaragua", iso3: "NIC", iso: "NI", iso_name: "NICARAGUA", numcode: "558" }, - { name: "Saint Lucia", iso3: "LCA", iso: "LC", iso_name: "SAINT LUCIA", numcode: "662" }, - { name: "Fiji", iso3: "FJI", iso: "FJ", iso_name: "FIJI", numcode: "242" }, - { name: "Indonesia", iso3: "IDN", iso: "ID", iso_name: "INDONESIA", numcode: "360" }, - { name: "Niger", iso3: "NER", iso: "NE", iso_name: "NIGER", numcode: "562" }, - { name: "Saint Pierre and Miquelon", iso3: "SPM", iso: "PM", iso_name: "SAINT PIERRE AND MIQUELON", numcode: "666" }, - { name: "Finland", iso3: "FIN", iso: "FI", iso_name: "FINLAND", numcode: "246" }, - { name: "Nigeria", iso3: "NGA", iso: "NG", iso_name: "NIGERIA", numcode: "566" }, - { name: "Saint Vincent and the Grenadines", iso3: "VCT", iso: "VC", iso_name: "SAINT VINCENT AND THE GRENADINES", numcode: "670" }, - { name: "France", iso3: "FRA", iso: "FR", iso_name: "FRANCE", numcode: "250" }, - { name: "Iran, Islamic Republic of", iso3: "IRN", iso: "IR", iso_name: "IRAN, ISLAMIC REPUBLIC OF", numcode: "364" }, - { name: "Niue", iso3: "NIU", iso: "NU", iso_name: "NIUE", numcode: "570" }, - { name: "Samoa", iso3: "WSM", iso: "WS", iso_name: "SAMOA", numcode: "882" }, - { name: "French Guiana", iso3: "GUF", iso: "GF", iso_name: "FRENCH GUIANA", numcode: "254" }, - { name: "Iraq", iso3: "IRQ", iso: "IQ", iso_name: "IRAQ", numcode: "368" }, - { name: "San Marino", iso3: "SMR", iso: "SM", iso_name: "SAN MARINO", numcode: "674" }, - { name: "Ireland", iso3: "IRL", iso: "IE", iso_name: "IRELAND", numcode: "372" }, - { name: "Sao Tome and Principe", iso3: "STP", iso: "ST", iso_name: "SAO TOME AND PRINCIPE", numcode: "678" }, - { name: "Israel", iso3: "ISR", iso: "IL", iso_name: "ISRAEL", numcode: "376" }, - { name: "Saudi Arabia", iso3: "SAU", iso: "SA", iso_name: "SAUDI ARABIA", numcode: "682" }, - { name: "Italy", iso3: "ITA", iso: "IT", iso_name: "ITALY", numcode: "380" }, - { name: "Senegal", iso3: "SEN", iso: "SN", iso_name: "SENEGAL", numcode: "686" }, - { name: "Jamaica", iso3: "JAM", iso: "JM", iso_name: "JAMAICA", numcode: "388" }, - { name: "Japan", iso3: "JPN", iso: "JP", iso_name: "JAPAN", numcode: "392" }, - { name: "Jordan", iso3: "JOR", iso: "JO", iso_name: "JORDAN", numcode: "400" }, - { name: "Belgium", iso3: "BEL", iso: "BE", iso_name: "BELGIUM", numcode: "56" }, - { name: "Belize", iso3: "BLZ", iso: "BZ", iso_name: "BELIZE", numcode: "84" }, - { name: "Kazakhstan", iso3: "KAZ", iso: "KZ", iso_name: "KAZAKHSTAN", numcode: "398" }, - { name: "Uganda", iso3: "UGA", iso: "UG", iso_name: "UGANDA", numcode: "800" }, - { name: "Benin", iso3: "BEN", iso: "BJ", iso_name: "BENIN", numcode: "204" }, - { name: "Kenya", iso3: "KEN", iso: "KE", iso_name: "KENYA", numcode: "404" }, - { name: "Ukraine", iso3: "UKR", iso: "UA", iso_name: "UKRAINE", numcode: "804" }, - { name: "Bermuda", iso3: "BMU", iso: "BM", iso_name: "BERMUDA", numcode: "60" }, - { name: "Kiribati", iso3: "KIR", iso: "KI", iso_name: "KIRIBATI", numcode: "296" }, - { name: "Mexico", iso3: "MEX", iso: "MX", iso_name: "MEXICO", numcode: "484" }, - { name: "United Arab Emirates", iso3: "ARE", iso: "AE", iso_name: "UNITED ARAB EMIRATES", numcode: "784" }, - { name: "Bhutan", iso3: "BTN", iso: "BT", iso_name: "BHUTAN", numcode: "64" }, - { name: "Cuba", iso3: "CUB", iso: "CU", iso_name: "CUBA", numcode: "192" }, - { name: "North Korea", iso3: "PRK", iso: "KP", iso_name: "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF", numcode: "408" }, - { name: "Micronesia, Federated States of", iso3: "FSM", iso: "FM", iso_name: "MICRONESIA, FEDERATED STATES OF", numcode: "583" }, - { name: "United Kingdom", iso3: "GBR", iso: "GB", iso_name: "UNITED KINGDOM", numcode: "826" }, - { name: "Bolivia", iso3: "BOL", iso: "BO", iso_name: "BOLIVIA", numcode: "68" }, - { name: "Cyprus", iso3: "CYP", iso: "CY", iso_name: "CYPRUS", numcode: "196" }, - { name: "South Korea", iso3: "KOR", iso: "KR", iso_name: "KOREA, REPUBLIC OF", numcode: "410" }, - { name: "Moldova, Republic of", iso3: "MDA", iso: "MD", iso_name: "MOLDOVA, REPUBLIC OF", numcode: "498" }, - { name: "United States", iso3: "USA", iso: "US", iso_name: "UNITED STATES", numcode: "840" }, - { name: "Bosnia and Herzegovina", iso3: "BIH", iso: "BA", iso_name: "BOSNIA AND HERZEGOVINA", numcode: "70" }, - { name: "Czech Republic", iso3: "CZE", iso: "CZ", iso_name: "CZECH REPUBLIC", numcode: "203" }, - { name: "Kuwait", iso3: "KWT", iso: "KW", iso_name: "KUWAIT", numcode: "414" }, - { name: "Monaco", iso3: "MCO", iso: "MC", iso_name: "MONACO", numcode: "492" }, - { name: "Uruguay", iso3: "URY", iso: "UY", iso_name: "URUGUAY", numcode: "858" }, - { name: "Botswana", iso3: "BWA", iso: "BW", iso_name: "BOTSWANA", numcode: "72" }, - { name: "Denmark", iso3: "DNK", iso: "DK", iso_name: "DENMARK", numcode: "208" }, - { name: "Guadeloupe", iso3: "GLP", iso: "GP", iso_name: "GUADELOUPE", numcode: "312" }, - { name: "Kyrgyzstan", iso3: "KGZ", iso: "KG", iso_name: "KYRGYZSTAN", numcode: "417" }, - { name: "Mongolia", iso3: "MNG", iso: "MN", iso_name: "MONGOLIA", numcode: "496" }, - { name: "Philippines", iso3: "PHL", iso: "PH", iso_name: "PHILIPPINES", numcode: "608" }, - { name: "Brazil", iso3: "BRA", iso: "BR", iso_name: "BRAZIL", numcode: "76" }, - { name: "Djibouti", iso3: "DJI", iso: "DJ", iso_name: "DJIBOUTI", numcode: "262" }, - { name: "Guam", iso3: "GUM", iso: "GU", iso_name: "GUAM", numcode: "316" }, - { name: "Lao People's Democratic Republic", iso3: "LAO", iso: "LA", iso_name: "LAO PEOPLE'S DEMOCRATIC REPUBLIC", numcode: "418" }, - { name: "Montserrat", iso3: "MSR", iso: "MS", iso_name: "MONTSERRAT", numcode: "500" }, - { name: "Pitcairn", iso3: "PCN", iso: "PN", iso_name: "PITCAIRN", numcode: "612" }, - { name: "Uzbekistan", iso3: "UZB", iso: "UZ", iso_name: "UZBEKISTAN", numcode: "860" }, - { name: "Brunei Darussalam", iso3: "BRN", iso: "BN", iso_name: "BRUNEI DARUSSALAM", numcode: "96" }, - { name: "Dominica", iso3: "DMA", iso: "DM", iso_name: "DOMINICA", numcode: "212" }, - { name: "Guatemala", iso3: "GTM", iso: "GT", iso_name: "GUATEMALA", numcode: "320" }, - { name: "Morocco", iso3: "MAR", iso: "MA", iso_name: "MOROCCO", numcode: "504" }, - { name: "Poland", iso3: "POL", iso: "PL", iso_name: "POLAND", numcode: "616" }, - { name: "Vanuatu", iso3: "VUT", iso: "VU", iso_name: "VANUATU", numcode: "548" }, - { name: "Dominican Republic", iso3: "DOM", iso: "DO", iso_name: "DOMINICAN REPUBLIC", numcode: "214" }, - { name: "Mozambique", iso3: "MOZ", iso: "MZ", iso_name: "MOZAMBIQUE", numcode: "508" }, - { name: "Portugal", iso3: "PRT", iso: "PT", iso_name: "PORTUGAL", numcode: "620" }, - { name: "Sudan", iso3: "SDN", iso: "SD", iso_name: "SUDAN", numcode: "736" }, - { name: "Venezuela", iso3: "VEN", iso: "VE", iso_name: "VENEZUELA", numcode: "862" }, - { name: "Ecuador", iso3: "ECU", iso: "EC", iso_name: "ECUADOR", numcode: "218" }, - { name: "Guinea", iso3: "GIN", iso: "GN", iso_name: "GUINEA", numcode: "324" }, - { name: "Myanmar", iso3: "MMR", iso: "MM", iso_name: "MYANMAR", numcode: "104" }, - { name: "Puerto Rico", iso3: "PRI", iso: "PR", iso_name: "PUERTO RICO", numcode: "630" }, - { name: "Suriname", iso3: "SUR", iso: "SR", iso_name: "SURINAME", numcode: "740" }, - { name: "Viet Nam", iso3: "VNM", iso: "VN", iso_name: "VIET NAM", numcode: "704" }, - { name: "Egypt", iso3: "EGY", iso: "EG", iso_name: "EGYPT", numcode: "818" }, - { name: "Guinea-Bissau", iso3: "GNB", iso: "GW", iso_name: "GUINEA-BISSAU", numcode: "624" }, - { name: "Namibia", iso3: "NAM", iso: "NA", iso_name: "NAMIBIA", numcode: "516" }, - { name: "Qatar", iso3: "QAT", iso: "QA", iso_name: "QATAR", numcode: "634" }, - { name: "Svalbard and Jan Mayen", iso3: "SJM", iso: "SJ", iso_name: "SVALBARD AND JAN MAYEN", numcode: "744" }, - { name: "El Salvador", iso3: "SLV", iso: "SV", iso_name: "EL SALVADOR", numcode: "222" }, - { name: "Guyana", iso3: "GUY", iso: "GY", iso_name: "GUYANA", numcode: "328" }, - { name: "Reunion", iso3: "REU", iso: "RE", iso_name: "REUNION", numcode: "638" }, - { name: "Haiti", iso3: "HTI", iso: "HT", iso_name: "HAITI", numcode: "332" }, - { name: "Romania", iso3: "ROM", iso: "RO", iso_name: "ROMANIA", numcode: "642" }, - { name: "Swaziland", iso3: "SWZ", iso: "SZ", iso_name: "SWAZILAND", numcode: "748" }, - { name: "Holy See (Vatican City State)", iso3: "VAT", iso: "VA", iso_name: "HOLY SEE (VATICAN CITY STATE)", numcode: "336" }, - { name: "Russian Federation", iso3: "RUS", iso: "RU", iso_name: "RUSSIAN FEDERATION", numcode: "643" }, - { name: "Sweden", iso3: "SWE", iso: "SE", iso_name: "SWEDEN", numcode: "752" }, - { name: "Honduras", iso3: "HND", iso: "HN", iso_name: "HONDURAS", numcode: "340" }, - { name: "Rwanda", iso3: "RWA", iso: "RW", iso_name: "RWANDA", numcode: "646" }, - { name: "Switzerland", iso3: "CHE", iso: "CH", iso_name: "SWITZERLAND", numcode: "756" }, - { name: "Hong Kong", iso3: "HKG", iso: "HK", iso_name: "HONG KONG", numcode: "344" }, - { name: "Syrian Arab Republic", iso3: "SYR", iso: "SY", iso_name: "SYRIAN ARAB REPUBLIC", numcode: "760" }, - { name: "Taiwan", iso3: "TWN", iso: "TW", iso_name: "TAIWAN, PROVINCE OF CHINA", numcode: "158" }, - { name: "Tajikistan", iso3: "TJK", iso: "TJ", iso_name: "TAJIKISTAN", numcode: "762" }, - { name: "Tanzania, United Republic of", iso3: "TZA", iso: "TZ", iso_name: "TANZANIA, UNITED REPUBLIC OF", numcode: "834" }, - { name: "Armenia", iso3: "ARM", iso: "AM", iso_name: "ARMENIA", numcode: "51" }, - { name: "Aruba", iso3: "ABW", iso: "AW", iso_name: "ARUBA", numcode: "533" }, - { name: "Australia", iso3: "AUS", iso: "AU", iso_name: "AUSTRALIA", numcode: "36" }, - { name: "Thailand", iso3: "THA", iso: "TH", iso_name: "THAILAND", numcode: "764" }, - { name: "Austria", iso3: "AUT", iso: "AT", iso_name: "AUSTRIA", numcode: "40" }, - { name: "Madagascar", iso3: "MDG", iso: "MG", iso_name: "MADAGASCAR", numcode: "450" }, - { name: "Togo", iso3: "TGO", iso: "TG", iso_name: "TOGO", numcode: "768" }, - { name: "Azerbaijan", iso3: "AZE", iso: "AZ", iso_name: "AZERBAIJAN", numcode: "31" }, - { name: "Chile", iso3: "CHL", iso: "CL", iso_name: "CHILE", numcode: "152" }, - { name: "Malawi", iso3: "MWI", iso: "MW", iso_name: "MALAWI", numcode: "454" }, - { name: "Tokelau", iso3: "TKL", iso: "TK", iso_name: "TOKELAU", numcode: "772" }, - { name: "Bahamas", iso3: "BHS", iso: "BS", iso_name: "BAHAMAS", numcode: "44" }, - { name: "China", iso3: "CHN", iso: "CN", iso_name: "CHINA", numcode: "156" }, - { name: "Malaysia", iso3: "MYS", iso: "MY", iso_name: "MALAYSIA", numcode: "458" }, - { name: "Tonga", iso3: "TON", iso: "TO", iso_name: "TONGA", numcode: "776" }, - { name: "Bahrain", iso3: "BHR", iso: "BH", iso_name: "BAHRAIN", numcode: "48" }, - { name: "Colombia", iso3: "COL", iso: "CO", iso_name: "COLOMBIA", numcode: "170" }, - { name: "Maldives", iso3: "MDV", iso: "MV", iso_name: "MALDIVES", numcode: "462" }, - { name: "Trinidad and Tobago", iso3: "TTO", iso: "TT", iso_name: "TRINIDAD AND TOBAGO", numcode: "780" }, - { name: "Bangladesh", iso3: "BGD", iso: "BD", iso_name: "BANGLADESH", numcode: "50" }, - { name: "Comoros", iso3: "COM", iso: "KM", iso_name: "COMOROS", numcode: "174" }, - { name: "French Polynesia", iso3: "PYF", iso: "PF", iso_name: "FRENCH POLYNESIA", numcode: "258" }, - { name: "Mali", iso3: "MLI", iso: "ML", iso_name: "MALI", numcode: "466" }, - { name: "Norfolk Island", iso3: "NFK", iso: "NF", iso_name: "NORFOLK ISLAND", numcode: "574" }, - { name: "Tunisia", iso3: "TUN", iso: "TN", iso_name: "TUNISIA", numcode: "788" }, - { name: "Barbados", iso3: "BRB", iso: "BB", iso_name: "BARBADOS", numcode: "52" }, - { name: "Congo", iso3: "COG", iso: "CG", iso_name: "CONGO", numcode: "178" }, - { name: "Gabon", iso3: "GAB", iso: "GA", iso_name: "GABON", numcode: "266" }, - { name: "Malta", iso3: "MLT", iso: "MT", iso_name: "MALTA", numcode: "470" }, - { name: "Northern Mariana Islands", iso3: "MNP", iso: "MP", iso_name: "NORTHERN MARIANA ISLANDS", numcode: "580" }, - { name: "Turkey", iso3: "TUR", iso: "TR", iso_name: "TURKEY", numcode: "792" }, - { name: "Congo, the Democratic Republic of the", iso3: "COD", iso: "CD", iso_name: "CONGO, THE DEMOCRATIC REPUBLIC OF THE", numcode: "180" }, - { name: "Marshall Islands", iso3: "MHL", iso: "MH", iso_name: "MARSHALL ISLANDS", numcode: "584" }, - { name: "Norway", iso3: "NOR", iso: "NO", iso_name: "NORWAY", numcode: "578" }, - { name: "Turkmenistan", iso3: "TKM", iso: "TM", iso_name: "TURKMENISTAN", numcode: "795" }, - { name: "Belarus", iso3: "BLR", iso: "BY", iso_name: "BELARUS", numcode: "112" }, - { name: "Cook Islands", iso3: "COK", iso: "CK", iso_name: "COOK ISLANDS", numcode: "184" }, - { name: "Gambia", iso3: "GMB", iso: "GM", iso_name: "GAMBIA", numcode: "270" }, - { name: "Martinique", iso3: "MTQ", iso: "MQ", iso_name: "MARTINIQUE", numcode: "474" }, - { name: "Oman", iso3: "OMN", iso: "OM", iso_name: "OMAN", numcode: "512" }, - { name: "Seychelles", iso3: "SYC", iso: "SC", iso_name: "SEYCHELLES", numcode: "690" }, - { name: "Turks and Caicos Islands", iso3: "TCA", iso: "TC", iso_name: "TURKS AND CAICOS ISLANDS", numcode: "796" }, - { name: "Georgia", iso3: "GEO", iso: "GE", iso_name: "GEORGIA", numcode: "268" }, - { name: "Mauritania", iso3: "MRT", iso: "MR", iso_name: "MAURITANIA", numcode: "478" }, - { name: "Pakistan", iso3: "PAK", iso: "PK", iso_name: "PAKISTAN", numcode: "586" }, - { name: "Sierra Leone", iso3: "SLE", iso: "SL", iso_name: "SIERRA LEONE", numcode: "694" }, - { name: "Tuvalu", iso3: "TUV", iso: "TV", iso_name: "TUVALU", numcode: "798" }, - { name: "Costa Rica", iso3: "CRI", iso: "CR", iso_name: "COSTA RICA", numcode: "188" }, - { name: "Germany", iso3: "DEU", iso: "DE", iso_name: "GERMANY", numcode: "276" }, - { name: "Mauritius", iso3: "MUS", iso: "MU", iso_name: "MAURITIUS", numcode: "480" }, - { name: "Palau", iso3: "PLW", iso: "PW", iso_name: "PALAU", numcode: "585" }, - { name: "Cote D'Ivoire", iso3: "CIV", iso: "CI", iso_name: "COTE D'IVOIRE", numcode: "384" }, - { name: "Panama", iso3: "PAN", iso: "PA", iso_name: "PANAMA", numcode: "591" }, - { name: "Singapore", iso3: "SGP", iso: "SG", iso_name: "SINGAPORE", numcode: "702" }, - { name: "Croatia", iso3: "HRV", iso: "HR", iso_name: "CROATIA", numcode: "191" }, - { name: "Ghana", iso3: "GHA", iso: "GH", iso_name: "GHANA", numcode: "288" }, - { name: "Papua New Guinea", iso3: "PNG", iso: "PG", iso_name: "PAPUA NEW GUINEA", numcode: "598" }, - { name: "Slovakia", iso3: "SVK", iso: "SK", iso_name: "SLOVAKIA", numcode: "703" }, - { name: "Gibraltar", iso3: "GIB", iso: "GI", iso_name: "GIBRALTAR", numcode: "292" }, - { name: "Paraguay", iso3: "PRY", iso: "PY", iso_name: "PARAGUAY", numcode: "600" }, - { name: "Slovenia", iso3: "SVN", iso: "SI", iso_name: "SLOVENIA", numcode: "705" }, - { name: "Greece", iso3: "GRC", iso: "GR", iso_name: "GREECE", numcode: "300" }, - { name: "Peru", iso3: "PER", iso: "PE", iso_name: "PERU", numcode: "604" }, - { name: "Solomon Islands", iso3: "SLB", iso: "SB", iso_name: "SOLOMON ISLANDS", numcode: "90" }, - { name: "Greenland", iso3: "GRL", iso: "GL", iso_name: "GREENLAND", numcode: "304" }, - { name: "Somalia", iso3: "SOM", iso: "SO", iso_name: "SOMALIA", numcode: "706" }, - { name: "Grenada", iso3: "GRD", iso: "GD", iso_name: "GRENADA", numcode: "308" }, - { name: "South Africa", iso3: "ZAF", iso: "ZA", iso_name: "SOUTH AFRICA", numcode: "710" }, - { name: "Spain", iso3: "ESP", iso: "ES", iso_name: "SPAIN", numcode: "724" }, - { name: "Sri Lanka", iso3: "LKA", iso: "LK", iso_name: "SRI LANKA", numcode: "144" }, - { name: "Afghanistan", iso3: "AFG", iso: "AF", iso_name: "AFGHANISTAN", numcode: "4" }, - { name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", numcode: "8" }, - { name: "Algeria", iso3: "DZA", iso: "DZ", iso_name: "ALGERIA", numcode: "12" }, - { name: "Latvia", iso3: "LVA", iso: "LV", iso_name: "LATVIA", numcode: "428" }, - { name: "American Samoa", iso3: "ASM", iso: "AS", iso_name: "AMERICAN SAMOA", numcode: "16" }, - { name: "Bulgaria", iso3: "BGR", iso: "BG", iso_name: "BULGARIA", numcode: "100" }, - { name: "Lebanon", iso3: "LBN", iso: "LB", iso_name: "LEBANON", numcode: "422" }, - { name: "Andorra", iso3: "AND", iso: "AD", iso_name: "ANDORRA", numcode: "20" }, - { name: "Burkina Faso", iso3: "BFA", iso: "BF", iso_name: "BURKINA FASO", numcode: "854" }, - { name: "Lesotho", iso3: "LSO", iso: "LS", iso_name: "LESOTHO", numcode: "426" }, - { name: "Angola", iso3: "AGO", iso: "AO", iso_name: "ANGOLA", numcode: "24" }, - { name: "Burundi", iso3: "BDI", iso: "BI", iso_name: "BURUNDI", numcode: "108" }, - { name: "Liberia", iso3: "LBR", iso: "LR", iso_name: "LIBERIA", numcode: "430" }, - { name: "Virgin Islands, British", iso3: "VGB", iso: "VG", iso_name: "VIRGIN ISLANDS, BRITISH", numcode: "92" }, - { name: "Anguilla", iso3: "AIA", iso: "AI", iso_name: "ANGUILLA", numcode: "660" }, - { name: "Cambodia", iso3: "KHM", iso: "KH", iso_name: "CAMBODIA", numcode: "116" }, - { name: "Equatorial Guinea", iso3: "GNQ", iso: "GQ", iso_name: "EQUATORIAL GUINEA", numcode: "226" }, - { name: "Libyan Arab Jamahiriya", iso3: "LBY", iso: "LY", iso_name: "LIBYAN ARAB JAMAHIRIYA", numcode: "434" }, - { name: "Nauru", iso3: "NRU", iso: "NR", iso_name: "NAURU", numcode: "520" }, - { name: "Virgin Islands, U.S.", iso3: "VIR", iso: "VI", iso_name: "VIRGIN ISLANDS, U.S.", numcode: "850" }, - { name: "Antigua and Barbuda", iso3: "ATG", iso: "AG", iso_name: "ANTIGUA AND BARBUDA", numcode: "28" }, - { name: "Cameroon", iso3: "CMR", iso: "CM", iso_name: "CAMEROON", numcode: "120" }, - { name: "Liechtenstein", iso3: "LIE", iso: "LI", iso_name: "LIECHTENSTEIN", numcode: "438" }, - { name: "Nepal", iso3: "NPL", iso: "NP", iso_name: "NEPAL", numcode: "524" }, - { name: "Wallis and Futuna", iso3: "WLF", iso: "WF", iso_name: "WALLIS AND FUTUNA", numcode: "876" }, - { name: "Western Sahara", iso3: "ESH", iso: "EH", iso_name: "WESTERN SAHARA", numcode: "732" }, - { name: "Argentina", iso3: "ARG", iso: "AR", iso_name: "ARGENTINA", numcode: "32" }, - { name: "Canada", iso3: "CAN", iso: "CA", iso_name: "CANADA", numcode: "124" }, - { name: "Eritrea", iso3: "ERI", iso: "ER", iso_name: "ERITREA", numcode: "232" }, - { name: "Lithuania", iso3: "LTU", iso: "LT", iso_name: "LITHUANIA", numcode: "440" }, - { name: "Netherlands", iso3: "NLD", iso: "NL", iso_name: "NETHERLANDS", numcode: "528" }, - { name: "Yemen", iso3: "YEM", iso: "YE", iso_name: "YEMEN", numcode: "887" }, - { name: "Cape Verde", iso3: "CPV", iso: "CV", iso_name: "CAPE VERDE", numcode: "132" }, - { name: "Estonia", iso3: "EST", iso: "EE", iso_name: "ESTONIA", numcode: "233" }, - { name: "Luxembourg", iso3: "LUX", iso: "LU", iso_name: "LUXEMBOURG", numcode: "442" }, - { name: "Netherlands Antilles", iso3: "ANT", iso: "AN", iso_name: "NETHERLANDS ANTILLES", numcode: "530" }, - { name: "Saint Helena", iso3: "SHN", iso: "SH", iso_name: "SAINT HELENA", numcode: "654" }, - { name: "Zambia", iso3: "ZMB", iso: "ZM", iso_name: "ZAMBIA", numcode: "894" }, - { name: "Cayman Islands", iso3: "CYM", iso: "KY", iso_name: "CAYMAN ISLANDS", numcode: "136" }, - { name: "Ethiopia", iso3: "ETH", iso: "ET", iso_name: "ETHIOPIA", numcode: "231" }, - { name: "Hungary", iso3: "HUN", iso: "HU", iso_name: "HUNGARY", numcode: "348" }, - { name: "Macao", iso3: "MAC", iso: "MO", iso_name: "MACAO", numcode: "446" }, - { name: "New Caledonia", iso3: "NCL", iso: "NC", iso_name: "NEW CALEDONIA", numcode: "540" }, - { name: "Zimbabwe", iso3: "ZWE", iso: "ZW", iso_name: "ZIMBABWE", numcode: "716" }, - { name: "Central African Republic", iso3: "CAF", iso: "CF", iso_name: "CENTRAL AFRICAN REPUBLIC", numcode: "140" }, - { name: "Falkland Islands (Malvinas)", iso3: "FLK", iso: "FK", iso_name: "FALKLAND ISLANDS (MALVINAS)", numcode: "238" }, - { name: "Iceland", iso3: "ISL", iso: "IS", iso_name: "ICELAND", numcode: "352" }, - { name: "Macedonia", iso3: "MKD", iso: "MK", iso_name: "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF", numcode: "807" }, - { name: "New Zealand", iso3: "NZL", iso: "NZ", iso_name: "NEW ZEALAND", numcode: "554" }, - { name: "Saint Kitts and Nevis", iso3: "KNA", iso: "KN", iso_name: "SAINT KITTS AND NEVIS", numcode: "659" }, - { name: "Serbia", iso3: "SRB", iso: "RS", "iso_name" => "SERBIA", numcode: "999" } -]) +# frozen_string_literal: true + +Spree::Country.create!( + [ + { name: "Chad", iso3: "TCD", iso: "TD", iso_name: "CHAD", numcode: "148" }, + { name: "Faroe Islands", iso3: "FRO", iso: "FO", + iso_name: "FAROE ISLANDS", numcode: "234" }, + { name: "India", iso3: "IND", iso: "IN", iso_name: "INDIA", + numcode: "356" }, + { name: "Nicaragua", iso3: "NIC", iso: "NI", iso_name: "NICARAGUA", + numcode: "558" }, + { name: "Saint Lucia", iso3: "LCA", iso: "LC", iso_name: "SAINT LUCIA", + numcode: "662" }, + { name: "Fiji", iso3: "FJI", iso: "FJ", iso_name: "FIJI", numcode: "242" }, + { name: "Indonesia", iso3: "IDN", iso: "ID", iso_name: "INDONESIA", + numcode: "360" }, + { name: "Niger", iso3: "NER", iso: "NE", iso_name: "NIGER", + numcode: "562" }, + { name: "Saint Pierre and Miquelon", iso3: "SPM", iso: "PM", + iso_name: "SAINT PIERRE AND MIQUELON", numcode: "666" }, + { name: "Finland", iso3: "FIN", iso: "FI", iso_name: "FINLAND", + numcode: "246" }, + { name: "Nigeria", iso3: "NGA", iso: "NG", iso_name: "NIGERIA", + numcode: "566" }, + { name: "Saint Vincent and the Grenadines", iso3: "VCT", iso: "VC", + iso_name: "SAINT VINCENT AND THE GRENADINES", numcode: "670" }, + { name: "France", iso3: "FRA", iso: "FR", iso_name: "FRANCE", + numcode: "250" }, + { name: "Iran, Islamic Republic of", iso3: "IRN", iso: "IR", + iso_name: "IRAN, ISLAMIC REPUBLIC OF", numcode: "364" }, + { name: "Niue", iso3: "NIU", iso: "NU", iso_name: "NIUE", numcode: "570" }, + { name: "Samoa", iso3: "WSM", iso: "WS", iso_name: "SAMOA", + numcode: "882" }, + { name: "French Guiana", iso3: "GUF", iso: "GF", + iso_name: "FRENCH GUIANA", numcode: "254" }, + { name: "Iraq", iso3: "IRQ", iso: "IQ", iso_name: "IRAQ", numcode: "368" }, + { name: "San Marino", iso3: "SMR", iso: "SM", iso_name: "SAN MARINO", + numcode: "674" }, + { name: "Ireland", iso3: "IRL", iso: "IE", iso_name: "IRELAND", + numcode: "372" }, + { name: "Sao Tome and Principe", iso3: "STP", iso: "ST", iso_name: "SAO TOME AND PRINCIPE", + numcode: "678" }, + { name: "Israel", iso3: "ISR", iso: "IL", iso_name: "ISRAEL", + numcode: "376" }, + { name: "Saudi Arabia", iso3: "SAU", iso: "SA", iso_name: "SAUDI ARABIA", + numcode: "682" }, + { name: "Italy", iso3: "ITA", iso: "IT", iso_name: "ITALY", + numcode: "380" }, + { name: "Senegal", iso3: "SEN", iso: "SN", iso_name: "SENEGAL", + numcode: "686" }, + { name: "Jamaica", iso3: "JAM", iso: "JM", iso_name: "JAMAICA", + numcode: "388" }, + { name: "Japan", iso3: "JPN", iso: "JP", iso_name: "JAPAN", + numcode: "392" }, + { name: "Jordan", iso3: "JOR", iso: "JO", iso_name: "JORDAN", + numcode: "400" }, + { name: "Belgium", iso3: "BEL", iso: "BE", iso_name: "BELGIUM", + numcode: "56" }, + { name: "Belize", iso3: "BLZ", iso: "BZ", iso_name: "BELIZE", + numcode: "84" }, + { name: "Kazakhstan", iso3: "KAZ", iso: "KZ", iso_name: "KAZAKHSTAN", + numcode: "398" }, + { name: "Uganda", iso3: "UGA", iso: "UG", iso_name: "UGANDA", + numcode: "800" }, + { name: "Benin", iso3: "BEN", iso: "BJ", iso_name: "BENIN", + numcode: "204" }, + { name: "Kenya", iso3: "KEN", iso: "KE", iso_name: "KENYA", + numcode: "404" }, + { name: "Ukraine", iso3: "UKR", iso: "UA", iso_name: "UKRAINE", + numcode: "804" }, + { name: "Bermuda", iso3: "BMU", iso: "BM", iso_name: "BERMUDA", + numcode: "60" }, + { name: "Kiribati", iso3: "KIR", iso: "KI", iso_name: "KIRIBATI", + numcode: "296" }, + { name: "Mexico", iso3: "MEX", iso: "MX", iso_name: "MEXICO", + numcode: "484" }, + { name: "United Arab Emirates", iso3: "ARE", iso: "AE", iso_name: "UNITED ARAB EMIRATES", + numcode: "784" }, + { name: "Bhutan", iso3: "BTN", iso: "BT", iso_name: "BHUTAN", + numcode: "64" }, + { name: "Cuba", iso3: "CUB", iso: "CU", iso_name: "CUBA", numcode: "192" }, + { name: "North Korea", iso3: "PRK", iso: "KP", + iso_name: "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF", numcode: "408" }, + { name: "Micronesia, Federated States of", iso3: "FSM", iso: "FM", + iso_name: "MICRONESIA, FEDERATED STATES OF", numcode: "583" }, + { name: "United Kingdom", iso3: "GBR", iso: "GB", + iso_name: "UNITED KINGDOM", numcode: "826" }, + { name: "Bolivia", iso3: "BOL", iso: "BO", iso_name: "BOLIVIA", + numcode: "68" }, + { name: "Cyprus", iso3: "CYP", iso: "CY", iso_name: "CYPRUS", + numcode: "196" }, + { name: "South Korea", iso3: "KOR", iso: "KR", + iso_name: "KOREA, REPUBLIC OF", numcode: "410" }, + { name: "Moldova, Republic of", iso3: "MDA", iso: "MD", iso_name: "MOLDOVA, REPUBLIC OF", + numcode: "498" }, + { name: "United States", iso3: "USA", iso: "US", + iso_name: "UNITED STATES", numcode: "840" }, + { name: "Bosnia and Herzegovina", iso3: "BIH", iso: "BA", iso_name: "BOSNIA AND HERZEGOVINA", + numcode: "70" }, + { name: "Czech Republic", iso3: "CZE", iso: "CZ", + iso_name: "CZECH REPUBLIC", numcode: "203" }, + { name: "Kuwait", iso3: "KWT", iso: "KW", iso_name: "KUWAIT", + numcode: "414" }, + { name: "Monaco", iso3: "MCO", iso: "MC", iso_name: "MONACO", + numcode: "492" }, + { name: "Uruguay", iso3: "URY", iso: "UY", iso_name: "URUGUAY", + numcode: "858" }, + { name: "Botswana", iso3: "BWA", iso: "BW", iso_name: "BOTSWANA", + numcode: "72" }, + { name: "Denmark", iso3: "DNK", iso: "DK", iso_name: "DENMARK", + numcode: "208" }, + { name: "Guadeloupe", iso3: "GLP", iso: "GP", iso_name: "GUADELOUPE", + numcode: "312" }, + { name: "Kyrgyzstan", iso3: "KGZ", iso: "KG", iso_name: "KYRGYZSTAN", + numcode: "417" }, + { name: "Mongolia", iso3: "MNG", iso: "MN", iso_name: "MONGOLIA", + numcode: "496" }, + { name: "Philippines", iso3: "PHL", iso: "PH", iso_name: "PHILIPPINES", + numcode: "608" }, + { name: "Brazil", iso3: "BRA", iso: "BR", iso_name: "BRAZIL", + numcode: "76" }, + { name: "Djibouti", iso3: "DJI", iso: "DJ", iso_name: "DJIBOUTI", + numcode: "262" }, + { name: "Guam", iso3: "GUM", iso: "GU", iso_name: "GUAM", numcode: "316" }, + { name: "Lao People's Democratic Republic", iso3: "LAO", iso: "LA", + iso_name: "LAO PEOPLE'S DEMOCRATIC REPUBLIC", numcode: "418" }, + { name: "Montserrat", iso3: "MSR", iso: "MS", iso_name: "MONTSERRAT", + numcode: "500" }, + { name: "Pitcairn", iso3: "PCN", iso: "PN", iso_name: "PITCAIRN", + numcode: "612" }, + { name: "Uzbekistan", iso3: "UZB", iso: "UZ", iso_name: "UZBEKISTAN", + numcode: "860" }, + { name: "Brunei Darussalam", iso3: "BRN", iso: "BN", iso_name: "BRUNEI DARUSSALAM", + numcode: "96" }, + { name: "Dominica", iso3: "DMA", iso: "DM", iso_name: "DOMINICA", + numcode: "212" }, + { name: "Guatemala", iso3: "GTM", iso: "GT", iso_name: "GUATEMALA", + numcode: "320" }, + { name: "Morocco", iso3: "MAR", iso: "MA", iso_name: "MOROCCO", + numcode: "504" }, + { name: "Poland", iso3: "POL", iso: "PL", iso_name: "POLAND", + numcode: "616" }, + { name: "Vanuatu", iso3: "VUT", iso: "VU", iso_name: "VANUATU", + numcode: "548" }, + { name: "Dominican Republic", iso3: "DOM", iso: "DO", iso_name: "DOMINICAN REPUBLIC", + numcode: "214" }, + { name: "Mozambique", iso3: "MOZ", iso: "MZ", iso_name: "MOZAMBIQUE", + numcode: "508" }, + { name: "Portugal", iso3: "PRT", iso: "PT", iso_name: "PORTUGAL", + numcode: "620" }, + { name: "Sudan", iso3: "SDN", iso: "SD", iso_name: "SUDAN", + numcode: "736" }, + { name: "Venezuela", iso3: "VEN", iso: "VE", iso_name: "VENEZUELA", + numcode: "862" }, + { name: "Ecuador", iso3: "ECU", iso: "EC", iso_name: "ECUADOR", + numcode: "218" }, + { name: "Guinea", iso3: "GIN", iso: "GN", iso_name: "GUINEA", + numcode: "324" }, + { name: "Myanmar", iso3: "MMR", iso: "MM", iso_name: "MYANMAR", + numcode: "104" }, + { name: "Puerto Rico", iso3: "PRI", iso: "PR", iso_name: "PUERTO RICO", + numcode: "630" }, + { name: "Suriname", iso3: "SUR", iso: "SR", iso_name: "SURINAME", + numcode: "740" }, + { name: "Viet Nam", iso3: "VNM", iso: "VN", iso_name: "VIET NAM", + numcode: "704" }, + { name: "Egypt", iso3: "EGY", iso: "EG", iso_name: "EGYPT", + numcode: "818" }, + { name: "Guinea-Bissau", iso3: "GNB", iso: "GW", + iso_name: "GUINEA-BISSAU", numcode: "624" }, + { name: "Namibia", iso3: "NAM", iso: "NA", iso_name: "NAMIBIA", + numcode: "516" }, + { name: "Qatar", iso3: "QAT", iso: "QA", iso_name: "QATAR", + numcode: "634" }, + { name: "Svalbard and Jan Mayen", iso3: "SJM", iso: "SJ", iso_name: "SVALBARD AND JAN MAYEN", + numcode: "744" }, + { name: "El Salvador", iso3: "SLV", iso: "SV", iso_name: "EL SALVADOR", + numcode: "222" }, + { name: "Guyana", iso3: "GUY", iso: "GY", iso_name: "GUYANA", + numcode: "328" }, + { name: "Reunion", iso3: "REU", iso: "RE", iso_name: "REUNION", + numcode: "638" }, + { name: "Haiti", iso3: "HTI", iso: "HT", iso_name: "HAITI", + numcode: "332" }, + { name: "Romania", iso3: "ROM", iso: "RO", iso_name: "ROMANIA", + numcode: "642" }, + { name: "Swaziland", iso3: "SWZ", iso: "SZ", iso_name: "SWAZILAND", + numcode: "748" }, + { name: "Holy See (Vatican City State)", iso3: "VAT", iso: "VA", + iso_name: "HOLY SEE (VATICAN CITY STATE)", numcode: "336" }, + { name: "Russian Federation", iso3: "RUS", iso: "RU", iso_name: "RUSSIAN FEDERATION", + numcode: "643" }, + { name: "Sweden", iso3: "SWE", iso: "SE", iso_name: "SWEDEN", + numcode: "752" }, + { name: "Honduras", iso3: "HND", iso: "HN", iso_name: "HONDURAS", + numcode: "340" }, + { name: "Rwanda", iso3: "RWA", iso: "RW", iso_name: "RWANDA", + numcode: "646" }, + { name: "Switzerland", iso3: "CHE", iso: "CH", iso_name: "SWITZERLAND", + numcode: "756" }, + { name: "Hong Kong", iso3: "HKG", iso: "HK", iso_name: "HONG KONG", + numcode: "344" }, + { name: "Syrian Arab Republic", iso3: "SYR", iso: "SY", iso_name: "SYRIAN ARAB REPUBLIC", + numcode: "760" }, + { name: "Taiwan", iso3: "TWN", iso: "TW", + iso_name: "TAIWAN, PROVINCE OF CHINA", numcode: "158" }, + { name: "Tajikistan", iso3: "TJK", iso: "TJ", iso_name: "TAJIKISTAN", + numcode: "762" }, + { name: "Tanzania, United Republic of", iso3: "TZA", iso: "TZ", + iso_name: "TANZANIA, UNITED REPUBLIC OF", numcode: "834" }, + { name: "Armenia", iso3: "ARM", iso: "AM", iso_name: "ARMENIA", + numcode: "51" }, + { name: "Aruba", iso3: "ABW", iso: "AW", iso_name: "ARUBA", + numcode: "533" }, + { name: "Australia", iso3: "AUS", iso: "AU", iso_name: "AUSTRALIA", + numcode: "36" }, + { name: "Thailand", iso3: "THA", iso: "TH", iso_name: "THAILAND", + numcode: "764" }, + { name: "Austria", iso3: "AUT", iso: "AT", iso_name: "AUSTRIA", + numcode: "40" }, + { name: "Madagascar", iso3: "MDG", iso: "MG", iso_name: "MADAGASCAR", + numcode: "450" }, + { name: "Togo", iso3: "TGO", iso: "TG", iso_name: "TOGO", numcode: "768" }, + { name: "Azerbaijan", iso3: "AZE", iso: "AZ", iso_name: "AZERBAIJAN", + numcode: "31" }, + { name: "Chile", iso3: "CHL", iso: "CL", iso_name: "CHILE", + numcode: "152" }, + { name: "Malawi", iso3: "MWI", iso: "MW", iso_name: "MALAWI", + numcode: "454" }, + { name: "Tokelau", iso3: "TKL", iso: "TK", iso_name: "TOKELAU", + numcode: "772" }, + { name: "Bahamas", iso3: "BHS", iso: "BS", iso_name: "BAHAMAS", + numcode: "44" }, + { name: "China", iso3: "CHN", iso: "CN", iso_name: "CHINA", + numcode: "156" }, + { name: "Malaysia", iso3: "MYS", iso: "MY", iso_name: "MALAYSIA", + numcode: "458" }, + { name: "Tonga", iso3: "TON", iso: "TO", iso_name: "TONGA", + numcode: "776" }, + { name: "Bahrain", iso3: "BHR", iso: "BH", iso_name: "BAHRAIN", + numcode: "48" }, + { name: "Colombia", iso3: "COL", iso: "CO", iso_name: "COLOMBIA", + numcode: "170" }, + { name: "Maldives", iso3: "MDV", iso: "MV", iso_name: "MALDIVES", + numcode: "462" }, + { name: "Trinidad and Tobago", iso3: "TTO", iso: "TT", iso_name: "TRINIDAD AND TOBAGO", + numcode: "780" }, + { name: "Bangladesh", iso3: "BGD", iso: "BD", iso_name: "BANGLADESH", + numcode: "50" }, + { name: "Comoros", iso3: "COM", iso: "KM", iso_name: "COMOROS", + numcode: "174" }, + { name: "French Polynesia", iso3: "PYF", iso: "PF", iso_name: "FRENCH POLYNESIA", + numcode: "258" }, + { name: "Mali", iso3: "MLI", iso: "ML", iso_name: "MALI", numcode: "466" }, + { name: "Norfolk Island", iso3: "NFK", iso: "NF", + iso_name: "NORFOLK ISLAND", numcode: "574" }, + { name: "Tunisia", iso3: "TUN", iso: "TN", iso_name: "TUNISIA", + numcode: "788" }, + { name: "Barbados", iso3: "BRB", iso: "BB", iso_name: "BARBADOS", + numcode: "52" }, + { name: "Congo", iso3: "COG", iso: "CG", iso_name: "CONGO", + numcode: "178" }, + { name: "Gabon", iso3: "GAB", iso: "GA", iso_name: "GABON", + numcode: "266" }, + { name: "Malta", iso3: "MLT", iso: "MT", iso_name: "MALTA", + numcode: "470" }, + { name: "Northern Mariana Islands", iso3: "MNP", iso: "MP", + iso_name: "NORTHERN MARIANA ISLANDS", numcode: "580" }, + { name: "Turkey", iso3: "TUR", iso: "TR", iso_name: "TURKEY", + numcode: "792" }, + { name: "Congo, the Democratic Republic of the", iso3: "COD", iso: "CD", + iso_name: "CONGO, THE DEMOCRATIC REPUBLIC OF THE", numcode: "180" }, + { name: "Marshall Islands", iso3: "MHL", iso: "MH", iso_name: "MARSHALL ISLANDS", + numcode: "584" }, + { name: "Norway", iso3: "NOR", iso: "NO", iso_name: "NORWAY", + numcode: "578" }, + { name: "Turkmenistan", iso3: "TKM", iso: "TM", iso_name: "TURKMENISTAN", + numcode: "795" }, + { name: "Belarus", iso3: "BLR", iso: "BY", iso_name: "BELARUS", + numcode: "112" }, + { name: "Cook Islands", iso3: "COK", iso: "CK", iso_name: "COOK ISLANDS", + numcode: "184" }, + { name: "Gambia", iso3: "GMB", iso: "GM", iso_name: "GAMBIA", + numcode: "270" }, + { name: "Martinique", iso3: "MTQ", iso: "MQ", iso_name: "MARTINIQUE", + numcode: "474" }, + { name: "Oman", iso3: "OMN", iso: "OM", iso_name: "OMAN", numcode: "512" }, + { name: "Seychelles", iso3: "SYC", iso: "SC", iso_name: "SEYCHELLES", + numcode: "690" }, + { name: "Turks and Caicos Islands", iso3: "TCA", iso: "TC", + iso_name: "TURKS AND CAICOS ISLANDS", numcode: "796" }, + { name: "Georgia", iso3: "GEO", iso: "GE", iso_name: "GEORGIA", + numcode: "268" }, + { name: "Mauritania", iso3: "MRT", iso: "MR", iso_name: "MAURITANIA", + numcode: "478" }, + { name: "Pakistan", iso3: "PAK", iso: "PK", iso_name: "PAKISTAN", + numcode: "586" }, + { name: "Sierra Leone", iso3: "SLE", iso: "SL", iso_name: "SIERRA LEONE", + numcode: "694" }, + { name: "Tuvalu", iso3: "TUV", iso: "TV", iso_name: "TUVALU", + numcode: "798" }, + { name: "Costa Rica", iso3: "CRI", iso: "CR", iso_name: "COSTA RICA", + numcode: "188" }, + { name: "Germany", iso3: "DEU", iso: "DE", iso_name: "GERMANY", + numcode: "276" }, + { name: "Mauritius", iso3: "MUS", iso: "MU", iso_name: "MAURITIUS", + numcode: "480" }, + { name: "Palau", iso3: "PLW", iso: "PW", iso_name: "PALAU", + numcode: "585" }, + { name: "Cote D'Ivoire", iso3: "CIV", iso: "CI", + iso_name: "COTE D'IVOIRE", numcode: "384" }, + { name: "Panama", iso3: "PAN", iso: "PA", iso_name: "PANAMA", + numcode: "591" }, + { name: "Singapore", iso3: "SGP", iso: "SG", iso_name: "SINGAPORE", + numcode: "702" }, + { name: "Croatia", iso3: "HRV", iso: "HR", iso_name: "CROATIA", + numcode: "191" }, + { name: "Ghana", iso3: "GHA", iso: "GH", iso_name: "GHANA", + numcode: "288" }, + { name: "Papua New Guinea", iso3: "PNG", iso: "PG", iso_name: "PAPUA NEW GUINEA", + numcode: "598" }, + { name: "Slovakia", iso3: "SVK", iso: "SK", iso_name: "SLOVAKIA", + numcode: "703" }, + { name: "Gibraltar", iso3: "GIB", iso: "GI", iso_name: "GIBRALTAR", + numcode: "292" }, + { name: "Paraguay", iso3: "PRY", iso: "PY", iso_name: "PARAGUAY", + numcode: "600" }, + { name: "Slovenia", iso3: "SVN", iso: "SI", iso_name: "SLOVENIA", + numcode: "705" }, + { name: "Greece", iso3: "GRC", iso: "GR", iso_name: "GREECE", + numcode: "300" }, + { name: "Peru", iso3: "PER", iso: "PE", iso_name: "PERU", numcode: "604" }, + { name: "Solomon Islands", iso3: "SLB", iso: "SB", + iso_name: "SOLOMON ISLANDS", numcode: "90" }, + { name: "Greenland", iso3: "GRL", iso: "GL", iso_name: "GREENLAND", + numcode: "304" }, + { name: "Somalia", iso3: "SOM", iso: "SO", iso_name: "SOMALIA", + numcode: "706" }, + { name: "Grenada", iso3: "GRD", iso: "GD", iso_name: "GRENADA", + numcode: "308" }, + { name: "South Africa", iso3: "ZAF", iso: "ZA", iso_name: "SOUTH AFRICA", + numcode: "710" }, + { name: "Spain", iso3: "ESP", iso: "ES", iso_name: "SPAIN", + numcode: "724" }, + { name: "Sri Lanka", iso3: "LKA", iso: "LK", iso_name: "SRI LANKA", + numcode: "144" }, + { name: "Afghanistan", iso3: "AFG", iso: "AF", iso_name: "AFGHANISTAN", + numcode: "4" }, + { name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", + numcode: "8" }, + { name: "Algeria", iso3: "DZA", iso: "DZ", iso_name: "ALGERIA", + numcode: "12" }, + { name: "Latvia", iso3: "LVA", iso: "LV", iso_name: "LATVIA", + numcode: "428" }, + { name: "American Samoa", iso3: "ASM", iso: "AS", + iso_name: "AMERICAN SAMOA", numcode: "16" }, + { name: "Bulgaria", iso3: "BGR", iso: "BG", iso_name: "BULGARIA", + numcode: "100" }, + { name: "Lebanon", iso3: "LBN", iso: "LB", iso_name: "LEBANON", + numcode: "422" }, + { name: "Andorra", iso3: "AND", iso: "AD", iso_name: "ANDORRA", + numcode: "20" }, + { name: "Burkina Faso", iso3: "BFA", iso: "BF", iso_name: "BURKINA FASO", + numcode: "854" }, + { name: "Lesotho", iso3: "LSO", iso: "LS", iso_name: "LESOTHO", + numcode: "426" }, + { name: "Angola", iso3: "AGO", iso: "AO", iso_name: "ANGOLA", + numcode: "24" }, + { name: "Burundi", iso3: "BDI", iso: "BI", iso_name: "BURUNDI", + numcode: "108" }, + { name: "Liberia", iso3: "LBR", iso: "LR", iso_name: "LIBERIA", + numcode: "430" }, + { name: "Virgin Islands, British", iso3: "VGB", iso: "VG", iso_name: "VIRGIN ISLANDS, BRITISH", + numcode: "92" }, + { name: "Anguilla", iso3: "AIA", iso: "AI", iso_name: "ANGUILLA", + numcode: "660" }, + { name: "Cambodia", iso3: "KHM", iso: "KH", iso_name: "CAMBODIA", + numcode: "116" }, + { name: "Equatorial Guinea", iso3: "GNQ", iso: "GQ", iso_name: "EQUATORIAL GUINEA", + numcode: "226" }, + { name: "Libyan Arab Jamahiriya", iso3: "LBY", iso: "LY", iso_name: "LIBYAN ARAB JAMAHIRIYA", + numcode: "434" }, + { name: "Nauru", iso3: "NRU", iso: "NR", iso_name: "NAURU", + numcode: "520" }, + { name: "Virgin Islands, U.S.", iso3: "VIR", iso: "VI", iso_name: "VIRGIN ISLANDS, U.S.", + numcode: "850" }, + { name: "Antigua and Barbuda", iso3: "ATG", iso: "AG", iso_name: "ANTIGUA AND BARBUDA", + numcode: "28" }, + { name: "Cameroon", iso3: "CMR", iso: "CM", iso_name: "CAMEROON", + numcode: "120" }, + { name: "Liechtenstein", iso3: "LIE", iso: "LI", + iso_name: "LIECHTENSTEIN", numcode: "438" }, + { name: "Nepal", iso3: "NPL", iso: "NP", iso_name: "NEPAL", + numcode: "524" }, + { name: "Wallis and Futuna", iso3: "WLF", iso: "WF", iso_name: "WALLIS AND FUTUNA", + numcode: "876" }, + { name: "Western Sahara", iso3: "ESH", iso: "EH", + iso_name: "WESTERN SAHARA", numcode: "732" }, + { name: "Argentina", iso3: "ARG", iso: "AR", iso_name: "ARGENTINA", + numcode: "32" }, + { name: "Canada", iso3: "CAN", iso: "CA", iso_name: "CANADA", + numcode: "124" }, + { name: "Eritrea", iso3: "ERI", iso: "ER", iso_name: "ERITREA", + numcode: "232" }, + { name: "Lithuania", iso3: "LTU", iso: "LT", iso_name: "LITHUANIA", + numcode: "440" }, + { name: "Netherlands", iso3: "NLD", iso: "NL", iso_name: "NETHERLANDS", + numcode: "528" }, + { name: "Yemen", iso3: "YEM", iso: "YE", iso_name: "YEMEN", + numcode: "887" }, + { name: "Cape Verde", iso3: "CPV", iso: "CV", iso_name: "CAPE VERDE", + numcode: "132" }, + { name: "Estonia", iso3: "EST", iso: "EE", iso_name: "ESTONIA", + numcode: "233" }, + { name: "Luxembourg", iso3: "LUX", iso: "LU", iso_name: "LUXEMBOURG", + numcode: "442" }, + { name: "Netherlands Antilles", iso3: "ANT", iso: "AN", iso_name: "NETHERLANDS ANTILLES", + numcode: "530" }, + { name: "Saint Helena", iso3: "SHN", iso: "SH", iso_name: "SAINT HELENA", + numcode: "654" }, + { name: "Zambia", iso3: "ZMB", iso: "ZM", iso_name: "ZAMBIA", + numcode: "894" }, + { name: "Cayman Islands", iso3: "CYM", iso: "KY", + iso_name: "CAYMAN ISLANDS", numcode: "136" }, + { name: "Ethiopia", iso3: "ETH", iso: "ET", iso_name: "ETHIOPIA", + numcode: "231" }, + { name: "Hungary", iso3: "HUN", iso: "HU", iso_name: "HUNGARY", + numcode: "348" }, + { name: "Macao", iso3: "MAC", iso: "MO", iso_name: "MACAO", + numcode: "446" }, + { name: "New Caledonia", iso3: "NCL", iso: "NC", + iso_name: "NEW CALEDONIA", numcode: "540" }, + { name: "Zimbabwe", iso3: "ZWE", iso: "ZW", iso_name: "ZIMBABWE", + numcode: "716" }, + { name: "Central African Republic", iso3: "CAF", iso: "CF", + iso_name: "CENTRAL AFRICAN REPUBLIC", numcode: "140" }, + { name: "Falkland Islands (Malvinas)", iso3: "FLK", iso: "FK", + iso_name: "FALKLAND ISLANDS (MALVINAS)", numcode: "238" }, + { name: "Iceland", iso3: "ISL", iso: "IS", iso_name: "ICELAND", + numcode: "352" }, + { name: "Macedonia", iso3: "MKD", iso: "MK", + iso_name: "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF", numcode: "807" }, + { name: "New Zealand", iso3: "NZL", iso: "NZ", iso_name: "NEW ZEALAND", + numcode: "554" }, + { name: "Saint Kitts and Nevis", iso3: "KNA", iso: "KN", iso_name: "SAINT KITTS AND NEVIS", + numcode: "659" }, + { :name => "Serbia", :iso3 => "SRB", :iso => "RS", "iso_name" => "SERBIA", + :numcode => "999" } + ] +) diff --git a/db/default/users.rb b/db/default/users.rb index 617b1e560c..c28cb4b539 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'highline/import' # see last line where we create an admin if there is none, asking for email and password @@ -35,25 +37,30 @@ end def create_admin_user if ENV.fetch("AUTO_ACCEPT", true) - password = ENV.fetch("ADMIN_PASSWORD", "ofn123").dup - email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com").dup + password = ENV.fetch("ADMIN_PASSWORD", "ofn123") + email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com") else - puts 'Create the admin user (press enter for defaults).' - #name = prompt_for_admin_name unless name + Rails.logger.debug 'Create the admin user (press enter for defaults).' email = prompt_for_admin_email password = prompt_for_admin_password end attributes = { - :password => password, - :password_confirmation => password, - :email => email, - :login => email + password:, + password_confirmation: password, + email:, + login: email } load 'spree/user.rb' - if Spree::User.find_by(email: email) - say "\nWARNING: There is already a user with the email: #{email}, so no account changes were made. If you wish to create an additional admin user, please run rake spree_auth:admin:create again with a different email.\n\n" + if Spree::User.find_by(email:) + say <<~TEXT + + WARNING: There is already a user with the email: #{email}, + so no account changes were made. If you wish to create an additional admin + user, please run rake spree_auth:admin:create again with a different email. + + TEXT else admin = Spree::User.new(attributes) admin.skip_confirmation! diff --git a/db/default/zones.rb b/db/default/zones.rb index 10dd53b1d2..2b2689b12c 100644 --- a/db/default/zones.rb +++ b/db/default/zones.rb @@ -1,12 +1,15 @@ +# frozen_string_literal: true + unless Spree::Zone.find_by(name: "EU_VAT") - eu_vat = Spree::Zone.create!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.") + eu_vat = Spree::Zone.create!(name: "EU_VAT", + description: "Countries that make up the EU VAT zone.") ["Poland", "Finland", "Portugal", "Romania", "Germany", "France", "Slovakia", "Hungary", "Slovenia", "Ireland", "Austria", "Spain", "Italy", "Belgium", "Sweden", "Latvia", "Bulgaria", "United Kingdom", "Lithuania", "Cyprus", "Luxembourg", "Malta", "Denmark", "Netherlands", "Estonia"].each do |name| - eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(name: name)) + eu_vat.zone_members.create!(zoneable: Spree::Country.find_by!(name:)) end end @@ -14,6 +17,6 @@ unless Spree::Zone.find_by(name: "North America") north_america = Spree::Zone.create!(name: "North America", description: "USA + Canada") ["United States", "Canada"].each do |name| - north_america.zone_members.create!(zoneable: Spree::Country.find_by!(name: name)) + north_america.zone_members.create!(zoneable: Spree::Country.find_by!(name:)) end end From 8c68179069af79da7ef78fc66a08572b01b330ee Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 Jan 2025 10:55:11 +1100 Subject: [PATCH 4/6] Style default user creation --- db/default/users.rb | 65 +++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/db/default/users.rb b/db/default/users.rb index c28cb4b539..e65657411f 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -36,20 +36,7 @@ def prompt_for_admin_email end def create_admin_user - if ENV.fetch("AUTO_ACCEPT", true) - password = ENV.fetch("ADMIN_PASSWORD", "ofn123") - email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com") - else - Rails.logger.debug 'Create the admin user (press enter for defaults).' - email = prompt_for_admin_email - password = prompt_for_admin_password - end - attributes = { - password:, - password_confirmation: password, - email:, - login: email - } + attributes = read_user_attributes load 'spree/user.rb' @@ -61,24 +48,44 @@ def create_admin_user user, please run rake spree_auth:admin:create again with a different email. TEXT + + return + end + + admin = Spree::User.new(attributes) + admin.skip_confirmation! + admin.skip_confirmation_notification! + + # The default domain example.com is not resolved by all nameservers. + ValidEmail2::Address.define_method(:valid_mx?) { true } + + if admin.save + admin.spree_roles << Spree::Role.admin + say "New admin user persisted!" else - admin = Spree::User.new(attributes) - admin.skip_confirmation! - admin.skip_confirmation_notification! - - # The default domain example.com is not resolved by all nameservers. - ValidEmail2::Address.define_method(:valid_mx?) { true } - - if admin.save - admin.spree_roles << Spree::Role.admin - say "New admin user persisted!" - else - say "There was some problems with persisting new admin user:" - admin.errors.full_messages.each do |error| - say error - end + say "There was some problems with persisting new admin user:" + admin.errors.full_messages.each do |error| + say error end end end +def read_user_attributes + if ENV.fetch("AUTO_ACCEPT", true) + password = ENV.fetch("ADMIN_PASSWORD", "ofn123") + email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com") + else + Rails.logger.debug 'Create the admin user (press enter for defaults).' + email = prompt_for_admin_email + password = prompt_for_admin_password + end + + { + password:, + password_confirmation: password, + email:, + login: email + } +end + create_admin_user if Spree::User.admin.empty? From 971d5bea4428bd94a93e9c635f541e9adb8a7abf Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 Jan 2025 10:59:50 +1100 Subject: [PATCH 5/6] Police new migrations --- .rubocop_styleguide.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index d83be12661..ae1fb8345f 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -3,11 +3,13 @@ # These are the rules we agreed upon and we work towards. AllCops: NewCops: enable + MigratedSchemaVersion: "20250111000000" Exclude: - bin/**/* - config/**/* - db/bad_migrations/* - - db/migrate/* + - db/migrate/201* + - db/migrate/202[0-4]* - db/schema.rb - script/**/* - vendor/**/* From fcc31fffcdea17962966f6dfe1d7db7b0ca97cf4 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 16 Jan 2025 10:47:45 +1100 Subject: [PATCH 6/6] Fix user seeding --- db/default/users.rb | 4 ++-- db/seeds.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db/default/users.rb b/db/default/users.rb index e65657411f..23ba8f549b 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -40,7 +40,7 @@ def create_admin_user load 'spree/user.rb' - if Spree::User.find_by(email:) + if Spree::User.find_by(email: attributes[:email]) say <<~TEXT WARNING: There is already a user with the email: #{email}, @@ -75,7 +75,7 @@ def read_user_attributes password = ENV.fetch("ADMIN_PASSWORD", "ofn123") email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com") else - Rails.logger.debug 'Create the admin user (press enter for defaults).' + say 'Create the admin user (press enter for defaults).' email = prompt_for_admin_email password = prompt_for_admin_password end diff --git a/db/seeds.rb b/db/seeds.rb index 1fedc9fc2c..9192a35e61 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,26 +8,26 @@ require 'yaml' # We need mail_configuration to create a user account, because it sends a confirmation email. MailConfiguration.apply! -Rails.logger.debug "[db:seed] Seeding Countries" +Rails.logger.info "[db:seed] Seeding Countries" unless Spree::Country.find_by(iso: ENV.fetch('DEFAULT_COUNTRY_CODE', nil)) require File.join(File.dirname(__FILE__), 'default', 'countries') end country = Spree::Country.find_by(iso: ENV.fetch('DEFAULT_COUNTRY_CODE', nil)) -Rails.logger.debug { "Default country is #{country}" } +Rails.logger.info { "Default country is #{country}" } -Rails.logger.debug { "[db:seed] Seeding states for #{country.name}" } +Rails.logger.info { "[db:seed] Seeding states for #{country.name}" } states = YAML.load_file "db/default/spree/states.yml" states.each do |state| - Rails.logger.debug { "State: #{state}" } + Rails.logger.info { "State: #{state}" } unless Spree::State.find_by(name: state['name']) Spree::State.create!({ name: state['name'], abbr: state['abbr'], country: }) end end -Rails.logger.debug "[db:seed] Seeding Zones" +Rails.logger.info "[db:seed] Seeding Zones" require File.join(File.dirname(__FILE__), 'default', 'zones') -Rails.logger.debug "[db:seed] Seeding Users" +Rails.logger.info "[db:seed] Seeding Users" require File.join(File.dirname(__FILE__), 'default', 'users') DefaultStockLocation.find_or_create