-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
db/migrations/20210217224833_add_latitude_and_longitude_to_businesses.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class AddLatitudeAndLongitudeToBusinesses::V20210217224833 < Avram::Migrator::Migration::V1 | ||
def migrate | ||
execute <<-SQL | ||
ALTER TABLE businesses | ||
ADD COLUMN latitude DOUBLE PRECISION, | ||
ADD COLUMN longitude DOUBLE PRECISION; | ||
SQL | ||
end | ||
|
||
def rollback | ||
alter :businesses do | ||
remove :latitude | ||
remove :longitude | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ private class SaveBusiness < Business::SaveOperation | |
permit_columns number | ||
end | ||
|
||
permit_columns name | ||
permit_columns name, latitude, longitude | ||
has_one save_email_address : SaveEmailAddress | ||
has_one save_tax_id : SaveTaxId | ||
end | ||
|
@@ -136,7 +136,7 @@ describe "Avram::SaveOperation with nested operation" do | |
|
||
context "when all forms are valid" do | ||
it "sets the relationship and creates both" do | ||
params = NestedParams.new business: {"name" => "Fubar"}, | ||
params = NestedParams.new business: {"name" => "Fubar", "latitude" => "46.383488", "longitude" => "22.774896"}, | ||
email_address: {"address" => "[email protected]"}, | ||
tax_id: {"number" => "123"} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class BusinessFactory < BaseFactory | ||
def initialize | ||
name "My Biz" | ||
latitude 46.383488 | ||
longitude 22.774896 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters