spree_purchase_order 2.2.0 → 2.3.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -12
  3. data/Rakefile +12 -10
  4. data/app/assets/stylesheets/spree/backend/spree_purchase_order.css +0 -26
  5. data/app/models/spree/order_decorator.rb +15 -0
  6. data/app/models/spree/payment_decorator.rb +2 -2
  7. data/app/models/spree/payment_method/purchase_order.rb +18 -8
  8. data/app/models/spree/purchase_order.rb +1 -16
  9. data/app/views/spree/checkout/payment/_purchaseorder.html.erb +15 -9
  10. data/db/migrate/20160111163926_add_po_number_to_spree_payments.rb +5 -0
  11. data/lib/spree_purchase_order/engine.rb +1 -4
  12. data/lib/spree_purchase_order/version.rb +1 -1
  13. metadata +9 -106
  14. data/config/locales/en.yml +0 -10
  15. data/spec/dummy/Rakefile +0 -3
  16. data/spec/dummy/app/assets/javascripts/application.js +0 -1
  17. data/spec/dummy/app/assets/stylesheets/application.css +0 -4
  18. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  19. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  20. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  21. data/spec/dummy/bin/bundle +0 -3
  22. data/spec/dummy/bin/rails +0 -4
  23. data/spec/dummy/bin/rake +0 -4
  24. data/spec/dummy/bin/setup +0 -22
  25. data/spec/dummy/config/application.rb +0 -26
  26. data/spec/dummy/config/boot.rb +0 -5
  27. data/spec/dummy/config/database.yml +0 -8
  28. data/spec/dummy/config/environment.rb +0 -3
  29. data/spec/dummy/config/environments/test.rb +0 -13
  30. data/spec/dummy/config/initializers/assets.rb +0 -1
  31. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -1
  32. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -1
  33. data/spec/dummy/config/initializers/session_store.rb +0 -1
  34. data/spec/dummy/config/initializers/spree.rb +0 -2
  35. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -3
  36. data/spec/dummy/config/locales/en.yml +0 -2
  37. data/spec/dummy/config/routes.rb +0 -2
  38. data/spec/dummy/config/secrets.yml +0 -8
  39. data/spec/dummy/config.ru +0 -2
  40. data/spec/factories/purchase_orders.rb +0 -75
  41. data/spec/models/spree/purchase_order_spec.rb +0 -61
  42. data/spec/spec_helper.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0c969a1a8f0ec4fe390aa67a47ea4550a5961eb
4
- data.tar.gz: e87c4bf6201defd8852a23b5a1fd494a3af1ef0f
3
+ metadata.gz: a6868ac4dc810cfcd75c34a21fd59fb387e0db35
4
+ data.tar.gz: 8e6b5d31274f438f06167debf9636c84f41dfbe9
5
5
  SHA512:
6
- metadata.gz: 9015288194e1c9d587cca2dc88c740be2efe4810ae3b39e289b997ec4314d61df1df6c6a040ec5929b6fbd7f1880afb34d4b807eb26d60642d0a10c392486738
7
- data.tar.gz: 02adb981c6ab36417e22955d375351f0409af81cafee0ecedd3639c5267b8d5649756b22e72c8c6e20184756faccb35ef6d383aadffc835ead8a2955a6f5387a
6
+ metadata.gz: 69b319f7f42cd625c357a6d05367a8e64a75d5bc518e21a69f9963622c23de2213ee01ebb169b77d6187b45dc6e741480242b89b4b638f9f44297d652f17e67f
7
+ data.tar.gz: c8157f21bb8bb5eebb2a702a445ff02fd1f2fa58d2b0c551b5065632ef366ecb4eb08694414eae1985592dfd11c54e7124e4e651e202fd3d5af87fea5d91c724
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
- ```ruby
11
- gem 'spree_purchase_order'
12
- ```
8
+
9
+ gem 'spree_purchase_order'
13
10
 
14
11
  2. Install the gem using Bundler:
