From d356743c95bb2db7f04756d5787c507acc540979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Mon, 23 Jan 2023 16:19:12 +0000 Subject: [PATCH 1/9] add Addresses::Country and Addresses::Region --- app/models/addresses/country.rb | 22 ++++++++++++++++++++++ app/models/addresses/region.rb | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 app/models/addresses/country.rb create mode 100644 app/models/addresses/region.rb diff --git a/app/models/addresses/country.rb b/app/models/addresses/country.rb new file mode 100644 index 000000000..9402dcce5 --- /dev/null +++ b/app/models/addresses/country.rb @@ -0,0 +1,22 @@ +class Addresses::Country < ApplicationHash + include Addresses::Countries::Base + # 🚅 add concerns above. + + # 🚅 add belongs_to associations above. + + # 🚅 add has_many associations above. + + # 🚅 add oauth providers above. + + # 🚅 add has_one associations above. + + # 🚅 add scopes above. + + # 🚅 add validations above. + + # 🚅 add callbacks above. + + # 🚅 add delegations above. + + # 🚅 add methods above. +end diff --git a/app/models/addresses/region.rb b/app/models/addresses/region.rb new file mode 100644 index 000000000..95a5876d0 --- /dev/null +++ b/app/models/addresses/region.rb @@ -0,0 +1,22 @@ +class Addresses::Region < ApplicationHash + include Addresses::Regions::Base + # 🚅 add concerns above. + + # 🚅 add belongs_to associations above. + + # 🚅 add has_many associations above. + + # 🚅 add oauth providers above. + + # 🚅 add has_one associations above. + + # 🚅 add scopes above. + + # 🚅 add validations above. + + # 🚅 add callbacks above. + + # 🚅 add delegations above. + + # 🚅 add methods above. +end \ No newline at end of file From 62705d5e3db9db094e776a881578a304223be60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Mon, 23 Jan 2023 18:41:14 +0000 Subject: [PATCH 2/9] add Address model, factory --- app/models/address.rb | 24 +++++++++++++++++++ db/migrate/20230123162616_create_addresses.rb | 16 +++++++++++++ db/schema.rb | 17 ++++++++++++- test/factories/addresses.rb | 12 ++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 app/models/address.rb create mode 100644 db/migrate/20230123162616_create_addresses.rb create mode 100644 test/factories/addresses.rb diff --git a/app/models/address.rb b/app/models/address.rb new file mode 100644 index 000000000..0a885f885 --- /dev/null +++ b/app/models/address.rb @@ -0,0 +1,24 @@ +class Address < ApplicationRecord + extend ActiveHash::Associations::ActiveRecordExtensions + + include Addresses::Base + # 🚅 add concerns above. + + # 🚅 add belongs_to associations above. + + # 🚅 add has_many associations above. + + # 🚅 add oauth providers above. + + # 🚅 add has_one associations above. + + # 🚅 add scopes above. + + # 🚅 add validations above. + + # 🚅 add callbacks above. + + # 🚅 add delegations above. + + # 🚅 add methods above. +end diff --git a/db/migrate/20230123162616_create_addresses.rb b/db/migrate/20230123162616_create_addresses.rb new file mode 100644 index 000000000..8deaf2e65 --- /dev/null +++ b/db/migrate/20230123162616_create_addresses.rb @@ -0,0 +1,16 @@ +class CreateAddresses < ActiveRecord::Migration[7.0] + def change + create_table :addresses do |t| + t.references :addressable, polymorphic: true, null: false + t.string :address_one + t.string :address_two + t.string :city + t.integer :region_id + t.string :region_name + t.integer :country_id + t.string :postal_code + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f52d0bb36..ab239c3dc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_12_31_003438) do +ActiveRecord::Schema[7.0].define(version: 2023_01_23_162616) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -61,6 +61,21 @@ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end + create_table "addresses", force: :cascade do |t| + t.string "addressable_type", null: false + t.bigint "addressable_id", null: false + t.string "address_one" + t.string "address_two" + t.string "city" + t.integer "region_id" + t.string "region_name" + t.integer "country_id" + t.string "postal_code" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["addressable_type", "addressable_id"], name: "index_addresses_on_addressable" + end + create_table "integrations_stripe_installations", force: :cascade do |t| t.bigint "team_id", null: false t.bigint "oauth_stripe_account_id", null: false diff --git a/test/factories/addresses.rb b/test/factories/addresses.rb new file mode 100644 index 000000000..8b1b29a30 --- /dev/null +++ b/test/factories/addresses.rb @@ -0,0 +1,12 @@ +FactoryBot.define do + factory :address do + addressable { nil } + address_one { "1000 Vin Scully Avenue" } + address_two { nil } + city { "Los Angeles" } + region_id { 1416 } + region_name { "California" } + country_id { 233 } + postal_code { "90090" } + end +end From 52f3f16c4aec8f5d2c1a42e2ec337eb20199b5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Fri, 27 Jan 2023 22:20:21 +0000 Subject: [PATCH 3/9] add snail gem --- Gemfile | 3 +++ Gemfile.lock | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index a677d6b97..68e0c3788 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,9 @@ gem "bootsnap", require: false # A natural language date/time parser. gem "chronic" +# Address formatting +gem "snail" + group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[mri mingw x64_mingw] diff --git a/Gemfile.lock b/Gemfile.lock index 9cc962dbe..7eaa7737b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -526,6 +526,8 @@ GEM simplecov_json_formatter (0.1.4) simpleidn (0.2.1) unf (~> 0.1.4) + snail (2.2.3) + activesupport snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) From e01bfa424b6fbfcc093b6fa2f8f28c478589454b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Fri, 27 Jan 2023 22:30:26 +0000 Subject: [PATCH 4/9] tangible_thing_test: check address fields refresh on country change --- test/system/tangible_thing_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/system/tangible_thing_test.rb b/test/system/tangible_thing_test.rb index 5efadaeb6..a86b40e81 100644 --- a/test/system/tangible_thing_test.rb +++ b/test/system/tangible_thing_test.rb @@ -41,6 +41,11 @@ class TangibleThingTest < ApplicationSystemTestCase fill_in "Email Field Value", with: "me@acme.com" fill_in "Password Field Value", with: "secure-password" fill_in "Phone Field Value", with: "(201) 551-8321" + + assert page.has_content? "State / Province" + select "Japan", from: "Country" + assert page.has_content? "Prefecture" + select "One", from: "Super Select Value" select2_select "Multiple Super Select Values", ["Five", "Six"] fill_in "Text Area Value", with: "Long text for this text area field" From bc9e81e8de3370db268d885bf345604a2492dbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Mon, 30 Jan 2023 16:13:33 +0000 Subject: [PATCH 5/9] remove snail gem --- Gemfile | 3 --- Gemfile.lock | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 68e0c3788..a677d6b97 100644 --- a/Gemfile +++ b/Gemfile @@ -56,9 +56,6 @@ gem "bootsnap", require: false # A natural language date/time parser. gem "chronic" -# Address formatting -gem "snail" - group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[mri mingw x64_mingw] diff --git a/Gemfile.lock b/Gemfile.lock index 7eaa7737b..b7ade9420 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -526,8 +526,6 @@ GEM simplecov_json_formatter (0.1.4) simpleidn (0.2.1) unf (~> 0.1.4) - snail (2.2.3) - activesupport snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) @@ -590,9 +588,14 @@ GEM zeitwerk (2.6.8) PLATFORMS +<<<<<<< HEAD arm64-darwin-21 arm64-darwin-22 ruby +||||||| parent of 9495313 (remove snail gem) +======= + x86_64-darwin-22 +>>>>>>> 9495313 (remove snail gem) x86_64-linux DEPENDENCIES From 7b486ce9f815a52bef6c1f0ef350e4091fbcbedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Mon, 30 Jan 2023 17:25:26 +0000 Subject: [PATCH 6/9] add Addresses::Continent and Addresses::Subcontinent --- app/models/addresses/continent.rb | 22 ++++++++++++++++++++++ app/models/addresses/subcontinent.rb | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 app/models/addresses/continent.rb create mode 100644 app/models/addresses/subcontinent.rb diff --git a/app/models/addresses/continent.rb b/app/models/addresses/continent.rb new file mode 100644 index 000000000..6a6f4cf81 --- /dev/null +++ b/app/models/addresses/continent.rb @@ -0,0 +1,22 @@ +class Addresses::Continent < ApplicationHash + include Addresses::Continents::Base + # 🚅 add concerns above. + + # 🚅 add belongs_to associations above. + + # 🚅 add has_many associations above. + + # 🚅 add oauth providers above. + + # 🚅 add has_one associations above. + + # 🚅 add scopes above. + + # 🚅 add validations above. + + # 🚅 add callbacks above. + + # 🚅 add delegations above. + + # 🚅 add methods above. +end \ No newline at end of file diff --git a/app/models/addresses/subcontinent.rb b/app/models/addresses/subcontinent.rb new file mode 100644 index 000000000..a37d2df1d --- /dev/null +++ b/app/models/addresses/subcontinent.rb @@ -0,0 +1,22 @@ +class Addresses::Subcontinent < ApplicationHash + include Addresses::Subcontinents::Base + # 🚅 add concerns above. + + # 🚅 add belongs_to associations above. + + # 🚅 add has_many associations above. + + # 🚅 add oauth providers above. + + # 🚅 add has_one associations above. + + # 🚅 add scopes above. + + # 🚅 add validations above. + + # 🚅 add callbacks above. + + # 🚅 add delegations above. + + # 🚅 add methods above. +end \ No newline at end of file From b83f31ce77410a37d67fed4787147afc6acac36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Lalibert=C3=A9?= Date: Thu, 16 Feb 2023 02:07:05 +0000 Subject: [PATCH 7/9] tests: fix find_stimulus_controller_for_label to permit multiple controllers --- test/application_system_test_case.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 084df5033..895981271 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -259,9 +259,9 @@ def assert_no_js_errors &block def find_stimulus_controller_for_label(label, stimulus_controller, wrapper = false) if wrapper wrapper_el = find("label", text: /\A#{label}\z/).first(:xpath, ".//..//..") - wrapper_el if wrapper_el["data-controller"] == stimulus_controller + wrapper_el if wrapper_el["data-controller"].split(" ").include?(stimulus_controller) else - find("label", text: /\A#{label}\z/).first(:xpath, ".//..").first('[data-controller="' + stimulus_controller + '"]') + find("label", text: /\A#{label}\z/).first(:xpath, ".//..").first('[data-controller~="' + stimulus_controller + '"]') end end From d84836de26b1dd2e6a63c3b7d27cc69f0ddcd841 Mon Sep 17 00:00:00 2001 From: Jeremy Green Date: Thu, 10 Aug 2023 10:22:48 -0500 Subject: [PATCH 8/9] fix a merge conflict that snuck through --- Gemfile.lock | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b7ade9420..9cc962dbe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -588,14 +588,9 @@ GEM zeitwerk (2.6.8) PLATFORMS -<<<<<<< HEAD arm64-darwin-21 arm64-darwin-22 ruby -||||||| parent of 9495313 (remove snail gem) -======= - x86_64-darwin-22 ->>>>>>> 9495313 (remove snail gem) x86_64-linux DEPENDENCIES From 0674bdd258585060e40036ea7aa9dc9bdb2ed4e5 Mon Sep 17 00:00:00 2001 From: Jeremy Green Date: Thu, 10 Aug 2023 10:26:33 -0500 Subject: [PATCH 9/9] make the linter happy --- app/models/address.rb | 20 ++++++++++---------- app/models/addresses/continent.rb | 20 ++++++++++---------- app/models/addresses/region.rb | 20 ++++++++++---------- app/models/addresses/subcontinent.rb | 20 ++++++++++---------- test/system/tangible_thing_test.rb | 4 ++-- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/app/models/address.rb b/app/models/address.rb index 0a885f885..a52c02dfd 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -1,24 +1,24 @@ class Address < ApplicationRecord extend ActiveHash::Associations::ActiveRecordExtensions - + include Addresses::Base # 🚅 add concerns above. - + # 🚅 add belongs_to associations above. - + # 🚅 add has_many associations above. - + # 🚅 add oauth providers above. - + # 🚅 add has_one associations above. - + # 🚅 add scopes above. - + # 🚅 add validations above. - + # 🚅 add callbacks above. - + # 🚅 add delegations above. - + # 🚅 add methods above. end diff --git a/app/models/addresses/continent.rb b/app/models/addresses/continent.rb index 6a6f4cf81..aaaa00681 100644 --- a/app/models/addresses/continent.rb +++ b/app/models/addresses/continent.rb @@ -1,22 +1,22 @@ class Addresses::Continent < ApplicationHash include Addresses::Continents::Base # 🚅 add concerns above. - + # 🚅 add belongs_to associations above. - + # 🚅 add has_many associations above. - + # 🚅 add oauth providers above. - + # 🚅 add has_one associations above. - + # 🚅 add scopes above. - + # 🚅 add validations above. - + # 🚅 add callbacks above. - + # 🚅 add delegations above. - + # 🚅 add methods above. -end \ No newline at end of file +end diff --git a/app/models/addresses/region.rb b/app/models/addresses/region.rb index 95a5876d0..d753d4ff2 100644 --- a/app/models/addresses/region.rb +++ b/app/models/addresses/region.rb @@ -1,22 +1,22 @@ class Addresses::Region < ApplicationHash include Addresses::Regions::Base # 🚅 add concerns above. - + # 🚅 add belongs_to associations above. - + # 🚅 add has_many associations above. - + # 🚅 add oauth providers above. - + # 🚅 add has_one associations above. - + # 🚅 add scopes above. - + # 🚅 add validations above. - + # 🚅 add callbacks above. - + # 🚅 add delegations above. - + # 🚅 add methods above. -end \ No newline at end of file +end diff --git a/app/models/addresses/subcontinent.rb b/app/models/addresses/subcontinent.rb index a37d2df1d..22cc6446b 100644 --- a/app/models/addresses/subcontinent.rb +++ b/app/models/addresses/subcontinent.rb @@ -1,22 +1,22 @@ class Addresses::Subcontinent < ApplicationHash include Addresses::Subcontinents::Base # 🚅 add concerns above. - + # 🚅 add belongs_to associations above. - + # 🚅 add has_many associations above. - + # 🚅 add oauth providers above. - + # 🚅 add has_one associations above. - + # 🚅 add scopes above. - + # 🚅 add validations above. - + # 🚅 add callbacks above. - + # 🚅 add delegations above. - + # 🚅 add methods above. -end \ No newline at end of file +end diff --git a/test/system/tangible_thing_test.rb b/test/system/tangible_thing_test.rb index a86b40e81..c24652bb0 100644 --- a/test/system/tangible_thing_test.rb +++ b/test/system/tangible_thing_test.rb @@ -41,11 +41,11 @@ class TangibleThingTest < ApplicationSystemTestCase fill_in "Email Field Value", with: "me@acme.com" fill_in "Password Field Value", with: "secure-password" fill_in "Phone Field Value", with: "(201) 551-8321" - + assert page.has_content? "State / Province" select "Japan", from: "Country" assert page.has_content? "Prefecture" - + select "One", from: "Super Select Value" select2_select "Multiple Super Select Values", ["Five", "Six"] fill_in "Text Area Value", with: "Long text for this text area field"