[Git][noosfero/noosfero][master] shopping_cart: fix functional and selenium tests

Bráulio Bhavamitra gitlab at mg.gitlab.com
Sat Dec 12 15:25:41 BRST 2015


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
d79e1da5 by Braulio Bhavamitra at 2015-12-12T14:24:57Z
shopping_cart: fix functional and selenium tests

- - - - -


11 changed files:

- plugins/orders/lib/ext/profile.rb
- plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb
- − plugins/orders/views/orders_plugin_admin/_index.html.erb
- + plugins/orders/views/orders_plugin_admin/_index.html.slim
- − plugins/orders/views/orders_plugin_admin/_order.html.erb
- − plugins/orders/views/orders_plugin_admin/index.html.erb
- + plugins/orders/views/orders_plugin_admin/index.html.slim
- plugins/shopping_cart/features/delivery_client.feature
- plugins/shopping_cart/features/purchases.feature
- plugins/shopping_cart/features/sales.feature
- plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb


Changes:

=====================================
plugins/orders/lib/ext/profile.rb
=====================================
--- a/plugins/orders/lib/ext/profile.rb
+++ b/plugins/orders/lib/ext/profile.rb
@@ -12,10 +12,7 @@ subclass.class_eval do
   has_many :ordered_items, -> { order 'name ASC' }, through: :orders, source: :items
 
   has_many :sales_consumers, through: :sales, source: :consumer
-  has_many :purchases_consumers, through: :sales, source: :consumer
-
-  has_many :sales_profiles, through: :sales, source: :profile
-  has_many :purchases_profiles, through: :sales, source: :profile
+  has_many :purchases_suppliers, through: :purchases, source: :profile
 
 end
 end
@@ -30,12 +27,12 @@ class Profile
 
   def sales_all_consumers
     consumers = self.sales_consumers.order 'name ASC'
-    consumers.concat self.suppliers.except_self.order('name ASC') if self.respond_to? :suppliers
+    consumers.concat self.consumers.except_self.order('name ASC') if self.respond_to? :consumers
     consumers.uniq
   end
-  def purchases_all_consumers
-    consumers = self.purchases_consumers.order 'name ASC'
-    consumers.concat self.consumers.except_self.order('name ASC') if self.respond_to? :consumers
+  def purchases_all_suppliers
+    consumers = self.purchases_suppliers.order 'name ASC'
+    consumers.concat self.suppliers.except_self.order('name ASC') if self.respond_to? :suppliers
     consumers.uniq
   end
 


=====================================
plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb
=====================================
--- a/plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb
+++ b/plugins/orders/views/orders_plugin/mailer/order_confirmation.html.erb
@@ -28,10 +28,11 @@
 
     <%= render "orders_plugin_order/show_simple", order: @order, actor_name: :consumer %>
 
+
     <p>
       <%= t('orders_plugin.views.mailer.order_confirmation.your_order_can_be_che') %><br />
       <%= link_to t('orders_plugin.views.mailer.order_confirmation.order_code_of_profile') % {code: @order.code, name: @profile.name },
-        {controller: :orders_cycle_plugin_order, action: :edit, profile: @profile.identifier, id: @order.id, protocol: "http"} %>
+        {controller: :orders_plugin_order, action: :edit, profile: @profile.identifier, id: @order.id, protocol: "http"} %>
     </p>
 
     <p>


