solidus_volume_pricing 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08283fd45b610c42b6d37427a84de81b106b0a2dab729a45b3e8305148019c5f'
4
- data.tar.gz: 137f128fb1d1e761b371bab30b4a3277311d4d97b201f313197ed7f1775ead8e
3
+ metadata.gz: 98bbc2761ea5f9a04ec275d189fc8ef633a9a23a174b0fb0fe7183db0e51ac90
4
+ data.tar.gz: 966b8ca6e650a96310cd69d8c216fed8dff2705f2e35f4722bdf29ef9fe4b747
5
5
  SHA512:
6
- metadata.gz: bf43af51a07a4fcd12129e241c9b512472725dc884ea3d487f23152e8df135dcf82bff22753116fe45df983a231667feab640db82929b260058e55857ed71af5
7
- data.tar.gz: e2f055f385c8869c4e0407da0bc3f01946c1eb210c124704a49627b34b6b1762e5f0d9d5be244509385269dc0118fcbe7a35307b26580a36b8d6d948aeb9b9dc
6
+ metadata.gz: ea5dec857a30471edb436aadd74bdfd21f553e1320fc29fd787619b73eb74cfeddfea8699fc8c3c960e9a7630d4032591ba4c2fd2fba2527edc0ca0e6e1fb7a4
7
+ data.tar.gz: cf4b9beecf2f6cb70d05b4e1018ec910eff96a24c09535b350beb2de2bfa2b802a9e333a19f5242a9888a12347bfda8ad7236731f27bd3e8b9b8c1f63865a1a3
data/.gem_release.yml ADDED
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_volume_pricing/version.rb'
4
+ message: Bump SolidusVolumePricing to %{version}
5
+ tag: true
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
data/.github/stale.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
data/.gitignore CHANGED
@@ -1,14 +1,18 @@
1
1
  *.gem
2
- *.swp
3
- .bundle
4
- .idea
2
+ \#*
3
+ *~
4
+ .#*
5
5
  .DS_Store
