solidus_volume_pricing 0.1.1 → 0.2.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/.travis.yml +4 -6
- data/Gemfile +1 -1
- data/app/controllers/spree/admin/volume_price_models_controller.rb +5 -0
- data/app/models/spree/line_item_decorator.rb +8 -22
- data/app/views/spree/admin/variants/volume_prices.html.erb +1 -1
- data/app/views/spree/admin/volume_prices/_edit_fields.html.erb +1 -1
- data/app/views/spree/admin/volume_prices/_volume_price_fields.html.erb +2 -2
- data/lib/solidus_volume_pricing/version.rb +2 -2
- data/solidus_volume_pricing.gemspec +1 -1
- data/spec/support/database_cleaner.rb +11 -8
- metadata +2 -13
- data/app/assets/stylesheets/spree/backend/solidus_volume_pricing.css +0 -3
- data/spec/features/manage_volume_price_models_feature_spec.rb +0 -26
- data/spec/features/manage_volume_prices_feature_spec.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ab65d3e0219f88f5090273cae51341342455fbd
|
4
|
+
data.tar.gz: b410f7e09e809081651efa63c0815c0a386c3da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda5105921410138eb449b40605487fef91711b773b1b208349a7598bf48a662477c6ccb83baba53cd3d6853c580f5dec6204e113a0582ca2905c155f9fc0f47
|
7
|
+
data.tar.gz: 0dfdc9b4cbc45a51791ef82a09453b1acfc4a9ead09d0d16e91f2033315cd97d930fdeb320e3823f6eae6e55eca60d902d1ac19a74d309f0791477a185bad3f2
|
data/.travis.yml
CHANGED
@@ -6,9 +6,7 @@ cache: bundler
|
|
6
6
|
only: master
|
7
7
|
env:
|
8
8
|
matrix:
|
9
|
-
- SOLIDUS_BRANCH=v1.
|
10
|
-
- SOLIDUS_BRANCH=v1.
|
11
|
-
- SOLIDUS_BRANCH=v1.
|
12
|
-
- SOLIDUS_BRANCH=v1.
|
13
|
-
- SOLIDUS_BRANCH=v1.2 DB=mysql
|
14
|
-
- SOLIDUS_BRANCH=v1.2 DB=postgresql
|
9
|
+
- SOLIDUS_BRANCH=v1.3 DB=mysql
|
10
|
+
- SOLIDUS_BRANCH=v1.3 DB=postgresql
|
11
|
+
- SOLIDUS_BRANCH=v1.4 DB=mysql
|
12
|
+
- SOLIDUS_BRANCH=v1.4 DB=postgresql
|
data/Gemfile
CHANGED
@@ -3,6 +3,11 @@ module Spree
|
|
3
3
|
class VolumePriceModelsController < ResourceController
|
4
4
|
|
5
5
|
before_action :load_volume_prices, only: [:new, :edit]
|
6
|
+
respond_to :json, only: [:get_children]
|
7
|
+
|
8
|
+
def get_children
|
9
|
+
@volume_prices = VolumePrice.find(params[:parent_id]).children
|
10
|
+
end
|
6
11
|
|
7
12
|
private
|
8
13
|
|
@@ -1,27 +1,13 @@
|
|
1
|
-
Spree
|
2
|
-
|
1
|
+
module Spree
|
2
|
+
module LineItemPriceUpdater
|
3
|
+
def set_pricing_attributes
|
4
|
+
super
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
# chosen for the product. This is mainly for compatibility with spree_sale_products
|
7
|
-
#
|
8
|
-
# Assumption here is that the volume price currency is the same as the product currency
|
9
|
-
old_copy_price = instance_method(:copy_price)
|
10
|
-
define_method(:copy_price) do
|
11
|
-
old_copy_price.bind(self).call
|
12
|
-
return unless variant
|
13
|
-
|
14
|
-
if variant
|
15
|
-
if changed? && changes.keys.include?('quantity')
|
16
|
-
vprice = variant.volume_price(quantity, order.user)
|
17
|
-
if price.present? && vprice <= variant.price
|
18
|
-
self.price = vprice and return
|
19
|
-
end
|
6
|
+
if quantity_changed?
|
7
|
+
self.price = variant.volume_price(quantity, order.user)
|
20
8
|
end
|
21
|
-
|
22
|
-
self.price = variant.price if price.nil?
|
23
9
|
end
|
24
|
-
|
25
|
-
self.price = variant.price if price.nil?
|
26
10
|
end
|
27
11
|
end
|
12
|
+
|
13
|
+
Spree::LineItem.prepend(Spree::LineItemPriceUpdater)
|
@@ -24,7 +24,7 @@
|
|
24
24
|
</thead>
|
25
25
|
<tbody id="volume_prices">
|
26
26
|
<%= f.fields_for :volume_prices do |vp_form| %>
|
27
|
-
|
27
|
+
<%= render partial: 'spree/admin/volume_prices/volume_price_fields', locals: { f: vp_form } %>
|
28
28
|
<% end %>
|
29
29
|
</tbody>
|
30
30
|
<tbody id="volume_price_models">
|
@@ -9,7 +9,7 @@
|
|
9
9
|
["#{Spree.t(:total_price)}", 'price'],
|
10
10
|
["#{Spree.t(:percent_discount)}", 'percent'],
|
11
11
|
["#{Spree.t(:price_discount)}", 'dollar']
|
12
|
-
], {
|
12
|
+
], { inlcude_blank: true }, class: 'select2' %>
|
13
13
|
</td>
|
14
14
|
<td>
|
15
15
|
<%= error_message_on(f.object, :range) %>
|
@@ -28,6 +28,6 @@
|
|
28
28
|
<%= f.collection_select(:role_id, Spree::Role.all, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2' }) %>
|
29
29
|
</td>
|
30
30
|
<td class="actions">
|
31
|
-
<%=
|
31
|
+
<%= link_to_icon_remove_fields f %>
|
32
32
|
</td>
|
33
33
|
</tr>
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.require_path = 'lib'
|
22
22
|
s.requirements << 'none'
|
23
23
|
|
24
|
-
s.add_runtime_dependency 'solidus_core', '~> 1.
|
24
|
+
s.add_runtime_dependency 'solidus_core', '~> 1.3'
|
25
25
|
s.add_runtime_dependency 'deface', '~> 1.0'
|
26
26
|
|
27
27
|
s.add_development_dependency 'sqlite3', '>= 1.3.10'
|
@@ -2,20 +2,23 @@ require 'database_cleaner'
|
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
|
5
|
-
config.before
|
5
|
+
config.before(:suite) do
|
6
6
|
DatabaseCleaner.clean_with :truncation
|
7
7
|
end
|
8
8
|
|
9
|
-
config.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
config.before do
|
10
|
+
DatabaseCleaner.strategy = :transaction
|
11
|
+
end
|
12
|
+
|
13
|
+
config.before(:each, :js) do
|
14
|
+
DatabaseCleaner.strategy = :truncation
|
15
|
+
end
|
16
|
+
|
17
|
+
config.before do
|
15
18
|
DatabaseCleaner.start
|
16
19
|
end
|
17
20
|
|
18
|
-
config.
|
21
|
+
config.after do
|
19
22
|
DatabaseCleaner.clean
|
20
23
|
end
|
21
24
|
end
|
metadata
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_volume_pricing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
- - "<"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '1.3'
|
23
20
|
type: :runtime
|
@@ -25,9 +22,6 @@ dependencies:
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.0'
|
30
|
-
- - "<"
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: '1.3'
|
33
27
|
- !ruby/object:Gem::Dependency
|
@@ -244,7 +238,6 @@ files:
|
|
244
238
|
- README.md
|
245
239
|
- Rakefile
|
246
240
|
- app/assets/javascripts/spree/backend/solidus_volume_pricing.js
|
247
|
-
- app/assets/stylesheets/spree/backend/solidus_volume_pricing.css
|
248
241
|
- app/controllers/spree/admin/variants_controller_decorator.rb
|
249
242
|
- app/controllers/spree/admin/volume_price_models_controller.rb
|
250
243
|
- app/controllers/spree/admin/volume_prices_controller.rb
|
@@ -288,8 +281,6 @@ files:
|
|
288
281
|
- solidus_volume_pricing.gemspec
|
289
282
|
- spec/controllers/spree/admin/variants_controller_spec.rb
|
290
283
|
- spec/factories/volume_price_factory.rb
|
291
|
-
- spec/features/manage_volume_price_models_feature_spec.rb
|
292
|
-
- spec/features/manage_volume_prices_feature_spec.rb
|
293
284
|
- spec/helpers/base_helper_spec.rb
|
294
285
|
- spec/models/spree/line_item_spec.rb
|
295
286
|
- spec/models/spree/order_spec.rb
|
@@ -328,8 +319,6 @@ summary: Allow prices to be configured in quantity ranges for each variant
|
|
328
319
|
test_files:
|
329
320
|
- spec/controllers/spree/admin/variants_controller_spec.rb
|
330
321
|
- spec/factories/volume_price_factory.rb
|
331
|
-
- spec/features/manage_volume_price_models_feature_spec.rb
|
332
|
-
- spec/features/manage_volume_prices_feature_spec.rb
|
333
322
|
- spec/helpers/base_helper_spec.rb
|
334
323
|
- spec/models/spree/line_item_spec.rb
|
335
324
|
- spec/models/spree/order_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature 'Managing volume price models' do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
scenario 'a admin can create and remove volume price models', :js do
|
7
|
-
visit spree.admin_volume_price_models_path
|
8
|
-
expect(page).to have_content('Volume Price Models')
|
9
|
-
|
10
|
-
click_on 'New Volume Price Model'
|
11
|
-
fill_in 'Name', with: 'Discount'
|
12
|
-
within '#volume_prices' do
|
13
|
-
fill_in 'volume_price_model_volume_prices_attributes_0_name', with: '5 pieces discount'
|
14
|
-
select 'Total price', from: 'volume_price_model_volume_prices_attributes_0_discount_type'
|
15
|
-
fill_in 'volume_price_model_volume_prices_attributes_0_range', with: '1..5'
|
16
|
-
fill_in 'volume_price_model_volume_prices_attributes_0_amount', with: '1'
|
17
|
-
end
|
18
|
-
click_on 'Create'
|
19
|
-
|
20
|
-
within 'tr.volume_price.fields' do
|
21
|
-
expect(page).to have_field('volume_price_model_volume_prices_attributes_0_name', with: '5 pieces discount')
|
22
|
-
page.find('a[data-action="remove"]').click
|
23
|
-
expect(page).to_not have_field('volume_price_model_volume_prices_attributes_0_name', with: '5 pieces discount')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature 'Managing volume prices' do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
let(:variant) { create(:variant) }
|
7
|
-
|
8
|
-
scenario 'a admin can create and remove volume prices', :js do
|
9
|
-
visit spree.edit_admin_product_path(variant.product)
|
10
|
-
click_on 'Volume Pricing'
|
11
|
-
expect(page).to have_content('Volume Prices')
|
12
|
-
|
13
|
-
fill_in 'variant_volume_prices_attributes_0_name', with: '5 pieces discount'
|
14
|
-
select 'Total price', from: 'variant_volume_prices_attributes_0_discount_type'
|
15
|
-
fill_in 'variant_volume_prices_attributes_0_range', with: '1..5'
|
16
|
-
fill_in 'variant_volume_prices_attributes_0_amount', with: '1'
|
17
|
-
click_on 'Update'
|
18
|
-
|
19
|
-
within 'tr.volume_price.fields' do
|
20
|
-
expect(page).to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
|
21
|
-
page.find('a[data-action="remove"]').click
|
22
|
-
expect(page).to_not have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
scenario 'a admin editing a variant has a new volume price already built for her' do
|
27
|
-
visit spree.edit_admin_product_variant_path(product_id: variant.product, id: variant)
|
28
|
-
within '#volume_prices' do
|
29
|
-
expect(page).to have_field('variant_volume_prices_attributes_0_name')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|