=====================================
plugins/orders/views/orders_plugin_admin/_index.html.erb deleted
=====================================
--- a/plugins/orders/views/orders_plugin_admin/_index.html.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-<h1> <%= t('orders_plugin.lib.plugin.panel_button') %> </h1>
-
-<%= button :back, _('Back to control panel'), controller: 'profile_editor' %>
-
-<div>
-  <% if @purchases.present? and @sales.present? %>
-    <ul id="orders-tabs" class='nav nav-pills' data-tabs="orders-tabs">
-      <li class='active' data-toggle="orders-tabs"><a href='#purchases'><%= t('orders_plugin.terms.purchase.plural') %></a></li>
-      <li class='<%= 'active' if @purchases.blank? %>' data-toggle="orders-tabs"><a href='#sales'><%= t('orders_plugin.terms.sale.plural') %></a></li>
-    </ul>
-  <% end %>
-
-  <% if @purchases.present? %>
-    <div id='purchases' class="tab-pane">
-      <%= render 'orders_plugin_admin/purchases', actors: profile.sales_all_consumers,
-        orders_owner: profile, orders: @purchases, month: @purchases_month, year: @purchases_year, wireframe_size: false %>
-    </div>
-  <% end %>
-
-  <% if @sales.present? %>
-    <div id='sales' class="tab-pane">
-      <%= render 'orders_plugin_admin/sales', actors: profile.purchases_all_consumers,
-        orders_owner: profile, orders: @sales, month: @sales_month, year: @purchases_year, wireframe_size: false %>
-    </div>
-  <% end %>
-</div>


=====================================
plugins/orders/views/orders_plugin_admin/_index.html.slim
=====================================
--- /dev/null
+++ b/plugins/orders/views/orders_plugin_admin/_index.html.slim
@@ -0,0 +1,22 @@
+h1
+  = t('orders_plugin.lib.plugin.panel_button')
+
+= button :back, _('Back to control panel'), controller: 'profile_editor'
+
+div
+  - if @purchases.present? and @sales.present?
+    ul#orders-tabs.nav.nav-pills data-tabs="orders-tabs"
+      li.active data-toggle="orders-tabs"
+        a href="#purchases" = t('orders_plugin.terms.purchase.plural')
+      li class=("#{'active' if @purchases.blank?}") data-toggle="orders-tabs"
+        a href="#sales" = t('orders_plugin.terms.sale.plural')
+
+  - if @purchases.present?
+    #purchases.tab-pane
+      = render 'orders_plugin_admin/purchases', actors: profile.purchases_all_suppliers,
+        orders_owner: profile, orders: @purchases, month: @purchases_month, year: @purchases_year, wireframe_size: false
+
+  - if @sales.present?
+    #sales.tab-pane
+      = render 'orders_plugin_admin/sales', actors: profile.sales_all_consumers,
+        orders_owner: profile, orders: @sales, month: @sales_month, year: @purchases_year, wireframe_size: false


=====================================
plugins/orders/views/orders_plugin_admin/_order.html.erb deleted
=====================================
--- a/plugins/orders/views/orders_plugin_admin/_order.html.erb
+++ /dev/null
@@ -1,29 +0,0 @@
-<% other_actor_name = if actor_name == :supplier then :consumer else :supplier end %>
-<% edit = true if edit.nil? %>
-
-<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();">
-  <div class="box-view with-inner">
-    <div class="box-field select" toggle-ignore><%= check_box_tag "order_ids[]", order.id %></div>
-
-    <div class="box-view-inner">
-      <span class='box-field code'><%= order.code %></span>
-      <span class='box-field actor-name'><%= order.send("#{other_actor_name}_data")[:name] %></span>
-      <span class='box-field order-date'><%= datetime_full order.created_at %></span>
-      <span class='box-field last-update'><%= datetime_full order.updated_at %></span>
-      <span class='box-field total'><%= order.total_price_as_currency_number actor_name %></span>
-      <span class='box-field situation'><%= order_situation order %></span>
-    </div>
-
-    <%= edit_arrow "#order-row-#{order.id}", true, class: 'actions' %>
-
-    <div class="clean"></div>
-  </div>
-
-  <div class="box-edit <%= 'loading' if not edit %>">
-    <% if edit %>
-      <%= render 'orders_plugin_admin/edit', order: order, actor_name: actor_name, other_actor_name: other_actor_name %>
-    <% end %>
-  </div>
-
-  <div class="clean"></div>
-</div>


=====================================
plugins/orders/views/orders_plugin_admin/index.html.erb deleted
=====================================
--- a/plugins/orders/views/orders_plugin_admin/index.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-_index.html.erb
\ No newline at end of file


