Commit f71c2edbffe26ad50268305b773b846164653d10
1 parent
269bdeca
Exists in
master
and in
29 other branches
[purchase-order] Adding test for reports
Showing
3 changed files
with
22 additions
and
2 deletions
Show diff stats
plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb
@@ -83,6 +83,26 @@ class ShoppingCartPluginMyprofileControllerTest < Test::Unit::TestCase | @@ -83,6 +83,26 @@ class ShoppingCartPluginMyprofileControllerTest < Test::Unit::TestCase | ||
83 | assert_not_includes assigns(:orders), po4 | 83 | assert_not_includes assigns(:orders), po4 |
84 | end | 84 | end |
85 | 85 | ||
86 | + should 'group filtered orders products and quantities' do | ||
87 | + p1 = fast_create(Product, :enterprise_id => enterprise.id, :price => 1) | ||
88 | + p2 = fast_create(Product, :enterprise_id => enterprise.id, :price => 2) | ||
89 | + p3 = fast_create(Product, :enterprise_id => enterprise.id, :price => 3) | ||
90 | + po1_products = {p1.id => {:quantity => 1, :price => p1.price}, p2.id => {:quantity => 2, :price => p2.price }} | ||
91 | + po2_products = {p2.id => {:quantity => 1, :price => p2.price}, p3.id => {:quantity => 2, :price => p3.price }} | ||
92 | + po1 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :products_list => po1_products, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | ||
93 | + po2 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :products_list => po2_products, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | ||
94 | + | ||
95 | + post :reports, | ||
96 | + :profile => enterprise.identifier, | ||
97 | + :from => (Time.now - 1.day).strftime(TIME_FORMAT), | ||
98 | + :to => (Time.now + 1.day).strftime(TIME_FORMAT), | ||
99 | + :filter_status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED | ||
100 | + | ||
101 | + hash = {p1.id => 1, p2.id => 3, p3.id => 2} | ||
102 | + | ||
103 | + assert_equal hash, assigns(:products) | ||
104 | + end | ||
105 | + | ||
86 | should 'be able to update the order status' do | 106 | should 'be able to update the order status' do |
87 | po = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | 107 | po = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) |
88 | 108 |
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_orders_list.html.erb
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | <div style="display:none"> | 34 | <div style="display:none"> |
35 | <ul class="customer-details"> | 35 | <ul class="customer-details"> |
36 | <% { 'name' =>_('Name'), 'email' => _('E-mail'), 'contact_phone' => _('Contact phone'), 'address' => _('Address'), 'city' => _('City'), 'zip_code' => _('Zip code')}.each do |attribute, name| %> | 36 | <% { 'name' =>_('Name'), 'email' => _('E-mail'), 'contact_phone' => _('Contact phone'), 'address' => _('Address'), 'city' => _('City'), 'zip_code' => _('Zip code')}.each do |attribute, name| %> |
37 | - <%= content_tag('li', content_tag('strong', name+': ') + order.send('customer_'+attribute)) if order.send('customer_'+attribute) %> | 37 | + <%= content_tag('li', content_tag('strong', name+': ') + order.send('customer_'+attribute)) if !order.send('customer_'+attribute).blank? %> |
38 | <% end %> | 38 | <% end %> |
39 | </ul> | 39 | </ul> |
40 | <ul class="order-products"> | 40 | <ul class="order-products"> |
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_products_list.html.erb
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | </tr> | 8 | </tr> |
9 | <% @products.each do |id, quantity|%> | 9 | <% @products.each do |id, quantity|%> |
10 | <tr> | 10 | <tr> |
11 | - <td><%= Product.find(id).name %></td> | 11 | + <td><%= link_to(Product.find(id).name, Product.find(id).url) %></td> |
12 | <td style="text-align: center"><%= quantity %></td> | 12 | <td style="text-align: center"><%= quantity %></td> |
13 | </tr> | 13 | </tr> |
14 | <% end %> | 14 | <% end %> |