Commit 2b7a67f993a4ae381c2ade3839d402db1bbcb12f
1 parent
5efe2b44
Exists in
master
and in
29 other branches
ActionItem1178: fixed bug in Product
It was not properly saving product latitude and longitude.
Showing
2 changed files
with
2 additions
and
1 deletions
Show diff stats
app/models/product.rb
@@ -9,7 +9,7 @@ class Product < ActiveRecord::Base | @@ -9,7 +9,7 @@ class Product < ActiveRecord::Base | ||
9 | 9 | ||
10 | after_update :save_image | 10 | after_update :save_image |
11 | 11 | ||
12 | - after_create do |p| | 12 | + before_create do |p| |
13 | if p.enterprise | 13 | if p.enterprise |
14 | p['lat'] = p.enterprise.lat | 14 | p['lat'] = p.enterprise.lat |
15 | p['lng'] = p.enterprise.lng | 15 | p['lng'] = p.enterprise.lng |
test/unit/product_test.rb
@@ -82,6 +82,7 @@ class ProductTest < Test::Unit::TestCase | @@ -82,6 +82,7 @@ class ProductTest < Test::Unit::TestCase | ||
82 | ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_enterprise', :lat => 30.0, :lng => 30.0 ) | 82 | ent = Enterprise.create!(:name => 'test enterprise', :identifier => 'test_enterprise', :lat => 30.0, :lng => 30.0 ) |
83 | prod = ent.products.create!(:name => 'test product') | 83 | prod = ent.products.create!(:name => 'test product') |
84 | 84 | ||
85 | + prod = Product.find(prod.id) | ||
85 | assert_equal ent.lat, prod.lat | 86 | assert_equal ent.lat, prod.lat |
86 | assert_equal ent.lng, prod.lng | 87 | assert_equal ent.lng, prod.lng |
87 | end | 88 | end |