Commit 39215aac24eb73b824eb0928ff999008ff2a7953
Exists in
master
and in
29 other branches
Merge branch 'shopping_cart_bugs' into 'master'
Shopping cart bugs Same of #601, but against master. See merge request !606
Showing
6 changed files
with
23 additions
and
5 deletions
Show diff stats
plugins/shopping_cart/lib/shopping_cart_plugin.rb
1 | class ShoppingCartPlugin < Noosfero::Plugin | 1 | class ShoppingCartPlugin < Noosfero::Plugin |
2 | + include ModalHelper | ||
3 | + include ActionView::Helpers::UrlHelper | ||
2 | 4 | ||
3 | class << self | 5 | class << self |
4 | def plugin_name | 6 | def plugin_name |
@@ -63,4 +65,8 @@ class ShoppingCartPlugin < Noosfero::Plugin | @@ -63,4 +65,8 @@ class ShoppingCartPlugin < Noosfero::Plugin | ||
63 | 65 | ||
64 | buttons | 66 | buttons |
65 | end | 67 | end |
68 | + | ||
69 | + def controller | ||
70 | + context | ||
71 | + end | ||
66 | end | 72 | end |
plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
@@ -42,7 +42,7 @@ module ShoppingCartPlugin::CartHelper | @@ -42,7 +42,7 @@ module ShoppingCartPlugin::CartHelper | ||
42 | else | 42 | else |
43 | delivery = Product.new(:name => delivery_option || _('Delivery'), :price => settings.delivery_options[delivery_option]) | 43 | delivery = Product.new(:name => delivery_option || _('Delivery'), :price => settings.delivery_options[delivery_option]) |
44 | end | 44 | end |
45 | - delivery.save(false) | 45 | + delivery.save(validate: false) |
46 | items << [delivery.id, ''] | 46 | items << [delivery.id, ''] |
47 | end | 47 | end |
48 | 48 |
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
@@ -41,5 +41,19 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase | @@ -41,5 +41,19 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase | ||
41 | assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment) | 41 | assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment) |
42 | end | 42 | end |
43 | 43 | ||
44 | -end | 44 | + should 'return a table of items' do |
45 | + enterprise = Enterprise.new(name: "Test Enterprise", identifier: "test-enterprise") | ||
46 | + enterprise.environment = Environment.default | ||
47 | + enterprise.save! | ||
48 | + | ||
49 | + product_category = fast_create(ProductCategory, :name => 'Products') | ||
50 | + product = fast_create(Product, :name => 'test product1', :product_category_id => product_category.id, :profile_id => enterprise.id) | ||
51 | + setting = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin) | ||
52 | + setting.delivery = true | ||
53 | + setting.save! | ||
54 | + | ||
55 | + assert_match 'table id="cart-items-table"', items_table([product], enterprise) | ||
56 | + assert_match '<td>test product1</td>', items_table([product], enterprise) | ||
57 | + end | ||
45 | 58 | ||
59 | +end |
plugins/shopping_cart/views/cart.html.erb
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <a href="cart:clean" onclick="Cart.clean(this); return false" class="cart-clean"><%=_('Clean basket')%></a> | 5 | <a href="cart:clean" onclick="Cart.clean(this); return false" class="cart-clean"><%=_('Clean basket')%></a> |
6 | <ul class="cart-items"></ul> | 6 | <ul class="cart-items"></ul> |
7 | <div class="cart-total"><%=_('Total:')%> <b></b></div> | 7 | <div class="cart-total"><%=_('Total:')%> <b></b></div> |
8 | - <a href="/plugin/shopping_cart/buy" class="cart-buy modal"><%=_('Shopping checkout')%></a> | 8 | + <%= modal_link_to _('Shopping checkout'), { controller: 'shopping_cart_plugin', action: 'buy' }, { class: "cart-buy modal" } %> |
9 | </div> | 9 | </div> |
10 | <a href="#" onclick="Cart.toggle(this); return false" class="cart-toggle"> | 10 | <a href="#" onclick="Cart.toggle(this); return false" class="cart-toggle"> |
11 | <span class="str-show"><%=_('Show basket')%></span> | 11 | <span class="str-show"><%=_('Show basket')%></span> |
plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
@@ -24,7 +24,6 @@ | @@ -24,7 +24,6 @@ | ||
24 | <% end %> | 24 | <% end %> |
25 | <% delivery_option = @settings.delivery_options.first && @settings.delivery_options.first.first %> | 25 | <% delivery_option = @settings.delivery_options.first && @settings.delivery_options.first.first %> |
26 | <%= items_table(@cart[:items], @profile, delivery_option) %> | 26 | <%= items_table(@cart[:items], @profile, delivery_option) %> |
27 | - <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %> | ||
28 | </div> | 27 | </div> |
29 | 28 | ||
30 | <%= javascript_include_tag '../plugins/shopping_cart/buy' %> | 29 | <%= javascript_include_tag '../plugins/shopping_cart/buy' %> |
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
@@ -17,7 +17,6 @@ | @@ -17,7 +17,6 @@ | ||
17 | </div> | 17 | </div> |
18 | <% end %> | 18 | <% end %> |
19 | <%= items_table(session[:cart][:items], profile) %> | 19 | <%= items_table(session[:cart][:items], profile) %> |
20 | - <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %> | ||
21 | </div> | 20 | </div> |
22 | 21 | ||
23 | <script type="text/javascript"> | 22 | <script type="text/javascript"> |