spree_recurring_order 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/recurring_orders_controller.rb +4 -0
- data/app/controllers/spree/orders_controller_decorator.rb +6 -0
- data/app/controllers/spree/recurring_orders_controller.rb +2 -1
- data/app/models/spree/recurring_order.rb +13 -0
- data/app/views/spree/admin/recurring_orders/index.html.erb +4 -0
- data/app/views/spree/admin/recurring_orders/show.html.erb +42 -0
- data/app/views/spree/orders/show_recurring.html.erb +1 -0
- data/app/views/spree/recurring_orders/show.html.erb +1 -14
- data/config/routes.rb +1 -0
- data/db/migrate/20140211055527_add_number_to_recurring_order.rb +7 -0
- data/spec/controllers/spree/admin/recurring_orders_controller_spec.rb +13 -1
- data/spec/controllers/spree/orders_controller_spec.rb +4 -2
- data/spec/controllers/spree/recurring_order_controller_spec.rb +2 -2
- data/spec/models/spree/recurring_order_spec.rb +15 -0
- data/spree_recurring_order.gemspec +1 -1
- metadata +5 -7
- data/app/assets/stylesheets/store/order_complete.css +0 -8
- data/app/assets/stylesheets/store/show_order.css +0 -14
- data/app/overrides/add_recurring_order_form.rb +0 -5
- data/app/views/spree/orders/_recurring_order_form.html.erb +0 -16
- data/app/views/spree/recurring_orders/new.html.erb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76ffe7a472fefe7657097737d7ff66b0926226de
|
4
|
+
data.tar.gz: 23934df33f63bada758d01918898ed47d7ded4dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 002bc796fb66c3b4ffae936406329c5de2fd5a7c2cf89ce92ac74ad254576cded12d3c8145c75ba7ddd2a42603eacb5696d0fab87282e70ab609bdb2dac24266
|
7
|
+
data.tar.gz: 23c27260548c84e148cd9b9142e3cb94205fae67e0d49f389547459a92b1e654ad64a2a7ee492f8f91d12cd65ea31c837fe3846af68e768dae58f6e42c0cabd7
|
@@ -10,7 +10,8 @@ module Spree
|
|
10
10
|
if @recurring_order.save
|
11
11
|
redirect_to(spree.recurring_order_url(@recurring_order.id))
|
12
12
|
else
|
13
|
-
|
13
|
+
flash[:notice] = "Hmmm... There was a problem creating your recurring order. Please get in touch at hello@yourgrocer.com.au and we are going to sort it out for you."
|
14
|
+
redirect_to(order_url(original_order.number))
|
14
15
|
end
|
15
16
|
else
|
16
17
|
flash[:notice] = "Hmmm... It seems like this order already has a recurring order associated with it. Please get in touch at hello@yourgrocer.com.au if you have any doubts about it"
|
@@ -7,6 +7,8 @@ module Spree
|
|
7
7
|
|
8
8
|
belongs_to :original_order, class_name: 'Spree::Order'
|
9
9
|
|
10
|
+
after_create :generate_order_number
|
11
|
+
|
10
12
|
def self.create_from_order(order)
|
11
13
|
recurring_order = RecurringOrder.new
|
12
14
|
recurring_order.orders << order
|
@@ -32,5 +34,16 @@ module Spree
|
|
32
34
|
self.errors[:orders] << "cannot be empty" if orders.empty?
|
33
35
|
end
|
34
36
|
|
37
|
+
def generate_order_number
|
38
|
+
record = true
|
39
|
+
while record
|
40
|
+
random = "R#{Array.new(6){rand(6)}.join}"
|
41
|
+
record = self.class.where(number: random).first
|
42
|
+
end
|
43
|
+
self.number = random if self.number.blank?
|
44
|
+
self.number
|
45
|
+
self.save!
|
46
|
+
end
|
47
|
+
|
35
48
|
end
|
36
49
|
end
|
@@ -13,20 +13,24 @@
|
|
13
13
|
</colgroup>
|
14
14
|
<thead>
|
15
15
|
<tr>
|
16
|
+
<th><%= Spree.t(:recurring_order_number, resource: I18n.t(:other, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
16
17
|
<th><%= Spree.t(:original_order_number, resource: I18n.t(:other, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
17
18
|
<th><%= Spree.t(:customer_email, resource: I18n.t(:other, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
18
19
|
<th><%= Spree.t(:customer_phone, resource: I18n.t(:other, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
19
20
|
<th><%= Spree.t(:active?, resource: I18n.t(:other, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
21
|
+
<th><%= Spree.t(:number_of_orders, resource: I18n.t(:other, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
20
22
|
<th><%= Spree.t(:created_at, resource: I18n.t(:created_at, :scope => 'activerecord.attributes.spree/recurring_order')) %></th>
|
21
23
|
</tr>
|
22
24
|
</thead>
|
23
25
|
<tbody>
|
24
26
|
<% @recurring_orders.each do |order| %>
|
25
27
|
<tr class="<%= cycle('odd', 'even') %>">
|
28
|
+
<td class="align-center"><%= link_to order.number, admin_recurring_order_path(order.number) %></td>
|
26
29
|
<td class="align-center"><%= link_to order.original_order.number, edit_admin_order_path(order.original_order) %></td>
|
27
30
|
<td class="align-center"><%= mail_to order.email %></td>
|
28
31
|
<td class="align-center"><%= mail_to order.phone %></td>
|
29
32
|
<td class="align-center">YES</td>
|
33
|
+
<td class="align-center"><%= order.orders.count %></td>
|
30
34
|
<td class="align-center"><%= l (order.created_at).to_date %></td>
|
31
35
|
</tr>
|
32
36
|
<% end %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<% content_for :page_title do %>
|
2
|
+
<%= "Recurring Order #{@recurring_order.number}" %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for :sidebar_title do %>
|
6
|
+
<%= Spree.t(:recurring_information) %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% content_for :sidebar do %>
|
10
|
+
<header id="order_tab_summary" data-hook>
|
11
|
+
<dl class="additional-info">
|
12
|
+
<dt id="order_email" data-hook><%= Spree.t(:email) %>:</dt>
|
13
|
+
<dd><%= @recurring_order.email %></dd>
|
14
|
+
<dt id="order_phone" data-hook><%= Spree.t(:phone) %>:</dt>
|
15
|
+
<dd><%= @recurring_order.phone %></dd>
|
16
|
+
<dt id="order_original_order" data-hook><%= Spree.t(:original) %>:</dt>
|
17
|
+
<dd><%= @recurring_order.original_order.number %></dd>
|
18
|
+
<dt id="order_created_at" data-hook><%= Spree.t(:created_date) %>:</dt>
|
19
|
+
<dd><%= l (@recurring_order.created_at).to_date %></dd>
|
20
|
+
</dl>
|
21
|
+
</header>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<fieldset class='no-border-bottom'>
|
25
|
+
<legend>Orders</legend>
|
26
|
+
<table>
|
27
|
+
<thead>
|
28
|
+
<th><%= Spree.t('number')%></th>
|
29
|
+
<th><%= Spree.t('created_date')%></th>
|
30
|
+
<th><%= Spree.t('delivery_date')%></th>
|
31
|
+
</thead>
|
32
|
+
<tbody class="with-border">
|
33
|
+
<% @recurring_order.orders.each do |order| %>
|
34
|
+
<tr>
|
35
|
+
<td class="align-center"><strong><%= link_to order.number, edit_admin_order_path(order) %></strong></td>
|
36
|
+
<td class="align-center"><span><%= l (order.created_at).to_date %></span></td>
|
37
|
+
<td class="align-center"><span><%= l (order.delivery_date).to_date %></span></td>
|
38
|
+
</tr>
|
39
|
+
<% end %>
|
40
|
+
</tbody>
|
41
|
+
</table>
|
42
|
+
</fieldset>
|
@@ -0,0 +1 @@
|
|
1
|
+
You have to implement this view
|
@@ -1,14 +1 @@
|
|
1
|
-
|
2
|
-
<h1 class='title'>And that's all!</h1>
|
3
|
-
|
4
|
-
<h2 class='text'>
|
5
|
-
<%= "Grocery shopping just became much easier for you, #{@recurring_order.original_order.ship_address.firstname}." %>
|
6
|
-
</h2>
|
7
|
-
|
8
|
-
|
9
|
-
<h2 class='text'>
|
10
|
-
We are getting in touch to setup your recurring order,
|
11
|
-
so feel free to relax and think about all that time that you are going to have in your hands.
|
12
|
-
</h2>
|
13
|
-
|
14
|
-
</div>
|
1
|
+
You need to implement this view
|
data/config/routes.rb
CHANGED
@@ -4,4 +4,5 @@ Spree::Core::Engine.routes.draw do
|
|
4
4
|
get "/recurring_orders/:id", controller: 'recurring_orders', action: 'show', as: 'recurring_order'
|
5
5
|
|
6
6
|
get "admin/recurring_orders/", controller: 'admin/recurring_orders', action: 'index', as: 'admin_recurring_orders'
|
7
|
+
get "admin/recurring_orders/:number", controller: 'admin/recurring_orders', action: 'show', as: 'admin_recurring_order'
|
7
8
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::Admin::RecurringOrdersController do
|
4
|
-
|
4
|
+
|
5
5
|
let(:user) { mock_model Spree::User, :last_incomplete_spree_order => nil, :has_spree_role? => true, :spree_api_key => 'fake' }
|
6
6
|
|
7
7
|
before :each do
|
@@ -21,4 +21,16 @@ describe Spree::Admin::RecurringOrdersController do
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
+
describe 'show' do
|
25
|
+
|
26
|
+
it 'should assign recurring order' do
|
27
|
+
recurring_order = double(Spree::RecurringOrder)
|
28
|
+
Spree::RecurringOrder.should_receive(:find_by).with(number: 'R1234').and_return(recurring_order)
|
29
|
+
|
30
|
+
spree_get :show, number: 'R1234'
|
31
|
+
assigns(:recurring_order).should == recurring_order
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
24
36
|
end
|
@@ -29,14 +29,16 @@ describe Spree::OrdersController do
|
|
29
29
|
assigns(:recurring_order).should == recurring_order
|
30
30
|
end
|
31
31
|
|
32
|
-
it 'should
|
32
|
+
it 'should render show_recurring if order completed is true' do
|
33
33
|
spree_get :show, {id: "G2134", order_completed: true}
|
34
34
|
assigns(:present_recurring).should == true
|
35
|
+
response.should render_template('show_recurring')
|
35
36
|
end
|
36
37
|
|
37
|
-
it 'should
|
38
|
+
it 'should render show normally' do
|
38
39
|
spree_get :show, {id: "G2134"}
|
39
40
|
assigns(:present_recurring).should == false
|
41
|
+
response.should render_template('show')
|
40
42
|
end
|
41
43
|
|
42
44
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::RecurringOrdersController do
|
4
|
-
|
4
|
+
|
5
5
|
let(:original_order){ FactoryGirl.build(:order, id: 1, number: 'G1234') }
|
6
6
|
let(:orders){ [] }
|
7
7
|
let(:recurring_order){ double(Spree::RecurringOrder, save: true, id: 666, orders: orders).as_null_object }
|
@@ -42,7 +42,7 @@ describe Spree::RecurringOrdersController do
|
|
42
42
|
recurring_order.should_receive(:save).and_return(false)
|
43
43
|
|
44
44
|
spree_post :create, recurring_order: {original_order_id: 1}
|
45
|
-
response.should
|
45
|
+
response.should redirect_to("/orders/G1234")
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should render order complete if recurring order already exists' do
|
@@ -18,8 +18,23 @@ describe Spree::RecurringOrder do
|
|
18
18
|
recurring_order.original_order.should == order
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should assign number that starts with R" do
|
22
|
+
order = FactoryGirl.create(:order)
|
23
|
+
|
24
|
+
recurring_order = Spree::RecurringOrder.create_from_order(order)
|
25
|
+
recurring_order.number.should =~ /^R/
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should assign number that has 6 numbers" do
|
29
|
+
order = FactoryGirl.create(:order)
|
30
|
+
|
31
|
+
recurring_order = Spree::RecurringOrder.create_from_order(order)
|
32
|
+
recurring_order.number.should =~ /\d{6}$/
|
33
|
+
end
|
34
|
+
|
21
35
|
end
|
22
36
|
|
37
|
+
|
23
38
|
describe 'validation' do
|
24
39
|
|
25
40
|
it 'should have at least one order' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_recurring_order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francisco Trindade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -180,25 +180,23 @@ files:
|
|
180
180
|
- app/assets/javascripts/store/spree_recurring_order.js
|
181
181
|
- app/assets/stylesheets/admin/admin.scss
|
182
182
|
- app/assets/stylesheets/admin/spree_recurring_order.css
|
183
|
-
- app/assets/stylesheets/store/order_complete.css
|
184
|
-
- app/assets/stylesheets/store/show_order.css
|
185
183
|
- app/assets/stylesheets/store/spree_recurring_order.css
|
186
184
|
- app/controllers/spree/admin/recurring_orders_controller.rb
|
187
185
|
- app/controllers/spree/orders_controller_decorator.rb
|
188
186
|
- app/controllers/spree/recurring_orders_controller.rb
|
189
187
|
- app/models/spree/order_decorator.rb
|
190
188
|
- app/models/spree/recurring_order.rb
|
191
|
-
- app/overrides/add_recurring_order_form.rb
|
192
189
|
- app/overrides/add_tab_to_admin_menu.rb
|
193
190
|
- app/views/spree/admin/recurring_orders/index.html.erb
|
191
|
+
- app/views/spree/admin/recurring_orders/show.html.erb
|
194
192
|
- app/views/spree/admin/shared/_recurring_orders_tab.html.erb
|
195
|
-
- app/views/spree/orders/
|
196
|
-
- app/views/spree/recurring_orders/new.html.erb
|
193
|
+
- app/views/spree/orders/show_recurring.html.erb
|
197
194
|
- app/views/spree/recurring_orders/show.html.erb
|
198
195
|
- bin/rails
|
199
196
|
- config/locales/en.yml
|
200
197
|
- config/routes.rb
|
201
198
|
- db/migrate/20140204052508_create_recurring_orders_table.rb
|
199
|
+
- db/migrate/20140211055527_add_number_to_recurring_order.rb
|
202
200
|
- lib/generators/spree_recurring_order/install/install_generator.rb
|
203
201
|
- lib/spree_recurring_order.rb
|
204
202
|
- lib/spree_recurring_order/engine.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
div#show_recurring_order {
|
2
|
-
text-align: center;
|
3
|
-
margin-left: 10%;
|
4
|
-
margin-right: 10%;
|
5
|
-
}
|
6
|
-
|
7
|
-
div#show_recurring_order .title, div#show_recurring_order .text {
|
8
|
-
margin-top: 30px;;
|
9
|
-
}
|
10
|
-
|
11
|
-
div#show_recurring_order fieldset.share {
|
12
|
-
margin-top: 60px;
|
13
|
-
}
|
14
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<%- if @present_recurring %>
|
2
|
-
<fieldset id='recurring_orders'>
|
3
|
-
|
4
|
-
<h2>
|
5
|
-
<%= "Thanks #{@order.ship_address.firstname}!" %>
|
6
|
-
</h2>
|
7
|
-
<h2>Would you like to make this process even easier next time?</h2>
|
8
|
-
<p>Sign up for a recurring order and we will get in touch so you don't have to worry about your groceries anymore.</p>
|
9
|
-
|
10
|
-
<%= form_for @recurring_order do |f| %>
|
11
|
-
<%= f.hidden_field :original_order_id, value: @order.id %>
|
12
|
-
<%= f.submit "Send me hassle-free groceries" %>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
</fieldset>
|
16
|
-
<% end %>
|