Merge branch 'master' into units

This commit is contained in:
Rob H
2014-06-04 15:07:28 +10:00
5 changed files with 15 additions and 17 deletions

View File

@@ -28,7 +28,6 @@ Spree::Product.class_eval do
after_initialize :set_available_on_to_now, :if => :new_record?
after_save :update_units
before_save :add_primary_taxon_to_taxons
before_validation :set_primary_taxon_to_first_taxon
# -- Joins
@@ -163,10 +162,6 @@ Spree::Product.class_eval do
end
end
def set_primary_taxon_to_first_taxon
self.primary_taxon = taxons.first unless primary_taxon
end
def add_primary_taxon_to_taxons
taxons << primary_taxon unless taxons.find_by_id(primary_taxon)
end

View File

@@ -3,5 +3,6 @@
.small-12.large-9.columns
%p= current_distributor.long_description.andand.html_safe
.small-12.large-3.columns
%img.about.right{src: current_distributor.promo_image.url(:large)}
/ Hide image until image styles are working correctly:
/ %img.about.right{src: current_distributor.promo_image.url(:large)}

View File

@@ -1,15 +1,18 @@
class AddPrimaryTaxonToProducts < ActiveRecord::Migration
def change
def up
add_column :spree_products, :primary_taxon_id, :integer
<<<<<<< HEAD
<<<<<<< HEAD
add_index :spree_products, :primary_taxon_id
add_foreign_key :spree_products, :spree_taxons, column: :primary_taxon_id
=======
>>>>>>> fd1e7eb... Adding primary taxon field to product
=======
add_index :spree_products, :primary_taxon_id
add_foreign_key :spree_products, :spree_taxons, column: :primary_taxon_id
>>>>>>> 110a6f2... Adding primary taxon to admin forms
Spree::Product.all.each do |p|
p.update_column :primary_taxon_id, (p.taxons.first || Spree::Taxon.first)
end
change_column :spree_products, :primary_taxon_id, :integer, null: false
end
def down
remove_column :spree_products, :primary_taxon_id
end
end

View File

@@ -681,7 +681,7 @@ ActiveRecord::Schema.define(:version => 20140522044009) do
t.float "variant_unit_scale"
t.string "variant_unit_name"
t.text "notes"
t.integer "primary_taxon_id"
t.integer "primary_taxon_id", :null => false
end
add_index "spree_products", ["available_on"], :name => "index_products_on_available_on"

View File

@@ -24,7 +24,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should have_text distributor.name
find("#tab_about a").click
first("distributor img")['src'].should == distributor.logo.url(:thumb)
first("#about img")['src'].should == distributor.promo_image.url(:large)
end
it "shows the producers for a distributor" do