Removing Suburbs from the code

Suburbs are not used any more. Removing the last code bits should avoid
confusion and save a tiny bit of test time.
This commit is contained in:
Maikel Linke
2015-11-25 15:44:27 +11:00
parent d67a5aba0e
commit c4fb4a8510
6 changed files with 3 additions and 16972 deletions

View File

@@ -1,9 +0,0 @@
class Suburb < ActiveRecord::Base
belongs_to :state, :class_name => Spree::State
delegate :name, to: :state, prefix: true
scope :matching , ->(term) {
where("lower(name) like ? or cast(postcode as text) like ?", "%#{term.to_s.downcase}%", "%#{term}%")
}
end

View File

@@ -26,7 +26,3 @@ unless Spree::State.find_by_name 'Victoria'
Spree::State.create!({"name"=>state[0], "abbr"=>state[1], :country=>country}, :without_protection => true)
end
end
# -- Suburbs
require_relative './suburb_seeds'
SuburbSeeder.seed_suburbs unless Suburb.find_by_name("Dayton")

File diff suppressed because it is too large Load Diff

View File

@@ -740,41 +740,6 @@ describe Enterprise do
end
end
describe "geo search" do
before(:each) do
Enterprise.delete_all
state_id_vic = Spree::State.where(abbr: "Vic").first.id
state_id_nsw = Spree::State.where(abbr: "NSW").first.id
@suburb_in_vic = Suburb.create(name: "Camberwell", postcode: 3124, latitude: -37.824818, longitude: 145.057957, state_id: state_id_vic)
@suburb_in_nsw = Suburb.create(name: "Cabramatta", postcode: 2166, latitude: -33.89507, longitude: 150.935889, state_id: state_id_nsw)
address_vic1 = FactoryGirl.create(:address, state_id: state_id_vic, city: "Hawthorn", zipcode: "3123")
address_vic1.update_column(:latitude, -37.842105)
address_vic1.update_column(:longitude, 145.045951)
address_vic2 = FactoryGirl.create(:address, state_id: state_id_vic, city: "Richmond", zipcode: "3121")
address_vic2.update_column(:latitude, -37.826869)
address_vic2.update_column(:longitude, 145.007098)
FactoryGirl.create(:distributor_enterprise, address: address_vic1)
FactoryGirl.create(:distributor_enterprise, address: address_vic2)
end
it "should find nearby hubs if there are any" do
Enterprise.find_near(@suburb_in_vic).count.should eql(2)
end
it "should not have nils in the result" do
Enterprise.find_near(@suburb_in_vic).should_not include(nil)
end
it "should not find hubs if not nearby " do
Enterprise.find_near(@suburb_in_nsw).count.should eql(0)
end
end
describe "taxons" do
let(:distributor) { create(:distributor_enterprise) }
let(:supplier) { create(:supplier_enterprise) }

View File

@@ -6,11 +6,11 @@ describe ModelSet do
attrs = {collection_attributes: {'1' => {name: 's1'},
'2' => {name: 's2'}}}
ms = ModelSet.new(Suburb, Suburb.all, attrs)
ms = ModelSet.new(EnterpriseRelationshipPermission, EnterpriseRelationshipPermission.all, attrs)
expect { ms.save }.to change(Suburb, :count).by(2)
expect { ms.save }.to change(EnterpriseRelationshipPermission, :count).by(2)
Suburb.where(name: ['s1', 's2']).count.should == 2
EnterpriseRelationshipPermission.where(name: ['s1', 's2']).count.should == 2
end

View File

@@ -1,24 +0,0 @@
require 'spec_helper'
describe Suburb do
it { should belong_to(:state) }
it { should delegate(:name).to(:state).with_prefix }
describe "searching for matching suburbs" do
before(:each) do
Suburb.create(name: "Camberwell", postcode: 3124, latitude: -37.824818, longitude: 145.057957, state_id: Spree::State.first)
end
it "should find suburb on part of name" do
Suburb.matching("Camb").count.should be > 0
end
it "should find suburb on part of postcode" do
Suburb.matching(312).count.should be > 0
end
it "should find nothing where part doesn't match" do
Suburb.matching("blahblah1234#!!!").count.should_not be > 0
end
end
end