Commit 8ae01dc608f1a52d01e0209994ac8d80b517c7da
1 parent
d614abf8
Exists in
master
and in
29 other branches
ActionItem498: fixing tests for manage_products
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2244 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
11 additions
and
11 deletions
Show diff stats
app/controllers/my_profile/manage_products_controller.rb
... | ... | @@ -63,7 +63,7 @@ class ManageProductsController < ApplicationController |
63 | 63 | @current_category = ProductCategory.top_level_for(environment).first |
64 | 64 | @categories = @current_category.nil? ? [] : @current_category.children |
65 | 65 | end |
66 | - render :partial => 'shared/select_categories', :locals => {:object_name => 'product'}, :layout => false | |
66 | + render :partial => 'shared/select_categories', :locals => {:object_name => 'product', :multiple => false}, :layout => false | |
67 | 67 | end |
68 | 68 | |
69 | 69 | def new_consumption | ... | ... |
app/models/article.rb
test/functional/manage_products_controller_test.rb
... | ... | @@ -118,7 +118,7 @@ class ManageProductsControllerTest < Test::Unit::TestCase |
118 | 118 | category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) |
119 | 119 | category3 = ProductCategory.create!(:name => 'Category 3', :environment => environment, :parent => category2) |
120 | 120 | get :new, :profile => @enterprise.identifier |
121 | - assert_tag :tag => 'h3', :content => /Select a category:/, :sibling => { :tag => 'a', :content => /#{category2.name}/ } | |
121 | + assert_tag :tag => 'h3', :content => /Categories:/, :sibling => { :tag => 'a', :content => /#{category2.name}/ } | |
122 | 122 | end |
123 | 123 | |
124 | 124 | should 'show current category' do |
... | ... | @@ -126,7 +126,7 @@ class ManageProductsControllerTest < Test::Unit::TestCase |
126 | 126 | category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) |
127 | 127 | category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) |
128 | 128 | category3 = ProductCategory.create!(:name => 'Category 3', :environment => environment, :parent => category2) |
129 | - get 'update_subcategories', :profile => @enterprise.identifier, :id => category2.id | |
129 | + get 'update_categories', :profile => @enterprise.identifier, :category_id => category2.id | |
130 | 130 | assert_tag :tag => 'h3', :content => /Current category:/, :sibling => { :tag => 'a', :content => /#{category3.name}/ } |
131 | 131 | end |
132 | 132 | |
... | ... | @@ -135,24 +135,24 @@ class ManageProductsControllerTest < Test::Unit::TestCase |
135 | 135 | category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) |
136 | 136 | category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) |
137 | 137 | category3 = ProductCategory.create!(:name => 'Category 3', :environment => environment, :parent => category2) |
138 | - get 'update_subcategories', :profile => @enterprise.identifier, :id => category2.id | |
138 | + get 'update_categories', :profile => @enterprise.identifier, :category_id => category2.id | |
139 | 139 | assert !assigns(:categories).empty? |
140 | - assert_tag :tag => 'h3', :content => /Select a subcategory:/, :sibling => { :tag => 'a', :attributes => { :href => '#' }, :content => /#{category2.name}/ } | |
140 | + assert_tag :tag => 'h3', :content => /Categories:/, :sibling => { :tag => 'a', :attributes => { :href => '#' }, :content => /#{category2.name}/ } | |
141 | 141 | end |
142 | 142 | |
143 | 143 | should 'update subcategories' do |
144 | 144 | environment = Environment.default |
145 | 145 | category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) |
146 | 146 | category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) |
147 | - get 'update_subcategories', :profile => @enterprise.identifier, :id => category1.id | |
147 | + get 'update_categories', :profile => @enterprise.identifier, :category_id => category1.id | |
148 | 148 | assert_tag :tag => 'a', :attributes => { :href => '#' }, :content => /#{category2.name}/ |
149 | 149 | end |
150 | 150 | |
151 | 151 | should 'not show subcategories list when no subcategories' do |
152 | 152 | environment = Environment.default |
153 | - category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) | |
154 | - get 'update_subcategories', :profile => @enterprise.identifier, :id => category1.id | |
155 | - assert_no_tag :tag => 'p', :content => 'Select a subcategory:' | |
153 | + category1 = @enterprise.products.create!(:name => 'Category 1') | |
154 | + get 'update_categories', :profile => @enterprise.identifier, :id => category1.id | |
155 | + assert_no_tag :tag => 'h3', :content => 'Categories:' | |
156 | 156 | end |
157 | 157 | |
158 | 158 | should "create new product categorized" do | ... | ... |
test/unit/article_test.rb
... | ... | @@ -354,7 +354,7 @@ class ArticleTest < Test::Unit::TestCase |
354 | 354 | should 'not add a category twice to article' do |
355 | 355 | c1 = Category.create!(:environment => Environment.default, :name => 'c1') |
356 | 356 | c2 = c1.children.create!(:environment => Environment.default, :name => 'c2') |
357 | - c3 = c2.children.create!(:environment => Environment.default, :name => 'c3') | |
357 | + c3 = c1.children.create!(:environment => Environment.default, :name => 'c3') | |
358 | 358 | owner = create_user('testuser').person |
359 | 359 | art = owner.articles.create!(:name => 'ytest') |
360 | 360 | art.category_ids = [c2,c3,c3].map(&:id) | ... | ... |