spree_purchase_order 3.1.0 → 3.2.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -12
- data/Rakefile +12 -10
- data/app/assets/stylesheets/spree/backend/spree_purchase_order.css +0 -13
- data/app/models/spree/order_decorator.rb +15 -0
- data/app/models/spree/payment_decorator.rb +2 -2
- data/app/models/spree/payment_method/purchase_order.rb +18 -8
- data/app/models/spree/purchase_order.rb +2 -17
- data/db/migrate/20160111163926_add_po_number_to_spree_payments.rb +5 -0
- data/lib/spree_purchase_order/engine.rb +1 -4
- data/lib/spree_purchase_order/version.rb +1 -1
- metadata +10 -107
- data/config/locales/en.yml +0 -10
- data/spec/dummy/Rakefile +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -1
- data/spec/dummy/app/assets/stylesheets/application.css +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -22
- data/spec/dummy/config.ru +0 -2
- data/spec/dummy/config/application.rb +0 -28
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -8
- data/spec/dummy/config/environment.rb +0 -3
- data/spec/dummy/config/environments/test.rb +0 -13
- data/spec/dummy/config/initializers/assets.rb +0 -1
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -1
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -1
- data/spec/dummy/config/initializers/session_store.rb +0 -1
- data/spec/dummy/config/initializers/spree.rb +0 -2
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -3
- data/spec/dummy/config/locales/en.yml +0 -2
- data/spec/dummy/config/routes.rb +0 -2
- data/spec/dummy/config/secrets.yml +0 -8
- data/spec/factories/purchase_orders.rb +0 -87
- data/spec/models/spree/purchase_order_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc893506bcf017dd278386445d50d7181002605
|
4
|
+
data.tar.gz: 8846f86629849000a43c521e7f763097d581a97d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ef619077e637050594399fdddfc79648c16a9ea4392acf2e218c599ccf47e408881b24b748bbcdb5ddb60b996d97486774a6023a474efa915ec4721e5fd2374
|
7
|
+
data.tar.gz: 0db282df32f2f843037b0928837ab52e84ad73bf8689701cd2d16c3c232fef74b401e7cd41ebd32cf54c923deb9872a5c4c1d781d2ce0897c84bc3a5a17aabb0
|
data/README.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/deepakmahakale/spree_purchase_order.svg?branch=master)](https://travis-ci.org/deepakmahakale/spree_purchase_order)
|
2
|
-
|
3
1
|
# Spree Purchase Order
|
4
2
|
|
5
3
|
Add Purchase Order payment method in Spree
|
@@ -7,18 +5,15 @@ Add Purchase Order payment method in Spree
|
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
1. Add this line to your Gemfile:
|
10
|
-
|
11
|
-
|
12
|
-
```
|
8
|
+
|
9
|
+
gem 'spree_purchase_order'
|
13
10
|
|
14
11
|
2. Install the gem using Bundler:
|
15
|
-
|
16
|
-
|
17
|
-
```
|
12
|
+
|
13
|
+
bundle install
|
18
14
|
|
19
15
|
3. Copy & run migrations
|
20
|
-
```bash
|
21
|
-
bundle exec rails g spree_purchase_order:install
|
22
|
-
```
|
23
16
|
|
24
|
-
|
17
|
+
bundle exec rails g spree_purchase_order:install
|
18
|
+
|
19
|
+
3. Restart your server
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
1
|
begin
|
3
2
|
require 'bundler/setup'
|
4
3
|
rescue LoadError
|
@@ -11,21 +10,24 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
11
10
|
rdoc.rdoc_dir = 'rdoc'
|
12
11
|
rdoc.title = 'SpreePurchaseOrder'
|
13
12
|
rdoc.options << '--line-numbers'
|
14
|
-
rdoc.rdoc_files.include('README.
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
15
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
15
|
end
|
17
16
|
|
18
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
19
18
|
load 'rails/tasks/engine.rake'
|
20
19
|
|
21
|
-
|
20
|
+
load 'rails/tasks/statistics.rake'
|
22
21
|
|
23
|
-
|
22
|
+
Bundler::GemHelper.install_tasks
|
24
23
|
|
25
|
-
require '
|
26
|
-
require 'rspec/core/rake_task'
|
24
|
+
require 'rake/testtask'
|
27
25
|
|
28
|
-
|
29
|
-
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
30
32
|
|
31
|
-
task default: :
|
33
|
+
task default: :test
|
@@ -1,16 +1,3 @@
|
|
1
1
|
/*
|
2
2
|
*= require spree/backend
|
3
3
|
*/
|
4
|
-
.btn.action-complete {
|
5
|
-
color: #fff;
|
6
|
-
background-color: #7DB942;
|
7
|
-
border-color: #70a63b;
|
8
|
-
}
|
9
|
-
.btn.action-complete:hover {
|
10
|
-
color: #fff;
|
11
|
-
background-color: #649335;
|
12
|
-
border-color: #52792b;
|
13
|
-
}
|
14
|
-
.icon.icon-complete:before{
|
15
|
-
content: "\e013";
|
16
|
-
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Spree::Order.class_eval do
|
2
|
+
def authorize_digital?
|
3
|
+
return true if paid?
|
4
|
+
if pay_with_po?
|
5
|
+
payments.each do |payment|
|
6
|
+
return true if payment.po? && payment.source.attachment_file_name
|
7
|
+
end
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def pay_with_po?
|
13
|
+
payments.collect(&:po?).include?(true)
|
14
|
+
end
|
15
|
+
end
|
@@ -4,12 +4,28 @@ module Spree
|
|
4
4
|
Spree::PurchaseOrder
|
5
5
|
end
|
6
6
|
|
7
|
+
def actions
|
8
|
+
%w(complete void)
|
9
|
+
end
|
10
|
+
|
11
|
+
def can_complete?(payment)
|
12
|
+
%w(checkout pending).include?(payment.state)
|
13
|
+
end
|
14
|
+
|
15
|
+
def can_void?(payment)
|
16
|
+
payment.state != 'void'
|
17
|
+
end
|
18
|
+
|
7
19
|
def authorize(*args)
|
8
|
-
|
20
|
+
ActiveMerchant::Billing::Response.new(true, 'Purchase Order: Success', {}, {})
|
21
|
+
end
|
22
|
+
|
23
|
+
def complete(*)
|
24
|
+
ActiveMerchant::Billing::Response.new(true, 'Purchase Order: Success', {}, {})
|
9
25
|
end
|
10
26
|
|
11
27
|
def void(*args)
|
12
|
-
|
28
|
+
ActiveMerchant::Billing::Response.new(true, '', {}, {})
|
13
29
|
end
|
14
30
|
|
15
31
|
def source_required?
|
@@ -19,11 +35,5 @@ module Spree
|
|
19
35
|
def auto_capture?
|
20
36
|
false
|
21
37
|
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def simulated_successful_billing_response(message = "")
|
26
|
-
ActiveMerchant::Billing::Response.new(true, message, {}, {})
|
27
|
-
end
|
28
38
|
end
|
29
39
|
end
|
@@ -1,22 +1,7 @@
|
|
1
1
|
module Spree
|
2
|
-
class PurchaseOrder <
|
3
|
-
|
4
|
-
has_many :payments, as: :source
|
2
|
+
class PurchaseOrder < ActiveRecord::Base
|
3
|
+
has_one :payment, as: :source
|
5
4
|
|
6
5
|
validates_presence_of :po_number, :organization_name
|
7
|
-
|
8
|
-
def actions
|
9
|
-
%w(complete void)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Indicates whether its possible to complete the payment
|
13
|
-
def can_complete?(payment)
|
14
|
-
payment.pending? || payment.checkout?
|
15
|
-
end
|
16
|
-
|
17
|
-
# Indicates whether its possible to void the payment.
|
18
|
-
def can_void?(payment)
|
19
|
-
!payment.failed? && !payment.void?
|
20
|
-
end
|
21
6
|
end
|
22
7
|
end
|
@@ -7,10 +7,7 @@ module SpreePurchaseOrder
|
|
7
7
|
config.autoload_paths << "#{config.root}/lib"
|
8
8
|
|
9
9
|
config.generators do |g|
|
10
|
-
g.test_framework :rspec
|
11
|
-
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
12
|
-
g.assets false
|
13
|
-
g.helper false
|
10
|
+
g.test_framework :rspec
|
14
11
|
end
|
15
12
|
|
16
13
|
def self.activate
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_purchase_order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak Mahakale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,56 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.2.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: sqlite3
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec-rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: factory_girl_rails
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
26
|
+
version: 3.2.0.rc1
|
69
27
|
description: Adds Purchase Order as a Payment Method to Spree Commerce
|
70
28
|
email: deepakmahakale@gmail.com
|
71
29
|
executables: []
|
@@ -79,47 +37,20 @@ files:
|
|
79
37
|
- app/assets/javascripts/spree/frontend/spree_purchase_order.js
|
80
38
|
- app/assets/stylesheets/spree/backend/spree_purchase_order.css
|
81
39
|
- app/assets/stylesheets/spree/frontend/spree_purchase_order.css
|
40
|
+
- app/models/spree/order_decorator.rb
|
82
41
|
- app/models/spree/payment_decorator.rb
|
83
42
|
- app/models/spree/payment_method/purchase_order.rb
|
84
43
|
- app/models/spree/purchase_order.rb
|
85
44
|
- app/views/spree/checkout/payment/_purchaseorder.html.erb
|
86
|
-
- config/locales/en.yml
|
87
45
|
- config/routes.rb
|
88
46
|
- db/migrate/20160111123141_create_spree_purchase_orders.rb
|
47
|
+
- db/migrate/20160111163926_add_po_number_to_spree_payments.rb
|
89
48
|
- db/migrate/20161214190805_add_payment_method_id_to_spree_purchase_orders.rb
|
90
49
|
- db/migrate/20161214191512_add_user_id_to_spree_purchase_orders.rb
|
91
50
|
- lib/generators/spree_purchase_order/install/install_generator.rb
|
92
51
|
- lib/spree_purchase_order.rb
|
93
52
|
- lib/spree_purchase_order/engine.rb
|
94
53
|
- lib/spree_purchase_order/version.rb
|
95
|
-
- spec/dummy/Rakefile
|
96
|
-
- spec/dummy/app/assets/javascripts/application.js
|
97
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
98
|
-
- spec/dummy/app/controllers/application_controller.rb
|
99
|
-
- spec/dummy/app/helpers/application_helper.rb
|
100
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
101
|
-
- spec/dummy/bin/bundle
|
102
|
-
- spec/dummy/bin/rails
|
103
|
-
- spec/dummy/bin/rake
|
104
|
-
- spec/dummy/bin/setup
|
105
|
-
- spec/dummy/config.ru
|
106
|
-
- spec/dummy/config/application.rb
|
107
|
-
- spec/dummy/config/boot.rb
|
108
|
-
- spec/dummy/config/database.yml
|
109
|
-
- spec/dummy/config/environment.rb
|
110
|
-
- spec/dummy/config/environments/test.rb
|
111
|
-
- spec/dummy/config/initializers/assets.rb
|
112
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
113
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
114
|
-
- spec/dummy/config/initializers/session_store.rb
|
115
|
-
- spec/dummy/config/initializers/spree.rb
|
116
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
117
|
-
- spec/dummy/config/locales/en.yml
|
118
|
-
- spec/dummy/config/routes.rb
|
119
|
-
- spec/dummy/config/secrets.yml
|
120
|
-
- spec/factories/purchase_orders.rb
|
121
|
-
- spec/models/spree/purchase_order_spec.rb
|
122
|
-
- spec/spec_helper.rb
|
123
54
|
homepage: https://github.com/deepakmahakale/spree_purchase_order
|
124
55
|
licenses:
|
125
56
|
- MIT
|
@@ -132,12 +63,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
63
|
requirements:
|
133
64
|
- - ">="
|
134
65
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
66
|
+
version: 2.2.2
|
136
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
68
|
requirements:
|
138
|
-
- - "
|
69
|
+
- - ">"
|
139
70
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
71
|
+
version: 1.3.1
|
141
72
|
requirements:
|
142
73
|
- none
|
143
74
|
rubyforge_project:
|
@@ -145,32 +76,4 @@ rubygems_version: 2.5.1
|
|
145
76
|
signing_key:
|
146
77
|
specification_version: 4
|
147
78
|
summary: Adds Purchase Order as a Payment Method to Spree Commerce
|
148
|
-
test_files:
|
149
|
-
- spec/dummy/Rakefile
|
150
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
151
|
-
- spec/dummy/config/initializers/assets.rb
|
152
|
-
- spec/dummy/config/initializers/spree.rb
|
153
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
154
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
155
|
-
- spec/dummy/config/initializers/session_store.rb
|
156
|
-
- spec/dummy/config/application.rb
|
157
|
-
- spec/dummy/config/database.yml
|
158
|
-
- spec/dummy/config/boot.rb
|
159
|
-
- spec/dummy/config/environments/test.rb
|
160
|
-
- spec/dummy/config/secrets.yml
|
161
|
-
- spec/dummy/config/environment.rb
|
162
|
-
- spec/dummy/config/routes.rb
|
163
|
-
- spec/dummy/config/locales/en.yml
|
164
|
-
- spec/dummy/config.ru
|
165
|
-
- spec/dummy/bin/rake
|
166
|
-
- spec/dummy/bin/bundle
|
167
|
-
- spec/dummy/bin/rails
|
168
|
-
- spec/dummy/bin/setup
|
169
|
-
- spec/dummy/app/assets/javascripts/application.js
|
170
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
171
|
-
- spec/dummy/app/controllers/application_controller.rb
|
172
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
173
|
-
- spec/dummy/app/helpers/application_helper.rb
|
174
|
-
- spec/spec_helper.rb
|
175
|
-
- spec/models/spree/purchase_order_spec.rb
|
176
|
-
- spec/factories/purchase_orders.rb
|
79
|
+
test_files: []
|
data/config/locales/en.yml
DELETED
data/spec/dummy/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree .
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/spec/dummy/bin/bundle
DELETED
data/spec/dummy/bin/rails
DELETED
data/spec/dummy/bin/rake
DELETED
data/spec/dummy/bin/setup
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
-
|
7
|
-
Dir.chdir APP_ROOT do
|
8
|
-
|
9
|
-
puts "== Installing dependencies =="
|
10
|
-
system "gem install bundler --conservative"
|
11
|
-
system "bundle check || bundle install"
|
12
|
-
|
13
|
-
puts "\n== Preparing database =="
|
14
|
-
system "bin/rake db:setup"
|
15
|
-
|
16
|
-
puts "\n== Removing old logs and tempfiles =="
|
17
|
-
system "rm -f log/*"
|
18
|
-
system "rm -rf tmp/cache"
|
19
|
-
|
20
|
-
puts "\n== Restarting application server =="
|
21
|
-
system "touch tmp/restart.txt"
|
22
|
-
end
|
data/spec/dummy/config.ru
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require "active_record/railtie"
|
4
|
-
require "action_controller/railtie"
|
5
|
-
require "action_mailer/railtie"
|
6
|
-
require "action_view/railtie"
|
7
|
-
require "sprockets/railtie"
|
8
|
-
|
9
|
-
Bundler.require(*Rails.groups)
|
10
|
-
require "spree_purchase_order"
|
11
|
-
|
12
|
-
module Dummy
|
13
|
-
class Application < Rails::Application
|
14
|
-
|
15
|
-
config.to_prepare do
|
16
|
-
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
17
|
-
Rails.configuration.cache_classes ? require(c) : load(c)
|
18
|
-
end
|
19
|
-
|
20
|
-
Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
|
21
|
-
Rails.configuration.cache_classes ? require(c) : load(c)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
config.active_record.raise_in_transactional_callbacks = true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
data/spec/dummy/config/boot.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
Rails.application.configure do
|
2
|
-
config.cache_classes = true
|
3
|
-
config.eager_load = false
|
4
|
-
config.serve_static_files = true
|
5
|
-
config.static_cache_control = 'public, max-age=3600'
|
6
|
-
config.consider_all_requests_local = true
|
7
|
-
config.action_controller.perform_caching = false
|
8
|
-
config.action_dispatch.show_exceptions = false
|
9
|
-
config.action_controller.allow_forgery_protection = false
|
10
|
-
config.action_mailer.delivery_method = :test
|
11
|
-
config.active_support.test_order = :random
|
12
|
-
config.active_support.deprecation = :stderr
|
13
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Rails.application.config.assets.version = '1.0'
|
@@ -1 +0,0 @@
|
|
1
|
-
Rails.application.config.action_dispatch.cookies_serializer = :json
|
@@ -1 +0,0 @@
|
|
1
|
-
Rails.application.config.filter_parameters += [:password]
|
@@ -1 +0,0 @@
|
|
1
|
-
Rails.application.config.session_store :cookie_store, key: '_dummy_session'
|
data/spec/dummy/config/routes.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
secret_key_base: a21ce77d12504975623f2bc74d70b7cb4973f7495a5d4b1df2759dab2aa684a99a9391c4d2c0e2cf7e82409ffe37bb29ca978622a9c234b2aa25309fd1ee0404
|
3
|
-
|
4
|
-
test:
|
5
|
-
secret_key_base: 26cf60e63c4cf25d010087eff97d56793bddce5a85e63a1966c8922d2b2fa790a25d2ef5581d6e9ebfcfc69cd67d9a5d15c28c091231cd5029bfe00d357beaa1
|
6
|
-
|
7
|
-
production:
|
8
|
-
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -1,87 +0,0 @@
|
|
1
|
-
FactoryGirl.define do
|
2
|
-
sequence :user_authentication_token do |n|
|
3
|
-
"xxxx#{Time.current.to_i}#{rand(1000)}#{n}xxxxxxxxxxxxx"
|
4
|
-
end
|
5
|
-
|
6
|
-
factory :purchase_order, class: Spree::PurchaseOrder do
|
7
|
-
po_number 'PO-123'
|
8
|
-
organization_name 'Spree Commerce'
|
9
|
-
association(:payment_method, factory: :purchase_order_payment_method)
|
10
|
-
end
|
11
|
-
|
12
|
-
factory :purchase_order_payment_method, class: Spree::PaymentMethod::PurchaseOrder do
|
13
|
-
name 'Purchase Order'
|
14
|
-
end
|
15
|
-
factory :payment, class: Spree::Payment do
|
16
|
-
amount 45.75
|
17
|
-
association(:source, factory: :purchase_order)
|
18
|
-
association(:payment_method, factory: :purchase_order_payment_method)
|
19
|
-
order
|
20
|
-
state 'checkout'
|
21
|
-
response_code '12345'
|
22
|
-
end
|
23
|
-
factory :order, class: Spree::Order do
|
24
|
-
|
25
|
-
bill_address
|
26
|
-
completed_at nil
|
27
|
-
email { 'email@example.com' }
|
28
|
-
store
|
29
|
-
|
30
|
-
transient do
|
31
|
-
line_items_price BigDecimal.new(10)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
factory :store, class: Spree::Store do
|
36
|
-
sequence(:code) { |i| "spree_#{i}" }
|
37
|
-
name 'Spree Test Store'
|
38
|
-
url 'www.example.com'
|
39
|
-
mail_from_address 'spree@example.org'
|
40
|
-
end
|
41
|
-
|
42
|
-
# factory :user, class: Spree.user_class do
|
43
|
-
# email { generate(:random_email) }
|
44
|
-
# login { email }
|
45
|
-
# password 'secret'
|
46
|
-
# password_confirmation { password }
|
47
|
-
# authentication_token { generate(:user_authentication_token) } if Spree.user_class.attribute_method? :authentication_token
|
48
|
-
# end
|
49
|
-
factory :state, class: Spree::State do
|
50
|
-
sequence(:name) { |n| "STATE_NAME_#{n}" }
|
51
|
-
sequence(:abbr) { |n| "STATE_ABBR_#{n}" }
|
52
|
-
country do |country|
|
53
|
-
if usa = Spree::Country.find_by_numcode(840)
|
54
|
-
country = usa
|
55
|
-
else
|
56
|
-
country.association(:country)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
factory :country, class: Spree::Country do
|
61
|
-
sequence(:iso_name) { |n| "ISO_NAME_#{n}" }
|
62
|
-
sequence(:name) { |n| "NAME_#{n}" }
|
63
|
-
iso 'US'
|
64
|
-
iso3 'USA'
|
65
|
-
numcode 840
|
66
|
-
end
|
67
|
-
factory :address, aliases: [:bill_address, :ship_address], class: Spree::Address do
|
68
|
-
firstname 'John'
|
69
|
-
lastname 'Doe'
|
70
|
-
company 'Company'
|
71
|
-
address1 '10 Lovely Street'
|
72
|
-
address2 'Northwest'
|
73
|
-
city 'Herndon'
|
74
|
-
zipcode '35005'
|
75
|
-
phone '555-555-0199'
|
76
|
-
alternative_phone '555-555-0199'
|
77
|
-
|
78
|
-
state { |address| address.association(:state) || Spree::State.last }
|
79
|
-
country do |address|
|
80
|
-
if address.state
|
81
|
-
address.state.country
|
82
|
-
else
|
83
|
-
address.association(:country)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::PurchaseOrder, type: :model do
|
4
|
-
let(:valid_purchase_order_attributes) do
|
5
|
-
{
|
6
|
-
po_number: 'PO-123',
|
7
|
-
organization_name: 'Spree Commerce'
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.payment_states
|
12
|
-
Spree::Payment.state_machine.states.keys
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:purchase_order) { Spree::PurchaseOrder.new }
|
16
|
-
|
17
|
-
context "#can_complete?" do
|
18
|
-
it "should be true if payment is pending" do
|
19
|
-
payment = create(:payment, state: 'pending')
|
20
|
-
expect(purchase_order.can_complete?(payment)).to be true
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should be true if payment is checkout" do
|
24
|
-
payment = create(:payment, state: 'checkout')
|
25
|
-
expect(purchase_order.can_complete?(payment)).to be true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "#can_void?" do
|
30
|
-
it "should be true if payment is not void" do
|
31
|
-
payment = create(:payment, state: 'checkout')
|
32
|
-
expect(purchase_order.can_void?(payment)).to be true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "#valid?" do
|
37
|
-
it "should validate presence of po number" do
|
38
|
-
purchase_order.attributes = valid_purchase_order_attributes.except(:po_number)
|
39
|
-
expect(purchase_order).not_to be_valid
|
40
|
-
expect(purchase_order.errors[:po_number]).to eq(["can't be blank"])
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should validate presence of organization name" do
|
44
|
-
purchase_order.attributes = valid_purchase_order_attributes.except(:organization_name)
|
45
|
-
expect(purchase_order).not_to be_valid
|
46
|
-
expect(purchase_order.errors[:organization_name]).to eq(["can't be blank"])
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should only validate on create" do
|
50
|
-
purchase_order.attributes = valid_purchase_order_attributes
|
51
|
-
purchase_order.save
|
52
|
-
expect(purchase_order).to be_valid
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "#associations" do
|
57
|
-
it "should be able to access its payments" do
|
58
|
-
expect { purchase_order.payments.to_a }.not_to raise_error
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] ||= 'test'
|
2
|
-
|
3
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
-
require 'rspec/rails'
|
5
|
-
require 'rspec/autorun'
|
6
|
-
require 'factory_girl_rails'
|
7
|
-
|
8
|
-
Rails.backtrace_cleaner.remove_silencers!
|
9
|
-
|
10
|
-
# Load support files
|
11
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.mock_with :rspec
|
15
|
-
config.use_transactional_fixtures = true
|
16
|
-
config.infer_base_class_for_anonymous_controllers = false
|
17
|
-
config.order = "random"
|
18
|
-
|
19
|
-
config.include FactoryGirl::Syntax::Methods
|
20
|
-
end
|