15
- ```bash
16
- bundle install
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
- 4. Restart your server
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.md')
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("../spec/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
18
  load 'rails/tasks/engine.rake'
20
19
 
21
- Bundler::GemHelper.install_tasks
20
+ load 'rails/tasks/statistics.rake'
22
21
 
23
- Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
22
+ Bundler::GemHelper.install_tasks
24
23
 
25
- require 'rspec/core'
26
- require 'rspec/core/rake_task'
24
+ require 'rake/testtask'
27
25
 
28
- desc "Run all specs in spec directory (excluding plugin specs)"
29
- RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
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: :spec
33
+ task default: :test
@@ -1,29 +1,3 @@
1
1
  /*
2
2
  *= require spree/backend
3
3
  */
4
- table th.actions .fa-complete:hover, table td.actions .fa-complete:hover{
5
- background-color: #9FC820;
6
- color: #FFFFFF;
7
- }
8
- table tbody tr.before-highlight.action-complete td {
9
- border-bottom-color: #e0f1a9;
10
- }
11
- table tbody tr.highlight.action-complete td {
12
- background-color: #f8fceb;
13
- border-color: #e0f1a9;
14
- }
15
- .fa-complete:before {
16
- content: "\f00c";
17
- }
18
- #powerTip.complete {
19
- background-color: #9FC820;
20
- }
21
- #powerTip.complete.n:before, #powerTip.complete.ne:before, #powerTip.complete.nw:before {
22
- border-top-color: #9FC820;
23
- }
24
- #powerTip.complete.s:before, #powerTip.complete.se:before, #powerTip.complete.sw:before {
25
- border-bottom-color: #9FC820;
26
- }
27
- #powerTip.complete.w:before {
28
- border-left-color: #9FC820;
29
- }
@@ -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
@@ -1,7 +1,7 @@
1
1
  Spree::Payment.class_eval do
2
- scope :from_purchase_order, -> { where(source_type: 'Spree::PurchaseOrder') }
2
+ has_one :purchase_order
3
3
 
4
4
  def po?
5
- source_type == 'Spree::PurchaseOrder'
5
+ payment_method.type == 'Spree::PaymentMethod::PurchaseOrder'
6
6
  end
7
7
  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
- simulated_successful_billing_response('Purchase Order: Success')
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
- simulated_successful_billing_response
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
2
  class PurchaseOrder < ActiveRecord::Base
3
- belongs_to :payment_method
4
- has_many :payments, as: :source
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
@@ -1,9 +1,15 @@
1
- <% param_prefix = "payment_source[#{payment_method.id}]" %>
2
- <p class='field'>
3
- <%= label_tag :po_number, "PO Number" %><span class="required">*</span><br />
4
- <%= text_field_tag "#{param_prefix}[po_number]", '', id: :po_number, size: 10, maxlength: 10, autocomplete: "off" %>
5
- </p>
6
- <p class='field'>
7
- <%= label_tag :organization_name, "Organization Name" %><span class="required">*</span><br />
8
- <%= text_field_tag "#{param_prefix}[organization_name]", '', id: :organization_name, class: 'form-control required'%>
9
- </p>
1
+ <div class='well clearfix'>
2
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
3
+ <p class='field'>
4
+ <%= label_tag :po_number do %>
5
+ PO Number<abbr class='required' title='required'>*</abbr>
6
+ <% end %>
7
+ <%= text_field_tag "#{param_prefix}[po_number]", '', id: :po_number, class: 'form-control required', size: 10, maxlength: 10, autocomplete: "off" %>
8
+ </p>
9
+ <p class='field'>
10
+ <%= label_tag :organization_name do %>
11
+ Organization Name<abbr class='required' title='required'>*</abbr>
12
+ <% end %>
13
+ <%= text_field_tag "#{param_prefix}[organization_name]", '', id: :organization_name, class: 'form-control required'%>
14
+ </p>
15
+ </div>
@@ -0,0 +1,5 @@
1
+ class AddPoNumberToSpreePayments < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_payments, :po_number, :string
4
+ end
5
+ 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, fixture: false
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
@@ -1,3 +1,3 @@
1
1
  module SpreePurchaseOrder
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.0.beta'
3
3
  end
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: 2.2.0
4
+ version: 2.3.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-18 00:00:00.000000000 Z
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: 2.2.0
19
+ version: 2.3.0
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: 2.2.0
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: 2.3.0
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
@@ -135,9 +66,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
66
  version: 1.9.3
136
67
  required_rubygems_version: !ruby/object:Gem::Requirement
137
68
  requirements:
138
- - - ">="
69
+ - - ">"
139
70
  - !ruby/object:Gem::Version
140
- version: '0'
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: []
@@ -1,10 +0,0 @@
1
- en:
2
- spree:
3
- purchase_order: Purchase order
4
- activerecord:
5
- models:
6
- spree/purchase_order: Purchase order
7
- attributes:
8
- spree/purchase_order:
9
- po_number: Number
10
- organization_name: Organization name
data/spec/dummy/Rakefile DELETED
@@ -1,3 +0,0 @@
1
- require File.expand_path('../config/application', __FILE__)
2
-
3
- Rails.application.load_tasks
@@ -1 +0,0 @@
1
- //= require_tree .
@@ -1,4 +0,0 @@
1
- /*
2
- *= require_tree .
3
- *= require_self
4
- */
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery with: :exception
3
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -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>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
data/spec/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
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
@@ -1,26 +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
- end
25
- end
26
-
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,8 +0,0 @@
1
- default: &default
2
- adapter: sqlite3
3
- pool: 5
4
- timeout: 5000
5
-
6
- test:
7
- <<: *default
8
- database: db/test.sqlite3
@@ -1,3 +0,0 @@
1
- require File.expand_path('../application', __FILE__)
2
-
3
- Rails.application.initialize!
@@ -1,13 +0,0 @@
1
- Dummy::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'
@@ -1,2 +0,0 @@
1
- Spree.config do |config|
2
- end
@@ -1,3 +0,0 @@
1
- ActiveSupport.on_load(:action_controller) do
2
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
3
- end
@@ -1,2 +0,0 @@
1
- en:
2
- hello: "Hello world"
@@ -1,2 +0,0 @@
1
- Rails.application.routes.draw do
2
- end
@@ -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"] %>
data/spec/dummy/config.ru DELETED
@@ -1,2 +0,0 @@
1
- require ::File.expand_path('../config/environment', __FILE__)
2
- run Rails.application
@@ -1,75 +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
-
16
- factory :payment, class: Spree::Payment do
17
- amount 45.75
18
- association(:source, factory: :purchase_order)
19
- association(:payment_method, factory: :purchase_order_payment_method)
20
- order
21
- state 'checkout'
22
- response_code '12345'
23
- end
24
-
25
- factory :order, class: Spree::Order do
26
- bill_address
27
- completed_at nil
28
- email { 'email@example.com' }
29
-
30
- transient do
31
- line_items_price BigDecimal.new(10)
32
- end
33
- end
34
-
35
- factory :state, class: Spree::State do
36
- sequence(:name) { |n| "STATE_NAME_#{n}" }
37
- sequence(:abbr) { |n| "STATE_ABBR_#{n}" }
38
- country do |country|
39
- if usa = Spree::Country.find_by_numcode(840)
40
- country = usa
41
- else
42
- country.association(:country)
43
- end
44
- end
45
- end
46
-
47
- factory :country, class: Spree::Country do
48
- sequence(:iso_name) { |n| "ISO_NAME_#{n}" }
49
- sequence(:name) { |n| "NAME_#{n}" }
50
- iso 'US'
51
- iso3 'USA'
52
- numcode 840
53
- end
54
-
55
- factory :address, aliases: [:bill_address, :ship_address], class: Spree::Address do
56
- firstname 'John'
57
- lastname 'Doe'
58
- company 'Company'
59
- address1 '10 Lovely Street'
60
- address2 'Northwest'
61
- city 'Herndon'
62
- zipcode '35005'
63
- phone '555-555-0199'
64
- alternative_phone '555-555-0199'
65
-
66
- state { |address| address.association(:state) || Spree::State.last }
67
- country do |address|
68
- if address.state
69
- address.state.country
70
- else
71
- address.association(:country)
72
- end
73
- end
74
- end
75
- 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