Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Address model, Factory, Addresses::Country and Addresses::Region #635

Merged
merged 10 commits into from
Sep 1, 2023
24 changes: 24 additions & 0 deletions app/models/address.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions app/models/addresses/continent.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions app/models/addresses/country.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions app/models/addresses/region.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions app/models/addresses/subcontinent.rb
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions db/migrate/20230123162616_create_addresses.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 16 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions test/factories/addresses.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions test/system/tangible_thing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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"
Expand Down
Loading