solidus_ship_compliant 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +231 -0
  5. data/.travis.yml +21 -0
  6. data/Gemfile +19 -0
  7. data/LICENSE +26 -0
  8. data/README.md +49 -0
  9. data/Rakefile +21 -0
  10. data/app/assets/javascripts/spree/backend/solidus_ship_complaint.js +2 -0
  11. data/app/assets/javascripts/spree/frontend/solidus_ship_complaint.js +2 -0
  12. data/app/assets/stylesheets/spree/backend/solidus_ship_complaint.css +4 -0
  13. data/app/assets/stylesheets/spree/frontend/solidus_ship_complaint.css +4 -0
  14. data/app/controllers/spree/admin/orders_controller_decorator.rb +7 -0
  15. data/app/controllers/spree/admin/ship_compliant_settings_controller.rb +27 -0
  16. data/app/controllers/spree/checkout_controller_decorator.rb +6 -0
  17. data/app/models/spree/calculator/ship_compliant_calculator.rb +83 -0
  18. data/app/models/spree/ship_compliant.rb +96 -0
  19. data/app/models/spree/taxon_decorator.rb +11 -0
  20. data/app/models/spree/variant_decorator.rb +73 -0
  21. data/app/overrides/spree/admin/shared/_configuration_menu/_add_ship_compliant_config_menu.html.erb.deface +3 -0
  22. data/app/views/spree/admin/shared/_ship_complaint_tabs.html.erb +9 -0
  23. data/app/views/spree/admin/ship_compliant_settings/edit.html.erb +30 -0
  24. data/bin/rails +7 -0
  25. data/config/locales/en.yml +23 -0
  26. data/config/routes.rb +5 -0
  27. data/lib/generators/solidus_ship_compliant/install/install_generator.rb +20 -0
  28. data/lib/solidus_ship_compliant.rb +2 -0
  29. data/lib/solidus_ship_compliant/configuration.rb +7 -0
  30. data/lib/solidus_ship_compliant/engine.rb +31 -0
  31. data/lib/solidus_ship_compliant/error.rb +4 -0
  32. data/lib/solidus_ship_compliant/factories.rb +6 -0
  33. data/lib/solidus_ship_compliant/version.rb +3 -0
  34. data/lib/tasks/solidus_ship_compliant/export.rake +78 -0
  35. data/solidus_ship_compliant.gemspec +35 -0
  36. data/spec/controllers/admin/ship_compliant_settings_controller_spec.rb +39 -0
  37. data/spec/factories/variant_factory_override.rb +0 -0
  38. data/spec/features/checkout_spec.rb +0 -0
  39. data/spec/models/calculator/ship_compliant_calculator_spec.rb +19 -0
  40. data/spec/models/spree/ship_compliant_spec.rb +21 -0
  41. data/spec/models/spree/taxon_spec.rb +16 -0
  42. data/spec/models/spree/variant_spec.rb +70 -0
  43. data/spec/spec_helper.rb +24 -0
  44. data/spec/support/ability.rb +15 -0
  45. data/spec/support/database_cleaner.rb +23 -0
  46. data/spec/support/devise.rb +5 -0
  47. data/spec/support/factory_bot.rb +5 -0
  48. data/spec/support/preferences.rb +5 -0
  49. data/spec/support/spree.rb +14 -0
  50. metadata +307 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cafaf19d6825daea91808c5497cbb179b74882cb
