Fixing spec regression

This commit is contained in:
Will Marshall
2014-07-03 12:22:26 +10:00
committed by Rohan Mitchell
parent 6d4dfad336
commit c57148340c
3 changed files with 38 additions and 32 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,6 +29,7 @@ class Enterprise < ActiveRecord::Base
validates_presence_of :address
validates_associated :address
before_create :initialize_country
before_validation :set_unused_address_fields
after_validation :geocode_address
@@ -206,6 +206,12 @@ 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?
end
def set_unused_address_fields
address.firstname = address.lastname = address.phone = 'unused' if address.present?
end

View File

@@ -1,35 +1,35 @@
= inject_enterprises
-#.producers{"ng-controller" => "ProducersCtrl"}
-#.row
-#.small-12.columns.text-center.pad-top
-#%h1 Producers
-#%div
-#Select a
-#%ofn-modal{title: "producer"}
-#= render partial: "modals/producers"
-#from the list below:
.producers{"ng-controller" => "ProducersCtrl"}
.row
.small-12.columns.text-center.pad-top
%h1 Producers
%div
Select a
%ofn-modal{title: "producer"}
= render partial: "modals/producers"
from the list below:
-##active-table-search.row.pad-top
-#.small-12.columns
-#%i.ofn-i_020-search
-#%input{type: :text,
-#"ng-model" => "query",
-#placeholder: "Search postcode, suburb or producer name...",
-#"ng-debounce" => "150",
-#"ofn-disable-enter" => true}
#active-table-search.row.pad-top
.small-12.columns
%i.ofn-i_020-search
%input{type: :text,
"ng-model" => "query",
placeholder: "Search postcode, suburb or producer name...",
"ng-debounce" => "150",
"ofn-disable-enter" => true}
-#.row{bindonce: true}
-#.small-12.columns
-#.active_table
-#%producer.active_table_node.row.animate-repeat{id: "{{producer.path}}",
-#"scroll-after-load" => true,
-#"ng-repeat" => "producer in filteredProducers = (Producers.visible | filterProducers:query)",
-#"ng-controller" => "ProducerNodeCtrl",
-#"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",
-#id: "{{producer.hash}}"}
.row{bindonce: true}
.small-12.columns
.active_table
%producer.active_table_node.row.animate-repeat{id: "{{producer.path}}",
"scroll-after-load" => true,
"ng-repeat" => "producer in filteredProducers = (Producers.visible | filterProducers:query)",
"ng-controller" => "ProducerNodeCtrl",
"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",
id: "{{producer.hash}}"}
-#.small-12.columns
-#= render partial: 'producers/skinny'
-#= render partial: 'producers/fat'
.small-12.columns
= render partial: 'producers/skinny'
= render partial: 'producers/fat'
-#= render partial: "shared/footer"
= render partial: "shared/footer"

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