solidus_volume_pricing 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/volume_price_models_controller.rb +0 -5
- 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 +1 -1
- data/spec/features/manage_volume_price_models_feature_spec.rb +26 -0
- data/spec/features/manage_volume_prices_feature_spec.rb +32 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/support/database_cleaner.rb +8 -11
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe1e772f2746fe3ef1be321bebf2677d6adb6f1
|
4
|
+
data.tar.gz: '09057b1c10577aef143f72ce88e4f29e93424ee8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d90d442c9da53d8229c6f8cc8cf06a0a047ab212084eb2fe76a36fbb3fb1ba8e585855bcfc467e0f15737af12340687114c51abde3c6f66ebb09b84645372e9c
|
7
|
+
data.tar.gz: 4eb845de35f1c6edf05f5c9e8c267f3b99ba2a1e01b6118126afb20673a0d4e469cd9cf5d738b8c03ce0c7804f9a291fb215f28392d5653eee0c7d4de8cbdc18
|
@@ -3,11 +3,6 @@ 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
|
11
6
|
|
12
7
|
private
|
13
8
|
|
@@ -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
|
+
], { include_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_remove_fields Spree.t(:remove), f, no_text: true %>
|
32
32
|
</td>
|
33
33
|
</tr>
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,32 @@
|
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -2,23 +2,20 @@ 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
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
config.before do
|
9
|
+
config.prepend_before(:each) do
|
10
|
+
if RSpec.current_example.metadata[:js]
|
11
|
+
DatabaseCleaner.strategy = :truncation
|
12
|
+
else
|
13
|
+
DatabaseCleaner.strategy = :transaction
|
14
|
+
end
|
18
15
|
DatabaseCleaner.start
|
19
16
|
end
|
20
17
|
|
21
|
-
config.
|
18
|
+
config.append_after(:each) do
|
22
19
|
DatabaseCleaner.clean
|
23
20
|
end
|
24
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_volume_pricing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -281,6 +281,8 @@ files:
|
|
281
281
|
- solidus_volume_pricing.gemspec
|
282
282
|
- spec/controllers/spree/admin/variants_controller_spec.rb
|
283
283
|
- spec/factories/volume_price_factory.rb
|
284
|
+
- spec/features/manage_volume_price_models_feature_spec.rb
|
285
|
+
- spec/features/manage_volume_prices_feature_spec.rb
|
284
286
|
- spec/helpers/base_helper_spec.rb
|
285
287
|
- spec/models/spree/line_item_spec.rb
|
286
288
|
- spec/models/spree/order_spec.rb
|
@@ -319,6 +321,8 @@ summary: Allow prices to be configured in quantity ranges for each variant
|
|
319
321
|
test_files:
|
320
322
|
- spec/controllers/spree/admin/variants_controller_spec.rb
|
321
323
|
- spec/factories/volume_price_factory.rb
|
324
|
+
- spec/features/manage_volume_price_models_feature_spec.rb
|
325
|
+
- spec/features/manage_volume_prices_feature_spec.rb
|
322
326
|
- spec/helpers/base_helper_spec.rb
|
323
327
|
- spec/models/spree/line_item_spec.rb
|
324
328
|
- spec/models/spree/order_spec.rb
|