Fixing spec regression

This commit is contained in:
Will Marshall
2014-07-03 12:22:26 +10:00
parent 2f98da8eef
commit fab96b58a7
2 changed files with 3 additions and 3 deletions

View File

@@ -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?

View File

@@ -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