Commit 196faf057f9b1e3187005cd4ec24e9339672ab4e

Authored by Braulio Bhavamitra
1 parent 3f7a7a8b

Add STI, serialized field and rename enterprise_id

app/models/enterprise.rb
... ... @@ -10,7 +10,7 @@ class Enterprise < Organization
10 10  
11 11 N_('Enterprise')
12 12  
13   - has_many :products, :dependent => :destroy, :order => 'name ASC'
  13 + has_many :products, :foreign_key => :profile_id, :dependent => :destroy, :order => 'name ASC'
14 14 has_many :inputs, :through => :products
15 15 has_many :production_costs, :as => :owner
16 16  
... ...
app/models/environment.rb
... ... @@ -792,7 +792,7 @@ class Environment < ActiveRecord::Base
792 792 end
793 793  
794 794 def highlighted_products_with_image(options = {})
795   - Product.find(:all, {:conditions => {:highlighted => true, :enterprise_id => self.enterprises.find(:all, :select => :id) }, :joins => :image}.merge(options))
  795 + Product.find(:all, {:conditions => {:highlighted => true, :profile_id => self.enterprises.find(:all, :select => :id) }, :joins => :image}.merge(options))
796 796 end
797 797  
798 798 settings_items :home_cache_in_minutes, :type => :integer, :default => 5
... ...
app/models/product.rb
... ... @@ -15,7 +15,8 @@ class Product < ActiveRecord::Base
15 15 'full'
16 16 end
17 17  
18   - belongs_to :enterprise
  18 + belongs_to :enterprise, :foreign_key => :profile_id, :class_name => 'Profile'
  19 + belongs_to :profile
19 20 has_one :region, :through => :enterprise
20 21 validates_presence_of :enterprise
21 22  
... ... @@ -29,7 +30,9 @@ class Product < ActiveRecord::Base
29 30 has_many :qualifiers, :through => :product_qualifiers
30 31 has_many :certifiers, :through => :product_qualifiers
31 32  
32   - validates_uniqueness_of :name, :scope => :enterprise_id, :allow_nil => true
  33 + acts_as_having_settings :field => :data
  34 +
  35 + validates_uniqueness_of :name, :scope => :profile_id, :allow_nil => true
33 36 validates_presence_of :product_category_id
34 37 validates_associated :product_category
35 38  
... ...
db/migrate/20130702135550_add_sti_and_serialized_data_to_products.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +class AddStiAndSerializedDataToProducts < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :products, :type, :string
  4 + add_column :products, :data, :text
  5 + rename_column :products, :enterprise_id, :profile_id
  6 + end
  7 +
  8 + def self.down
  9 + remove_column :products, :type
  10 + remove_column :products, :data
  11 + rename_column :products, :profile_id, :enterprise_id
  12 + end
  13 +end
... ...
plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb
... ... @@ -199,7 +199,7 @@ class BscPluginMyprofileController &lt; MyProfileController
199 199 enterprises = enterprises.blank? ? -1 : enterprises
200 200 added_products = (params[:added_products] || []).split(',')
201 201 added_products = added_products.blank? ? -1 : added_products
202   - render :text => Product.find(:all, :conditions => ["LOWER(name) LIKE ? AND enterprise_id IN (?) AND id NOT IN (?)", "%#{query}%", enterprises, added_products]).
  202 + render :text => Product.find(:all, :conditions => ["LOWER(name) LIKE ? AND profile_id IN (?) AND id NOT IN (?)", "%#{query}%", enterprises, added_products]).
