Commit d79e1da5bf3b4fac2cfe5e3ab466c46358ba50cd

Authored by Braulio Bhavamitra
1 parent 632d06f9

shopping_cart: fix functional and selenium tests

plugins/orders/lib/ext/profile.rb
@@ -12,10 +12,7 @@ subclass.class_eval do @@ -12,10 +12,7 @@ subclass.class_eval do
12 has_many :ordered_items, -> { order 'name ASC' }, through: :orders, source: :items 12 has_many :ordered_items, -> { order 'name ASC' }, through: :orders, source: :items
13 13
14 has_many :sales_consumers, through: :sales, source: :consumer 14 has_many :sales_consumers, through: :sales, source: :consumer
15 - has_many :purchases_consumers, through: :sales, source: :consumer  
16 -  
17 - has_many :sales_profiles, through: :sales, source: :profile  
18 - has_many :purchases_profiles, through: :sales, source: :profile 15 + has_many :purchases_suppliers, through: :purchases, source: :profile
19 16
20 end 17 end
21 end 18 end
@@ -30,12 +27,12 @@ class Profile @@ -30,12 +27,12 @@ class Profile
30 27
31 def sales_all_consumers 28 def sales_all_consumers
32 consumers = self.sales_consumers.order 'name ASC' 29 consumers = self.sales_consumers.order 'name ASC'
33 - consumers.concat self.suppliers.except_self.order('name ASC') if self.respond_to? :suppliers 30 + consumers.concat self.consumers.except_self.order('name ASC') if self.respond_to? :consumers
34 consumers.uniq 31 consumers.uniq
35 end 32 end
36 - def purchases_all_consumers  
37 - consumers = self.purchases_consumers.order 'name ASC'  
38 - consumers.concat self.consumers.except_self.order('name ASC') if self.respond_to? :consumers 33 + def purchases_all_suppliers
  34 + consumers = self.purchases_suppliers.order 'name ASC'
  35 + consumers.concat self.suppliers.except_self.order('name ASC') if self.respond_to? :suppliers
39 consumers.uniq 36 consumers.uniq
40 end 37 end
41 38
plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb
@@ -28,10 +28,11 @@ @@ -28,10 +28,11 @@
28 28
29 <%= render "orders_plugin_order/show_simple", order: @order, actor_name: :consumer %> 29 <%= render "orders_plugin_order/show_simple", order: @order, actor_name: :consumer %>
30 30
  31 +
31 <p> 32 <p>
32 <%= t('orders_plugin.views.mailer.order_confirmation.your_order_can_be_che') %><br /> 33 <%= t('orders_plugin.views.mailer.order_confirmation.your_order_can_be_che') %><br />
33 <%= link_to t('orders_plugin.views.mailer.order_confirmation.order_code_of_profile') % {code: @order.code, name: @profile.name }, 34 <%= link_to t('orders_plugin.views.mailer.order_confirmation.order_code_of_profile') % {code: @order.code, name: @profile.name },
34 - {controller: :orders_cycle_plugin_order, action: :edit, profile: @profile.identifier, id: @order.id, protocol: "http"} %> 35 + {controller: :orders_plugin_order, action: :edit, profile: @profile.identifier, id: @order.id, protocol: "http"} %>
35 </p> 36 </p>
36 37
37 <p> 38 <p>
plugins/orders/views/orders_plugin_admin/_index.html.erb
@@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
1 -<h1> <%= t('orders_plugin.lib.plugin.panel_button') %> </h1>  
2 -  
3 -<%= button :back, _('Back to control panel'), controller: 'profile_editor' %>  
4 -  
5 -<div>  
6 - <% if @purchases.present? and @sales.present? %>  
7 - <ul id="orders-tabs" class='nav nav-pills' data-tabs="orders-tabs">  
8 - <li class='active' data-toggle="orders-tabs"><a href='#purchases'><%= t('orders_plugin.terms.purchase.plural') %></a></li>  
9 - <li class='<%= 'active' if @purchases.blank? %>' data-toggle="orders-tabs"><a href='#sales'><%= t('orders_plugin.terms.sale.plural') %></a></li>  
10 - </ul>  
11 - <% end %>  
12 -  
13 - <% if @purchases.present? %>  
14 - <div id='purchases' class="tab-pane">  
15 - <%= render 'orders_plugin_admin/purchases', actors: profile.sales_all_consumers,  
16 - orders_owner: profile, orders: @purchases, month: @purchases_month, year: @purchases_year, wireframe_size: false %>  
17 - </div>  
18 - <% end %>  
19 -  
20 - <% if @sales.present? %>  
21 - <div id='sales' class="tab-pane">  
22 - <%= render 'orders_plugin_admin/sales', actors: profile.purchases_all_consumers,  
23 - orders_owner: profile, orders: @sales, month: @sales_month, year: @purchases_year, wireframe_size: false %>  
24 - </div>  
25 - <% end %>  
26 -</div>  
plugins/orders/views/orders_plugin_admin/_index.html.slim 0 → 100644
@@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
  1 +h1
  2 + = t('orders_plugin.lib.plugin.panel_button')
  3 +
  4 += button :back, _('Back to control panel'), controller: 'profile_editor'
  5 +
  6 +div
  7 + - if @purchases.present? and @sales.present?
  8 + ul#orders-tabs.nav.nav-pills data-tabs="orders-tabs"
  9 + li.active data-toggle="orders-tabs"
  10 + a href="#purchases" = t('orders_plugin.terms.purchase.plural')
  11 + li class=("#{'active' if @purchases.blank?}") data-toggle="orders-tabs"
  12 + a href="#sales" = t('orders_plugin.terms.sale.plural')
  13 +
  14 + - if @purchases.present?
  15 + #purchases.tab-pane
  16 + = render 'orders_plugin_admin/purchases', actors: profile.purchases_all_suppliers,
  17 + orders_owner: profile, orders: @purchases, month: @purchases_month, year: @purchases_year, wireframe_size: false
  18 +
  19 + - if @sales.present?
  20 + #sales.tab-pane
  21 + = render 'orders_plugin_admin/sales', actors: profile.sales_all_consumers,
  22 + orders_owner: profile, orders: @sales, month: @sales_month, year: @purchases_year, wireframe_size: false
