spree_minicart 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +1 -2
- data/README.md +1 -1
- data/app/controllers/orders_controller_decorator.rb +8 -0
- data/app/helpers/spree/base_helper_decorator.rb +21 -0
- data/app/views/spree/shared/_minicart.html.erb +3 -4
- data/app/views/spree/shared/_minicart_line_items.html.erb +1 -1
- data/lib/spree_minicart/version.rb +1 -1
- data/spec/requests/minicart_spec.rb +58 -1
- metadata +68 -22
data/.bundle/config
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
---
|
2
|
-
BUNDLE_DISABLE_SHARED_GEMS: '1'
|
1
|
+
--- {}
|
data/README.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
OrdersController.class_eval do
|
3
|
+
before_filter :set_current_order, :only => [:populate]
|
4
|
+
|
3
5
|
respond_to :js, :only => [:populate, :update]
|
6
|
+
|
7
|
+
ssl_allowed :populate, :update
|
8
|
+
|
9
|
+
def set_current_order
|
10
|
+
current_order(true)
|
11
|
+
end
|
4
12
|
end
|
5
13
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Spree
|
2
|
+
BaseHelper.module_eval do
|
3
|
+
|
4
|
+
# removed current_page? check because link_to_cart is called everywhere by spree_minicart
|
5
|
+
def link_to_cart(text = nil)
|
6
|
+
text = text ? h(text) : t('cart')
|
7
|
+
css_class = nil
|
8
|
+
|
9
|
+
if current_order.nil? or current_order.line_items.empty?
|
10
|
+
text = "#{text}: (#{t('empty')})"
|
11
|
+
css_class = 'empty'
|
12
|
+
else
|
13
|
+
text = "#{text}: (#{current_order.item_count}) <span class='amount'>#{order_subtotal(current_order)}</span>".html_safe
|
14
|
+
css_class = 'full'
|
15
|
+
end
|
16
|
+
|
17
|
+
link_to text, cart_path, :class => css_class
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
<% @minicart_order ||= current_order(true) %>
|
2
1
|
<div id="minicart">
|
3
2
|
<% @body_id = 'cart' %>
|
4
3
|
|
5
|
-
<% if
|
4
|
+
<% if current_order.nil? || current_order.line_items.empty? %>
|
6
5
|
|
7
6
|
<div data-hook="empty_minicart">
|
8
7
|
<p><%= t(:your_cart_is_empty) %></p>
|
@@ -13,11 +12,11 @@
|
|
13
12
|
<div data-hook="outside_minicart_form">
|
14
13
|
<div id="minicart-details" data-hook="minicart_details" class="clearfix">
|
15
14
|
<p>
|
16
|
-
<span><%= t(:subtotal) %>: <span class="order-total"><%= order_subtotal(
|
15
|
+
<span><%= t(:subtotal) %>: <span class="order-total"><%= order_subtotal(current_order) %></span></span>
|
17
16
|
<%= link_to t(:checkout), checkout_path, :class => 'button checkout primary', :id => 'checkout-link' %>
|
18
17
|
</p>
|
19
18
|
</div>
|
20
|
-
<%= form_for
|
19
|
+
<%= form_for current_order, :url => update_cart_path, :html => {:id => 'update-minicart'}, :remote => true do |order_form| %>
|
21
20
|
<div data-hook="inside_minicart_form">
|
22
21
|
|
23
22
|
<div data-hook="minicart_items" class="clearfix">
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<span><%= link_to variant.product.name, product_path(variant.product) %></span>
|
12
12
|
<span><%= "x#{line_item.quantity}" -%></span>
|
13
13
|
<%= variant.options_text %>
|
14
|
-
<% if
|
14
|
+
<% if current_order.insufficient_stock_lines.include? line_item %>
|
15
15
|
<span class="out-of-stock">
|
16
16
|
<%= variant.in_stock? ? t(:insufficient_stock, :on_hand => variant.on_hand) : t(:out_of_stock) %><br />
|
17
17
|
</span>
|
@@ -1,12 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
feature "minicart", :js => true do
|
4
|
-
background { @product =
|
4
|
+
background { @product = FactoryGirl.create(:product, :name => "ror mug", :price => 30) }
|
5
5
|
|
6
6
|
scenario "customer should be able to add and delete a product in the minicart" do
|
7
7
|
visit spree.products_path
|
8
|
+
|
8
9
|
click_link("ror mug")
|
9
10
|
|
11
|
+
within("li#link-to-cart") do
|
12
|
+
page.should have_content("Cart: (Empty)")
|
13
|
+
end
|
14
|
+
|
10
15
|
click_button "Add To Cart"
|
11
16
|
|
12
17
|
within("#link-to-cart a") do
|
@@ -26,6 +31,52 @@ feature "minicart", :js => true do
|
|
26
31
|
click_link "Delete"
|
27
32
|
end
|
28
33
|
|
34
|
+
within("li#link-to-cart") do
|
35
|
+
page.should have_content("Cart: (Empty)")
|
36
|
+
end
|
37
|
+
|
38
|
+
URI.parse(current_url).path.should =~ /products/
|
39
|
+
|
40
|
+
within("#minicart") do
|
41
|
+
page.should_not have_content("ror mug")
|
42
|
+
page.should_not have_content("$30")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
scenario "delete a line item with multiple quantity should totally remove from minicart" do
|
48
|
+
visit spree.products_path
|
49
|
+
click_link("ror mug")
|
50
|
+
|
51
|
+
within("li#link-to-cart") do
|
52
|
+
page.should have_content("Cart: (Empty)")
|
53
|
+
end
|
54
|
+
|
55
|
+
click_button "Add To Cart"
|
56
|
+
click_button "Add To Cart"
|
57
|
+
|
58
|
+
within("#link-to-cart a") do
|
59
|
+
page.should have_content("(2)")
|
60
|
+
end
|
61
|
+
|
62
|
+
within("#minicart") do
|
63
|
+
page.should have_content("ror mug")
|
64
|
+
page.should have_content("$30")
|
65
|
+
end
|
66
|
+
|
67
|
+
page.execute_script '$("#minicart-items li").trigger("mouseenter")'
|
68
|
+
|
69
|
+
within "li div.minicart-actions" do
|
70
|
+
page.should have_content("Delete")
|
71
|
+
# manually sliding down the minicart actions, dont know why its not working
|
72
|
+
page.execute_script '$("#minicart-items li div.minicart-actions").slideDown()'
|
73
|
+
click_link "Delete"
|
74
|
+
end
|
75
|
+
|
76
|
+
within("li#link-to-cart") do
|
77
|
+
page.should have_content("Cart: (Empty)")
|
78
|
+
end
|
79
|
+
|
29
80
|
URI.parse(current_url).path.should =~ /products/
|
30
81
|
|
31
82
|
within("#minicart") do
|
@@ -41,4 +92,10 @@ feature "minicart", :js => true do
|
|
41
92
|
click_button "Add To Cart"
|
42
93
|
URI.parse(current_url).path.should == "/cart"
|
43
94
|
end
|
95
|
+
|
96
|
+
scenario 'minicart should not create new order for every visitor', :js => false do
|
97
|
+
expect {
|
98
|
+
visit spree.products_path
|
99
|
+
}.to_not change(Spree::Order, :count)
|
100
|
+
end
|
44
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_minicart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: spree_sample
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,21 +37,31 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: capybara
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
|
-
- - =
|
51
|
+
- - '='
|
42
52
|
- !ruby/object:Gem::Version
|
43
53
|
version: 1.0.1
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.1
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: factory_girl
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: ffaker
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: rspec-rails
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ~>
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '2.7'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.7'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: sqlite3
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,10 +117,15 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: sass-rails
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
94
129
|
none: false
|
95
130
|
requirements:
|
96
131
|
- - ! '>='
|
@@ -98,10 +133,15 @@ dependencies:
|
|
98
133
|
version: '0'
|
99
134
|
type: :development
|
100
135
|
prerelease: false
|
101
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
102
142
|
- !ruby/object:Gem::Dependency
|
103
143
|
name: debugger
|
104
|
-
requirement:
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
105
145
|
none: false
|
106
146
|
requirements:
|
107
147
|
- - ! '>='
|
@@ -109,7 +149,12 @@ dependencies:
|
|
109
149
|
version: '0'
|
110
150
|
type: :development
|
111
151
|
prerelease: false
|
112
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
113
158
|
description: Spree Minicart allows customer to add/remove an item from their cart
|
114
159
|
without ever leaving the page they're on.Let your customers preview their cart before
|
115
160
|
they start the checkout process.
|
@@ -132,6 +177,7 @@ files:
|
|
132
177
|
- app/assets/stylesheets/admin/spree_minicart.css
|
133
178
|
- app/assets/stylesheets/store/spree_minicart.css
|
134
179
|
- app/controllers/orders_controller_decorator.rb
|
180
|
+
- app/helpers/spree/base_helper_decorator.rb
|
135
181
|
- app/overrides/layout.rb
|
136
182
|
- app/overrides/minicart.rb
|
137
183
|
- app/views/spree/orders/populate.js.erb
|
@@ -171,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
217
|
requirements:
|
172
218
|
- none
|
173
219
|
rubyforge_project:
|
174
|
-
rubygems_version: 1.8.
|
220
|
+
rubygems_version: 1.8.24
|
175
221
|
signing_key:
|
176
222
|
specification_version: 3
|
177
223
|
summary: Spree Minicart displays a minicart in your spree store
|