mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Fixing spec regression
This commit is contained in:
@@ -17,7 +17,6 @@ class Enterprise < ActiveRecord::Base
|
||||
has_many :distributor_shipping_methods, foreign_key: :distributor_id
|
||||
has_many :shipping_methods, through: :distributor_shipping_methods
|
||||
|
||||
|
||||
delegate :latitude, :longitude, :city, :state_name, :to => :address
|
||||
|
||||
accepts_nested_attributes_for :address
|
||||
@@ -30,7 +29,7 @@ class Enterprise < ActiveRecord::Base
|
||||
validates_presence_of :address
|
||||
validates_associated :address
|
||||
|
||||
after_initialize :initialize_country
|
||||
before_create :initialize_country
|
||||
before_validation :set_unused_address_fields
|
||||
after_validation :geocode_address
|
||||
|
||||
@@ -207,6 +206,7 @@ class Enterprise < ActiveRecord::Base
|
||||
url.andand.sub /(https?:\/\/)?(www\.)?/, ''
|
||||
end
|
||||
|
||||
# Give us an empty address on create, and set the country to the default
|
||||
def initialize_country
|
||||
self.address ||= Spree::Address.new
|
||||
self.address.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record?
|
||||
|
||||
@@ -68,7 +68,7 @@ describe Enterprise do
|
||||
end
|
||||
|
||||
it "should default address country to system country" do
|
||||
subject.address.country.should == Spree::Country.find_by_id(Spree::Config[:default_country_id])
|
||||
create(:distributor_enterprise).address.country.should == Spree::Country.find_by_id(Spree::Config[:default_country_id])
|
||||
end
|
||||
|
||||
describe "scopes" do
|
||||
|
||||
Reference in New Issue
Block a user