203 203 map {|product| { :id => product.id,
204 204 :name => short_text(product_display_name(product), 60),
205 205 :sale_id => params[:sale_id],
... ...
plugins/bsc/lib/bsc_plugin/bsc.rb
... ... @@ -2,7 +2,7 @@ class BscPlugin::Bsc &lt; Enterprise
2 2  
3 3 has_many :enterprises
4 4 has_many :enterprise_requests, :class_name => 'BscPlugin::AssociateEnterprise'
5   - has_many :products, :finder_sql => 'select * from products where enterprise_id in (#{enterprises.map(&:id).join(",")})'
  5 + has_many :products, :finder_sql => 'select * from products where profile_id in (#{enterprises.map(&:id).join(",")})'
6 6 has_many :contracts, :class_name => 'BscPlugin::Contract'
7 7  
8 8 validates_presence_of :nickname
... ...
plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb
... ... @@ -308,9 +308,9 @@ class BscPluginMyprofileControllerTest &lt; ActionController::TestCase
308 308 enterprise1 = fast_create(Enterprise)
309 309 enterprise2 = fast_create(Enterprise)
310 310 enterprise3 = fast_create(Enterprise)
311   - product1 = fast_create(Product, :enterprise_id => enterprise1.id, :name => 'Black Bycicle')
312   - product2 = fast_create(Product, :enterprise_id => enterprise2.id, :name => 'Black Guitar')
313   - product3 = fast_create(Product, :enterprise_id => enterprise3.id, :name => 'Black Notebook')
  311 + product1 = fast_create(Product, :profile_id => enterprise1.id, :name => 'Black Bycicle')
  312 + product2 = fast_create(Product, :profile_id => enterprise2.id, :name => 'Black Guitar')
  313 + product3 = fast_create(Product, :profile_id => enterprise3.id, :name => 'Black Notebook')
314 314  
315 315 get :search_sale_product, :profile => bsc.identifier, :enterprises => [enterprise1.id,enterprise2.id].join(','), :added_products => [product2.id].join(','),:sales => {1 => {:product_id => 'black'}}
316 316  
... ...
plugins/bsc/test/unit/ext/product_test.rb
... ... @@ -6,7 +6,7 @@ class ProductTest &lt; ActiveSupport::TestCase
6 6 should 'return have bsc' do
7 7 bsc = BscPlugin::Bsc.create!({:business_name => 'Sample Bsc', :identifier => 'sample-bsc', :company_name => 'Sample Bsc Ltda.', :cnpj => VALID_CNPJ})
8 8 enterprise = fast_create(Enterprise, :bsc_id => bsc.id)
9   - product = fast_create(Product, :enterprise_id => enterprise.id)
  9 + product = fast_create(Product, :profile_id => enterprise.id)
10 10  
11 11 assert_equal bsc, product.bsc
12 12 end
... ...
plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb
... ... @@ -13,12 +13,12 @@ class ShoppingCartPluginController &lt; PublicController
13 13 def get
14 14 config =
15 15 if cart.nil?
16   - { :enterprise_id => nil,
  16 + { :profile_id => nil,
17 17 :has_products => false,
18 18 :visible => false,
19 19 :products => []}
20 20 else
21   - { :enterprise_id => cart[:enterprise_id],
  21 + { :profile_id => cart[:profile_id],
22 22 :has_products => (cart[:items].keys.size > 0),
23 23 :visible => visible?,
24 24 :products => products}
... ... @@ -29,7 +29,7 @@ class ShoppingCartPluginController &lt; PublicController
29 29 def add
30 30 product = find_product(params[:id])
31 31 if product && enterprise = validate_same_enterprise(product)
32   - self.cart = { :enterprise_id => enterprise.id, :items => {} } if self.cart.nil?
  32 + self.cart = { :profile_id => enterprise.id, :items => {} } if self.cart.nil?
33 33 self.cart[:items][product.id] = 0 if self.cart[:items][product.id].nil?
34 34 self.cart[:items][product.id] += 1
35 35 render :text => {
... ... @@ -95,7 +95,7 @@ class ShoppingCartPluginController &lt; PublicController
95 95  
96 96 def buy
97 97 @cart = cart
98   - @enterprise = environment.enterprises.find(cart[:enterprise_id])
  98 + @enterprise = environment.enterprises.find(cart[:profile_id])
99 99 @settings = Noosfero::Plugin::Settings.new(@enterprise, ShoppingCartPlugin)
100 100 render :layout => false
101 101 end
... ... @@ -103,7 +103,7 @@ class ShoppingCartPluginController &lt; PublicController
103 103 def send_request
104 104 register_order(params[:customer], self.cart[:items])
105 105 begin
106   - enterprise = environment.enterprises.find(cart[:enterprise_id])
  106 + enterprise = environment.enterprises.find(cart[:profile_id])
107 107 ShoppingCartPlugin::Mailer.deliver_customer_notification(params[:customer], enterprise, self.cart[:items], params[:delivery_option])
108 108 ShoppingCartPlugin::Mailer.deliver_supplier_notification(params[:customer], enterprise, self.cart[:items], params[:delivery_option])
109 109 self.cart = nil
... ... @@ -166,7 +166,7 @@ class ShoppingCartPluginController &lt; PublicController
166 166 end
167 167  
168 168 def update_delivery_option
169   - enterprise = environment.enterprises.find(cart[:enterprise_id])
  169 + enterprise = environment.enterprises.find(cart[:profile_id])
170 170 settings = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin)
171 171 delivery_price = settings.delivery_options[params[:delivery_option]]
172 172 delivery = Product.new(:name => params[:delivery_option], :price => delivery_price)
... ... @@ -187,7 +187,7 @@ class ShoppingCartPluginController &lt; PublicController
187 187 private
188 188  
189 189 def validate_same_enterprise(product)
190   - if self.cart && self.cart[:enterprise_id] && product.enterprise_id != self.cart[:enterprise_id]
  190 + if self.cart && self.cart[:profile_id] && product.profile_id != self.cart[:profile_id]
191 191 render :text => {
192 192 :ok => false,
193 193 :error => {
... ... @@ -266,7 +266,7 @@ class ShoppingCartPluginController &lt; PublicController
266 266 new_items[id] = {:quantity => quantity, :price => price, :name => product.name}
267 267 end
268 268 ShoppingCartPlugin::PurchaseOrder.create!(
269   - :seller => Enterprise.find(cart[:enterprise_id]),
  269 + :seller => Enterprise.find(cart[:profile_id]),
270 270 :customer => user,
271 271 :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED,
272 272 :products_list => new_items,
... ...
plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
... ... @@ -11,7 +11,7 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
11 11 @request = ActionController::TestRequest.new
12 12 @response = ActionController::TestResponse.new
13 13 @enterprise = fast_create(Enterprise)
14   - @product = fast_create(Product, :enterprise_id => @enterprise.id)
  14 + @product = fast_create(Product, :profile_id => @enterprise.id)
15 15 end
16 16 attr_reader :enterprise
17 17 attr_reader :product
... ... @@ -62,7 +62,7 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
62 62 end
63 63  
64 64 should 'just remove product if there are other products on cart' do
65   - another_product = fast_create(Product, :enterprise_id => enterprise.id)
  65 + another_product = fast_create(Product, :profile_id => enterprise.id)
66 66 get :add, :id => product.id
67 67 get :add, :id => another_product.id
68 68  
... ... @@ -135,7 +135,7 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
135 135 end
136 136  
137 137 should 'clean the cart' do
138   - another_product = fast_create(Product, :enterprise_id => enterprise.id)
  138 + another_product = fast_create(Product, :profile_id => enterprise.id)
139 139 get :add, :id => product.id
140 140 get :add, :id => another_product.id
141 141  
... ... @@ -150,9 +150,9 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
150 150 end
151 151  
152 152 should 'register order on send request' do
153   - product1 = fast_create(Product, :enterprise_id => enterprise.id, :price => 1.99)
154   - product2 = fast_create(Product, :enterprise_id => enterprise.id, :price => 2.23)
155   - @controller.stubs(:cart).returns({ :enterprise_id => enterprise.id, :items => {product1.id => 1, product2.id => 2}})
  153 + product1 = fast_create(Product, :profile_id => enterprise.id, :price => 1.99)
  154 + product2 = fast_create(Product, :profile_id => enterprise.id, :price => 2.23)
  155 + @controller.stubs(:cart).returns({ :profile_id => enterprise.id, :items => {product1.id => 1, product2.id => 2}})
156 156 assert_difference ShoppingCartPlugin::PurchaseOrder, :count, 1 do
157 157 post :send_request,
158 158 :customer => {:name => "Manuel", :email => "manuel@ceu.com"}
... ... @@ -168,8 +168,8 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
168 168 end
169 169  
170 170 should 'register order on send request and not crash if product is not defined' do
171   - product1 = fast_create(Product, :enterprise_id => enterprise.id)
172   - @controller.stubs(:cart).returns({ :enterprise_id => enterprise.id, :items => {product1.id => 1}})
  171 + product1 = fast_create(Product, :profile_id => enterprise.id)
  172 + @controller.stubs(:cart).returns({ :profile_id => enterprise.id, :items => {product1.id => 1}})
173 173 assert_difference ShoppingCartPlugin::PurchaseOrder, :count, 1 do
174 174 post :send_request,
175 175 :customer => {:name => "Manuel", :email => "manuel@ceu.com"}
... ... @@ -181,7 +181,7 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
181 181 end
182 182  
183 183 should 'clean the cart after placing the order' do
184   - product1 = fast_create(Product, :enterprise_id => enterprise.id)
  184 + product1 = fast_create(Product, :profile_id => enterprise.id)
185 185 post :add, :id => product1.id
186 186 post :send_request, :customer => { :name => "Manuel", :email => "manuel@ceu.com" }
187 187 assert !cart?, "cart expected to be empty!"
... ...
plugins/solr/features/.search_products.feature.swp
No preview for this file type
plugins/solr/lib/.solr_plugin.rb.swp
No preview for this file type
plugins/solr/lib/solr_plugin/.search_helper.rb.swp
No preview for this file type
plugins/solr/test/functional/.search_controller_test.rb.swp
No preview for this file type
plugins/solr/test/functional/search_controller_test.rb
... ... @@ -81,7 +81,7 @@ class SearchControllerTest &lt; ActionController::TestCase
81 81 state = fast_create(State, :name => 'Acre', :acronym => 'AC')
82 82 city = fast_create(City, :name => 'Rio Branco', :parent_id => state.id)
83 83 ent = fast_create(Enterprise, :region_id => city.id)
84   - prod = Product.create!(:name => 'Sound System', :enterprise_id => ent.id, :product_category_id => @product_category.id)
  84 + prod = Product.create!(:name => 'Sound System', :profile_id => ent.id, :product_category_id => @product_category.id)
85 85 qualifier1 = fast_create(Qualifier)
86 86 qualifier2 = fast_create(Qualifier)
87 87 prod.qualifiers_list = [[qualifier1.id, 0], [qualifier2.id, 0]]
... ... @@ -159,7 +159,7 @@ class SearchControllerTest &lt; ActionController::TestCase
159 159 prod_cat = ProductCategory.create!(:name => 'prod cat test', :environment => Environment.default)
160 160 ent = create_profile_with_optional_category(Enterprise, 'test enterprise')
161 161 (1..SearchController::LIST_SEARCH_LIMIT+5).each do |n|
162   - fast_create(Product, {:name => "produto #{n}", :enterprise_id => ent.id, :product_category_id => prod_cat.id}, :search => true)
  162 + fast_create(Product, {:name => "produto #{n}", :profile_id => ent.id, :product_category_id => prod_cat.id}, :search => true)
163 163 end
164 164  
165 165 get :products
... ... @@ -183,13 +183,13 @@ class SearchControllerTest &lt; ActionController::TestCase
183 183  
184 184 cat = fast_create(ProductCategory)
185 185 ent1 = Enterprise.create!(:name => 'ent1', :identifier => 'ent1', :lat => '1.3', :lng => '1.3')
186   - prod1 = Product.create!(:name => 'produto 1', :enterprise_id => ent1.id, :product_category_id => cat.id)
  186 + prod1 = Product.create!(:name => 'produto 1', :profile_id => ent1.id, :product_category_id => cat.id)
187 187 ent2 = Enterprise.create!(:name => 'ent2', :identifier => 'ent2', :lat => '2.0', :lng => '2.0')
188   - prod2 = Product.create!(:name => 'produto 2', :enterprise_id => ent2.id, :product_category_id => cat.id)
  188 + prod2 = Product.create!(:name => 'produto 2', :profile_id => ent2.id, :product_category_id => cat.id)
189 189 ent3 = Enterprise.create!(:name => 'ent3', :identifier => 'ent3', :lat => '1.6', :lng => '1.6')
190   - prod3 = Product.create!(:name => 'produto 3', :enterprise_id => ent3.id, :product_category_id => cat.id)
  190 + prod3 = Product.create!(:name => 'produto 3', :profile_id => ent3.id, :product_category_id => cat.id)
191 191 ent4 = Enterprise.create!(:name => 'ent4', :identifier => 'ent4', :lat => '10', :lng => '10')
192   - prod4 = Product.create!(:name => 'produto 4', :enterprise_id => ent4.id, :product_category_id => cat.id)
  192 + prod4 = Product.create!(:name => 'produto 4', :profile_id => ent4.id, :product_category_id => cat.id)
193 193  
194 194 get :products
195 195 assert_equivalent [prod1, prod3, prod2], assigns(:searches)[:products][:results].docs
... ... @@ -216,9 +216,9 @@ class SearchControllerTest &lt; ActionController::TestCase
216 216  
217 217 should 'order product results by more recent when requested' do
218 218 ent = fast_create(Enterprise)
219   - prod1 = Product.create!(:name => 'product 1', :enterprise_id => ent.id, :product_category_id => @product_category.id)
220   - prod2 = Product.create!(:name => 'product 2', :enterprise_id => ent.id, :product_category_id => @product_category.id)
221   - prod3 = Product.create!(:name => 'product 3', :enterprise_id => ent.id, :product_category_id => @product_category.id)
  219 + prod1 = Product.create!(:name => 'product 1', :profile_id => ent.id, :product_category_id => @product_category.id)
  220 + prod2 = Product.create!(:name => 'product 2', :profile_id => ent.id, :product_category_id => @product_category.id)
  221 + prod3 = Product.create!(:name => 'product 3', :profile_id => ent.id, :product_category_id => @product_category.id)
222 222  
223 223 # change others attrs will make updated_at = Time.now for all
224 224 Product.record_timestamps = false
... ... @@ -235,8 +235,8 @@ class SearchControllerTest &lt; ActionController::TestCase
235 235 should 'only list products from enabled enterprises' do
236 236 ent1 = fast_create(Enterprise, :enabled => true)
237 237 ent2 = fast_create(Enterprise, :enabled => false)
238   - prod1 = Product.create!(:name => 'product 1', :enterprise_id => ent1.id, :product_category_id => @product_category.id)
239   - prod2 = Product.create!(:name => 'product 2', :enterprise_id => ent2.id, :product_category_id => @product_category.id)
  238 + prod1 = Product.create!(:name => 'product 1', :profile_id => ent1.id, :product_category_id => @product_category.id)
  239 + prod2 = Product.create!(:name => 'product 2', :profile_id => ent2.id, :product_category_id => @product_category.id)
240 240  
241 241 get :products, :query => 'product'
242 242  
... ... @@ -246,9 +246,9 @@ class SearchControllerTest &lt; ActionController::TestCase
246 246  
247 247 should 'order product results by name when requested' do
248 248 ent = fast_create(Enterprise)
249   - prod1 = Product.create!(:name => 'product 1', :enterprise_id => ent.id, :product_category_id => @product_category.id)
250   - prod2 = Product.create!(:name => 'product 2', :enterprise_id => ent.id, :product_category_id => @product_category.id)
251   - prod3 = Product.create!(:name => 'product 3', :enterprise_id => ent.id, :product_category_id => @product_category.id)
  249 + prod1 = Product.create!(:name => 'product 1', :profile_id => ent.id, :product_category_id => @product_category.id)
  250 + prod2 = Product.create!(:name => 'product 2', :profile_id => ent.id, :product_category_id => @product_category.id)
  251 + prod3 = Product.create!(:name => 'product 3', :profile_id => ent.id, :product_category_id => @product_category.id)
252 252  
253 253 prod3.update_attribute :name, 'product A'
254 254 prod2.update_attribute :name, 'product B'
... ... @@ -269,11 +269,11 @@ class SearchControllerTest &lt; ActionController::TestCase
269 269  
270 270 cat = fast_create(ProductCategory)
271 271 ent1 = Enterprise.create!(:name => 'ent1', :identifier => 'ent1', :lat => '-5.0', :lng => '-5.0')
272   - prod1 = Product.create!(:name => 'product 1', :enterprise_id => ent1.id, :product_category_id => cat.id)
  272 + prod1 = Product.create!(:name => 'product 1', :profile_id => ent1.id, :product_category_id => cat.id)
273 273 ent2 = Enterprise.create!(:name => 'ent2', :identifier => 'ent2', :lat => '2.0', :lng => '2.0')
274   - prod2 = Product.create!(:name => 'product 2', :enterprise_id => ent2.id, :product_category_id => cat.id)
  274 + prod2 = Product.create!(:name => 'product 2', :profile_id => ent2.id, :product_category_id => cat.id)
275 275 ent3 = Enterprise.create!(:name => 'ent3', :identifier => 'ent3', :lat => '10.0', :lng => '10.0')
276   - prod3 = Product.create!(:name => 'product 3', :enterprise_id => ent3.id, :product_category_id => cat.id)
  276 + prod3 = Product.create!(:name => 'product 3', :profile_id => ent3.id, :product_category_id => cat.id)
277 277  
278 278 get :products, :query => 'product', :order_by => :closest
279 279 assert_equal [prod2, prod1, prod3], assigns(:searches)[:products][:results].docs
... ...
plugins/solr/test/unit/enterprise_test.rb
... ... @@ -11,7 +11,7 @@ class EnterpriseTest &lt; ActiveSupport::TestCase
11 11  
12 12 should 'reindex when products are changed' do
13 13 enterprise = fast_create(Enterprise)
14   - product = fast_create(Product, :enterprise_id => enterprise.id, :product_category_id => product_category.id)
  14 + product = fast_create(Product, :profile_id => enterprise.id, :product_category_id => product_category.id)
15 15 Product.expects(:solr_batch_add_association).with(product, :enterprise)
16 16 product.update_attribute :name, "novo nome"
17 17 end
... ...
plugins/solr/test/unit/product_test.rb
... ... @@ -13,7 +13,7 @@ class ProductTest &lt; ActiveSupport::TestCase
13 13 should 'reindex enterprise after saving' do
14 14 ent = fast_create(Enterprise)
15 15 cat = fast_create(ProductCategory)
16   - prod = Product.create!(:name => 'something', :enterprise_id => ent.id, :product_category_id => cat.id)
  16 + prod = Product.create!(:name => 'something', :profile_id => ent.id, :product_category_id => cat.id)
17 17 Product.expects(:solr_batch_add).with([ent])
18 18 prod.save!
19 19 end
... ... @@ -23,7 +23,7 @@ class ProductTest &lt; ActiveSupport::TestCase
23 23 c = fast_create(City, :name => 'Tabajara', :parent_id => s.id)
24 24 ent = fast_create(Enterprise, :region_id => c.id)
25 25 cat = fast_create(ProductCategory, :name => 'hardcore')
26   - p = Product.create!(:name => 'black flag', :enterprise_id => ent.id, :product_category_id => cat.id)
  26 + p = Product.create!(:name => 'black flag', :profile_id => ent.id, :product_category_id => cat.id)
27 27 pq = p.product_qualifiers.create!(:qualifier => fast_create(Qualifier, :name => 'qualifier'),
28 28 :certifier => fast_create(Certifier, :name => 'certifier'))
29 29 assert_equal 'Related products', Product.facet_by_id(:solr_plugin_f_category)[:label]
... ... @@ -39,7 +39,7 @@ class ProductTest &lt; ActiveSupport::TestCase
39 39 c = fast_create(City, :name => 'Tabajara', :parent_id => s.id)
40 40 ent = fast_create(Enterprise, :region_id => c.id, :name => "Black Sun")
41 41 category = fast_create(ProductCategory, :name => "homemade", :acronym => "hm", :abbreviation => "homey")
42   - p = Product.create!(:name => 'bananas syrup', :description => 'surrounded by mosquitos', :enterprise_id => ent.id,
  42 + p = Product.create!(:name => 'bananas syrup', :description => 'surrounded by mosquitos', :profile_id => ent.id,
43 43 :product_category_id => category.id)
44 44 qual = Qualifier.create!(:name => 'qualificador', :environment_id => Environment.default.id)
45 45 cert = Certifier.create!(:name => 'certificador', :environment_id => Environment.default.id)
... ... @@ -70,28 +70,28 @@ class ProductTest &lt; ActiveSupport::TestCase
70 70 TestSolr.enable
71 71 ent = fast_create(Enterprise)
72 72 cat = fast_create(ProductCategory)
73   - in_desc = Product.create!(:name => 'something', :enterprise_id => ent.id, :description => 'bananas in the description!',
  73 + in_desc = Product.create!(:name => 'something', :profile_id => ent.id, :description => 'bananas in the description!',
74 74 :product_category_id => cat.id)
75   - in_name = Product.create!(:name => 'bananas in the name!', :enterprise_id => ent.id, :product_category_id => cat.id)
  75 + in_name = Product.create!(:name => 'bananas in the name!', :profile_id => ent.id, :product_category_id => cat.id)
76 76 assert_equal [in_name, in_desc], Product.find_by_contents('bananas')[:results].docs
77 77 end
78 78  
79 79 should 'boost search results that include an image' do
80 80 TestSolr.enable
81 81 product_without_image = Product.create!(:name => 'product without image', :product_category => product_category,
82   - :enterprise_id => profile.id)
  82 + :profile_id => profile.id)
83 83 product_with_image = Product.create!(:name => 'product with image', :product_category => product_category,
84 84 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')},
85   - :enterprise_id => profile.id)
  85 + :profile_id => profile.id)
86 86 assert_equal [product_with_image, product_without_image], Product.find_by_contents('product image')[:results].docs
87 87 end
88 88  
89 89 should 'boost search results that include qualifier' do
90 90 TestSolr.enable
91 91 product_without_q = Product.create!(:name => 'product without qualifier', :product_category => product_category,
92   - :enterprise_id => profile.id)
  92 + :profile_id => profile.id)
93 93 product_with_q = Product.create!(:name => 'product with qualifier', :product_category => product_category,
94   - :enterprise_id => profile.id)
  94 + :profile_id => profile.id)
95 95 product_with_q.product_qualifiers.create(:qualifier => fast_create(Qualifier), :certifier => nil)
96 96 product_with_q.save!
97 97  
... ... @@ -100,8 +100,8 @@ class ProductTest &lt; ActiveSupport::TestCase
100 100  
101 101 should 'boost search results with open price' do
102 102 TestSolr.enable
103   - product = Product.create!(:name => 'product 1', :product_category => product_category, :enterprise_id => profile.id, :price => 100)
104   - open_price = Product.new(:name => 'product 2', :product_category => product_category, :enterprise_id => profile.id, :price => 100)
  103 + product = Product.create!(:name => 'product 1', :product_category => product_category, :profile_id => profile.id, :price => 100)
  104 + open_price = Product.new(:name => 'product 2', :product_category => product_category, :profile_id => profile.id, :price => 100)
105 105 open_price.inputs << Input.new(:product => open_price, :product_category_id => product_category.id, :amount_used => 10, :price_per_unit => 10)
106 106 open_price.save!
107 107  
... ... @@ -110,14 +110,14 @@ class ProductTest &lt; ActiveSupport::TestCase
110 110  
111 111 should 'boost search results with solidarity inputs' do
112 112 TestSolr.enable
113   - product = Product.create!(:name => 'product 1', :product_category => product_category, :enterprise_id => profile.id)
114   - perc_50 = Product.create!(:name => 'product 2', :product_category => product_category, :enterprise_id => profile.id)
  113 + product = Product.create!(:name => 'product 1', :product_category => product_category, :profile_id => profile.id)
  114 + perc_50 = Product.create!(:name => 'product 2', :product_category => product_category, :profile_id => profile.id)
115 115 Input.create!(:product_id => perc_50.id, :product_category_id => product_category.id,
116 116 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true)
117 117 Input.create!(:product_id => perc_50.id, :product_category_id => product_category.id,
118 118 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false)
119 119 perc_50.save!
120   - perc_75 = Product.create!(:name => 'product 3', :product_category => product_category, :enterprise_id => profile.id)
  120 + perc_75 = Product.create!(:name => 'product 3', :product_category => product_category, :profile_id => profile.id)
121 121 Input.create!(:product_id => perc_75.id, :product_category_id => product_category.id,
122 122 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false)
123 123 Input.create!(:product_id => perc_75.id, :product_category_id => product_category.id,
... ... @@ -133,10 +133,10 @@ class ProductTest &lt; ActiveSupport::TestCase
133 133  
134 134 should 'boost available search results' do
135 135 TestSolr.enable
136   - product = Product.create!(:name => 'product 1', :product_category => product_category, :enterprise_id => profile.id)
  136 + product = Product.create!(:name => 'product 1', :product_category => product_category, :profile_id => profile.id)
137 137 product.available = false
138 138 product.save!
139   - product2 = Product.create!(:name => 'product 2', :product_category => product_category, :enterprise_id => profile.id)
  139 + product2 = Product.create!(:name => 'product 2', :product_category => product_category, :profile_id => profile.id)
140 140 product2.available = true
141 141 product2.save!
142 142  
... ... @@ -145,18 +145,18 @@ class ProductTest &lt; ActiveSupport::TestCase
145 145  
146 146 should 'boost search results created updated recently' do
147 147 TestSolr.enable
148   - product = Product.create!(:name => 'product 1', :product_category => product_category, :enterprise_id => profile.id)
  148 + product = Product.create!(:name => 'product 1', :product_category => product_category, :profile_id => profile.id)
149 149 product.update_attribute :created_at, Time.now - 10.day
150   - product2 = Product.create!(:name => 'product 2', :product_category => product_category, :enterprise_id => profile.id)
  150 + product2 = Product.create!(:name => 'product 2', :product_category => product_category, :profile_id => profile.id)
151 151  
152 152 assert_equal [product2, product], Product.find_by_contents('product')[:results].docs
153 153 end
154 154  
155 155 should 'boost search results with description' do
156 156 TestSolr.enable
157   - product = Product.create!(:name => 'product 1', :product_category => product_category, :enterprise_id => profile.id,
  157 + product = Product.create!(:name => 'product 1', :product_category => product_category, :profile_id => profile.id,
158 158 :description => '')
159   - product2 = Product.create!(:name => 'product 2', :product_category => product_category, :enterprise_id => profile.id,
  159 + product2 = Product.create!(:name => 'product 2', :product_category => product_category, :profile_id => profile.id,
160 160 :description => 'a small description')
161 161  
162 162 assert_equal [product2, product], Product.find_by_contents('product')[:results].docs
... ... @@ -165,23 +165,23 @@ class ProductTest &lt; ActiveSupport::TestCase
165 165 should 'boost if enterprise is enabled' do
166 166 TestSolr.enable
167 167 ent = Enterprise.create!(:name => 'ent', :identifier => 'ent', :enabled => false)
168   - product = Product.create!(:name => 'product 1', :product_category => product_category, :enterprise_id => ent.id)
169   - product2 = Product.create!(:name => 'product 2', :product_category => product_category, :enterprise_id => profile.id)
  168 + product = Product.create!(:name => 'product 1', :product_category => product_category, :profile_id => ent.id)
  169 + product2 = Product.create!(:name => 'product 2', :product_category => product_category, :profile_id => profile.id)
170 170  
171 171 assert_equal [product2, product], Product.find_by_contents('product')[:results].docs
172 172 end
173 173  
174 174 should 'combine different boost types' do
175 175 TestSolr.enable
176   - product = Product.create!(:name => 'product', :product_category => product_category, :enterprise_id => profile.id)
  176 + product = Product.create!(:name => 'product', :product_category => product_category, :profile_id => profile.id)
177 177 image_only = Product.create!(:name => 'product with image', :product_category => product_category,
178 178 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')},
179   - :enterprise_id => profile.id)
  179 + :profile_id => profile.id)
180 180 qual_only = Product.create!(:name => 'product with qualifier', :product_category => product_category,
181   - :enterprise_id => profile.id)
  181 + :profile_id => profile.id)
182 182 img_and_qual = Product.create!(:name => 'product with image and qualifier', :product_category => product_category,
183 183 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')},
184   - :enterprise_id => profile.id)
  184 + :profile_id => profile.id)
185 185 qual_only.product_qualifiers.create(:qualifier => fast_create(Qualifier), :certifier => nil)
186 186 img_and_qual.product_qualifiers.create(:qualifier => fast_create(Qualifier), :certifier => nil)
187 187 qual_only.save!
... ... @@ -195,8 +195,8 @@ class ProductTest &lt; ActiveSupport::TestCase
195 195 parent_cat = fast_create(ProductCategory, :name => 'Parent')
196 196 prod_cat = fast_create(ProductCategory, :name => 'Category1', :parent_id => parent_cat.id)
197 197 prod_cat2 = fast_create(ProductCategory, :name => 'Category2')
198   - p = Product.create(:name => 'a test', :product_category => prod_cat, :enterprise_id => @profile.id)
199   - p2 = Product.create(:name => 'another test', :product_category => prod_cat2, :enterprise_id => @profile.id)
  198 + p = Product.create(:name => 'a test', :product_category => prod_cat, :profile_id => @profile.id)
  199 + p2 = Product.create(:name => 'another test', :product_category => prod_cat2, :profile_id => @profile.id)
200 200  
201 201 r = Product.find_by_contents('Parent')[:results].docs
202 202 assert_includes r, p
... ... @@ -206,10 +206,10 @@ class ProductTest &lt; ActiveSupport::TestCase
206 206 should 'index by schema name when database is postgresql' do
207 207 TestSolr.enable
208 208 uses_postgresql 'schema_one'
209   - p1 = Product.create!(:name => 'some thing', :product_category => @product_category, :enterprise_id => @profile.id)
  209 + p1 = Product.create!(:name => 'some thing', :product_category => @product_category, :profile_id => @profile.id)
210 210 assert_equal [p1], Product.find_by_contents('thing')[:results].docs
211 211 uses_postgresql 'schema_two'
212   - p2 = Product.create!(:name => 'another thing', :product_category => @product_category, :enterprise_id => @profile.id)
  212 + p2 = Product.create!(:name => 'another thing', :product_category => @product_category, :profile_id => @profile.id)
213 213 assert_not_includes Product.find_by_contents('thing')[:results], p1
214 214 assert_includes Product.find_by_contents('thing')[:results], p2
215 215 uses_postgresql 'schema_one'
... ... @@ -221,9 +221,9 @@ class ProductTest &lt; ActiveSupport::TestCase
221 221 should 'not index by schema name when database is not postgresql' do
222 222 TestSolr.enable
223 223 uses_sqlite
224   - p1 = Product.create!(:name => 'some thing', :product_category => @product_category, :enterprise_id => @profile.id)
  224 + p1 = Product.create!(:name => 'some thing', :product_category => @product_category, :profile_id => @profile.id)
225 225 assert_equal [p1], Product.find_by_contents('thing')[:results].docs
226   - p2 = Product.create!(:name => 'another thing', :product_category => @product_category, :enterprise_id => @profile.id)
  226 + p2 = Product.create!(:name => 'another thing', :product_category => @product_category, :profile_id => @profile.id)
227 227 assert_includes Product.find_by_contents('thing')[:results], p1
228 228 assert_includes Product.find_by_contents('thing')[:results], p2
229 229 end
... ...
plugins/solr/views/search/.communities.rhtml.swp
No preview for this file type
plugins/solr/views/search/.people.rhtml.swp
No preview for this file type
script/sample-products
... ... @@ -14,7 +14,7 @@ for thing in THINGS
14 14 rand(10).times do |i|
15 15 save Product.new(
16 16 :name => name,
17   - :enterprise_id => enterprises.rand.id, :price => (i * 13.7),
  17 + :profile_id => enterprises.rand.id, :price => (i * 13.7),
18 18 :product_category_id => categories.rand.id
19 19 )
20 20 end
... ...
test/functional/catalog_controller_test.rb
... ... @@ -18,7 +18,7 @@ class CatalogControllerTest &lt; ActionController::TestCase
18 18 def test_local_files_reference
19 19 assert_local_files_reference :get, :index, :profile => @enterprise.identifier
20 20 end
21   -
  21 +
22 22 def test_valid_xhtml
23 23 assert_valid_xhtml
24 24 end
... ... @@ -33,7 +33,7 @@ class CatalogControllerTest &lt; ActionController::TestCase
33 33 get :index, :profile => 'testent'
34 34 assert_response :success
35 35 end
36   -
  36 +
37 37 should 'list products of enterprise' do
38 38 get :index, :profile => @enterprise.identifier
39 39 assert_kind_of Array, assigns(:products)
... ... @@ -41,7 +41,7 @@ class CatalogControllerTest &lt; ActionController::TestCase
41 41  
42 42 should 'paginate enterprise products list' do
43 43 1.upto(12).map do
44   - fast_create(Product, :enterprise_id => @enterprise.id)
  44 + fast_create(Product, :profile_id => @enterprise.id)
45 45 end
46 46  
47 47 assert_equal 12, @enterprise.products.count
... ... @@ -91,7 +91,7 @@ class CatalogControllerTest &lt; ActionController::TestCase
91 91 end
92 92 end
93 93  
94   - product = fast_create(Product, :enterprise_id => @enterprise.id)
  94 + product = fast_create(Product, :profile_id => @enterprise.id)
95 95 environment = Environment.default
96 96 environment.enable_plugin(Plugin1.name)
97 97 environment.enable_plugin(Plugin2.name)
... ... @@ -107,10 +107,10 @@ class CatalogControllerTest &lt; ActionController::TestCase
107 107 pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id)
108 108 pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id)
109 109 pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id)
110   - p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
111   - p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
112   - p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
113   - p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  110 + p1 = fast_create(Product, :product_category_id => pc1.id, :profile_id => @enterprise.id)
  111 + p2 = fast_create(Product, :product_category_id => pc2.id, :profile_id => @enterprise.id)
  112 + p3 = fast_create(Product, :product_category_id => pc3.id, :profile_id => @enterprise.id)
  113 + p4 = fast_create(Product, :product_category_id => pc4.id, :profile_id => @enterprise.id)
114 114  
115 115 get :index, :profile => @enterprise.identifier, :level => pc1.id
116 116  
... ... @@ -125,10 +125,10 @@ class CatalogControllerTest &lt; ActionController::TestCase
125 125 pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id)
126 126 pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id)
127 127 pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id)
128   - p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
129   - p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
130   - p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
131   - p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  128 + p1 = fast_create(Product, :product_category_id => pc1.id, :profile_id => @enterprise.id)
  129 + p2 = fast_create(Product, :product_category_id => pc2.id, :profile_id => @enterprise.id)
  130 + p3 = fast_create(Product, :product_category_id => pc3.id, :profile_id => @enterprise.id)
  131 + p4 = fast_create(Product, :product_category_id => pc4.id, :profile_id => @enterprise.id)
