[Git][noosfero/noosfero][master] 4 commits: Change deprecated save in shopping_cart plugin

Bráulio Bhavamitra gitlab at gitlab.com
Wed Jun 17 18:50:37 BRT 2015


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


Commits:
e6ab61ce by Arthur Del Esposte at 2015-06-17T17:38:23Z
Change deprecated save in shopping_cart plugin

- - - - -
ea74d2b3 by Arthur Del Esposte at 2015-06-17T17:46:58Z
Fix modal buy view from shopping cart plugin

- - - - -
13583f20 by Arthur Del Esposte at 2015-06-17T17:48:41Z
Removing unnecessary button from shopping_cart's modal views

- - - - -
39215aac by Bráulio Bhavamitra at 2015-06-17T21:50:25Z
Merge branch 'shopping_cart_bugs' into 'master'

Shopping cart bugs

Same of #601, but against master.

See merge request !606

- - - - -


6 changed files:

- plugins/shopping_cart/lib/shopping_cart_plugin.rb
- plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
- plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
- plugins/shopping_cart/views/cart.html.erb
- plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
- plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb


Changes:

=====================================
plugins/shopping_cart/lib/shopping_cart_plugin.rb
=====================================
--- a/plugins/shopping_cart/lib/shopping_cart_plugin.rb
+++ b/plugins/shopping_cart/lib/shopping_cart_plugin.rb
@@ -1,4 +1,6 @@
 class ShoppingCartPlugin < Noosfero::Plugin
+  include ModalHelper
+  include ActionView::Helpers::UrlHelper
 
   class << self
     def plugin_name
@@ -63,4 +65,8 @@ class ShoppingCartPlugin < Noosfero::Plugin
 
     buttons
   end
+
+  def controller
+    context
+  end
 end


=====================================
plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
=====================================
--- a/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
+++ b/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
@@ -42,7 +42,7 @@ module ShoppingCartPlugin::CartHelper
       else
         delivery = Product.new(:name => delivery_option || _('Delivery'), :price => settings.delivery_options[delivery_option])
       end
-      delivery.save(false)
+      delivery.save(validate: false)
       items << [delivery.id, '']
     end
 


=====================================
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
=====================================
--- a/plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
+++ b/plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
@@ -41,5 +41,19 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase
     assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment)
   end
 
-end
+  should 'return a table of items' do
+    enterprise = Enterprise.new(name: "Test Enterprise", identifier: "test-enterprise")
+    enterprise.environment = Environment.default
+    enterprise.save!
+
+    product_category = fast_create(ProductCategory, :name => 'Products')
+    product = fast_create(Product, :name => 'test product1', :product_category_id => product_category.id, :profile_id => enterprise.id)
+    setting = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin)
+    setting.delivery = true
+    setting.save!
+
+    assert_match 'table id="cart-items-table"', items_table([product], enterprise)
+    assert_match '<td>test product1</td>', items_table([product], enterprise)
+  end
 
+end


=====================================
plugins/shopping_cart/views/cart.html.erb
=====================================
--- a/plugins/shopping_cart/views/cart.html.erb
+++ b/plugins/shopping_cart/views/cart.html.erb
@@ -5,7 +5,7 @@
       <a href="cart:clean" onclick="Cart.clean(this); return false" class="cart-clean"><%=_('Clean basket')%></a>
       <ul class="cart-items"></ul>
       <div class="cart-total"><%=_('Total:')%> <b></b></div>
-      <a href="/plugin/shopping_cart/buy" class="cart-buy modal"><%=_('Shopping checkout')%></a>
+      <%= modal_link_to _('Shopping checkout'), { controller: 'shopping_cart_plugin', action: 'buy' }, { class: "cart-buy modal" } %>
     </div>
     <a href="#" onclick="Cart.toggle(this); return false" class="cart-toggle">
       <span class="str-show"><%=_('Show basket')%></span>


=====================================
plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
=====================================
--- a/plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
+++ b/plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
@@ -24,7 +24,6 @@
   <% end %>
   <% delivery_option = @settings.delivery_options.first && @settings.delivery_options.first.first %>
   <%= items_table(@cart[:items], @profile, delivery_option) %>
-  <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %>
 </div>
 
 <%= javascript_include_tag '../plugins/shopping_cart/buy' %>


=====================================
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
=====================================
--- a/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
+++ b/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
@@ -17,7 +17,6 @@
     </div>
   <% end %>
   <%= items_table(session[:cart][:items], profile) %>
-  <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %>
 </div>
 
 <script type="text/javascript">



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/53c76729fced2e974abfafb065ac2397d7ef6faa...39215aac24eb73b824eb0928ff999008ff2a7953
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150617/081a10ed/attachment-0001.html>


More information about the Noosfero-dev mailing list