4
+ data.tar.gz: aa01b95db8b388b49fc5064ab3ef06b22fe524a9
5
+ SHA512:
6
+ metadata.gz: 31ecec5d0aaf85380b7011925d88a5a9b52a14a6e8c4e3495cdacb326a8941cde11c261087071ec36300e58c2f3777b744aac42b1b3e063e6a3903341fbc76b4
7
+ data.tar.gz: 4bb8c7ebedddfe011f99bd3c2e3daf536c626252f266ad4b48f1e59cc8bc8915b6c61cd329707681bcfab96c2e6f17011ee5e7d434ab4e7c099225b1abb6c790
@@ -0,0 +1,15 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,231 @@
1
+ # Relaxed.Ruby.Style
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - 'spec/dummy/**/*'
6
+ - 'vendor/bundle/**/*'
7
+ TargetRubyVersion: 2.1
8
+
9
+ # Sometimes I believe this reads better
10
+ # This also causes spacing issues on multi-line fixes
11
+ Style/BracesAroundHashParameters:
12
+ Enabled: false
13
+
14
+ # We use class vars and will have to continue doing so for compatability
15
+ Style/ClassVars:
16
+ Enabled: false
17
+
18
+ # We need these names for backwards compatability
19
+ Style/PredicateName:
20
+ Enabled: false
21
+
22
+ Style/AccessorMethodName:
23
+ Enabled: false
24
+
25
+ # This has been used for customization
26
+ Style/MutableConstant:
27
+ Enabled: false
28
+
29
+ Style/ClassAndModuleChildren:
30
+ Enabled: false
31
+
32
+ Style/GuardClause:
33
+ Enabled: false
34
+
35
+ Style/WordArray:
36
+ Enabled: false
37
+
38
+ Style/ConditionalAssignment:
39
+ Enabled: false
40
+
41
+ Performance/Count:
42
+ Enabled: false
43
+
44
+ Style/RaiseArgs:
45
+ Enabled: false
46
+
47
+ Style/OpMethod:
48
+ Enabled: false
49
+
50
+ # We can use good judgement here
51
+ Style/RegexpLiteral:
52
+ Enabled: false
53
+
54
+ # Unicode comments are useful
55
+ Style/AsciiComments:
56
+ Enabled: false
57
+
58
+ Lint/EndAlignment:
59
+ Enabled: false
60
+
61
+ Style/ElseAlignment:
62
+ Enabled: false
63
+
64
+ Style/IndentationWidth:
65
+ Enabled: false
66
+
67
+ Style/AlignParameters:
68
+ Enabled: false
69
+
70
+ Style/ClosingParenthesisIndentation:
71
+ Enabled: false
72
+
73
+ Style/MultilineMethodCallIndentation:
74
+ Enabled: false
75
+
76
+ Style/IndentArray:
77
+ Enabled: false
78
+
79
+ Style/IndentHash:
80
+ Enabled: false
81
+
82
+ Style/AlignHash:
83
+ Enabled: false
84
+
85
+ # From http://relaxed.ruby.style/
86
+
87
+ Style/Alias:
88
+ Enabled: false
89
+ StyleGuide: http://relaxed.ruby.style/#stylealias
90
+
91
+ Style/BeginBlock:
92
+ Enabled: false
93
+ StyleGuide: http://relaxed.ruby.style/#stylebeginblock
94
+
95
+ Style/BlockDelimiters:
96
+ Enabled: false
97
+ StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
98
+
99
+ Style/Documentation:
100
+ Enabled: false
101
+ StyleGuide: http://relaxed.ruby.style/#styledocumentation
102
+
103
+ Style/DotPosition:
104
+ Enabled: false
105
+ StyleGuide: http://relaxed.ruby.style/#styledotposition
106
+
107
+ Style/DoubleNegation:
108
+ Enabled: false
109
+ StyleGuide: http://relaxed.ruby.style/#styledoublenegation
110
+
111
+ Style/EndBlock:
112
+ Enabled: false
113
+ StyleGuide: http://relaxed.ruby.style/#styleendblock
114
+
115
+ Style/FormatString:
116
+ Enabled: false
117
+ StyleGuide: http://relaxed.ruby.style/#styleformatstring
118
+
119
+ Style/IfUnlessModifier:
120
+ Enabled: false
121
+ StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
122
+
123
+ Style/Lambda:
124
+ Enabled: false
125
+ StyleGuide: http://relaxed.ruby.style/#stylelambda
126
+
127
+ Style/ModuleFunction:
128
+ Enabled: false
129
+ StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
130
+
131
+ Style/MultilineBlockChain:
132
+ Enabled: false
133
+ StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
134
+
135
+ Style/NegatedIf:
136
+ Enabled: false
137
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedif
138
+
139
+ Style/NegatedWhile:
140
+ Enabled: false
141
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
142
+
143
+ Style/ParallelAssignment:
144
+ Enabled: false
145
+ StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
146
+
147
+ Style/PercentLiteralDelimiters:
148
+ Enabled: false
149
+ StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
150
+
151
+ Style/PerlBackrefs:
152
+ Enabled: false
153
+ StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
154
+
155
+ Style/Semicolon:
156
+ Enabled: false
157
+ StyleGuide: http://relaxed.ruby.style/#stylesemicolon
158
+
159
+ Style/SignalException:
160
+ Enabled: false
161
+ StyleGuide: http://relaxed.ruby.style/#stylesignalexception
162
+
163
+ Style/SingleLineBlockParams:
164
+ Enabled: false
165
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
166
+
167
+ Style/SingleLineMethods:
168
+ Enabled: false
169
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
170
+
171
+ Style/SpaceBeforeBlockBraces:
172
+ Enabled: false
173
+ StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
174
+
175
+ Style/SpaceInsideParens:
176
+ Enabled: false
177
+ StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
178
+
179
+ Style/SpecialGlobalVars:
180
+ Enabled: false
181
+ StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
182
+
183
+ Style/StringLiterals:
184
+ Enabled: false
185
+ StyleGuide: http://relaxed.ruby.style/#stylestringliterals
186
+
187
+ Style/SymbolProc:
188
+ Enabled: false
189
+
190
+ Style/WhileUntilModifier:
191
+ Enabled: false
192
+ StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
193
+
194
+ Lint/AmbiguousRegexpLiteral:
195
+ Enabled: false
196
+ StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
197
+
198
+ Lint/AssignmentInCondition:
199
+ Enabled: false
200
+ StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
201
+
202
+ Lint/HandleExceptions:
203
+ Exclude:
204
+ - 'Rakefile'
205
+
206
+ Metrics/AbcSize:
207
+ Enabled: false
208
+
209
+ Metrics/BlockNesting:
210
+ Enabled: false
211
+
212
+ Metrics/ClassLength:
213
+ Enabled: false
214
+
215
+ Metrics/ModuleLength:
216
+ Enabled: false
217
+
218
+ Metrics/CyclomaticComplexity:
219
+ Enabled: false
220
+
221
+ Metrics/LineLength:
222
+ Enabled: false
223
+
224
+ Metrics/MethodLength:
225
+ Enabled: false
226
+
227
+ Metrics/ParameterLists:
228
+ Enabled: false
229
+
230
+ Metrics/PerceivedComplexity:
231
+ Enabled: false
@@ -0,0 +1,21 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 2.3.1
6
+ env:
7
+ matrix:
8
+ - SOLIDUS_BRANCH=v2.0 DB=postgres
9
+ - SOLIDUS_BRANCH=v2.1 DB=postgres
10
+ - SOLIDUS_BRANCH=v2.2 DB=postgres
11
+ - SOLIDUS_BRANCH=v2.3 DB=postgres
12
+ - SOLIDUS_BRANCH=v2.4 DB=postgres
13
+ - SOLIDUS_BRANCH=v2.5 DB=postgres
14
+ - SOLIDUS_BRANCH=master DB=postgres
15
+ - SOLIDUS_BRANCH=v2.0 DB=mysql
16
+ - SOLIDUS_BRANCH=v2.1 DB=mysql
17
+ - SOLIDUS_BRANCH=v2.2 DB=mysql
18
+ - SOLIDUS_BRANCH=v2.3 DB=mysql
19
+ - SOLIDUS_BRANCH=v2.4 DB=mysql
20
+ - SOLIDUS_BRANCH=v2.5 DB=mysql
21
+ - SOLIDUS_BRANCH=master DB=mysql
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+
3
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
4
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
5
+ gem 'solidus_auth_devise', github: 'solidusio/solidus_auth_devise'
6
+
7
+ if branch == 'master' || branch >= 'v2.0'
8
+ gem 'rails-controller-testing', group: :test
9
+ else
10
+ gem 'rails_test_params_backport', group: :test
11
+ end
12
+
13
+ gem 'ship_compliant', github: 'ShipCompliant/ship_compliant-ruby', require: true
14
+
15
+ gem 'pg', '~> 0.21'
16
+ gem 'sqlite3'
17
+ gem 'mysql2', '~> 0.4.10'
18
+
19
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2018 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,49 @@
1
+ SolidusShipCompliant
2
+ ====================
3
+
4
+ [![Build Status](https://travis-ci.org/jtapia/solidus_ship_compliant.svg?branch=master)](https://travis-ci.org/jtapia/solidus_ship_compliant)
5
+
6
+ Add Solidus ability to calculate rate taxes based on Ship Compliant third party
7
+
8
+ Requirements
9
+ ------------
10
+
11
+ - Define taxonomies and taxons related # [ Brand, Categories ]
12
+ - Define the necessary `option_types` # [ bottle_size ]
13
+ - Define the necessary `product_properties` # [ default_case, default_wholesale_case_price, percent_alcohol, varietal, vintage, volume_amount, volume_unit ]
14
+ - Create relation between `products` - `taxons`, `product_properties` and `option_types`
15
+
16
+ Installation
17
+ ------------
18
+
19
+ Add solidus_ship_compliant to your Gemfile:
20
+
21
+ ```ruby
22
+ gem 'solidus_ship_compliant'
23
+ ```
24
+
25
+ Bundle your dependencies and run the installation generator:
26
+
27
+ ```shell
28
+ bundle
29
+ bundle exec rails g solidus_ship_compliant:install
30
+ ```
31
+
32
+ Testing
33
+ -------
34
+
35
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
36
+
37
+ ```shell
38
+ bundle
39
+ bundle exec rake
40
+ ```
41
+
42
+ When testing your applications integration with this extension you may use it's factories.
43
+ Simply add this require statement to your spec_helper:
44
+
45
+ ```ruby
46
+ require 'solidus_ship_compliant/factories'
47
+ ```
48
+
49
+ Copyright (c) 2018 [name of extension creator], released under the New BSD License
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'solidus_ship_compliant'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,7 @@
1
+ Spree::Admin::OrdersController.class_eval do
2
+ rescue_from SolidusShipCompliant::Error do |exception|
3
+ exception_message = exception.problem
4
+ flash[:error] = Spree.t(:address_verification_failed) + (exception_message ? ": #{exception_message}" : '')
5
+ redirect_to edit_admin_order_customer_path(@order)
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ module Spree
2
+ module Admin
3
+ class ShipCompliantSettingsController < Spree::Admin::BaseController
4
+ before_action :load_config
5
+
6
+ def edit
7
+ @preferences_ship_compliant = [:username, :password, :partner_key, :service_url]
8
+ end
9
+
10
+ def update
11
+ params.each do |name, value|
12
+ next unless @config.has_preference? name
13
+ @config[name] = value
14
+ end
15
+
16
+ flash[:success] = Spree.t(:ship_compliant_settings_updated)
17
+ redirect_to edit_admin_ship_compliant_settings_path
18
+ end
19
+
20
+ private
21
+
22
+ def load_config
23
+ @config ||= SolidusShipCompliant::Config
24
+ end
25
+ end
26
+ end
27
+ end