132 132  
133 133 get :index, :profile => @enterprise.identifier, :level => pc2.id
134 134  
... ... @@ -139,12 +139,12 @@ class CatalogControllerTest &lt; ActionController::TestCase
139 139 end
140 140  
141 141 should 'get products ordered by availability, highlighted and then name' do
142   - p1 = fast_create(Product, :enterprise_id => @enterprise.id, :name => 'Zebra', :available => true, :highlighted => true)
143   - p2 = fast_create(Product, :enterprise_id => @enterprise.id, :name => 'Car', :available => true)
144   - p3 = fast_create(Product, :enterprise_id => @enterprise.id, :name => 'Panda', :available => true)
145   - p4 = fast_create(Product, :enterprise_id => @enterprise.id, :name => 'Pen', :available => false, :highlighted => true)
146   - p5 = fast_create(Product, :enterprise_id => @enterprise.id, :name => 'Ball', :available => false)
147   - p6 = fast_create(Product, :enterprise_id => @enterprise.id, :name => 'Medal', :available => false)
  142 + p1 = fast_create(Product, :profile_id => @enterprise.id, :name => 'Zebra', :available => true, :highlighted => true)
  143 + p2 = fast_create(Product, :profile_id => @enterprise.id, :name => 'Car', :available => true)
  144 + p3 = fast_create(Product, :profile_id => @enterprise.id, :name => 'Panda', :available => true)
  145 + p4 = fast_create(Product, :profile_id => @enterprise.id, :name => 'Pen', :available => false, :highlighted => true)
  146 + p5 = fast_create(Product, :profile_id => @enterprise.id, :name => 'Ball', :available => false)
  147 + p6 = fast_create(Product, :profile_id => @enterprise.id, :name => 'Medal', :available => false)