6
- Gemfile.lock
7
- pkg/*
8
- spec/dummy
6
+ .idea
7
+ .project
8
+ .sass-cache
9
9
  coverage
10
- .rvmrc
11
- .ruby-version
12
- .ruby-gemset
10
+ Gemfile.lock
13
11
  tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
14
16
  spec/examples.txt
17
+ .byebug*
18
+ Gemfile-local
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
1
  --color
2
- -f documentation
3
- -r spec_helper
2
+ --format documentation
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,12 +1,4 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  require:
4
- - solidus_extension_dev_tools/rubocop
2
+ - solidus_dev_support/rubocop
5
3
 
6
- inherit_gem:
7
- solidus_extension_dev_tools: .rubocop.extension.yml
8
-
9
- AllCops:
10
- Exclude:
11
- - spec/dummy/**/*
12
- - vendor/**/*
4
+ inherit_from: .rubocop_todo.yml
data/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.1.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.1.0) (2023-02-09)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v1.0.0...v1.1.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Dependabot can't resolve your Ruby dependency files [\#57](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/57)
10
+ - Prepare Solidus Volume Pricing for Solidus 3.0 [\#53](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/53)
11
+ - Dependabot can't resolve your Ruby dependency files [\#52](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/52)
12
+ - Dependabot can't resolve your Ruby dependency files [\#51](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/51)
13
+ - Role base volume pricing not working [\#47](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/47)
14
+ - Dependabot couldn't find a Gemfile-local for this project [\#44](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/44)
15
+ - Dependabot can't resolve your Ruby dependency files [\#42](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/42)
16
+ - Dependabot can't resolve your Ruby dependency files [\#41](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/41)
17
+ - Dependabot can't resolve your Ruby dependency files [\#40](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/40)
18
+ - Dependabot can't resolve your Ruby dependency files [\#39](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/39)
19
+ - Dependabot can't resolve your Ruby dependency files [\#38](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/38)
20
+ - Dependabot can't resolve your Ruby dependency files [\#37](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/37)
21
+ - Dependabot can't resolve your Ruby dependency files [\#36](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/36)
22
+ - Dependabot can't resolve your Ruby dependency files [\#35](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/35)
23
+ - Can we get a new release? [\#29](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/29)
24
+
25
+ **Merged pull requests:**
26
+
27
+ - Update supported ruby version [\#66](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/66) ([mcrisologo](https://github.com/mcrisologo))
28
+ - Bump version to 1.1.0 [\#65](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/65) ([mcrisologo](https://github.com/mcrisologo))
29
+ - Update to use forked solidus\_frontend when needed [\#64](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/64) ([waiting-for-dev](https://github.com/waiting-for-dev))
30
+ - Configure autoloader to ignore decorators [\#61](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/61) ([pelargir](https://github.com/pelargir))
31
+ - Updating gemspec for Ruby 3 support [\#60](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/60) ([embold-given](https://github.com/embold-given))
32
+ - Solidus 3 preparation [\#59](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/59) ([cpfergus1](https://github.com/cpfergus1))
33
+ - Upgrade to GitHub-native Dependabot [\#58](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/58) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
34
+ - Relax solidus\_support dependency [\#50](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/50) ([kennyadsl](https://github.com/kennyadsl))
35
+ - Fix Dependabot looking for Gemfile-local [\#48](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/48) ([aldesantis](https://github.com/aldesantis))
36
+ - Fix role discounts [\#46](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/46) ([hrdchz](https://github.com/hrdchz))
37
+ - Rerun dev tools extension update command to improve the structure [\#45](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/45) ([blocknotes](https://github.com/blocknotes))
38
+ - Upgrade the extension using solidus\_dev\_support [\#43](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/43) ([blocknotes](https://github.com/blocknotes))
39
+
3
40
  ## [v1.0.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.0.0) (2019-11-23)
4
41
 
5
42
  [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.2.1...v1.0.0)
@@ -33,25 +70,17 @@
33
70
  - 1.0 fixes [\#7](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/7) ([tvdeyen](https://github.com/tvdeyen))
34
71
  - Add pricers to calculate volume prices [\#4](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/4) ([tvdeyen](https://github.com/tvdeyen))
35
72
  - Remove String monkey patch [\#3](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/3) ([tvdeyen](https://github.com/tvdeyen))
73
+ - Solidus 1.3 [\#2](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/2) ([tvdeyen](https://github.com/tvdeyen))
74
+ - Rename to solidus [\#1](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/1) ([tvdeyen](https://github.com/tvdeyen))
36
75
 
37
76
  ## [v0.2.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.2.1) (2017-01-20)
38
77
 
39
78
  [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.1.1...v0.2.1)
40
79
 
41
- **Merged pull requests:**
42
-
43
- - 0.2 fixes [\#6](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/6) ([tvdeyen](https://github.com/tvdeyen))
44
- - Solidus 1.3 [\#2](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/2) ([tvdeyen](https://github.com/tvdeyen))
45
-
46
80
  ## [v0.1.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.1.1) (2017-01-20)
47
81
 
48
82
  [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/9bcf78426749d2d73878c6c7c8eb3bf0e5747ada...v0.1.1)
49
83
 
50
- **Merged pull requests:**
51
-
52
- - 0.1 fixes [\#5](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/5) ([tvdeyen](https://github.com/tvdeyen))
53
- - Rename to solidus [\#1](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/1) ([tvdeyen](https://github.com/tvdeyen))
54
-
55
84
 
56
85
 
57
86
  \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -1,27 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
5
 
5
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
6
- gem 'solidus', git: 'https://github.com/solidusio/solidus.git', branch: branch
7
+ solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
8
+ %w[solidusio/solidus solidusio/solidus_frontend]
9
+ else
10
+ %w[solidusio/solidus] * 2
11
+ end
12
+ gem 'solidus', github: solidus_git, branch: branch
13
+ gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
7
14
 
8
15
  # Needed to help Bundler figure out how to resolve dependencies,
9
- # otherwise it takes forever to resolve them
10
- if branch == 'master' || Gem::Version.new(branch[1..-1]) >= Gem::Version.new('2.10.0')
11
- gem 'rails', '~> 6.0'
12
- else
13
- gem 'rails', '~> 5.2'
14
- end
16
+ # otherwise it takes forever to resolve them.
17
+ # See https://github.com/bundler/bundler/issues/6677
18
+ gem 'rails', '>0.a'
19
+
20
+ # Provides basic authentication functionality for testing parts of your engine
21
+ gem 'solidus_auth_devise'
15
22
 
16
23
  case ENV['DB']
17
- when 'postgresql'
18
- gem 'pg'
19
24
  when 'mysql'
20
25
  gem 'mysql2'
26
+ when 'postgresql'
27
+ gem 'pg'
21
28
  else
22
29
  gem 'sqlite3'
23
30
  end
24
31
 
25
- gem 'solidus_extension_dev_tools', github: 'solidusio-contrib/solidus_extension_dev_tools'
26
-
27
32
  gemspec
33
+
34
+ # Use a local Gemfile to include development dependencies that might not be
35
+ # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
36
+ send :eval_gemfile, 'Gemfile-local' if File.exist? 'Gemfile-local'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2015 Spree Commerce and contributors.
1
+ Copyright (c) 2009-2015 Spree Commerce and contributors, 2019 Sean Schofield
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
@@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
9
9
  * Redistributions in binary form must reproduce the above copyright notice,
10
10
  this list of conditions and the following disclaimer in the documentation
11
11
  and/or other materials provided with the distribution.
12
- * Neither the name Spree nor the names of its contributors may be used to
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
13
  endorse or promote products derived from this software without specific
14
14
  prior written permission.
15
15
 
data/README.md CHANGED
@@ -14,14 +14,14 @@ Each VolumePrice contains the following values:
14
14
 
15
15
  1. **Variant:** Each VolumePrice is associated with a _Variant_, which is used to link products to
16
16
  particular prices.
17
- 1. **Name:** The human readable representation of the quantity range (Ex. 10-100). (Optional)
18
- 1. **Discount Type** The type of discount to apply. **Price:** sets price to the amount specified.
17
+ 2. **Name:** The human readable representation of the quantity range (Ex. 10-100). (Optional)
18
+ 3. **Discount Type** The type of discount to apply. **Price:** sets price to the amount specified.
19
19
  * **Dollar:** subtracts specified amount from the Variant price.
20
20
  * **Percent:** subtracts the specified amounts percentage from the Variant price.
21
- 1. **Range:** The quantity range for which the price is valid (See Below for Examples of Valid
21
+ 4. **Range:** The quantity range for which the price is valid (See Below for Examples of Valid
22
22
  Ranges.)
23
- 1. **Amount:** The price of the product if the line item quantity falls within the specified range.
24
- 1. **Position:** Integer value for `acts_as_list` (Helps keep the volume prices in a defined order.)
23
+ 5. **Amount:** The price of the product if the line item quantity falls within the specified range.
24
+ 6. **Position:** Integer value for `acts_as_list` (Helps keep the volume prices in a defined order.)
25
25
 
26
26
  ## Install
27
27
 
data/Rakefile CHANGED
@@ -1,23 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler'
4
- Bundler::GemHelper.install_tasks
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
5
5
 
6
- require 'rspec/core/rake_task'
7
- require 'spree/testing_support/extension_rake'
8
-
9
- RSpec::Core::RakeTask.new
10
-
11
- task :default do
12
- if Dir["spec/dummy"].empty?
13
- Rake::Task[:test_app].invoke
14
- Dir.chdir("../../")
15
- end
16
- Rake::Task[:spec].invoke
17
- end
18
-
19
- desc 'Generates a dummy app for testing'
20
- task :test_app do
21
- ENV['LIB_NAME'] = 'solidus_volume_pricing'
22
- Rake::Task['extension:test_app'].invoke
23
- end
6
+ task default: 'extension:specs'
@@ -18,7 +18,7 @@ class Spree::VolumePrice < ApplicationRecord
18
18
  def self.for_variant(variant, user: nil)
19
19
  roles = [nil]
20
20
  if user
21
- roles << user.resolve_role&.id
21
+ user.spree_roles.each {|r| roles << r.id}
22
22
  end
23
23
 
24
24
  where(
@@ -27,7 +27,9 @@
27
27
  <%= error_message_on(f.object, :role_id) %>
28
28
  <%= f.collection_select(:role_id, Spree::Role.all, :id, :name, { include_blank: t('spree.match_choices.none') }, { class: 'custom-select' }) %>
29
29
  </td>
30
- <td class="actions">
31
- <%= link_to_remove_fields t('spree.remove'), f, no_text: true %>
32
- </td>
30
+ <% if f.object.persisted? %>
31
+ <td class="actions">
32
+ <%= link_to_delete f.object, url: admin_volume_price_url(f.object.id), no_text: true %>
33
+ </td>
34
+ <% end %>
33
35
  </tr>
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require "bundler/setup"
6
+ require "solidus_volume_pricing"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+ $LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
11
+
12
+ # (If you use this, don't forget to add pry to your Gemfile!)
13
+ # require "pry"
14
+ # Pry.start
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
data/bin/rails CHANGED
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  # frozen_string_literal: true
3
4
 
4
- ENGINE_ROOT = File.expand_path('..', __dir__)
5
- ENGINE_PATH = File.expand_path('../lib/solidus_volume_pricing/engine', __dir__)
5
+ app_root = 'spec/dummy'
6
+
7
+ unless File.exist? "#{app_root}/bin/rails"
8
+ system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
9
+ warn "Automatic creation of the dummy app failed"
10
+ exit 1
11
+ end
12
+ end
6
13
 
7
- require 'rails/all'
8
- require 'rails/engine/commands'
14
+ Dir.chdir app_root
15
+ exec 'bin/rails', *ARGV
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ gem install bundler --conservative
7
+ bundle update
8
+ bundle exec rake clobber
@@ -10,7 +10,9 @@ module SolidusVolumePricing
10
10
  end
11
11
 
12
12
  def run_migrations
13
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
13
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(
14
+ ask('Would you like to run the migrations now? [Y/n]')
15
+ )
14
16
  if run_migrations
15
17
  run 'bundle exec rake db:migrate'
16
18
  else
@@ -1,25 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/core'
4
+
3
5
  module SolidusVolumePricing
4
6
  class Engine < Rails::Engine
7
+ include SolidusSupport::EngineExtensions
8
+
5
9
  isolate_namespace ::Spree
10
+
6
11
  engine_name 'solidus_volume_pricing'
7
12
 
8
13
  initializer 'solidus_volume_pricing.preferences', before: 'spree.environment' do
9
14
  ::Spree::AppConfiguration.class_eval do
10
15
  preference :use_master_variant_volume_pricing, :boolean, default: false
11
- preference :volume_pricing_role, :string, default: 'wholesale'
12
16
  end
13
17
  end
14
18
 
15
19
  def self.activate
16
20
  Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
17
21
  Rails.configuration.cache_classes ? require(c) : load(c)
22
+ Rails.autoloaders.main.ignore(c) if Rails.autoloaders.zeitwerk_enabled?
18
23
  end
19
24
  ::Spree::BackendConfiguration::CONFIGURATION_TABS << :volume_price_models
20
25
  end
21
26
 
22
- config.autoload_paths += %W(#{config.root}/lib)
23
27
  config.to_prepare(&method(:activate).to_proc)
28
+
29
+ # use rspec for tests
30
+ config.generators do |g|
31
+ g.test_framework :rspec
32
+ end
24
33
  end
25
34
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  FactoryBot.define do
4
- factory :volume_price, class: Spree::VolumePrice do
4
+ factory :volume_price, class: 'Spree::VolumePrice' do
5
5
  amount { 10 }
6
6
  discount_type { 'price' }
7
7
  range { '(1..5)' }
8
8
  association :variant
9
9
  end
10
10
 
11
- factory :volume_price_model, class: Spree::VolumePriceModel do
11
+ factory :volume_price_model, class: 'Spree::VolumePriceModel' do
12
12
  name { 'name' }
13
13
  end
14
14
  end
@@ -1,20 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusVolumePricing
4
- module_function
5
-
6
- # Returns the version of the currently loaded SolidusVolumePricing as a
7
- # <tt>Gem::Version</tt>.
8
- def version
9
- Gem::Version.new VERSION::STRING
10
- end
11
-
12
- module VERSION
13
- MAJOR = 1
14
- MINOR = 0
15
- TINY = 0
16
- PRE = nil
17
-
18
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
19
- end
4
+ VERSION = '1.1.0'
20
5
  end
@@ -4,6 +4,7 @@ require 'active_support/deprecation'
4
4
  require 'sassc/rails'
5
5
  require 'deface'
6
6
  require 'solidus_core'
7
+ require 'solidus_support'
7
8
  require 'solidus_volume_pricing/engine'
8
9
  require 'solidus_volume_pricing/version'
9
10
  require 'solidus_volume_pricing/range_from_string'
@@ -1,32 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
-
3
+ $:.push File.expand_path('lib', __dir__)
6
4
  require 'solidus_volume_pricing/version'
7
5
 
8
6
  Gem::Specification.new do |s|
9
7
  s.platform = Gem::Platform::RUBY
10
8
  s.name = 'solidus_volume_pricing'
11
- s.version = SolidusVolumePricing.version
9
+ s.version = SolidusVolumePricing::VERSION
12
10
  s.summary = 'Allow prices to be configured in quantity ranges for each variant'
13
11
  s.description = s.summary
14
- s.required_ruby_version = '>= 2.2.3'
12
+
13
+ s.required_ruby_version = '>= 2.5'
15
14
 
16
15
  s.author = 'Sean Schofield'
17
16
  s.email = 'sean@railsdog.com'
18
17
  s.homepage = 'https://github.com/solidusio-contrib/solidus_volume_pricing'
19
- s.license = 'BSD-3'
18
+ s.license = 'BSD-3-Clause'
19
+
20
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ s.test_files = Dir['spec/**/*']
24
+ s.bindir = "exe"
25
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ s.require_paths = ["lib"]
27
+
28
+ if s.respond_to?(:metadata)
29
+ s.metadata["homepage_uri"] = s.homepage if s.homepage
30
+ s.metadata["source_code_uri"] = s.homepage if s.homepage
31
+ end
20
32
 
21
- s.files = `git ls-files`.split("\n")
22
- s.test_files = `git ls-files -- spec/*`.split("\n")
23
- s.require_path = 'lib'
24
- s.requirements << 'none'
33
+ s.add_runtime_dependency 'solidus_backend', ['>= 2.4.0', '< 4']
25
34
 
26
- s.add_runtime_dependency 'deface', '~> 1.0'
27
- s.add_runtime_dependency 'solidus_backend', '>= 2.0'
28
- s.add_runtime_dependency 'solidus_core', '>= 2.0'
35
+ s.add_dependency 'coffee-rails'
36
+ s.add_dependency 'deface'
37
+ s.add_dependency 'sassc-rails'
38
+ s.add_dependency 'solidus_core', ['>= 2.4.0', '< 4']
39
+ s.add_dependency 'solidus_support', '~> 0.8'
29
40
 
30
41
  s.add_development_dependency 'shoulda-matchers'
31
- s.add_development_dependency 'solidus_extension_dev_tools'
42
+ s.add_development_dependency 'solidus_dev_support'
32
43
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  RSpec.describe 'Managing volume price models' do
6
6
  stub_authorization!
7
7
 
8
- it 'a admin can create and remove volume price models', :js do
8
+ it 'an admin can create and remove volume price models', :js do
9
9
  visit spree.admin_volume_price_models_path
10
10
  expect(page).to have_content('Volume Price Models')
11
11
 
@@ -19,10 +19,6 @@ RSpec.describe 'Managing volume price models' do
19
19
  end
20
20
  click_on 'Create'
21
21
 
22
- within 'tr.volume_price.fields' do
23
- expect(page).to have_field('volume_price_model_volume_prices_attributes_0_name', with: '5 pieces discount')
24
- page.find('a[data-action="remove"]').click
25
- expect(page).not_to have_field('volume_price_model_volume_prices_attributes_0_name', with: '5 pieces discount')
26
- end
22
+ expect(page).to have_content('Discount')
27
23
  end
28
24
  end
@@ -7,7 +7,7 @@ RSpec.describe 'Managing volume prices' do
7
7
 
8
8
  let(:variant) { create(:variant) }
9
9
 
10
- it 'a admin can create and remove volume prices', :js do
10
+ it 'an admin can create and remove volume prices', :js do
11
11
  visit spree.edit_admin_product_path(variant.product)
12
12
  click_on 'Volume Pricing'
13
13
  expect(page).to have_content('Volume Prices')
@@ -18,14 +18,13 @@ RSpec.describe 'Managing volume prices' do
18
18
  fill_in 'variant_volume_prices_attributes_0_amount', with: '1'
19
19
  click_on 'Update'
20
20
 
21
- within 'tr.volume_price.fields' do
22
- expect(page).to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
23
- page.find('a[data-action="remove"]').click
24
- expect(page).not_to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
25
- end
21
+ expect(page).to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
22
+ accept_confirm { page.find('a[data-action="remove"]').click }
23
+
24
+ expect(page).not_to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
26
25
  end
27
26
 
28
- it 'a admin editing a variant has a new volume price already built for her' do
27
+ it 'an admin editing a variant has a new volume price already built for her' do
29
28
  visit spree.edit_admin_product_variant_path(product_id: variant.product, id: variant)
30
29
  within '#volume_prices' do
31
30
  expect(page).to have_field('variant_volume_prices_attributes_0_name')
@@ -14,10 +14,6 @@ RSpec.describe SolidusVolumePricing::Pricer do
14
14
  let(:user) { create(:user) }
15
15
  let(:variant) { create(:variant, price: 10) }
16
16
 
17
- before do
18
- stub_spree_preferences(volume_pricing_role: role.name)
19
- end
20
-
21
17
  it 'inherits from default variant pricer' do
22
18
  expect(described_class < Spree::Variant::PriceSelector).to be(true)
23
19
  end
@@ -19,7 +19,6 @@ RSpec.describe Spree::LineItem, type: :model do
19
19
 
20
20
  it 'updates the line item price when the quantity changes to match a range and role matches' do
21
21
  order.user.spree_roles << role
22
- stub_spree_preferences(volume_pricing_role: role.name)
23
22
  expect(order.user.has_spree_role?(role.name.to_sym)).to be(true)
24
23
  variant.volume_prices.first.update(role_id: role.id)
25
24
  expect(line_item.price.to_f).to be(10.00)
@@ -11,12 +11,7 @@ RSpec.describe Spree::VolumePrice, type: :model do
11
11
  it { is_expected.to validate_presence_of(:discount_type) }
12
12
  it { is_expected.to validate_presence_of(:amount) }
13
13
 
14
- it do
15
- expect(subject).to \
16
- validate_inclusion_of(:discount_type).
17
- in_array(%w(price dollar percent)).
18
- with_message('shoulda-matchers test string is not a valid Volume Price Type')
19
- end
14
+ it { is_expected.to validate_inclusion_of(:discount_type).in_array(%w[price dollar percent]) }
20
15
 
21
16
  describe '.for_variant' do
22
17
  subject { described_class.for_variant(variant, user: user) }
@@ -44,10 +39,6 @@ RSpec.describe Spree::VolumePrice, type: :model do
44
39
  create_list(:volume_price, 2, variant: variant, role_id: role.id)
45
40
  end
46
41
 
47
- before do
48
- stub_spree_preferences(volume_pricing_role: role.name)
49
- end
50
-
51
42
  context 'whose role matches' do
52
43
  before do
53
44
  user.spree_roles = [role]
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Configure Rails Environment
3
4
  ENV['RAILS_ENV'] ||= 'test'
4
5
 
5
- require 'solidus_extension_dev_tools/rspec/coverage'
6
+ # Run Coverage report
7
+ require 'solidus_dev_support/rspec/coverage'
6
8
 
7
9
  require File.expand_path('dummy/config/environment.rb', __dir__)
8
10
 
9
- require 'solidus_extension_dev_tools/rspec/feature_helper'
11
+ # Requires factories and other useful helpers defined in spree_core.
12
+ require 'solidus_dev_support/rspec/feature_helper'
10
13
 
14
+ # Requires supporting ruby files with custom matchers and macros, etc,
15
+ # in spec/support/ and its subdirectories.
11
16
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
17
+
18
+ # Requires factories defined in lib/solidus_volume_pricing/testing_support/factories.rb
19
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusVolumePricing::Engine)
20
+
21
+ RSpec.configure do |config|
22
+ config.infer_spec_type_from_file_location!
23
+ config.use_transactional_fixtures = false
24
+ end
metadata CHANGED
@@ -1,57 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_volume_pricing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-25 00:00:00.000000000 Z
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: solidus_backend
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.4.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.4.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4'
33
+ - !ruby/object:Gem::Dependency
34
+ name: coffee-rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
13
47
  - !ruby/object:Gem::Dependency
14
48
  name: deface
15
49
  requirement: !ruby/object:Gem::Requirement
16
50
  requirements:
17
- - - "~>"
51
+ - - ">="
18
52
  - !ruby/object:Gem::Version
19
- version: '1.0'
53
+ version: '0'
20
54
  type: :runtime
21
55
  prerelease: false
22
56
  version_requirements: !ruby/object:Gem::Requirement
23
57
  requirements:
24
- - - "~>"
58
+ - - ">="
25
59
  - !ruby/object:Gem::Version
26
- version: '1.0'
60
+ version: '0'
27
61
  - !ruby/object:Gem::Dependency
28
- name: solidus_backend
62
+ name: sassc-rails
29
63
  requirement: !ruby/object:Gem::Requirement
30
64
  requirements:
31
65
  - - ">="
32
66
  - !ruby/object:Gem::Version
33
- version: '2.0'
67
+ version: '0'
34
68
  type: :runtime
35
69
  prerelease: false
36
70
  version_requirements: !ruby/object:Gem::Requirement
37
71
  requirements:
38
72
  - - ">="
39
73
  - !ruby/object:Gem::Version
40
- version: '2.0'
74
+ version: '0'
41
75
  - !ruby/object:Gem::Dependency
42
76
  name: solidus_core
43
77
  requirement: !ruby/object:Gem::Requirement
44
78
  requirements:
45
79
  - - ">="
46
80
  - !ruby/object:Gem::Version
47
- version: '2.0'
81
+ version: 2.4.0
82
+ - - "<"
83
+ - !ruby/object:Gem::Version
84
+ version: '4'
48
85
  type: :runtime
49
86
  prerelease: false
50
87
  version_requirements: !ruby/object:Gem::Requirement
51
88
  requirements:
52
89
  - - ">="
53
90
  - !ruby/object:Gem::Version
54
- version: '2.0'
91
+ version: 2.4.0
92
+ - - "<"
93
+ - !ruby/object:Gem::Version
94
+ version: '4'
95
+ - !ruby/object:Gem::Dependency
96
+ name: solidus_support
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.8'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.8'
55
109
  - !ruby/object:Gem::Dependency
56
110
  name: shoulda-matchers
57
111
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +121,7 @@ dependencies:
67
121
  - !ruby/object:Gem::Version
68
122
  version: '0'
69
123
  - !ruby/object:Gem::Dependency
70
- name: solidus_extension_dev_tools
124
+ name: solidus_dev_support
71
125
  requirement: !ruby/object:Gem::Requirement
72
126
  requirements:
73
127
  - - ">="
@@ -87,6 +141,9 @@ extensions: []
87
141
  extra_rdoc_files: []
88
142
  files:
89
143
  - ".circleci/config.yml"
144
+ - ".gem_release.yml"
145
+ - ".github/dependabot.yml"
146
+ - ".github/stale.yml"
90
147
  - ".gitignore"
91
148
  - ".rspec"
92
149
  - ".rubocop.yml"
@@ -94,7 +151,7 @@ files:
94
151
  - CHANGELOG.md
95
152
  - Gemfile
96
153
  - Guardfile
97
- - LICENSE.md
154
+ - LICENSE
98
155
  - README.md
99
156
  - Rakefile
100
157
  - app/assets/javascripts/spree/backend/solidus_volume_pricing.js
@@ -103,7 +160,6 @@ files:
103
160
  - app/decorators/controllers/solidus_volume_pricing/spree/admin/variants_controller_decorator.rb
104
161
  - app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb
105
162
  - app/decorators/models/solidus_volume_pricing/spree/line_item_decorator.rb
106
- - app/decorators/models/solidus_volume_pricing/spree/user_decorator.rb
107
163
  - app/decorators/models/solidus_volume_pricing/spree/variant_decorator.rb
108
164
  - app/models/solidus_volume_pricing/price_display.rb
109
165
  - app/models/solidus_volume_pricing/pricer.rb
@@ -124,7 +180,9 @@ files:
124
180
  - app/views/spree/admin/volume_prices/_table.html.erb
125
181
  - app/views/spree/admin/volume_prices/_volume_price_fields.html.erb
126
182
  - app/views/spree/products/_volume_pricing.html.erb
183
+ - bin/console
127
184
  - bin/rails
185
+ - bin/setup
128
186
  - config/locales/de.yml
129
187
  - config/locales/en.yml
130
188
  - config/locales/pt.yml
@@ -142,10 +200,10 @@ files:
142
200
  - lib/solidus_volume_pricing.rb
143
201
  - lib/solidus_volume_pricing/engine.rb
144
202
  - lib/solidus_volume_pricing/range_from_string.rb
203
+ - lib/solidus_volume_pricing/testing_support/factories.rb
145
204
  - lib/solidus_volume_pricing/version.rb
146
205
  - solidus_volume_pricing.gemspec
147
206
  - spec/controllers/spree/admin/variants_controller_spec.rb
148
- - spec/factories/volume_price_factory.rb
149
207
  - spec/features/manage_volume_price_models_feature_spec.rb
150
208
  - spec/features/manage_volume_prices_feature_spec.rb
151
209
  - spec/helpers/base_helper_spec.rb
@@ -160,9 +218,11 @@ files:
160
218
  - spec/support/shoulda.rb
161
219
  homepage: https://github.com/solidusio-contrib/solidus_volume_pricing
162
220
  licenses:
163
- - BSD-3
164
- metadata: {}
165
- post_install_message:
221
+ - BSD-3-Clause
222
+ metadata:
223
+ homepage_uri: https://github.com/solidusio-contrib/solidus_volume_pricing
224
+ source_code_uri: https://github.com/solidusio-contrib/solidus_volume_pricing
225
+ post_install_message:
166
226
  rdoc_options: []
167
227
  require_paths:
168
228
  - lib
@@ -170,21 +230,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
230
  requirements:
171
231
  - - ">="
172
232
  - !ruby/object:Gem::Version
173
- version: 2.2.3
233
+ version: '2.5'
174
234
  required_rubygems_version: !ruby/object:Gem::Requirement
175
235
  requirements:
176
236
  - - ">="
177
237
  - !ruby/object:Gem::Version
178
238
  version: '0'
179
- requirements:
180
- - none
181
- rubygems_version: 3.0.6
182
- signing_key:
239
+ requirements: []
240
+ rubygems_version: 3.3.7
241
+ signing_key:
183
242
  specification_version: 4
184
243
  summary: Allow prices to be configured in quantity ranges for each variant
185
244
  test_files:
186
245
  - spec/controllers/spree/admin/variants_controller_spec.rb
187
- - spec/factories/volume_price_factory.rb
188
246
  - spec/features/manage_volume_price_models_feature_spec.rb
189
247
  - spec/features/manage_volume_prices_feature_spec.rb
190
248
  - spec/helpers/base_helper_spec.rb
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SolidusVolumePricing
4
- module Spree
5
- module UserDecorator
6
- def resolve_role
7
- if has_spree_role? ::Spree::Config.volume_pricing_role.to_sym
8
- ::Spree::Role.find_by name: ::Spree::Config.volume_pricing_role
9
- else
10
- ::Spree::Role.find_by name: 'user'
11
- end
12
- end
13
-
14
- ::Spree.user_class.prepend self
15
- end
16
- end
17
- end