plugins/orders/views/orders_plugin_admin/_order.html.erb
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -<% other_actor_name = if actor_name == :supplier then :consumer else :supplier end %>  
2 -<% edit = true if edit.nil? %>  
3 -  
4 -<div id="order-row-<%=order.id%>" data-id="<%=order.id%>" class="order value-row <%=order.status%>" onclick="orders.admin.load_edit(this, '<%= url_for action: :edit, id: order.id, actor_name: actor_name %>')" toggle-edit="orders.admin.toggle_edit();">  
5 - <div class="box-view with-inner">  
6 - <div class="box-field select" toggle-ignore><%= check_box_tag "order_ids[]", order.id %></div>  
7 -  
8 - <div class="box-view-inner">  
9 - <span class='box-field code'><%= order.code %></span>  
10 - <span class='box-field actor-name'><%= order.send("#{other_actor_name}_data")[:name] %></span>  
11 - <span class='box-field order-date'><%= datetime_full order.created_at %></span>  
12 - <span class='box-field last-update'><%= datetime_full order.updated_at %></span>  
13 - <span class='box-field total'><%= order.total_price_as_currency_number actor_name %></span>  
14 - <span class='box-field situation'><%= order_situation order %></span>  
15 - </div>  
16 -  
17 - <%= edit_arrow "#order-row-#{order.id}", true, class: 'actions' %>  
18 -  
19 - <div class="clean"></div>  
20 - </div>  
21 -  
22 - <div class="box-edit <%= 'loading' if not edit %>">  
23 - <% if edit %>  
24 - <%= render 'orders_plugin_admin/edit', order: order, actor_name: actor_name, other_actor_name: other_actor_name %>  
25 - <% end %>  
26 - </div>  
27 -  
28 - <div class="clean"></div>  
29 -</div>  
plugins/orders/views/orders_plugin_admin/index.html.erb
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -_index.html.erb  
2 \ No newline at end of file 0 \ No newline at end of file
plugins/orders/views/orders_plugin_admin/index.html.slim 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +_index.html.slim
0 \ No newline at end of file 2 \ No newline at end of file
plugins/shopping_cart/features/delivery_client.feature
@@ -37,7 +37,7 @@ Feature: delivery client @@ -37,7 +37,7 @@ Feature: delivery client
37 And I should see "Show basket" 37 And I should see "Show basket"
38 And I follow "Show basket" 38 And I follow "Show basket"
39 And I follow "Shopping checkout" 39 And I follow "Shopping checkout"
40 - And I fill in "Contact phone" with "123456789" 40 + And I fill in "order_consumer_data_contact_phone" with "123456789"
41 When I select "Bike ($8.00)" from "Option" 41 When I select "Bike ($8.00)" from "Option"
42 Then I should see "My good old bike." within ".instructions" 42 Then I should see "My good old bike." within ".instructions"
43 And I should see "Address" 43 And I should see "Address"
@@ -51,7 +51,7 @@ Feature: delivery client @@ -51,7 +51,7 @@ Feature: delivery client
51 And I should see "Show basket" 51 And I should see "Show basket"
52 And I follow "Show basket" 52 And I follow "Show basket"
53 And I follow "Shopping checkout" 53 And I follow "Shopping checkout"
54 - And I fill in "Contact phone" with "123456789" 54 + And I fill in "order_consumer_data_contact_phone" with "123456789"
55 When I select "Bar" from "Option" 55 When I select "Bar" from "Option"
56 Then I should see "Come to my bar and drink it!" within ".instructions" 56 Then I should see "Come to my bar and drink it!" within ".instructions"
57 And I should not see "Address" 57 And I should not see "Address"
@@ -69,7 +69,7 @@ Feature: delivery client @@ -69,7 +69,7 @@ Feature: delivery client
69 And I should see "Show basket" 69 And I should see "Show basket"
70 And I follow "Show basket" 70 And I follow "Show basket"
71 And I follow "Shopping checkout" 71 And I follow "Shopping checkout"
72 - And I fill in "Contact phone" with "123456789" 72 + And I fill in "order_consumer_data_contact_phone" with "123456789"
73 When I select "Bike ($8.00)" from "Option" 73 When I select "Bike ($8.00)" from "Option"
74 Then I should see "My good old bike." within ".instructions" 74 Then I should see "My good old bike." within ".instructions"
75 And I should see "Address" 75 And I should see "Address"
plugins/shopping_cart/features/purchases.feature
@@ -108,7 +108,7 @@ Feature: purchases @@ -108,7 +108,7 @@ Feature: purchases
108 And I follow "Purchases made" 108 And I follow "Purchases made"
109 And I should see "Moes Tavern" within any ".actor-name" 109 And I should see "Moes Tavern" within any ".actor-name"
110 And I should see "First Church of Springfield" within any ".actor-name" 110 And I should see "First Church of Springfield" within any ".actor-name"
111 - And I select "Moes Tavern" from "supplier" 111 + And I select "Moes Tavern" from "supplier_id"
112 When I press "Filter" 112 When I press "Filter"
113 Then I should see "Moes Tavern" within any ".actor-name" 113 Then I should see "Moes Tavern" within any ".actor-name"
114 And I should not see "First Church of Springfield" within any ".actor-name" 114 And I should not see "First Church of Springfield" within any ".actor-name"
@@ -125,7 +125,7 @@ Feature: purchases @@ -125,7 +125,7 @@ Feature: purchases
125 And I follow "Add to basket" 125 And I follow "Add to basket"
126 And I follow "Show basket" 126 And I follow "Show basket"
127 And I follow "Shopping checkout" 127 And I follow "Shopping checkout"
128 - And I fill in "Contact phone" with "123456789" 128 + And I fill in "order_consumer_data_contact_phone" with "123456789"
129 And I select "Bike ($8.00)" from "Option" 129 And I select "Bike ($8.00)" from "Option"
130 And I press "Send buy request" 130 And I press "Send buy request"
131 And I go to homer's control panel 131 And I go to homer's control panel
plugins/shopping_cart/features/sales.feature
@@ -98,7 +98,7 @@ Feature: sales @@ -98,7 +98,7 @@ Feature: sales
98 And I follow "Purchases and Sales" 98 And I follow "Purchases and Sales"
99 And I should see "Homer" within any ".actor-name" 99 And I should see "Homer" within any ".actor-name"
100 And I should see "Reverend Lovejoy" within any ".actor-name" 100 And I should see "Reverend Lovejoy" within any ".actor-name"
101 - And I select "Homer" from "consumer" 101 + And I select "Homer" from "consumer_id"
102 When I press "Filter" 102 When I press "Filter"
103 Then I should see "Homer" within any ".actor-name" 103 Then I should see "Homer" within any ".actor-name"
104 And I should not see "Reverend Lovejoy" within any ".actor-name" 104 And I should not see "Reverend Lovejoy" within any ".actor-name"
plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
@@ -16,11 +16,11 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase @@ -16,11 +16,11 @@ class ShoppingCartPluginControllerTest &lt; ActionController::TestCase
16 16
17 should 'force cookie expiration with explicit path for an empty cart' do 17 should 'force cookie expiration with explicit path for an empty cart' do
18 get :get, id: product.id 18 get :get, id: product.id
19 - assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/ 19 + assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart/
20 20
21 get :add, id: product.id 21 get :add, id: product.id
22 get :remove, id: product.id 22 get :remove, id: product.id
23 - assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/ 23 + assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart/
24 end 24 end
25 25
26 should 'add a new product to cart' do 26 should 'add a new product to cart' do