148 148  
149 149 get :index, :profile => @enterprise.identifier
150 150  
... ... @@ -174,10 +174,10 @@ class CatalogControllerTest &lt; ActionController::TestCase
174 174 pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id)
175 175 pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id)
176 176 pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id)
177   - p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
178   - p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
179   - p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
180   - p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  177 + p1 = fast_create(Product, :product_category_id => pc1.id, :profile_id => @enterprise.id)
  178 + p2 = fast_create(Product, :product_category_id => pc2.id, :profile_id => @enterprise.id)
  179 + p3 = fast_create(Product, :product_category_id => pc3.id, :profile_id => @enterprise.id)
  180 + p4 = fast_create(Product, :product_category_id => pc4.id, :profile_id => @enterprise.id)
181 181  
182 182 get :index, :profile => @enterprise.identifier
183 183  
... ... @@ -193,10 +193,10 @@ class CatalogControllerTest &lt; ActionController::TestCase
193 193 pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id)
194 194 pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id)
195 195 pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id)
196   - p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
197   - p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
198   - p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
199   - p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  196 + p1 = fast_create(Product, :product_category_id => pc1.id, :profile_id => @enterprise.id)
  197 + p2 = fast_create(Product, :product_category_id => pc2.id, :profile_id => @enterprise.id)
  198 + p3 = fast_create(Product, :product_category_id => pc3.id, :profile_id => @enterprise.id)
  199 + p4 = fast_create(Product, :product_category_id => pc4.id, :profile_id => @enterprise.id)
