Commit 4cafc3b86f327f2e3ae2d345a5ed357207a1a989
1 parent
684589bc
Exists in
master
and in
29 other branches
Avoid mass-assignment of product profile on product_category test
Showing
1 changed file
with
10 additions
and
4 deletions
Show diff stats
test/unit/product_category_test.rb
@@ -41,13 +41,19 @@ class ProductCategoryTest < ActiveSupport::TestCase | @@ -41,13 +41,19 @@ class ProductCategoryTest < ActiveSupport::TestCase | ||
41 | c1 = ProductCategory.create!(:name => 'test cat 1', :environment => Environment.default) | 41 | c1 = ProductCategory.create!(:name => 'test cat 1', :environment => Environment.default) |
42 | c2 = ProductCategory.create!(:name => 'test cat 2', :environment => Environment.default) | 42 | c2 = ProductCategory.create!(:name => 'test cat 2', :environment => Environment.default) |
43 | c3 = ProductCategory.create!(:name => 'test cat 3', :environment => Environment.default) | 43 | c3 = ProductCategory.create!(:name => 'test cat 3', :environment => Environment.default) |
44 | - p1 = Product.create(:name => 'product1', :product_category => c1, :profile_id => enterprise.id) | ||
45 | - p2 = Product.create(:name => 'product2', :product_category => c1, :profile_id => enterprise.id) | ||
46 | - p3 = Product.create(:name => 'product3', :product_category => c2, :profile_id => enterprise.id) | 44 | + p1 = Product.new(:name => 'product1', :product_category => c1) |
45 | + p1.profile = enterprise | ||
46 | + p1.save! | ||
47 | + p2 = Product.new(:name => 'product2', :product_category => c1) | ||
48 | + p2.profile = enterprise | ||
49 | + p2.save! | ||
50 | + p3 = Product.new(:name => 'product3', :product_category => c2) | ||
51 | + p3.profile = enterprise | ||
52 | + p3.save! | ||
47 | 53 | ||
48 | scope = ProductCategory.by_enterprise(enterprise) | 54 | scope = ProductCategory.by_enterprise(enterprise) |
49 | 55 | ||
50 | - assert_equal ActiveRecord::NamedScope::Scope, scope.class | 56 | + assert_equal ActiveRecord::Relation, scope.class |
51 | assert_equivalent [c1,c2], scope | 57 | assert_equivalent [c1,c2], scope |
52 | end | 58 | end |
53 | 59 |