Skip to content

Commit

Permalink
Add some tests on Double Precision
Browse files Browse the repository at this point in the history
  • Loading branch information
brunto committed Mar 4, 2021
1 parent 3d6e8ca commit 3eaad57
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
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
4 changes: 2 additions & 2 deletions spec/operations/nested_save_operation_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}

Expand Down
2 changes: 2 additions & 0 deletions spec/support/factories/business_factory.cr
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
2 changes: 2 additions & 0 deletions spec/support/models/business.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class Business < BaseModel
table do
column name : String
column latitude : Float64?
column longitude : Float64?
has_one tax_id : TaxId
has_one email_address : EmailAddress
end
Expand Down

0 comments on commit 3eaad57

Please sign in to comment.