200 200  
201 201 get :index, :profile => @enterprise.identifier, :level => pc4.id
202 202  
... ... @@ -208,8 +208,8 @@ class CatalogControllerTest &lt; ActionController::TestCase
208 208  
209 209 should 'add product status on the class css' do
210 210 category = ProductCategory.create!(:name => "Cateogry", :environment => @enterprise.environment)
211   - p1 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :highlighted => true)
212   - p2 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :available => false)
  211 + p1 = fast_create(Product, :product_category_id => category.id, :profile_id => @enterprise.id, :highlighted => true)
  212 + p2 = fast_create(Product, :product_category_id => category.id, :profile_id => @enterprise.id, :available => false)
213 213  
214 214 get :index, :profile => @enterprise.identifier
215 215  
... ... @@ -224,10 +224,10 @@ class CatalogControllerTest &lt; ActionController::TestCase
224 224 pc2 = ProductCategory.create!(:name => "Bananas", :environment => environment)
225 225 pc3 = ProductCategory.create!(:name => "Sodas", :environment => environment)
226 226 pc4 = ProductCategory.create!(:name => "Pies", :environment => environment)
227   - p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
228   - p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
229   - p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
230   - p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  227 + p1 = fast_create(Product, :product_category_id => pc1.id, :profile_id => @enterprise.id)
  228 + p2 = fast_create(Product, :product_category_id => pc2.id, :profile_id => @enterprise.id)
  229 + p3 = fast_create(Product, :product_category_id => pc3.id, :profile_id => @enterprise.id)
  230 + p4 = fast_create(Product, :product_category_id => pc4.id, :profile_id => @enterprise.id)
231 231  
232 232 get :index, :profile => @enterprise.identifier
233 233  
... ...
test/functional/manage_products_controller_test.rb
... ... @@ -20,11 +20,11 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
20 20 def test_local_files_reference
21 21 assert_local_files_reference :get, :index, :profile => @enterprise.identifier
22 22 end
23   -
  23 +
24 24 def test_valid_xhtml
25 25 assert_valid_xhtml
26 26 end
27   -
  27 +
28 28 should "not have permission" do
29 29 u = create_user('user_test')
30 30 login_as :user_test
... ... @@ -44,7 +44,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
44 44 assert_response :success
45 45 assert assigns(:product)
46 46 assert_template 'new'
47   - assert_tag :tag => 'form', :attributes => { :action => /new/ }
  47 + assert_tag :tag => 'form', :attributes => { :action => /new/ }
48 48 end
49 49  
50 50 should "create new product" do
... ... @@ -65,7 +65,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
65 65 end
66 66  
67 67 should "get edit name form" do
68   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  68 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
69 69 get 'edit', :profile => @enterprise.identifier, :id => product.id, :field => 'name'
70 70 assert_response :success
71 71 assert assigns(:product)
... ... @@ -73,7 +73,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
73 73 end
74 74  
75 75 should "get edit info form" do
76   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  76 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
77 77 get 'edit', :profile => @enterprise.identifier, :id => product.id, :field => 'info'
78 78 assert_response :success
79 79 assert assigns(:product)
... ... @@ -81,7 +81,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
81 81 end
82 82  
83 83 should "get edit image form" do
84   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  84 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
85 85 get 'edit', :profile => @enterprise.identifier, :id => product.id, :field => 'image'
86 86 assert_response :success
87 87 assert assigns(:product)
... ... @@ -89,7 +89,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
89 89 end
90 90  
91 91 should "edit product name" do
92   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  92 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
93 93 post :edit, :profile => @enterprise.identifier, :product => {:name => 'new test product'}, :id => product.id, :field => 'name'
94 94 assert_response :success
95 95 assert assigns(:product)
... ... @@ -98,7 +98,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
98 98 end
99 99  
100 100 should "edit product description" do
101   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id, :description => 'My product is very good')
  101 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id, :description => 'My product is very good')
