spree_delivery_options 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52f21254b9962301d3e30a2b21d337639a244953
4
- data.tar.gz: 9a2630c0803e3bc1fd35e0b9af41061168682bb7
3
+ metadata.gz: 632e270bb1dff806503365bb70f806b2ebe304b4
4
+ data.tar.gz: 2656de02711cbcf5177606224145b6c18ca6ac2f
5
5
  SHA512:
6
- metadata.gz: 64c60f96d12889e601897415f265f4b396906a7c95c0e6cd43c3eae0ec23d7b03323abe9538c7d3b356ef5ee2a40fa0186b4d93ee0dc90f7ed55554b25275e2d
7
- data.tar.gz: 316e6f37b0b8893c9090ab30bd2be0e0fb99a7f69fa9e339dcdc14d9eda8988733bc56bdc479fdf5f298fc3f1cc586182543ac7b0dd2f83533a8a337680494ab
6
+ metadata.gz: cde0b744c696b162fbfa4fdd6f0f6e7df8c75dafac7052992ce3093ca97232ed936e6c52975fddbb3f08e9599d5bfd7f576f86d2da1aecd0585c6e5641b29d06
7
+ data.tar.gz: 8fdfc598b17bfd9e78857f05636023e34948e7c78e873251b288bf73b80bfff9477dc5587459659e69f4cfd343184644a1a4bf8485edd664d5a1b959c9d4b8be
@@ -40,7 +40,7 @@ function SpreeDeliveryOptions() {
40
40
  };
41
41
 
42
42
  this.populate_delivery_time = function(options) {
43
- if (options) {
43
+ if (options && options.length > 0) {
44
44
  var selected_delivery_time = $('.selected-delivery-time').attr("data");
45
45
  var arLen = options.length;
46
46
  var newList = "";
@@ -23,8 +23,8 @@ Spree::Order.class_eval do
23
23
  self.errors[:delivery_date] << 'cannot be today or in the past' if self.delivery_date <= Date.current
24
24
 
25
25
  options = delivery_time_options(self.delivery_date)
26
- unless options
27
- self.errors[:delivery_date] << "is not available on the selected week day."
26
+ unless options && !options.empty?
27
+ self.errors[:delivery_date] << "is not available on the selected date."
28
28
  end
29
29
 
30
30
  cutoff_time = Time.zone.now.change(hour: SpreeDeliveryOptions::Config.delivery_cut_off_hour)
@@ -1,6 +1,6 @@
1
1
  module SpreeDeliveryOptions
2
2
  class Configuration < Spree::Preferences::Configuration
3
- preference :delivery_cut_off_hour, :integer, default: 12
3
+ preference :delivery_cut_off_hour, :integer, default: 13
4
4
  preference :delivery_time_options, :string, default: {monday: ['Between 6am-8am']}.to_json
5
5
  preference :show_homepage_form, :boolean, default: true
6
6
  end
@@ -21,12 +21,12 @@ describe SpreeDeliveryOptions::BaseHelper do
21
21
  end
22
22
 
23
23
  it 'should return the day before if delivery date is set' do
24
- SpreeDeliveryOptions::Config.delivery_cut_off_hour = 12
24
+ SpreeDeliveryOptions::Config.delivery_cut_off_hour = 13
25
25
  order.delivery_date = Date.parse('23/04/2014')
26
26
 
27
27
  time_now = DateTime.parse("20/03/2013")
28
28
  Timecop.freeze(time_now)
29
- helper.current_order_cutoff_time.should == 'Tuesday, 22 Apr before 12pm'
29
+ helper.current_order_cutoff_time.should == 'Tuesday, 22 Apr before 1pm'
30
30
  Timecop.return
31
31
  end
32
32
 
@@ -6,6 +6,7 @@ describe Spree::Order do
6
6
 
7
7
  before :each do
8
8
  SpreeDeliveryOptions::Config.delivery_time_options = {monday: ['Between 6-7am']}.to_json
9
+ SpreeDeliveryOptions::Config.delivery_cut_off_hour = 13
9
10
  end
10
11
 
11
12
  describe 'valid_delivery_instructions' do
@@ -64,7 +65,7 @@ describe Spree::Order do
64
65
  end
65
66
 
66
67
  it 'should be valid if delivery date is tomorrow and it is past the cutoff time by less than 15 min' do
67
- time_now = DateTime.parse("17/11/2013 #{SpreeDeliveryOptions::Config.delivery_cut_off_hour}:14 +1100")
68
+ time_now = DateTime.parse("17/11/2013 #{SpreeDeliveryOptions::Config.delivery_cut_off_hour}:14 +1100", "%d/%m/%Y %H:%M %z")
68
69
  Timecop.freeze(time_now)
69
70
 
70
71
  order.delivery_date = '18/11/2013'
@@ -74,7 +75,7 @@ describe Spree::Order do
74
75
  end
75
76
 
76
77
  it 'should not be valid if delivery date is tomorrow and it is past the cutoff time + 15 min' do
77
- time_now = DateTime.parse("17/11/2013 #{SpreeDeliveryOptions::Config.delivery_cut_off_hour}:16 +1100")
78
+ time_now = DateTime.parse("17/11/2013 #{SpreeDeliveryOptions::Config.delivery_cut_off_hour}:16 +1100", "%d/%m/%Y %H:%M %z")
78
79
  Timecop.freeze(time_now)
79
80
 
80
81
  order.delivery_date = '18/11/2013'
@@ -134,17 +135,31 @@ describe Spree::Order do
134
135
 
135
136
  describe "overriding delivery day with specific date" do
136
137
 
137
- before :each do
138
+ it 'should not allow delivery time to be in an invalid slot for the delivery day' do
138
139
  SpreeDeliveryOptions::Config.delivery_time_options = {monday: ['Between 6-7am'], '03/03/2014' => ['Between 9-12am']}.to_json
140
+
141
+ time_now = DateTime.parse("01/03/2014")
142
+ Timecop.freeze(time_now)
143
+
144
+ order.delivery_date = Date.parse('03/03/2014')
145
+ order.delivery_time = 'Between 6-7am'
146
+
147
+ order.valid_delivery_time?.should == false
148
+ order.errors[:delivery_time].should_not be_empty
149
+ Timecop.return
139
150
  end
140
151
 
141
- it 'should not allow delivery time to be in an invalid slot for the delivery day' do
152
+ it 'should not allow delivery time to be in date with empty options' do
153
+ SpreeDeliveryOptions::Config.delivery_time_options = {monday: ['Between 6-7am'], '03/03/2014' => []}.to_json
154
+
142
155
  time_now = DateTime.parse("01/03/2014")
143
156
  Timecop.freeze(time_now)
144
157
 
145
158
  order.delivery_date = Date.parse('03/03/2014')
146
159
  order.delivery_time = 'Between 6-7am'
147
160
 
161
+ order.valid_delivery_date?.should == false
162
+ order.errors[:delivery_date].should_not be_empty
148
163
  order.valid_delivery_time?.should == false
149
164
  order.errors[:delivery_time].should_not be_empty
150
165
  Timecop.return
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_delivery_options'
5
- s.version = '2.2.7'
5
+ s.version = '2.2.8'
6
6
  s.summary = 'Adds delivery date and time during checkout'
7
7
  s.description = ''
8
8
  s.required_ruby_version = '>= 2.0.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_delivery_options
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.2.8
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-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core