Skip to content

Commit

Permalink
228 remove location columns on organizations table and add zipcode to…
Browse files Browse the repository at this point in the history
… locations table (#230)

* Remove location fields to Organization

* Add zipcode field to locations

* Fix seeds

* Add zipcode to location factory

* WIP: Remove organization.city usage from views/organizations/home/index.html.erb

* Run automatic fixer

* Remove unecessary comment
  • Loading branch information
yuricarvalhop authored and ErinClaudio committed Oct 3, 2023
1 parent 7c655e1 commit 11802f5
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 20 deletions.
1 change: 1 addition & 0 deletions app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# latitude :float
# longitude :float
# province_state :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
#
Expand Down
3 changes: 0 additions & 3 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
# Table name: organizations
#
# id :bigint not null, primary key
# city :string
# country :string
# name :string
# slug :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
#
Expand Down
2 changes: 1 addition & 1 deletion app/views/organizations/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="row d-flex align-items-center">
<div class="col-xxl-5 col-xl-6 col-lg-6 col-12">
<div>
<h1 class="display-2 fw-bold mb-3">Rescue pets in <%= Current.organization.city %> at <u class="text-warning"><span class="text-primary"> <%= Current.organization.name %></span></u></h1>
<h1 class="display-2 fw-bold mb-3">Rescue pets near you at <u class="text-warning"><span class="text-primary"> <%= Current.organization.name %></span></u></h1>
<p class="lead mb-4">Rescue a really cute pet and be a hero</p>
<ul class="list-unstyled mb-5">
<li class="mb-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class RemoveLocationFieldsFromOrganizations < ActiveRecord::Migration[7.0]
def up
safety_assured do
remove_column :organizations, :city, :string
remove_column :organizations, :country, :string
remove_column :organizations, :zipcode, :string
end
end

def down
add_column :organizations, :city, :string
add_column :organizations, :country, :string
add_column :organizations, :zipcode, :string
end
end
9 changes: 9 additions & 0 deletions db/migrate/20231003095748_add_zipcode_to_locations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddZipcodeToLocations < ActiveRecord::Migration[7.0]
def up
add_column :locations, :zipcode, :string
end

def down
safety_assured { remove_column :locations, :zipcode, :string }
end
end
6 changes: 2 additions & 4 deletions db/schema.rb

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

12 changes: 6 additions & 6 deletions db/seeds/01_alta.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
organization = Organization.create!(
name: "Alta Pet Rescue",
city: "Alta",
country: "Mexico",
zipcode: "12345",
slug: "alta"
)

Expand Down Expand Up @@ -75,7 +72,8 @@
@location_one = Location.create!(
country: "Canada",
province_state: "Alberta",
city_town: "Canmore"
city_town: "Canmore",
zipcode: "12345"
)

@adopter_profile_one = AdopterProfile.create!(
Expand Down Expand Up @@ -118,7 +116,8 @@
@location_two = Location.create!(
country: "USA",
province_state: "Nevada",
city_town: "Reno"
city_town: "Reno",
zipcode: "12345"
)

@adopter_profile_two = AdopterProfile.create!(
Expand Down Expand Up @@ -164,7 +163,8 @@
@location_three = Location.create!(
country: "Nonsense",
province_state: "Nonsense",
city_town: "Nonsense"
city_town: "Nonsense",
zipcode: "12345"
)

@adopter_profile_three = AdopterProfile.create!(
Expand Down
12 changes: 6 additions & 6 deletions db/seeds/02_baja.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
organization = Organization.create!(
name: "Baja",
city: "Baja",
country: "Mexico",
zipcode: "12345",
slug: "baja"
)
ActsAsTenant.with_tenant(organization) do
Expand Down Expand Up @@ -74,7 +71,8 @@
@location_one = Location.create!(
country: "Canada",
province_state: "Alberta",
city_town: "Canmore"
city_town: "Canmore",
zipcode: "12345"
)

@adopter_profile_one = AdopterProfile.create!(
Expand Down Expand Up @@ -117,7 +115,8 @@
@location_two = Location.create!(
country: "USA",
province_state: "Nevada",
city_town: "Reno"
city_town: "Reno",
zipcode: "12345"
)

@adopter_profile_two = AdopterProfile.create!(
Expand Down Expand Up @@ -163,7 +162,8 @@
@location_three = Location.create!(
country: "Nonsense",
province_state: "Nonsense",
city_town: "Nonsense"
city_town: "Nonsense",
zipcode: "12345"
)

@adopter_profile_three = AdopterProfile.create!(
Expand Down
1 change: 1 addition & 0 deletions test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
city_town { Faker::Address.city }
sequence(:country) { |n| "Country#{n}" }
province_state { Faker::Address.state }
zipcode { Faker::Address.zip_code }

trait :with_adopter_profile do
after :create do |location|
Expand Down

0 comments on commit 11802f5

Please sign in to comment.