=====================================
plugins/orders/views/orders_plugin_admin/index.html.slim
=====================================
--- /dev/null
+++ b/plugins/orders/views/orders_plugin_admin/index.html.slim
@@ -0,0 +1 @@
+_index.html.slim
\ No newline at end of file


=====================================
plugins/shopping_cart/features/delivery_client.feature
=====================================
--- a/plugins/shopping_cart/features/delivery_client.feature
+++ b/plugins/shopping_cart/features/delivery_client.feature
@@ -37,7 +37,7 @@ Feature: delivery client
     And I should see "Show basket"
     And I follow "Show basket"
     And I follow "Shopping checkout"
-    And I fill in "Contact phone" with "123456789"
+    And I fill in "order_consumer_data_contact_phone" with "123456789"
     When I select "Bike ($8.00)" from "Option"
     Then I should see "My good old bike." within ".instructions"
     And I should see "Address"
@@ -51,7 +51,7 @@ Feature: delivery client
     And I should see "Show basket"
     And I follow "Show basket"
     And I follow "Shopping checkout"
-    And I fill in "Contact phone" with "123456789"
+    And I fill in "order_consumer_data_contact_phone" with "123456789"
     When I select "Bar" from "Option"
     Then I should see "Come to my bar and drink it!" within ".instructions"
     And I should not see "Address"
@@ -69,7 +69,7 @@ Feature: delivery client
     And I should see "Show basket"
     And I follow "Show basket"
     And I follow "Shopping checkout"
-    And I fill in "Contact phone" with "123456789"
+    And I fill in "order_consumer_data_contact_phone" with "123456789"
     When I select "Bike ($8.00)" from "Option"
     Then I should see "My good old bike." within ".instructions"
     And I should see "Address"


=====================================
plugins/shopping_cart/features/purchases.feature
=====================================
--- a/plugins/shopping_cart/features/purchases.feature
+++ b/plugins/shopping_cart/features/purchases.feature
@@ -108,7 +108,7 @@ Feature: purchases
     And I follow "Purchases made"
     And I should see "Moes Tavern" within any ".actor-name"
     And I should see "First Church of Springfield" within any ".actor-name"
-    And I select "Moes Tavern" from "supplier"
+    And I select "Moes Tavern" from "supplier_id"
     When I press "Filter"
     Then I should see "Moes Tavern" within any ".actor-name"
     And I should not see "First Church of Springfield" within any ".actor-name"
@@ -125,7 +125,7 @@ Feature: purchases
     And I follow "Add to basket"
     And I follow "Show basket"
     And I follow "Shopping checkout"
-    And I fill in "Contact phone" with "123456789"
+    And I fill in "order_consumer_data_contact_phone" with "123456789"
     And I select "Bike ($8.00)" from "Option"
     And I press "Send buy request"
     And I go to homer's control panel


=====================================
plugins/shopping_cart/features/sales.feature
=====================================
--- a/plugins/shopping_cart/features/sales.feature
+++ b/plugins/shopping_cart/features/sales.feature
@@ -98,7 +98,7 @@ Feature: sales
     And I follow "Purchases and Sales"
     And I should see "Homer" within any ".actor-name"
     And I should see "Reverend Lovejoy" within any ".actor-name"
-    And I select "Homer" from "consumer"
+    And I select "Homer" from "consumer_id"
     When I press "Filter"
     Then I should see "Homer" within any ".actor-name"
     And I should not see "Reverend Lovejoy" within any ".actor-name"


=====================================
plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
=====================================
--- a/plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
+++ b/plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
@@ -16,11 +16,11 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase
 
   should 'force cookie expiration with explicit path for an empty cart' do
     get :get, id: product.id
-    assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/
+    assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart/
 
     get :add, id: product.id
     get :remove, id: product.id
-    assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/
+    assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart/
   end
 
   should 'add a new product to cart' do



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/d79e1da5bf3b4fac2cfe5e3ab466c46358ba50cd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151212/63fc2f80/attachment-0001.html>


More information about the Noosfero-dev mailing list