solidus_related_products 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.hound.yml +8 -25
- data/.rubocop.yml +223 -4
- data/.travis.yml +15 -11
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +13 -2
- data/README.md +5 -5
- data/Rakefile +7 -1
- data/app/controllers/spree/admin/relations_controller.rb +1 -1
- data/app/models/spree/calculator/related_product_discount.rb +8 -8
- data/app/models/spree/product_decorator.rb +1 -1
- data/app/views/spree/admin/products/_related_products.html.erb +2 -2
- data/app/views/spree/admin/products/_related_products_table.html.erb +3 -6
- data/app/views/spree/admin/products/related.html.erb +14 -10
- data/bin/rails +1 -1
- data/config/locales/de.yml +3 -0
- data/config/routes.rb +1 -1
- data/lib/generators/solidus_related_products/install/install_generator.rb +1 -1
- data/lib/solidus_related_products/version.rb +1 -1
- data/solidus_related_products.gemspec +2 -6
- data/spec/controllers/spree/admin/relations_controller_spec.rb +6 -4
- data/spec/controllers/spree/api/relations_controller_spec.rb +1 -1
- data/spec/features/spree/admin/product_relation_spec.rb +2 -2
- data/spec/features/spree/admin/relation_types_spec.rb +1 -1
- data/spec/models/spree/calculator/related_product_discount_spec.rb +2 -2
- data/spec/models/spree/product_spec.rb +0 -12
- data/spec/models/spree/relation_type_spec.rb +1 -1
- metadata +14 -65
- data/Guardfile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 752931ed32a44beaa71d0065db52b172dca391c0
|
4
|
+
data.tar.gz: fb64275f2eca94076f2abb24c24e33a69204ff3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbb92a4271f86e0d5202375a244510f177bb9d478b566449856da8d50166282abe28a3edc2e28d9dcfb1c67336c7e75aa14c203a6071a57b4d65e6c3aae59d92
|
7
|
+
data.tar.gz: cf0926217e19ebbf9469b772afdf0cbb71a096c02b3882d9bd83dfb009ac972eee710a8a91af93a94a4aa29f7e86e601be68ec0aa852eedacf0c3130e5ba4864
|
data/.hound.yml
CHANGED
@@ -1,25 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# Neatly aligned code is too swell.
|
11
|
-
SpaceBeforeFirstArg:
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
# Don't mess with RSpec DSL.
|
15
|
-
Blocks:
|
16
|
-
Exclude:
|
17
|
-
- 'spec/**/*'
|
18
|
-
|
19
|
-
# It say we should use fail over raise.
|
20
|
-
SignalException:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
# Avoid contradictory style rules by enforce single quotes.
|
24
|
-
StringLiterals:
|
25
|
-
EnforcedStyle: single_quotes
|
1
|
+
ruby:
|
2
|
+
config_file: .rubocop.yml
|
3
|
+
scss:
|
4
|
+
enabled: false
|
5
|
+
coffeescript:
|
6
|
+
enabled: false
|
7
|
+
javascript:
|
8
|
+
enabled: false
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,227 @@
|
|
1
|
-
|
2
|
-
inherit_from: .hound.yml
|
1
|
+
# Relaxed.Ruby.Style
|
3
2
|
|
4
3
|
AllCops:
|
5
4
|
Exclude:
|
6
5
|
- spec/dummy/**/*
|
7
|
-
-
|
8
|
-
|
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
|
+
Metrics/AbcSize:
|
203
|
+
Enabled: false
|
204
|
+
|
205
|
+
Metrics/BlockNesting:
|
206
|
+
Enabled: false
|
207
|
+
|
208
|
+
Metrics/ClassLength:
|
209
|
+
Enabled: false
|
210
|
+
|
211
|
+
Metrics/ModuleLength:
|
212
|
+
Enabled: false
|
213
|
+
|
214
|
+
Metrics/CyclomaticComplexity:
|
215
|
+
Enabled: false
|
216
|
+
|
217
|
+
Metrics/LineLength:
|
218
|
+
Enabled: false
|
219
|
+
|
220
|
+
Metrics/MethodLength:
|
221
|
+
Enabled: false
|
222
|
+
|
223
|
+
Metrics/ParameterLists:
|
224
|
+
Enabled: false
|
225
|
+
|
226
|
+
Metrics/PerceivedComplexity:
|
227
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.1
|
4
|
-
- 2.2
|
5
1
|
sudo: false
|
6
2
|
cache: bundler
|
3
|
+
language: ruby
|
4
|
+
rvm:
|
5
|
+
- 2.3.1
|
7
6
|
env:
|
8
7
|
matrix:
|
9
|
-
- SOLIDUS_BRANCH=
|
10
|
-
- SOLIDUS_BRANCH=v1.2
|
11
|
-
- SOLIDUS_BRANCH=v1.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
- SOLIDUS_BRANCH=v1.1 DB=postgres
|
9
|
+
- SOLIDUS_BRANCH=v1.2 DB=postgres
|
10
|
+
- SOLIDUS_BRANCH=v1.3 DB=postgres
|
11
|
+
- SOLIDUS_BRANCH=v1.4 DB=postgres
|
12
|
+
- SOLIDUS_BRANCH=v2.0 DB=postgres
|
13
|
+
- SOLIDUS_BRANCH=master DB=postgres
|
14
|
+
- SOLIDUS_BRANCH=v1.1 DB=mysql
|
15
|
+
- SOLIDUS_BRANCH=v1.2 DB=mysql
|
16
|
+
- SOLIDUS_BRANCH=v1.3 DB=mysql
|
17
|
+
- SOLIDUS_BRANCH=v1.4 DB=mysql
|
18
|
+
- SOLIDUS_BRANCH=v2.0 DB=mysql
|
19
|
+
- SOLIDUS_BRANCH=master DB=mysql
|
data/CONTRIBUTING.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Contributing
|
2
2
|
|
3
|
-
|
3
|
+
Solidus Related Products is an open source project and we encourage contributions.
|
4
4
|
|
5
5
|
In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
|
6
6
|
|
@@ -30,7 +30,7 @@ In the issue itself please provide:
|
|
30
30
|
|
31
31
|
* A comprehensive list of steps to reproduce the issue.
|
32
32
|
* What you're *expecting* to happen compared with what's *actually* happening.
|
33
|
-
* The version of
|
33
|
+
* The version of Solidus *and* the version of Rails.
|
34
34
|
* A list of all extensions.
|
35
35
|
* Any relevant stack traces ("Full trace" preferred)
|
36
36
|
* Your `Gemfile`
|
@@ -77,5 +77,5 @@ Some things that will increase the chance that your pull request is accepted, ta
|
|
77
77
|
And in case we didn't emphasize it enough: **we love tests!**
|
78
78
|
|
79
79
|
[1]: http://www.fsf.org/licensing/essays/free-sw.html
|
80
|
-
[2]: https://github.com/
|
81
|
-
[3]: https://github.com/
|
80
|
+
[2]: https://github.com/solidusio-contrib/solidus_related_products/issues
|
81
|
+
[3]: https://github.com/solidusio-contrib/solidus_related_products/tree/master/config/locales
|
data/Gemfile
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
4
|
-
gem
|
4
|
+
gem "solidus", github: "solidusio/solidus", branch: branch
|
5
|
+
|
6
|
+
if branch == 'master' || branch >= "v2.0"
|
7
|
+
gem "rails-controller-testing", group: :test
|
8
|
+
end
|
9
|
+
|
10
|
+
gem 'pg'
|
11
|
+
gem 'mysql2'
|
12
|
+
|
13
|
+
group :development, :test do
|
14
|
+
gem "pry-rails"
|
15
|
+
end
|
5
16
|
|
6
17
|
gemspec
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ You can manage RelationTypes via the admin configuration menu, and you can maint
|
|
12
12
|
|
13
13
|
Add to `Gemfile`:
|
14
14
|
```ruby
|
15
|
-
gem '
|
15
|
+
gem 'solidus_related_products'
|
16
16
|
```
|
17
17
|
|
18
18
|
Run:
|
@@ -73,8 +73,8 @@ See corresponding [guidelines][4]
|
|
73
73
|
Copyright (c) 2010-2015 [Brian Quinn][5] and [contributors][6], released under the [New BSD License][3]
|
74
74
|
|
75
75
|
[1]: http://www.fsf.org/licensing/essays/free-sw.html
|
76
|
-
[2]: https://github.com/
|
77
|
-
[3]: https://github.com/
|
78
|
-
[4]: https://github.com/
|
76
|
+
[2]: https://github.com/solidusio-contrib/solidus_related_products/issues
|
77
|
+
[3]: https://github.com/solidusio-contrib/solidus_related_products/blob/master/LICENSE.md
|
78
|
+
[4]: https://github.com/solidusio-contrib/solidus_related_products/blob/master/CONTRIBUTING.md
|
79
79
|
[5]: https://github.com/BDQ
|
80
|
-
[6]: https://github.com/
|
80
|
+
[6]: https://github.com/solidusio-contrib/solidus_related_products/graphs/contributors
|
data/Rakefile
CHANGED
@@ -6,7 +6,13 @@ require 'spree/testing_support/common_rake'
|
|
6
6
|
|
7
7
|
RSpec::Core::RakeTask.new
|
8
8
|
|
9
|
-
task default
|
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
|
10
16
|
|
11
17
|
desc 'Generates a dummy app for testing'
|
12
18
|
task :test_app do
|
@@ -14,17 +14,17 @@ module Spree
|
|
14
14
|
|
15
15
|
return unless eligible?(order)
|
16
16
|
total = order.line_items.inject(0) do |sum, line_item|
|
17
|
-
relations =
|
18
|
-
discount_applies_to = relations.map {|rel| rel.related_to.master }
|
17
|
+
relations = Spree::Relation.where(*discount_query(line_item))
|
18
|
+
discount_applies_to = relations.map { |rel| rel.related_to.master }
|
19
19
|
|
20
20
|
order.line_items.each do |li|
|
21
|
-
next unless discount_applies_to.include? li.variant
|
21
|
+
next li unless discount_applies_to.include? li.variant
|
22
22
|
discount = relations.detect { |rel| rel.related_to.master == li.variant }.discount_amount
|
23
|
-
sum +=
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
sum += if li.quantity < line_item.quantity
|
24
|
+
(discount * li.quantity)
|
25
|
+
else
|
26
|
+
(discount * line_item.quantity)
|
27
|
+
end
|
28
28
|
end
|
29
29
|
|
30
30
|
sum
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<li<%== ' class="active"' if current == "Related Products" %>>
|
2
|
-
<%= link_to_with_icon '
|
3
|
-
</li>
|
2
|
+
<%= link_to_with_icon 'share-alt', Spree.t(:related_products), related_admin_product_url(@product) %>
|
3
|
+
</li>
|
@@ -25,12 +25,9 @@
|
|
25
25
|
<td><%= relation.relation_type.name %></td>
|
26
26
|
<td>
|
27
27
|
<%= form_for relation, url: admin_product_relation_path(relation.relatable, relation) do |f| %>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
<%= f.button Spree.t(:update), type: 'submit', class: 'btn btn-primary' %>
|
32
|
-
</span>
|
33
|
-
</div>
|
28
|
+
|
29
|
+
<%= f.text_field :discount_amount, class: 'form-control text-center' %>
|
30
|
+
<%= f.button Spree.t(:update), type: 'submit', class: 'button btn-primary' %>
|
34
31
|
<% end %>
|
35
32
|
</td>
|
36
33
|
<td class="actions">
|
@@ -7,34 +7,38 @@
|
|
7
7
|
<%= Spree.t(:no_relation_types) %>
|
8
8
|
</div>
|
9
9
|
<% else %>
|
10
|
+
|
10
11
|
<div id="add-line-item">
|
11
12
|
<fieldset>
|
12
13
|
<legend><%= Spree.t(:add_related_product) %></legend>
|
13
14
|
<div class="row">
|
14
|
-
<div id="related_product_name" class="
|
15
|
+
<div id="related_product_name" class="">
|
15
16
|
<div class="form-group">
|
16
17
|
<%= label_tag :add_variant_name, Spree.t(:name_or_sku_short) %>
|
17
18
|
<%= hidden_field_tag :add_variant_name, '', class: 'variant_autocomplete', style: "display: block !important;" %>
|
18
19
|
</div>
|
19
20
|
</div>
|
20
|
-
|
21
|
+
|
22
|
+
<div id="related_product_type" class="column">
|
21
23
|
<div class="form-group">
|
22
24
|
<%= label_tag :add_type, Spree.t(:type) %>
|
23
|
-
<%= select_tag :add_type, options_for_select(@relation_types.map { |rt| [rt.name, rt.id] }), class: 'select2' %>
|
25
|
+
<%= select_tag :add_type, options_for_select(@relation_types.map { |rt| [rt.name, rt.id] }), class: 'select2', style: "display: block" %>
|
24
26
|
</div>
|
25
27
|
</div>
|
26
|
-
|
28
|
+
|
29
|
+
<div id="related_product_discount" class="four width column">
|
27
30
|
<div class="form-group">
|
28
31
|
<%= label_tag :add_discount, Spree.t(:discount_amount) %>
|
29
|
-
|
30
|
-
<%= text_field_tag :add_discount, 0.0, class: 'form-control text-center' %>
|
31
|
-
<span class="input-group-btn">
|
32
|
-
<%= button_link_to Spree.t(:add), admin_product_relations_url(@product), icon: 'add', class: 'btn-success', id: 'add_related_product', data: { update: 'products-table-wrapper' } %>
|
33
|
-
</span>
|
34
|
-
</div>
|
32
|
+
<%= text_field_tag :add_discount, 0.0, class: 'form-control text-center' %>
|
35
33
|
</div>
|
36
34
|
</div>
|
35
|
+
|
37
36
|
</div>
|
37
|
+
<div class='row'>
|
38
|
+
<div class='column'>
|
39
|
+
<%= button_link_to Spree.t(:add), admin_product_relations_url(@product), icon: 'add', id: 'add_related_product', data: { update: 'products-table-wrapper' } %>
|
40
|
+
<div>
|
41
|
+
<div>
|
38
42
|
</fieldset>
|
39
43
|
</div>
|
40
44
|
|
data/bin/rails
CHANGED
data/config/locales/de.yml
CHANGED
@@ -16,3 +16,6 @@ de:
|
|
16
16
|
add_related_product: Verwandtes Produkt hinzufügen
|
17
17
|
name_or_sku_short: Name oder Artikelnummer
|
18
18
|
no_relation_types: "Sie müssen Verwandschaftstypen konfigurieren, bevor Sie diese Funktion nutzen können."
|
19
|
+
admin:
|
20
|
+
tab:
|
21
|
+
relation_types: Verwandschaftstypen
|
data/config/routes.rb
CHANGED
@@ -8,7 +8,7 @@ module SolidusRelatedProducts
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run_migrations
|
11
|
-
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask
|
11
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
12
12
|
if run_migrations
|
13
13
|
run 'bundle exec rake db:migrate'
|
14
14
|
else
|
@@ -23,8 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.has_rdoc = false
|
25
25
|
|
26
|
-
s.add_runtime_dependency 'solidus_backend', '
|
27
|
-
s.add_runtime_dependency 'deface'
|
26
|
+
s.add_runtime_dependency 'solidus_backend', ['>= 1.0', '< 3']
|
27
|
+
s.add_runtime_dependency 'deface', '~> 1.0'
|
28
28
|
|
29
29
|
s.add_development_dependency 'factory_girl', '~> 4.5'
|
30
30
|
s.add_development_dependency 'ffaker'
|
@@ -36,10 +36,6 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_development_dependency 'shoulda-matchers', '~> 2.5'
|
37
37
|
s.add_development_dependency 'simplecov', '~> 0.9'
|
38
38
|
s.add_development_dependency 'database_cleaner', '~> 1.3'
|
39
|
-
s.add_development_dependency 'coffee-rails'
|
40
|
-
s.add_development_dependency 'sass-rails'
|
41
|
-
s.add_development_dependency 'guard-rspec'
|
42
|
-
s.add_development_dependency 'pry-rails'
|
43
39
|
s.add_development_dependency 'rubocop', '>= 0.24.1'
|
44
40
|
s.add_development_dependency 'rspec-activemodel-mocks'
|
45
41
|
end
|
@@ -39,6 +39,8 @@ RSpec.describe Spree::Admin::RelationsController, type: :controller do
|
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
+
let(:invalid_params) { { format: :js, product_id: product.id } }
|
43
|
+
|
42
44
|
context '#create' do
|
43
45
|
it 'is not routable' do
|
44
46
|
spree_post :create, valid_params
|
@@ -53,14 +55,14 @@ RSpec.describe Spree::Admin::RelationsController, type: :controller do
|
|
53
55
|
|
54
56
|
it 'raises error with invalid params' do
|
55
57
|
expect {
|
56
|
-
spree_post :create,
|
57
|
-
}.to raise_error
|
58
|
+
spree_post :create, invalid_params
|
59
|
+
}.to raise_error(ActionController::ParameterMissing)
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
63
|
context '#update' do
|
62
64
|
it 'redirects to product/related url' do
|
63
|
-
spree_put :update, product_id: product.id, id:
|
65
|
+
spree_put :update, product_id: product.id, id: relation.id, relation: { discount_amount: 2.0 }
|
64
66
|
expect(response).to redirect_to(spree.admin_product_path(relation.relatable) + '/related')
|
65
67
|
end
|
66
68
|
end
|
@@ -68,7 +70,7 @@ RSpec.describe Spree::Admin::RelationsController, type: :controller do
|
|
68
70
|
context '#destroy' do
|
69
71
|
it 'records successfully' do
|
70
72
|
expect {
|
71
|
-
spree_delete :destroy, id:
|
73
|
+
spree_delete :destroy, id: relation.id, product_id: product.id, format: :js
|
72
74
|
}.to change(Spree::Relation, :count).by(-1)
|
73
75
|
end
|
74
76
|
end
|
@@ -70,7 +70,7 @@ RSpec.describe Spree::Api::RelationsController, type: :controller do
|
|
70
70
|
context '#destroy with' do
|
71
71
|
it 'records successfully' do
|
72
72
|
expect {
|
73
|
-
spree_delete :destroy, id:
|
73
|
+
spree_delete :destroy, id: relation.id, product_id: product.id, format: :json, token: user.spree_api_key
|
74
74
|
}.to change(Spree::Relation, :count).by(-1)
|
75
75
|
end
|
76
76
|
end
|
@@ -12,7 +12,7 @@ RSpec.feature 'Admin Product Relation', :js do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
scenario 'create relation' do
|
15
|
-
expect(page).to have_text
|
15
|
+
expect(page).to have_text /ADD RELATED PRODUCT/i
|
16
16
|
expect(page).to have_text product.name
|
17
17
|
|
18
18
|
within('#add-line-item') do
|
@@ -48,7 +48,7 @@ RSpec.feature 'Admin Product Relation', :js do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
scenario 'ensure content exist' do
|
51
|
-
expect(page).to have_text
|
51
|
+
expect(page).to have_text /ADD RELATED PRODUCT/i
|
52
52
|
expect(page).to have_text product.name
|
53
53
|
expect(page).to have_text other.name
|
54
54
|
|
@@ -35,9 +35,9 @@ RSpec.describe Spree::Calculator::RelatedProductDiscount, type: :model do
|
|
35
35
|
create(:relation, relatable: product, related_to: related_product, relation_type: relation_type, discount_amount: 1.0)
|
36
36
|
end
|
37
37
|
|
38
|
+
# TODO: figure out what this test is trying to accomplish
|
38
39
|
it 'returns total count of Array' do
|
39
|
-
|
40
|
-
expect(subject.compute(objects)).to be_nil
|
40
|
+
expect(subject.compute([])).to be_nil
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'returns total count' do
|
@@ -114,16 +114,4 @@ RSpec.describe Spree::Product, type: :model do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
|
-
|
118
|
-
context 'instance when relation_types table is missing' do
|
119
|
-
it 'method missing should not throw ActiveRecord::StatementInvalid when the spree_relation_types table is missing' do
|
120
|
-
described_class.connection.rename_table('spree_relation_types', 'missing_relation_types')
|
121
|
-
begin
|
122
|
-
product = described_class.new
|
123
|
-
expect { product.foo }.to raise_error(NameError)
|
124
|
-
ensure
|
125
|
-
described_class.connection.rename_table('missing_relation_types', 'spree_relation_types')
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
117
|
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_related_products
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Quinn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_backend
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: deface
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
39
|
+
version: '1.0'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
46
|
+
version: '1.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: factory_girl
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,62 +184,6 @@ dependencies:
|
|
178
184
|
- - "~>"
|
179
185
|
- !ruby/object:Gem::Version
|
180
186
|
version: '1.3'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: coffee-rails
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: sass-rails
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: guard-rspec
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - ">="
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '0'
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - ">="
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: pry-rails
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
187
|
- !ruby/object:Gem::Dependency
|
238
188
|
name: rubocop
|
239
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -275,7 +225,6 @@ files:
|
|
275
225
|
- ".travis.yml"
|
276
226
|
- CONTRIBUTING.md
|
277
227
|
- Gemfile
|
278
|
-
- Guardfile
|
279
228
|
- LICENSE.md
|
280
229
|
- README.md
|
281
230
|
- Rakefile
|
data/Guardfile
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
guard 'rspec', cmd: 'bundle exec rspec' do
|
2
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
3
|
-
watch('config/routes.rb') { 'spec/controllers' }
|
4
|
-
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
-
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
6
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
-
watch(%r{^app/(.*)(\.erb)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
8
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
9
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
|
10
|
-
end
|