102 102 post :edit, :profile => @enterprise.identifier, :product => {:description => 'A very good product!'}, :id => product.id, :field => 'info'
103 103 assert_response :success
104 104 assert assigns(:product)
... ... @@ -107,7 +107,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
107 107 end
108 108  
109 109 should "edit product image" do
110   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  110 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
111 111 post :edit, :profile => @enterprise.identifier, :product => { :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') } }, :id => product.id, :field => 'image'
112 112 assert_response :success
113 113 assert assigns(:product)
... ... @@ -116,32 +116,32 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
116 116 end
117 117  
118 118 should "not edit to invalid parameters" do
119   - product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  119 + product = fast_create(Product, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
120 120 post 'edit_category', :profile => @enterprise.identifier, :selected_category_id => nil, :id => product.id
121 121 assert_response :success
122 122 assert_template 'shared/_dialog_error_messages'
123 123 end
124 124  
125 125 should "not crash if product has no category" do
126   - product = fast_create(Product, :enterprise_id => @enterprise.id)
  126 + product = fast_create(Product, :profile_id => @enterprise.id)
127 127 assert_nothing_raised do
128 128 post 'edit_category', :profile => @enterprise.identifier, :id => product.id
129 129 end
130 130 end
131 131  
132 132 should "destroy product" do
133   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  133 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
134 134 assert_difference Product, :count, -1 do
135 135 post 'destroy', :profile => @enterprise.identifier, :id => product.id
136 136 assert_response :redirect
137 137 assert_redirected_to :action => 'index'
138 138 assert assigns(:product)
139 139 assert ! Product.find_by_name('test product')
140   - end
  140 + end
141 141 end
142 142  
143 143 should "fail to destroy product" do
144   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  144 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
145 145 Product.any_instance.stubs(:destroy).returns(false)
146 146 assert_no_difference Product, :count do
147 147 post 'destroy', :profile => @enterprise.identifier, :id => product.id
... ... @@ -184,11 +184,11 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
184 184 end
185 185  
186 186 should 'filter html with white list from description of product' do
187   - product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  187 + product = fast_create(Product, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
188 188 post 'edit', :profile => @enterprise.identifier, :id => product.id, :field => 'info', :product => { :name => 'name', :description => "<b id='html_descr'>descr bold</b>" }
189 189 assert_equal "<b>descr bold</b>", assigns(:product).description
190 190 end
191   -
  191 +
192 192 should 'not let users in if environment do not let' do
193 193 env = Environment.default
194 194 env.enable('disable_products_for_enterprises')
... ... @@ -279,14 +279,14 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
279 279 end
280 280  
281 281 should 'not show product price when showing product if not informed' do
282   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  282 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
283 283 get :show, :id => product.id, :profile => @enterprise.identifier
284 284  
285 285 assert_no_tag :tag => 'span', :attributes => { :class => 'product_price' }, :content => /Price:/
286 286 end
287 287  
288 288 should 'show product price when showing product if unit was informed' do
289   - product = fast_create(Product, :name => 'test product', :price => 50.00, :unit_id => fast_create(Unit).id, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  289 + product = fast_create(Product, :name => 'test product', :price => 50.00, :unit_id => fast_create(Unit).id, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
290 290 get :show, :id => product.id, :profile => @enterprise.identifier
291 291  
292 292 assert_tag :tag => 'span', :attributes => { :class => 'field-name' }, :content => /Price:/
... ... @@ -294,7 +294,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
294 294 end
295 295  
296 296 should 'show product price when showing product if discount was informed' do
297   - product = fast_create(Product, :name => 'test product', :price => 50.00, :unit_id => fast_create(Unit).id, :discount => 3.50, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  297 + product = fast_create(Product, :name => 'test product', :price => 50.00, :unit_id => fast_create(Unit).id, :discount => 3.50, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
298 298 get :show, :id => product.id, :profile => @enterprise.identifier
299 299  
300 300 assert_tag :tag => 'span', :attributes => { :class => 'field-name' }, :content => /List price:/
... ... @@ -304,7 +304,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
304 304 end
305 305  
306 306 should 'show product price when showing product if unit not informed' do
307   - product = fast_create(Product, :name => 'test product', :price => 50.00, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  307 + product = fast_create(Product, :name => 'test product', :price => 50.00, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
308 308 get :show, :id => product.id, :profile => @enterprise.identifier
309 309  
310 310 assert_tag :tag => 'span', :attributes => { :class => 'field-name' }, :content => /Price:/
... ... @@ -312,7 +312,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
312 312 end
313 313  
314 314 should 'display button to add input when product has no input' do
315   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  315 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
316 316 get :show, :id => product.id, :profile => @enterprise.identifier
317 317  
318 318 assert_tag :tag => 'div', :attributes => { :id => 'display-add-input-button'},
... ... @@ -320,13 +320,13 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
320 320 end
321 321  
322 322 should 'has instance of input list when showing product' do
323   - product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  323 + product = fast_create(Product, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
324 324 get :show, :id => product.id, :profile => @enterprise.identifier
325 325 assert_equal [], assigns(:inputs)
326 326 end
327 327  
328 328 should 'remove input of a product' do
329   - product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  329 + product = fast_create(Product, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
330 330 input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id)
331 331 assert_equal [input], product.inputs
332 332  
... ... @@ -336,7 +336,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
336 336 end
337 337  
338 338 should 'save inputs order' do
339   - product = fast_create(Product, :enterprise_id => @enterprise.id)
  339 + product = fast_create(Product, :profile_id => @enterprise.id)
340 340 first = Input.create!(:product => product, :product_category => fast_create(ProductCategory))
341 341 second = Input.create!(:product => product, :product_category => fast_create(ProductCategory))
342 342 third = Input.create!(:product => product, :product_category => fast_create(ProductCategory))
... ... @@ -357,7 +357,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
357 357 should 'not list all the products of enterprise' do
358 358 @enterprise.products = []
359 359 1.upto(12) do |n|
360   - fast_create(Product, :name => "test product_#{n}", :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  360 + fast_create(Product, :name => "test product_#{n}", :profile_id => @enterprise.id, :product_category_id => @product_category.id)
361 361 end
362 362 get :index, :profile => @enterprise.identifier
363 363 assert_equal 10, assigns(:products).count
... ... @@ -366,7 +366,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
366 366 should 'paginate the manage products list of enterprise' do
367 367 @enterprise.products = []
368 368 1.upto(12) do |n|
369   - fast_create(Product, :name => "test product_#{n}", :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  369 + fast_create(Product, :name => "test product_#{n}", :profile_id => @enterprise.id, :product_category_id => @product_category.id)
370 370 end
371 371 get :index, :profile => @enterprise.identifier
372 372 assert_tag :tag => 'a', :attributes => { :rel => 'next', :href => "/myprofile/#{@enterprise.identifier}/manage_products?page=2" }
... ... @@ -376,7 +376,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
376 376 end
377 377  
378 378 should 'display tabs even if description and inputs are empty and user is allowed' do
379   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  379 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
380 380 get :show, :id => product.id, :profile => @enterprise.identifier
381 381  
382 382 assert_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }
... ... @@ -387,7 +387,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
387 387  
388 388 login_as 'foo'
389 389  
390   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  390 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
391 391 get :show, :id => product.id, :profile => @enterprise.identifier
392 392  
393 393 assert_no_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }
... ... @@ -396,7 +396,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
396 396 should 'not display tabs if description and inputs are empty and user is not logged in' do
397 397 logout
398 398  
399   - product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  399 + product = fast_create(Product, :name => 'test product', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
400 400 get :show, :id => product.id, :profile => @enterprise.identifier
401 401  
402 402 assert_no_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }
... ... @@ -406,7 +406,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
406 406 create_user('foo')
407 407  
408 408 login_as 'foo'
409   - product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  409 + product = fast_create(Product, :description => 'This product is very good', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
410 410 get :show, :id => product.id, :profile => @enterprise.identifier
411 411 assert_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }, :descendant => {:tag => 'a', :attributes => {:href => '#product-description'}, :content => 'Description'}
412 412 assert_no_tag :tag => 'div', :attributes => { :id => "product-#{product.id}-tabs" }, :descendant => {:tag => 'a', :attributes => {:href => '#inputs'}, :content => 'Inputs and raw material'}
... ... @@ -416,7 +416,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
416 416 create_user 'foo'
417 417  
418 418 login_as 'foo'
419   - product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  419 + product = fast_create(Product, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
420 420 input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id)
421 421  
422 422 get :show, :id => product.id, :profile => @enterprise.identifier
... ... @@ -428,7 +428,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
428 428 create_user('foo')
429 429  
430 430 login_as 'foo'
431   - product = fast_create(Product, :description => 'This product is very good', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  431 + product = fast_create(Product, :description => 'This product is very good', :profile_id => @enterprise.id, :product_category_id => @product_category.id)
432 432 input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id)
433 433  
434 434 get :show, :id => product.id, :profile => @enterprise.identifier
... ... @@ -448,7 +448,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
448 448 end
449 449 end
450 450  
451   - product = fast_create(Product, :enterprise_id => @enterprise.id)
  451 + product = fast_create(Product, :profile_id => @enterprise.id)
452 452  
453 453 Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestProductInfoExtras1Plugin.new, TestProductInfoExtras2Plugin.new])
454 454  
... ... @@ -470,7 +470,7 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
470 470 end
471 471  
472 472 should 'remove price detail of a product' do
473   - product = fast_create(Product, :enterprise_id => @enterprise.id, :product_category_id => @product_category.id)
  473 + product = fast_create(Product, :profile_id => @enterprise.id, :product_category_id => @product_category.id)
474 474 cost = fast_create(ProductionCost, :owner_id => Environment.default.id, :owner_type => 'Environment')
475 475 detail = product.price_details.create(:production_cost_id => cost.id, :price => 10)
476 476  
... ...
test/functional/map_balloon_controller_test.rb
... ... @@ -18,26 +18,26 @@ class MapBalloonControllerTest &lt; ActionController::TestCase
18 18  
19 19 should 'find product to show' do
20 20 prod = Product.create!(:name => 'Product1', :product_category_id => fast_create(ProductCategory).id,
21   - :enterprise_id => fast_create(Enterprise).id)
22   - get :product, :id => prod.id
  21 + :profile_id => fast_create(Enterprise).id)
  22 + get :product, :id => prod.id
23 23 assert_equal prod, assigns(:product)
24 24 end
25 25  
26 26 should 'find person to show' do
27 27 pers = Person.create!(:name => 'Person1', :user_id => fast_create(User).id, :identifier => 'pers1')
28   - get :person, :id => pers.id
  28 + get :person, :id => pers.id
29 29 assert_equal pers, assigns(:profile)
30 30 end
31 31  
32 32 should 'find enterprise to show' do
33 33 ent = Enterprise.create!(:name => 'Enterprise1', :identifier => 'ent1')
34   - get :enterprise, :id => ent.id
  34 + get :enterprise, :id => ent.id
35 35 assert_equal ent, assigns(:profile)
36 36 end
37 37  
38 38 should 'find community to show' do
39 39 comm = Community.create!(:name => 'Community1', :identifier => 'comm1')
40   - get :community, :id => comm.id
  40 + get :community, :id => comm.id
41 41 assert_equal comm, assigns(:profile)
42 42 end
43 43 end
... ...
test/functional/search_controller_test.rb
... ... @@ -166,7 +166,7 @@ class SearchControllerTest &lt; ActionController::TestCase
166 166  
167 167 enterprise = fast_create(Enterprise)
168 168 prod_cat = fast_create(ProductCategory)
169   - product = fast_create(Product, {:enterprise_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true)
  169 + product = fast_create(Product, {:profile_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true)
170 170  
171 171 e = Environment.default
172 172 e.enable_plugin(Plugin1.name)
... ... @@ -191,7 +191,7 @@ class SearchControllerTest &lt; ActionController::TestCase
191 191 end
192 192 enterprise = fast_create(Enterprise)
193 193 prod_cat = fast_create(ProductCategory)
194   - product = fast_create(Product, {:enterprise_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true)
  194 + product = fast_create(Product, {:profile_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true)
195 195  
196 196 environment = Environment.default
197 197 environment.enable_plugin(Plugin1.name)
... ... @@ -348,15 +348,15 @@ class SearchControllerTest &lt; ActionController::TestCase
348 348 should 'show events for current month by default' do
349 349 person = create_user('someone').person
350 350  
351   - ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id],
  351 + ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id],
352 352 :start_date => Date.today + 2.month)
353   - ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id],
  353 + ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id],
354 354 :start_date => Date.today + 2.day)
355 355  
356 356 get :events
357 357  
358 358 assert_not_includes assigns(:searches)[:events][:results], ev1
359   - assert_includes assigns(:searches)[:events][:results], ev2
  359 + assert_includes assigns(:searches)[:events][:results], ev2
360 360 end
361 361  
362 362 should 'list events for a given month' do
... ... @@ -394,7 +394,7 @@ class SearchControllerTest &lt; ActionController::TestCase
394 394 prod_cat2 = ProductCategory.create!(:name => 'prod cat test 2', :environment => Environment.default, :parent => prod_cat1)
395 395 ent = create_profile_with_optional_category(Enterprise, 'test ent', cat)
396 396  
397   - product = prod_cat2.products.create!(:name => 'prod test 1', :enterprise_id => ent.id)
  397 + product = prod_cat2.products.create!(:name => 'prod test 1', :profile_id => ent.id)
398 398  
399 399 get :products, :category_path => cat.path.split('/'), :product_category => prod_cat1.id
400 400  
... ... @@ -590,7 +590,7 @@ class SearchControllerTest &lt; ActionController::TestCase
590 590 a = Article.create!(:name => 'my article', :profile_id => fast_create(Person).id)
591 591 a.tag_list = ['one', 'two']
592 592 a.save_tags
593   -
  593 +
594 594 get :tags
595 595  
596 596 assert assigns(:tags)["two"] = 1
... ... @@ -605,7 +605,7 @@ class SearchControllerTest &lt; ActionController::TestCase
605 605 a2.tag_list = ['two', 'three']
606 606 a.save_tags
607 607 a2.save_tags
608   -
  608 +
609 609 get :tag, :tag => 'two'
610 610  
611 611 assert_equal [a, a2], assigns(:searches)[:tag][:results]
... ... @@ -621,7 +621,7 @@ class SearchControllerTest &lt; ActionController::TestCase
621 621 p2 = Person.create!(:name => 'Adamastor', :identifier => 'adam', :user_id => fast_create(User).id)
622 622 art1 = Article.create!(:name => 'my article', :profile_id => p1.id)
623 623 art2 = Article.create!(:name => 'my article', :profile_id => p2.id)
624   -
  624 +
625 625 get :articles, :query => 'my article'
626 626  
627 627 assert_equal [art2], assigns(:searches)[:articles][:results]
... ... @@ -632,22 +632,22 @@ class SearchControllerTest &lt; ActionController::TestCase
632 632 art1 = Article.create!(:name => 'review C', :profile_id => fast_create(Person).id, :created_at => Time.now-1.days)
633 633 art2 = Article.create!(:name => 'review A', :profile_id => fast_create(Person).id, :created_at => Time.now)
634 634 art3 = Article.create!(:name => 'review B', :profile_id => fast_create(Person).id, :created_at => Time.now-2.days)
635   -
  635 +
636 636 get :articles, :filter => :more_recent
637 637  
638 638 assert_equal [art2, art1, art3], assigns(:searches)[:articles][:results]
639 639 end
640   -
  640 +
641 641 should 'add highlighted CSS class around a highlighted product' do
642 642 enterprise = fast_create(Enterprise)
643   - product = Product.create!(:name => 'Enter Sandman', :enterprise_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => true)
  643 + product = Product.create!(:name => 'Enter Sandman', :profile_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => true)
644 644 get :products
645 645 assert_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Enter Sandman/
646 646 end
647 647  
648 648 should 'do not add highlighted CSS class around an ordinary product' do
649 649 enterprise = fast_create(Enterprise)
650   - product = Product.create!(:name => 'Holier Than Thou', :enterprise_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => false)
  650 + product = Product.create!(:name => 'Holier Than Thou', :profile_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => false)
651 651 get :products
652 652 assert_no_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Holier Than Thou/
653 653 end
... ...
test/unit/enterprise_test.rb
... ... @@ -393,13 +393,13 @@ class EnterpriseTest &lt; ActiveSupport::TestCase
393 393 p1 = e1.products.create!(:name => 'test_prod1', :product_category_id => @product_category.id)
394 394 products = []
395 395 3.times {|n|
396   - products.push(Product.create!(:name => "product #{n}", :enterprise_id => e1.id,
  396 + products.push(Product.create!(:name => "product #{n}", :profile_id => e1.id,
397 397 :highlighted => true, :product_category_id => @product_category.id,
398 398 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }
399 399 ))
400 400 }
401   - Product.create!(:name => "product 4", :enterprise_id => e1.id, :product_category_id => @product_category.id, :highlighted => true)
402   - Product.create!(:name => "product 5", :enterprise_id => e1.id, :product_category_id => @product_category.id, :image_builder => {
  401 + Product.create!(:name => "product 4", :profile_id => e1.id, :product_category_id => @product_category.id, :highlighted => true)
  402 + Product.create!(:name => "product 5", :profile_id => e1.id, :product_category_id => @product_category.id, :image_builder => {
403 403 :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')
404 404 })
405 405 assert_equal products, e1.highlighted_products_with_image
... ... @@ -407,7 +407,7 @@ class EnterpriseTest &lt; ActiveSupport::TestCase
407 407  
408 408 should 'has many inputs through products' do
409 409 enterprise = fast_create(Enterprise)
410   - product = fast_create(Product, :enterprise_id => enterprise.id, :product_category_id => @product_category.id)
  410 + product = fast_create(Product, :profile_id => enterprise.id, :product_category_id => @product_category.id)
411 411 product.inputs << Input.new(:product_category => @product_category)
412 412 product.inputs << Input.new(:product_category => @product_category)
413 413  
... ...
test/unit/environment_test.rb
... ... @@ -399,13 +399,13 @@ class EnvironmentTest &lt; ActiveSupport::TestCase
399 399 p1 = e1.products.create!(:name => 'test_prod1', :product_category_id => category.id)
400 400 products = []
401 401 3.times {|n|
402   - products.push(Product.create!(:name => "product #{n}", :enterprise_id => e1.id,
  402 + products.push(Product.create!(:name => "product #{n}", :profile_id => e1.id,
403 403 :product_category_id => category.id, :highlighted => true,
404 404 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }
405 405 ))
406 406 }
407   - Product.create!(:name => "product 4", :enterprise_id => e1.id, :product_category_id => category.id, :highlighted => true)
408   - Product.create!(:name => "product 5", :enterprise_id => e1.id, :product_category_id => category.id, :image_builder => {
  407 + Product.create!(:name => "product 4", :profile_id => e1.id, :product_category_id => category.id, :highlighted => true)
  408 + Product.create!(:name => "product 5", :profile_id => e1.id, :product_category_id => category.id, :image_builder => {
409 409 :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')
410 410 })
411 411 assert_equal products, env.highlighted_products_with_image
... ... @@ -733,7 +733,7 @@ class EnvironmentTest &lt; ActiveSupport::TestCase
733 733 assert_equal c, e.portal_community
734 734 e.unset_portal_community!
735 735 e.reload
736   - assert_nil e.portal_community
  736 + assert_nil e.portal_community
737 737 assert_equal [], e.portal_folders
738 738 assert_equal 0, e.news_amount_by_folder
739 739 assert_equal false, e.enabled?('use_portal_community')
... ...
test/unit/featured_products_block_test.rb
... ... @@ -13,7 +13,7 @@ class FeaturedProductsBlockTest &lt; ActiveSupport::TestCase
13 13 profile = fast_create(Enterprise)
14 14 products = []
15 15 category = fast_create(ProductCategory)
16   - 3.times {|n| products.push(Product.create!(:name => "product #{n}", :enterprise_id => profile.id, :product_category_id => category.id)) }
  16 + 3.times {|n| products.push(Product.create!(:name => "product #{n}", :profile_id => profile.id, :product_category_id => category.id)) }
17 17 featured_products_block = FeaturedProductsBlock.create!(:product_ids => products.map(&:id))
18 18 assert_equal products, featured_products_block.products
19 19 end
... ... @@ -66,7 +66,7 @@ class FeaturedProductsBlockTest &lt; ActiveSupport::TestCase
66 66 enterprise = Enterprise.create!(:name => "My enterprise", :identifier => 'myenterprise', :environment => @environment)
67 67 category = fast_create(ProductCategory)
68 68 3.times {|n|
69   - Product.create!(:name => "product #{n}", :enterprise_id => enterprise.id,
  69 + Product.create!(:name => "product #{n}", :profile_id => enterprise.id,
70 70 :highlighted => true, :product_category_id => category.id,
71 71 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }
72 72 )
... ... @@ -82,7 +82,7 @@ class FeaturedProductsBlockTest &lt; ActiveSupport::TestCase
82 82 enterprise = Enterprise.create!(:name => "My enterprise", :identifier => 'myenterprise', :environment => @environment)
83 83 category = fast_create(ProductCategory)
84 84 3.times {|n|
85   - Product.create!(:name => "product #{n}", :enterprise_id => enterprise.id, :highlighted => true, :product_category_id => category.id)
  85 + Product.create!(:name => "product #{n}", :profile_id => enterprise.id, :highlighted => true, :product_category_id => category.id)
86 86 }
87 87 @environment.boxes.first.blocks<< block
88 88  
... ... @@ -95,7 +95,7 @@ class FeaturedProductsBlockTest &lt; ActiveSupport::TestCase
95 95 enterprise = Enterprise.create!(:name => "My enterprise", :identifier => 'myenterprise', :environment => @environment)
96 96 category = fast_create(ProductCategory)
97 97 3.times {|n|
98   - Product.create!(:name => "product #{n}", :enterprise_id => enterprise.id, :product_category_id => category.id, :image_builder => {
  98 + Product.create!(:name => "product #{n}", :profile_id => enterprise.id, :product_category_id => category.id, :image_builder => {
99 99 :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')
100 100 })
101 101 }
... ... @@ -118,13 +118,13 @@ class FeaturedProductsBlockTest &lt; ActiveSupport::TestCase
118 118 category = fast_create(ProductCategory)
119 119 products = []
120 120 3.times {|n|
121   - products.push(Product.create!(:name => "product #{n}", :enterprise_id => enterprise.id,
  121 + products.push(Product.create!(:name => "product #{n}", :profile_id => enterprise.id,
122 122 :highlighted => true, :product_category_id => category.id,
123 123 :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }
124 124 ))
125 125 }
126   - Product.create!(:name => "product 4", :enterprise_id => enterprise.id, :product_category_id => category.id, :highlighted => true)
127   - Product.create!(:name => "product 5", :enterprise_id => enterprise.id, :product_category_id => category.id, :image_builder => {
  126 + Product.create!(:name => "product 4", :profile_id => enterprise.id, :product_category_id => category.id, :highlighted => true)
  127 + Product.create!(:name => "product 5", :profile_id => enterprise.id, :product_category_id => category.id, :image_builder => {
128 128 :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')
129 129 })
130 130 @environment.boxes.first.blocks<< block
... ...
test/unit/input_test.rb
... ... @@ -115,7 +115,7 @@ class InputTest &lt; ActiveSupport::TestCase
115 115 should 'display amount used' do
116 116 ent = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
117 117 product_category = fast_create(ProductCategory, :name => 'Products')
118   - product = fast_create(Product, :enterprise_id => ent.id, :product_category_id => product_category.id)
  118 + product = fast_create(Product, :profile_id => ent.id, :product_category_id => product_category.id)
119 119  
120 120 input = Input.new(:product => product)
121 121 input.amount_used = 10.45
... ... @@ -134,7 +134,7 @@ class InputTest &lt; ActiveSupport::TestCase
134 134 should 'display only integer value if decimal value is 00' do
135 135 ent = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
136 136 product_category = fast_create(ProductCategory, :name => 'Products')
137   - product = fast_create(Product, :enterprise_id => ent.id, :product_category_id => product_category.id)
  137 + product = fast_create(Product, :profile_id => ent.id, :product_category_id => product_category.id)
138 138  
139 139 input = Input.new(:product => product)
140 140 input.amount_used = 10.00
... ... @@ -144,7 +144,7 @@ class InputTest &lt; ActiveSupport::TestCase
144 144 should 'display formatted value' do
145 145 ent = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
146 146 product_category = fast_create(ProductCategory, :name => 'Products')
147   - product = fast_create(Product, :enterprise_id => ent.id, :product_category_id => product_category.id)
  147 + product = fast_create(Product, :profile_id => ent.id, :product_category_id => product_category.id)
148 148  
149 149 input = Input.new(:product => product)
150 150 input.price_per_unit = 1.45
... ...
test/unit/price_detail_test.rb
... ... @@ -70,7 +70,7 @@ class PriceDetailTest &lt; ActiveSupport::TestCase
70 70  
71 71 should 'format values to float with 2 decimals' do
72 72 enterprise = fast_create(Enterprise)
73   - product = fast_create(Product, :enterprise_id => enterprise.id)
  73 + product = fast_create(Product, :profile_id => enterprise.id)
74 74 cost = fast_create(ProductionCost, :owner_id => Environment.default.id, :owner_type => 'environment')
75 75  
76 76 price_detail = product.price_details.create(:production_cost_id => cost.id, :price => 10)
... ...
test/unit/product_category_test.rb
... ... @@ -7,12 +7,12 @@ class ProductCategoryTest &lt; ActiveSupport::TestCase
7 7 assert_equivalent [], c0.all_products
8 8  
9 9 profile = fast_create(Enterprise)
10   - p0 = Product.create(:name => 'product1', :product_category => c0, :enterprise_id => profile.id)
  10 + p0 = Product.create(:name => 'product1', :product_category => c0, :profile_id => profile.id)
11 11 c0.reload
12 12 assert_equivalent [p0], c0.all_products
13 13  
14 14 c1 = ProductCategory.create!(:name => 'cat_1', :parent => c0, :environment => Environment.default)
15   - p1 = Product.create(:name => 'product2', :product_category => c1, :enterprise_id => profile.id)
  15 + p1 = Product.create(:name => 'product2', :product_category => c1, :profile_id => profile.id)
16 16 c0.reload; c1.reload
17 17 assert_equivalent [p0, p1], c0.all_products
18 18 assert_equivalent [p1], c1.all_products
... ...
test/unit/product_test.rb
... ... @@ -18,14 +18,14 @@ class ProductTest &lt; ActiveSupport::TestCase
18 18 should 'return associated enterprise region' do
19 19 @profile.region = fast_create Region, :name => 'Salvador'
20 20 @profile.save!
21   - p = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :enterprise_id => @profile.id)
  21 + p = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :profile_id => @profile.id)
22 22  
23 23 assert_equal @profile.region, p.region
24 24 end
25 25  
26 26 should 'create product' do
27 27 assert_difference Product, :count do
28   - p = Product.new(:name => 'test product1', :product_category => @product_category, :enterprise_id => @profile.id)
  28 + p = Product.new(:name => 'test product1', :product_category => @product_category, :profile_id => @profile.id)
29 29 assert p.save
30 30 end
31 31 end
... ... @@ -84,7 +84,7 @@ class ProductTest &lt; ActiveSupport::TestCase
84 84 assert_difference Product, :count do
85 85 p = Product.create!(:name => 'test product1', :product_category => @product_category, :image_builder => {
86 86 :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')
87   - }, :enterprise_id => @profile.id)
  87 + }, :profile_id => @profile.id)
88 88 assert_equal p.image(true).filename, 'rails.png'
89 89 end
90 90 end
... ... @@ -138,7 +138,7 @@ class ProductTest &lt; ActiveSupport::TestCase
138 138  
139 139 should 'respond to public? as its enterprise public?' do
140 140 e1 = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
141   - p1 = fast_create(Product, :name => 'test product 1', :enterprise_id => e1.id, :product_category_id => @product_category.id)
  141 + p1 = fast_create(Product, :name => 'test product 1', :profile_id => e1.id, :product_category_id => @product_category.id)
142 142  
143 143 assert p1.public?
144 144  
... ... @@ -197,7 +197,7 @@ class ProductTest &lt; ActiveSupport::TestCase
197 197 end
198 198  
199 199 should 'use name of category when has no name yet' do
200   - product = Product.new(:product_category => @product_category, :enterprise_id => @profile.id)
  200 + product = Product.new(:product_category => @product_category, :profile_id => @profile.id)
201 201 assert product.valid?
202 202 assert_equal product.name, @product_category.name
203 203 end
... ... @@ -217,7 +217,7 @@ class ProductTest &lt; ActiveSupport::TestCase
217 217  
218 218 should 'format values to float with 2 decimals' do
219 219 ent = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
220   - product = fast_create(Product, :enterprise_id => ent.id, :price => 12.994, :discount => 1.994)
  220 + product = fast_create(Product, :profile_id => ent.id, :price => 12.994, :discount => 1.994)
221 221  
222 222 assert_equal "12.99", product.formatted_value(:price)
223 223 assert_equal "1.99", product.formatted_value(:discount)
... ... @@ -225,14 +225,14 @@ class ProductTest &lt; ActiveSupport::TestCase
225 225  
226 226 should 'calculate price with discount' do
227 227 ent = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
228   - product = fast_create(Product, :enterprise_id => ent.id, :price => 12.994, :discount => 1.994)
  228 + product = fast_create(Product, :profile_id => ent.id, :price => 12.994, :discount => 1.994)
229 229  
230 230 assert_equal 11.00, product.price_with_discount
231 231 end
232 232  
233 233 should 'calculate price without discount' do
234 234 ent = fast_create(Enterprise, :name => 'test ent 1', :identifier => 'test_ent1')
235   - product = fast_create(Product, :enterprise_id => ent.id, :price => 12.994, :discount => 0)
  235 + product = fast_create(Product, :profile_id => ent.id, :price => 12.994, :discount => 0)
236 236  
237 237 assert_equal product.price, product.price_with_discount
238 238 end
... ... @@ -254,7 +254,7 @@ class ProductTest &lt; ActiveSupport::TestCase
254 254  
255 255 should 'return product inputs' do
256 256 ent = fast_create(Enterprise)
257   - product = fast_create(Product, :enterprise_id => ent.id)
  257 + product = fast_create(Product, :profile_id => ent.id)
258 258 input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id)
259 259  
260 260 assert_equal [input], product.inputs
... ... @@ -262,7 +262,7 @@ class ProductTest &lt; ActiveSupport::TestCase
262 262  
263 263 should 'destroy inputs when product is removed' do
264 264 ent = fast_create(Enterprise)
265   - product = fast_create(Product, :enterprise_id => ent.id)
  265 + product = fast_create(Product, :profile_id => ent.id)
266 266 input = fast_create(Input, :product_id => product.id, :product_category_id => @product_category.id)
267 267  
268 268 services_category = fast_create(ProductCategory, :name => 'Services')
... ... @@ -414,7 +414,7 @@ class ProductTest &lt; ActiveSupport::TestCase
414 414  
415 415 should 'return production costs from enterprise and environment' do
416 416 ent = fast_create(Enterprise)
417   - product = fast_create(Product, :enterprise_id => ent.id)
  417 + product = fast_create(Product, :profile_id => ent.id)
418 418 ent_production_cost = fast_create(ProductionCost, :owner_id => ent.id, :owner_type => 'Profile')
419 419 env_production_cost = fast_create(ProductionCost, :owner_id => ent.environment.id, :owner_type => 'Environment')
420 420  
... ... @@ -423,7 +423,7 @@ class ProductTest &lt; ActiveSupport::TestCase
423 423  
424 424 should 'return all production costs' do
425 425 ent = fast_create(Enterprise)
426   - product = fast_create(Product, :enterprise_id => ent.id)
  426 + product = fast_create(Product, :profile_id => ent.id)
427 427  
428 428 env_production_cost = fast_create(ProductionCost, :owner_id => ent.environment.id, :owner_type => 'Environment')
429 429 ent_production_cost = fast_create(ProductionCost, :owner_id => ent.id, :owner_type => 'Profile')
... ... @@ -433,7 +433,7 @@ class ProductTest &lt; ActiveSupport::TestCase
433 433  
434 434 should 'return total value of production costs' do
435 435 ent = fast_create(Enterprise)
436   - product = fast_create(Product, :enterprise_id => ent.id)
  436 + product = fast_create(Product, :profile_id => ent.id)
437 437  
438 438 env_production_cost = fast_create(ProductionCost, :owner_id => ent.environment.id, :owner_type => 'Environment')
439 439 price_detail = product.price_details.create(:production_cost => env_production_cost, :price => 10)
... ... @@ -445,7 +445,7 @@ class ProductTest &lt; ActiveSupport::TestCase
445 445  
446 446 should 'return inputs cost as total value of production costs if has no price details' do
447 447 ent = fast_create(Enterprise)
448   - product = fast_create(Product, :enterprise_id => ent.id)
  448 + product = fast_create(Product, :profile_id => ent.id)
449 449  
450 450 input = fast_create(Input, :product_id => product.id, :product_category_id => fast_create(ProductCategory).id, :price_per_unit => 20.0, :amount_used => 2)
451 451  
... ... @@ -460,7 +460,7 @@ class ProductTest &lt; ActiveSupport::TestCase
460 460  
461 461 should 'format inputs cost values to float with 2 decimals' do
462 462 ent = fast_create(Enterprise)
463   - product = fast_create(Product, :enterprise_id => ent.id)
  463 + product = fast_create(Product, :profile_id => ent.id)
464 464 first = fast_create(Input, :product_id => product.id, :product_category_id => fast_create(ProductCategory).id, :price_per_unit => 20.0, :amount_used => 2)
465 465 second = fast_create(Input, :product_id => product.id, :product_category_id => fast_create(ProductCategory).id, :price_per_unit => 10.0, :amount_used => 1)
466 466  
... ... @@ -490,7 +490,7 @@ class ProductTest &lt; ActiveSupport::TestCase
490 490 end
491 491  
492 492 should 'return solidarity percentage from inputs' do
493   - prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :enterprise_id => @profile.id)
  493 + prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :profile_id => @profile.id)
494 494 assert_equal 0, prod.percentage_from_solidarity_economy.first
495 495  
496 496 Input.create!(:product_id => prod.id, :product_category_id => @product_category.id,
... ... @@ -505,7 +505,7 @@ class ProductTest &lt; ActiveSupport::TestCase
505 505 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false)
506 506 assert_equal 25, prod.percentage_from_solidarity_economy.first
507 507  
508   - prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :enterprise_id => @profile.id)
  508 + prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :profile_id => @profile.id)
509 509 Input.create!(:product_id => prod.id, :product_category_id => @product_category.id,
510 510 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true)
511 511 Input.create!(:product_id => prod.id, :product_category_id => @product_category.id,
... ... @@ -516,7 +516,7 @@ class ProductTest &lt; ActiveSupport::TestCase
516 516 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false)
517 517 assert_equal 75, prod.percentage_from_solidarity_economy.first
518 518  
519   - prod = fast_create(Product, :name => 'test product', :product_category_id => @product_category.id, :enterprise_id => @profile.id)
  519 + prod = fast_create(Product, :name => 'test product', :product_category_id => @product_category.id, :profile_id => @profile.id)
520 520 Input.create!(:product_id => prod.id, :product_category_id => @product_category.id,
521 521 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true)
522 522 assert_equal 100, prod.percentage_from_solidarity_economy.first
... ... @@ -526,7 +526,7 @@ class ProductTest &lt; ActiveSupport::TestCase
526 526 enterprise = fast_create(Enterprise)
527 527 Enterprise.any_instance.expects(:region)
528 528 Enterprise.any_instance.expects(:region_id)
529   - product = fast_create(Product, :enterprise_id => enterprise.id)
  529 + product = fast_create(Product, :profile_id => enterprise.id)
530 530 product.region
531 531 product.region_id
532 532 end
... ... @@ -535,7 +535,7 @@ class ProductTest &lt; ActiveSupport::TestCase
535 535 enterprise = fast_create(Enterprise)
536 536 Enterprise.any_instance.expects(:environment)
537 537 Enterprise.any_instance.expects(:environment_id)
538   - product = fast_create(Product, :enterprise_id => enterprise.id)
  538 + product = fast_create(Product, :profile_id => enterprise.id)
539 539 product.environment
540 540 product.environment_id
541 541 end
... ... @@ -543,9 +543,9 @@ class ProductTest &lt; ActiveSupport::TestCase
543 543 should 'return more recent products' do
544 544 Product.destroy_all
545 545  
546   - prod1 = Product.create!(:name => 'Damaged LP', :enterprise_id => @profile.id, :product_category_id => @product_category.id)
547   - prod2 = Product.create!(:name => 'Damaged CD', :enterprise_id => @profile.id, :product_category_id => @product_category.id)
548   - prod3 = Product.create!(:name => 'Damaged DVD', :enterprise_id => @profile.id, :product_category_id => @product_category.id)
  546 + prod1 = Product.create!(:name => 'Damaged LP', :profile_id => @profile.id, :product_category_id => @product_category.id)
  547 + prod2 = Product.create!(:name => 'Damaged CD', :profile_id => @profile.id, :product_category_id => @product_category.id)
  548 + prod3 = Product.create!(:name => 'Damaged DVD', :profile_id => @profile.id, :product_category_id => @product_category.id)
549 549  
550 550 prod1.update_attribute :created_at, Time.now-2.days
551 551 prod2.update_attribute :created_at, Time.now-1.days
... ... @@ -579,9 +579,9 @@ class ProductTest &lt; ActiveSupport::TestCase
579 579  
580 580 should 'return from_category scope untouched if passed nil' do
581 581 enterprise = fast_create(Enterprise)
582   - p1 = fast_create(Product, :enterprise_id => enterprise.id)
583   - p2 = fast_create(Product, :enterprise_id => enterprise.id)
584   - p3 = fast_create(Product, :enterprise_id => enterprise.id)
  582 + p1 = fast_create(Product, :profile_id => enterprise.id)
  583 + p2 = fast_create(Product, :profile_id => enterprise.id)
  584 + p3 = fast_create(Product, :profile_id => enterprise.id)
585 585  
586 586 products = enterprise.products.from_category(nil)
587 587  
... ...