Skip to content

Commit 685484b

Browse files
committed
Geocoder implemeted in tests, revert of changes in schema and other minor requested changes
1 parent feafcd7 commit 685484b

3 files changed

Lines changed: 11 additions & 33 deletions

File tree

app/models/donation_site.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class DonationSite < ApplicationRecord
2222

2323
belongs_to :organization
2424

25-
validates :name, presence: true
26-
validates :address, presence: true
25+
validates :name, :address, presence: true
2726
validates :name, uniqueness: {scope: :organization_id, message: "must be unique within the organization"}
2827
validates :contact_name, length: {minimum: 3}, allow_blank: true
2928
validates :email, format: {with: URI::MailTo::EMAIL_REGEXP, message: "is not a valid email format"}, allow_blank: true

db/schema.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,6 @@
231231
t.index ["user_id"], name: "index_deprecated_feedback_messages_on_user_id"
232232
end
233233

234-
create_table "diaper_drive_participants", id: :serial, force: :cascade do |t|
235-
t.string "contact_name"
236-
t.string "email"
237-
t.string "phone"
238-
t.string "comment"
239-
t.integer "organization_id"
240-
t.datetime "created_at", precision: nil, null: false
241-
t.datetime "updated_at", precision: nil, null: false
242-
t.string "address"
243-
t.string "business_name"
244-
t.float "latitude"
245-
t.float "longitude"
246-
t.index ["latitude", "longitude"], name: "index_diaper_drive_participants_on_latitude_and_longitude"
247-
end
248-
249234
create_table "distributions", id: :serial, force: :cascade do |t|
250235
t.text "comment"
251236
t.datetime "created_at", precision: nil, null: false
@@ -341,16 +326,6 @@
341326
t.index ["partner_id"], name: "index_families_on_partner_id"
342327
end
343328

344-
create_table "feedback_messages", force: :cascade do |t|
345-
t.bigint "user_id"
346-
t.string "message"
347-
t.string "path"
348-
t.datetime "created_at", precision: nil, null: false
349-
t.datetime "updated_at", precision: nil, null: false
350-
t.boolean "resolved"
351-
t.index ["user_id"], name: "index_feedback_messages_on_user_id"
352-
end
353-
354329
create_table "flipper_features", force: :cascade do |t|
355330
t.string "key", null: false
356331
t.datetime "created_at", precision: nil, null: false

spec/models/donation_site_spec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@
1616
# organization_id :integer
1717
#
1818

19-
require "rails_helper"
20-
2119
RSpec.describe DonationSite, type: :model do
2220
context "Validations >" do
2321
it { should belong_to(:organization) }
2422
it { should validate_presence_of(:name) }
2523
it { should validate_presence_of(:address) }
2624
end
2725

26+
before(:each) do
27+
Geocoder.configure(lookup: :test)
28+
29+
Geocoder::Lookup::Test.add_stub(
30+
"456 Donation Site Blvd", [
31+
{"latitude" => 38.8977, "longitude" => -77.0365, "address" => "456 Donation Site Blvd"}
32+
]
33+
)
34+
end
35+
2836
describe "import_csv" do
2937
let(:organization) { create(:organization) }
3038
let(:valid_csv_path) { Rails.root.join("spec", "fixtures", "files", "valid_donation_sites.csv") }
3139
let(:invalid_csv_path) { Rails.root.join("spec", "fixtures", "files", "invalid_donation_sites.csv") }
3240
let(:duplicated_name_csv_path) { Rails.root.join("spec", "fixtures", "files", "duplicated_name_donation_sites.csv") }
3341

34-
before do
35-
allow_any_instance_of(DonationSite).to receive(:geocode).and_return([40.7128, -74.0060])
36-
end
37-
3842
it "captures the error if the name is not unique in the invalid donation sites csv" do
3943
data = File.read(duplicated_name_csv_path, encoding: "BOM|UTF-8")
4044
csv = CSV.parse(data, headers: true)

0 commit comments

Comments
 (0)