spree_core 3.0.7 → 3.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -16
- data/app/models/spree/order.rb +2 -4
- data/app/models/spree/order/checkout.rb +0 -2
- data/config/initializers/assets.rb +1 -0
- data/db/migrate/20130228210442_create_shipping_method_zone.rb +6 -7
- data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +0 -5
- data/lib/generators/spree/install/install_generator.rb +20 -10
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/backend/all.js +5 -1
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/frontend/all.js +5 -1
- data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/backend/all.css +5 -1
- data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +5 -1
- data/lib/spree/core.rb +5 -0
- data/lib/spree/core/controller_helpers/auth.rb +4 -3
- data/lib/spree/core/controller_helpers/common.rb +1 -1
- data/lib/spree/core/controller_helpers/order.rb +1 -1
- data/lib/spree/core/token_generator.rb +22 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/migrations.rb +31 -22
- data/lib/spree/testing_support/capybara_ext.rb +18 -2
- data/lib/spree/testing_support/common_rake.rb +6 -14
- data/lib/spree/testing_support/controller_requests.rb +9 -0
- data/spec/lib/spree/core/token_generator_spec.rb +24 -0
- data/spec/lib/spree/migrations_spec.rb +9 -7
- data/spec/models/spree/order_spec.rb +4 -4
- data/spree_core.gemspec +4 -4
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 583794c5e3cd674e1f9789560d9e34515224977d
|
4
|
+
data.tar.gz: d6cf78844bad3a85cabc73e4bb54d0941dd8a9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e6b1eedc005c55272a53cbda8a31bdaf5ce8979144e5ba1aa262a28a57f825c2377cffb3ce18c2a44c57553eb3a824ffbfdd2fda6c1c12f8c06d24565549306
|
7
|
+
data.tar.gz: 94c3e21a3aff46211526a2a4d263306a7589a0a07d0f74700e588cdee5315d9365092d39d5c59ac736140fddc4a49b0c85de7534196875c5373c753a67860f45
|
data/Rakefile
CHANGED
@@ -1,27 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/testtask'
|
4
|
-
require 'rake/packagetask'
|
5
|
-
require 'rubygems/package_task'
|
6
4
|
require 'rspec/core/rake_task'
|
7
5
|
require 'spree/testing_support/common_rake'
|
8
|
-
load 'lib/tasks/exchanges.rake'
|
9
6
|
|
10
|
-
Bundler::GemHelper.install_tasks
|
11
7
|
RSpec::Core::RakeTask.new
|
12
8
|
|
13
|
-
|
14
|
-
Gem::PackageTask.new(spec) do |p|
|
15
|
-
p.gem_spec = spec
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "Release to gemcutter"
|
19
|
-
task :release do
|
20
|
-
version = File.read(File.expand_path("../../SPREE_VERSION", __FILE__)).strip
|
21
|
-
cmd = "cd pkg && gem push spree_core-#{version}.gem"; puts cmd; system cmd
|
22
|
-
end
|
23
|
-
|
24
|
-
task :default => :spec
|
9
|
+
task default: :spec
|
25
10
|
|
26
11
|
desc "Generates a dummy app for testing"
|
27
12
|
task :test_app do
|
data/app/models/spree/order.rb
CHANGED
@@ -13,6 +13,7 @@ module Spree
|
|
13
13
|
include Spree::Order::CurrencyUpdater
|
14
14
|
include Spree::Order::Payments
|
15
15
|
include Spree::NumberGenerator
|
16
|
+
include Spree::Core::TokenGenerator
|
16
17
|
|
17
18
|
def generate_number(options = {})
|
18
19
|
options[:prefix] ||= 'R'
|
@@ -628,10 +629,7 @@ module Spree
|
|
628
629
|
end
|
629
630
|
|
630
631
|
def create_token
|
631
|
-
self.guest_token ||=
|
632
|
-
random_token = SecureRandom.urlsafe_base64(nil, false)
|
633
|
-
break random_token unless self.class.exists?(guest_token: random_token)
|
634
|
-
end
|
632
|
+
self.guest_token ||= generate_guest_token
|
635
633
|
end
|
636
634
|
end
|
637
635
|
end
|
@@ -38,8 +38,6 @@ module Spree
|
|
38
38
|
|
39
39
|
klass = self
|
40
40
|
|
41
|
-
# To avoid a ton of warnings when the state machine is re-defined
|
42
|
-
StateMachines::Machine.ignore_method_conflicts = true
|
43
41
|
# To avoid multiple occurrences of the same transition being defined
|
44
42
|
# On first definition, state_machines will not be defined
|
45
43
|
state_machines.clear if respond_to?(:state_machines)
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w( logo/spree_50.png noimage/*.png )
|
@@ -1,16 +1,15 @@
|
|
1
1
|
class CreateShippingMethodZone < ActiveRecord::Migration
|
2
|
+
class ShippingMethodZone < ActiveRecord::Base
|
3
|
+
self.table_name = 'shipping_methods_zones'
|
4
|
+
end
|
2
5
|
def up
|
3
6
|
create_table :shipping_methods_zones, :id => false do |t|
|
4
7
|
t.integer :shipping_method_id
|
5
8
|
t.integer :zone_id
|
6
9
|
end
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Spree::ShippingMethod.has_and_belongs_to_many :zones, :join_table => 'shipping_methods_zones',
|
11
|
-
:class_name => 'Spree::Zone',
|
12
|
-
:foreign_key => 'shipping_method_id'
|
13
|
-
Spree::ShippingMethod.all.each{|sm| sm.zones << Spree::Zone.find(sm.zone_id)}
|
10
|
+
Spree::ShippingMethod.all.each do |sm|
|
11
|
+
ShippingMethodZone.create!(zone_id: sm.zone_id, shipping_method_id: sm.id)
|
12
|
+
end
|
14
13
|
|
15
14
|
remove_column :spree_shipping_methods, :zone_id
|
16
15
|
end
|
data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
class RenameShippingMethodsZonesToSpreeShippingMethodsZones < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
rename_table :shipping_methods_zones, :spree_shipping_methods_zones
|
4
|
-
# If Spree::ShippingMethod zones association was patched in
|
5
|
-
# CreateShippingMethodZone migrations, it needs to be patched back
|
6
|
-
Spree::ShippingMethod.has_and_belongs_to_many :zones, :join_table => 'spree_shipping_methods_zones',
|
7
|
-
:class_name => 'Spree::Zone',
|
8
|
-
:foreign_key => 'shipping_method_id'
|
9
4
|
end
|
10
5
|
end
|
@@ -38,14 +38,6 @@ module Spree
|
|
38
38
|
template 'config/initializers/spree.rb', 'config/initializers/spree.rb'
|
39
39
|
end
|
40
40
|
|
41
|
-
def config_spree_yml
|
42
|
-
create_file "config/spree.yml" do
|
43
|
-
settings = { 'version' => Spree.version }
|
44
|
-
|
45
|
-
settings.to_yaml
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
41
|
def additional_tweaks
|
50
42
|
return unless File.exists? 'public/robots.txt'
|
51
43
|
append_file "public/robots.txt", <<-ROBOTS
|
@@ -175,7 +167,7 @@ Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
|
175
167
|
# If you would like to change where this engine is mounted, simply change the :at option to something different.
|
176
168
|
#
|
177
169
|
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
|
178
|
-
mount Spree::Core::Engine, :
|
170
|
+
mount Spree::Core::Engine, at: '/'
|
179
171
|
}
|
180
172
|
end
|
181
173
|
|
@@ -183,7 +175,7 @@ Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
|
183
175
|
puts "*" * 50
|
184
176
|
puts "We added the following line to your application's config/routes.rb file:"
|
185
177
|
puts " "
|
186
|
-
puts " mount Spree::Core::Engine, :
|
178
|
+
puts " mount Spree::Core::Engine, at: '/'"
|
187
179
|
end
|
188
180
|
end
|
189
181
|
|
@@ -195,5 +187,23 @@ Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
|
195
187
|
puts "Enjoy!"
|
196
188
|
end
|
197
189
|
end
|
190
|
+
|
191
|
+
protected
|
192
|
+
|
193
|
+
def javascript_exists?(script)
|
194
|
+
extensions = %w(.js.coffee .js.erb .js.coffee.erb .js)
|
195
|
+
file_exists?(extensions, script)
|
196
|
+
end
|
197
|
+
|
198
|
+
def stylesheet_exists?(stylesheet)
|
199
|
+
extensions = %w(.css.scss .css.erb .css.scss.erb .css)
|
200
|
+
file_exists?(extensions, stylesheet)
|
201
|
+
end
|
202
|
+
|
203
|
+
def file_exists?(extensions, filename)
|
204
|
+
extensions.detect do |extension|
|
205
|
+
File.exists?("#{filename}#{extension}")
|
206
|
+
end
|
207
|
+
end
|
198
208
|
end
|
199
209
|
end
|
@@ -8,6 +8,10 @@
|
|
8
8
|
//= require jquery_ujs
|
9
9
|
//= require spree/backend
|
10
10
|
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/backend' %>
|
11
|
-
|
11
|
+
<% filename = "spree/backend/#{ options[:lib_name].gsub("/", "_") }" %>
|
12
|
+
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/javascripts/#{filename}") %>
|
13
|
+
<% if javascript_exists?(filepath) %>
|
14
|
+
//= require <%= filename %>
|
15
|
+
<% end %>
|
12
16
|
<% end %>
|
13
17
|
//= require_tree .
|
@@ -8,6 +8,10 @@
|
|
8
8
|
//= require jquery_ujs
|
9
9
|
//= require spree/frontend
|
10
10
|
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/frontend' %>
|
11
|
-
|
11
|
+
<% filename = "spree/frontend/#{ options[:lib_name].gsub("/", "_") }" %>
|
12
|
+
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/javascripts/#{ filename }") %>
|
13
|
+
<% if javascript_exists?(filepath) %>
|
14
|
+
//= require <%= filename %>
|
15
|
+
<% end %>
|
12
16
|
<% end %>
|
13
17
|
//= require_tree .
|
@@ -5,7 +5,11 @@
|
|
5
5
|
*
|
6
6
|
*= require spree/backend
|
7
7
|
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/backend' %>
|
8
|
-
|
8
|
+
<% filename = "spree/backend/#{ options[:lib_name].gsub("/", "_") }" %>
|
9
|
+
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/stylesheets/#{ filename }") %>
|
10
|
+
<% if stylesheet_exists?(filepath) %>
|
11
|
+
*= require <%= filename %>
|
12
|
+
<% end %>
|
9
13
|
<% end %>
|
10
14
|
*= require_self
|
11
15
|
*= require_tree .
|
data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/frontend/all.css
CHANGED
@@ -5,7 +5,11 @@
|
|
5
5
|
*
|
6
6
|
*= require spree/frontend
|
7
7
|
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/frontend' %>
|
8
|
-
|
8
|
+
<% filename = "spree/frontend/#{ options[:lib_name].gsub("/", "_") }" %>
|
9
|
+
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/stylesheets/#{ filename }") %>
|
10
|
+
<% if stylesheet_exists?(filepath) %>
|
11
|
+
*= require <%= filename %>
|
12
|
+
<% end %>
|
9
13
|
<% end %>
|
10
14
|
*= require_self
|
11
15
|
*= require_tree .
|
data/lib/spree/core.rb
CHANGED
@@ -15,6 +15,10 @@ require 'ransack'
|
|
15
15
|
require 'responders'
|
16
16
|
require 'state_machines-activerecord'
|
17
17
|
|
18
|
+
# This is required because ActiveModel::Validations#invalid? conflicts with the
|
19
|
+
# invalid state of a Payment. In the future this should be removed.
|
20
|
+
StateMachines::Machine.ignore_method_conflicts = true
|
21
|
+
|
18
22
|
module Spree
|
19
23
|
|
20
24
|
mattr_accessor :user_class
|
@@ -43,6 +47,7 @@ module Spree
|
|
43
47
|
|
44
48
|
module Core
|
45
49
|
autoload :ProductFilters, "spree/core/product_filters"
|
50
|
+
autoload :TokenGenerator, "spree/core/token_generator"
|
46
51
|
|
47
52
|
class GatewayError < RuntimeError; end
|
48
53
|
class DestroyWithOrdersError < StandardError; end
|
@@ -3,9 +3,10 @@ module Spree
|
|
3
3
|
module ControllerHelpers
|
4
4
|
module Auth
|
5
5
|
extend ActiveSupport::Concern
|
6
|
+
include Spree::Core::TokenGenerator
|
6
7
|
|
7
8
|
included do
|
8
|
-
|
9
|
+
before_action :set_guest_token
|
9
10
|
helper_method :try_spree_current_user
|
10
11
|
|
11
12
|
rescue_from CanCan::AccessDenied do |exception|
|
@@ -24,8 +25,8 @@ module Spree
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def set_guest_token
|
27
|
-
|
28
|
-
cookies.permanent.signed[:guest_token] =
|
28
|
+
if cookies.signed[:guest_token].blank?
|
29
|
+
cookies.permanent.signed[:guest_token] = generate_guest_token
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Spree
|
2
|
+
module Core
|
3
|
+
module TokenGenerator
|
4
|
+
def generate_guest_token(model_class = Spree::Order)
|
5
|
+
loop do
|
6
|
+
token = "#{random_token}#{unique_ending}"
|
7
|
+
break token unless model_class.exists?(guest_token: token)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def random_token
|
14
|
+
SecureRandom.urlsafe_base64(nil, false)
|
15
|
+
end
|
16
|
+
|
17
|
+
def unique_ending
|
18
|
+
(Time.now.to_f * 1000).to_i
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/migrations.rb
CHANGED
@@ -21,12 +21,12 @@ module Spree
|
|
21
21
|
# Shouldn't run on test mode because migrations inside engine don't have
|
22
22
|
# engine name on the file name
|
23
23
|
def check
|
24
|
-
if File.
|
24
|
+
if File.directory?(app_dir)
|
25
25
|
engine_in_app = app_migrations.map do |file_name|
|
26
26
|
name, engine = file_name.split(".", 2)
|
27
27
|
next unless match_engine?(engine)
|
28
28
|
name
|
29
|
-
end.compact
|
29
|
+
end.compact
|
30
30
|
|
31
31
|
missing_migrations = engine_migrations.sort - engine_in_app.sort
|
32
32
|
unless missing_migrations.empty?
|
@@ -41,28 +41,37 @@ module Spree
|
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
|
-
def engine_migrations
|
45
|
-
Dir.entries("#{config.root}/db/migrate").map do |file_name|
|
46
|
-
name = file_name.split("_", 2).last.split(".", 2).first
|
47
|
-
name.empty? ? next : name
|
48
|
-
end.compact! || []
|
49
|
-
end
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
45
|
+
def engine_migrations
|
46
|
+
Dir.entries(engine_dir).map do |file_name|
|
47
|
+
name = file_name.split("_", 2).last.split(".", 2).first
|
48
|
+
name.empty? ? next : name
|
49
|
+
end.compact! || []
|
50
|
+
end
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
52
|
+
def app_migrations
|
53
|
+
Dir.entries(app_dir).map do |file_name|
|
54
|
+
next if [".", ".."].include? file_name
|
55
|
+
name = file_name.split("_", 2).last
|
56
|
+
name.empty? ? next : name
|
57
|
+
end.compact! || []
|
58
|
+
end
|
59
|
+
|
60
|
+
def app_dir
|
61
|
+
"#{Rails.root}/db/migrate"
|
62
|
+
end
|
63
|
+
|
64
|
+
def engine_dir
|
65
|
+
"#{config.root}/db/migrate"
|
66
|
+
end
|
67
|
+
|
68
|
+
def match_engine?(engine)
|
69
|
+
if engine_name == "spree"
|
70
|
+
# Avoid stores upgrading from 1.3 getting wrong warnings
|
71
|
+
["spree.rb", "spree_promo.rb"].include? engine
|
72
|
+
else
|
73
|
+
engine == "#{engine_name}.rb"
|
66
74
|
end
|
75
|
+
end
|
67
76
|
end
|
68
77
|
end
|
@@ -101,12 +101,28 @@ module CapybaraExt
|
|
101
101
|
first(:xpath, "//label[text()[contains(.,'#{text}')]]")
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
# arg delay in seconds
|
105
|
+
def wait_for_ajax(delay = Capybara.default_max_wait_time)
|
105
106
|
counter = 0
|
107
|
+
delay_threshold = delay * 10
|
106
108
|
while page.evaluate_script("typeof($) === 'undefined' || $.active > 0")
|
107
109
|
counter += 1
|
108
110
|
sleep(0.1)
|
109
|
-
raise "AJAX request took longer than
|
111
|
+
raise "AJAX request took longer than #{delay} seconds." if counter >= delay_threshold
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# "Intelligiently" wait on condition
|
116
|
+
#
|
117
|
+
# Much better than a random sleep "here and there"
|
118
|
+
# it will not cause any delay in case the condition is fullfilled on first cycle.
|
119
|
+
def wait_for_condition(delay = Capybara.default_max_wait_time)
|
120
|
+
counter = 0
|
121
|
+
delay_threshold = delay * 10
|
122
|
+
while !yield
|
123
|
+
counter += 1
|
124
|
+
sleep(0.1)
|
125
|
+
raise "Could not achieve condition within #{delay} seconds." if counter >= delay_threshold
|
110
126
|
end
|
111
127
|
end
|
112
128
|
|
@@ -6,11 +6,11 @@ require 'generators/spree/dummy/dummy_generator'
|
|
6
6
|
|
7
7
|
desc "Generates a dummy app for testing"
|
8
8
|
namespace :common do
|
9
|
-
task :test_app, :user_class do |
|
10
|
-
args.with_defaults(:
|
11
|
-
require
|
9
|
+
task :test_app, :user_class do |_t, args|
|
10
|
+
args.with_defaults(user_class: "Spree::LegacyUser")
|
11
|
+
require ENV['LIB_NAME'].to_s
|
12
12
|
|
13
|
-
ENV[
|
13
|
+
ENV['RAILS_ENV'] = 'test'
|
14
14
|
|
15
15
|
Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", "--quiet"]
|
16
16
|
Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", "--auto-accept", "--migrate=false", "--seed=false", "--sample=false", "--quiet", "--user_class=#{args[:user_class]}"]
|
@@ -30,16 +30,8 @@ namespace :common do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
task :seed do |
|
33
|
+
task :seed do |_t|
|
34
34
|
puts "Seeding ..."
|
35
|
-
|
36
|
-
|
37
|
-
if RUBY_PLATFORM =~ /mswin|mingw/ # windows
|
38
|
-
cmd += " >nul"
|
39
|
-
else
|
40
|
-
cmd += " >/dev/null"
|
41
|
-
end
|
42
|
-
|
43
|
-
system(cmd)
|
35
|
+
system("bundle exec rake db:seed RAILS_ENV=test > #{File::NULL}")
|
44
36
|
end
|
45
37
|
end
|
@@ -46,6 +46,11 @@ module Spree
|
|
46
46
|
process_spree_action(action, parameters, session, flash, "PUT")
|
47
47
|
end
|
48
48
|
|
49
|
+
# Executes a request simulating PATCH HTTP method and set/volley the response
|
50
|
+
def spree_patch(action, parameters = nil, session = nil, flash = nil)
|
51
|
+
process_spree_action(action, parameters, session, flash, "PATCH")
|
52
|
+
end
|
53
|
+
|
49
54
|
# Executes a request simulating DELETE HTTP method and set/volley the response
|
50
55
|
def spree_delete(action, parameters = nil, session = nil, flash = nil)
|
51
56
|
process_spree_action(action, parameters, session, flash, "DELETE")
|
@@ -63,6 +68,10 @@ module Spree
|
|
63
68
|
process_spree_xhr_action(action, parameters, session, flash, :put)
|
64
69
|
end
|
65
70
|
|
71
|
+
def spree_xhr_patch(action, parameters = nil, session = nil, flash = nil)
|
72
|
+
process_spree_xhr_action(action, parameters, session, flash, :patch)
|
73
|
+
end
|
74
|
+
|
66
75
|
def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
|
67
76
|
process_spree_xhr_action(action, parameters, session, flash, :delete)
|
68
77
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Core::TokenGenerator do
|
4
|
+
class DummyClass
|
5
|
+
include Spree::Core::TokenGenerator
|
6
|
+
|
7
|
+
attr_reader :created_at
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@created_at = Time.now.to_i
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:dummy_class_instance) { DummyClass.new }
|
15
|
+
|
16
|
+
describe 'generate_guest_token' do
|
17
|
+
let(:generated_token) { dummy_class_instance.generate_guest_token }
|
18
|
+
|
19
|
+
it 'generates random token with timestamp' do
|
20
|
+
expect(generated_token.size).to eq 35
|
21
|
+
expect(generated_token).to include dummy_class_instance.created_at.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -7,16 +7,18 @@ module Spree
|
|
7
7
|
|
8
8
|
let(:config) { double("Config", root: "dir") }
|
9
9
|
|
10
|
-
|
10
|
+
let(:engine_dir) { "dir/db/migrate" }
|
11
|
+
let(:app_dir) { "#{Rails.root}/db/migrate" }
|
12
|
+
|
13
|
+
subject { described_class.new(config, "spree") }
|
11
14
|
|
12
15
|
before do
|
13
|
-
expect(File).to receive(:
|
14
|
-
expect(File).to receive(:directory?).with("db/migrate").and_return true
|
16
|
+
expect(File).to receive(:directory?).with(app_dir).and_return true
|
15
17
|
end
|
16
18
|
|
17
19
|
it "warns about missing migrations" do
|
18
|
-
expect(Dir).to receive(:entries).with(
|
19
|
-
expect(Dir).to receive(:entries).with(
|
20
|
+
expect(Dir).to receive(:entries).with(app_dir).and_return app_migrations
|
21
|
+
expect(Dir).to receive(:entries).with(engine_dir).and_return engine_migrations
|
20
22
|
|
21
23
|
silence_stream(STDOUT) {
|
22
24
|
expect(subject.check).to eq true
|
@@ -25,8 +27,8 @@ module Spree
|
|
25
27
|
|
26
28
|
context "no missing migrations" do
|
27
29
|
it "says nothing" do
|
28
|
-
expect(Dir).to receive(:entries).with(
|
29
|
-
expect(Dir).to receive(:entries).with(
|
30
|
+
expect(Dir).to receive(:entries).with(engine_dir).and_return engine_migrations
|
31
|
+
expect(Dir).to receive(:entries).with(app_dir).and_return(app_migrations + engine_migrations)
|
30
32
|
expect(subject.check).to eq nil
|
31
33
|
end
|
32
34
|
end
|
@@ -67,15 +67,15 @@ describe Spree::Order, :type => :model do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
context
|
70
|
+
context '#create' do
|
71
71
|
let(:order) { Spree::Order.create }
|
72
72
|
|
73
|
-
it
|
73
|
+
it 'should assign an order number' do
|
74
74
|
expect(order.number).not_to be_nil
|
75
75
|
end
|
76
76
|
|
77
|
-
it 'should create a randomized
|
78
|
-
expect(order.guest_token.size).to eq(
|
77
|
+
it 'should create a randomized 35 character token' do
|
78
|
+
expect(order.guest_token.size).to eq(35)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
data/spree_core.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
version
|
2
|
+
require_relative 'lib/spree/core/version.rb'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.name = 'spree_core'
|
7
|
-
s.version = version
|
7
|
+
s.version = Spree.version
|
8
8
|
s.summary = 'The bare bones necessary for Spree.'
|
9
9
|
s.description = 'The bare bones necessary for Spree.'
|
10
10
|
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.author = 'Sean Schofield'
|
15
15
|
s.email = 'sean@spreecommerce.com'
|
16
16
|
s.homepage = 'http://spreecommerce.com'
|
17
|
-
s.license =
|
17
|
+
s.license = 'BSD-3'
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.require_path = 'lib'
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_dependency 'stringex'
|
43
43
|
s.add_dependency 'truncate_html', '0.9.2'
|
44
44
|
s.add_dependency 'twitter_cldr', '~> 3.0'
|
45
|
-
s.add_dependency 'sprockets-rails'
|
45
|
+
s.add_dependency 'sprockets-rails'
|
46
46
|
|
47
47
|
s.add_development_dependency 'email_spec', '~> 1.6'
|
48
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -342,16 +342,16 @@ dependencies:
|
|
342
342
|
name: sprockets-rails
|
343
343
|
requirement: !ruby/object:Gem::Requirement
|
344
344
|
requirements:
|
345
|
-
- - "
|
345
|
+
- - ">="
|
346
346
|
- !ruby/object:Gem::Version
|
347
|
-
version: '
|
347
|
+
version: '0'
|
348
348
|
type: :runtime
|
349
349
|
prerelease: false
|
350
350
|
version_requirements: !ruby/object:Gem::Requirement
|
351
351
|
requirements:
|
352
|
-
- - "
|
352
|
+
- - ">="
|
353
353
|
- !ruby/object:Gem::Version
|
354
|
-
version: '
|
354
|
+
version: '0'
|
355
355
|
- !ruby/object:Gem::Dependency
|
356
356
|
name: email_spec
|
357
357
|
requirement: !ruby/object:Gem::Requirement
|
@@ -569,6 +569,7 @@ files:
|
|
569
569
|
- app/views/spree/shipment_mailer/shipped_email.text.erb
|
570
570
|
- app/views/spree/test_mailer/test_email.html.erb
|
571
571
|
- app/views/spree/test_mailer/test_email.text.erb
|
572
|
+
- config/initializers/assets.rb
|
572
573
|
- config/initializers/friendly_id.rb
|
573
574
|
- config/initializers/premailer_assets.rb
|
574
575
|
- config/initializers/user_class_extensions.rb
|
@@ -826,6 +827,7 @@ files:
|
|
826
827
|
- lib/spree/core/product_filters.rb
|
827
828
|
- lib/spree/core/routes.rb
|
828
829
|
- lib/spree/core/search/base.rb
|
830
|
+
- lib/spree/core/token_generator.rb
|
829
831
|
- lib/spree/core/validators/email.rb
|
830
832
|
- lib/spree/core/version.rb
|
831
833
|
- lib/spree/i18n.rb
|
@@ -914,6 +916,7 @@ files:
|
|
914
916
|
- spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
|
915
917
|
- spec/lib/spree/core/delegate_belongs_to_spec.rb
|
916
918
|
- spec/lib/spree/core/importer/order_spec.rb
|
919
|
+
- spec/lib/spree/core/token_generator_spec.rb
|
917
920
|
- spec/lib/spree/core/validators/email_spec.rb
|
918
921
|
- spec/lib/spree/localized_number_spec.rb
|
919
922
|
- spec/lib/spree/migrations_spec.rb
|