ba_spree_related_products 1.0.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.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.hound.yml +25 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +8 -0
  6. data/.travis.yml +55 -0
  7. data/Appraisals +25 -0
  8. data/CONTRIBUTING.md +81 -0
  9. data/Gemfile +7 -0
  10. data/Guardfile +10 -0
  11. data/LICENSE +713 -0
  12. data/LICENSE.md +26 -0
  13. data/README.md +84 -0
  14. data/Rakefile +17 -0
  15. data/app/controllers/spree/admin/relation_types_controller.rb +13 -0
  16. data/app/controllers/spree/admin/relations_controller.rb +79 -0
  17. data/app/controllers/spree/api/relations_controller.rb +82 -0
  18. data/app/controllers/spree_related_products/spree/admin/products_controller_decorator.rb +16 -0
  19. data/app/helpers/spree_related_products/products_helper_decorator.rb +40 -0
  20. data/app/models/spree/calculator/related_product_discount.rb +59 -0
  21. data/app/models/spree/relation.rb +24 -0
  22. data/app/models/spree/relation_type.rb +23 -0
  23. data/app/models/spree_related_products/spree/product_decorator.rb +128 -0
  24. data/app/overrides/add_condition_after_products_active.rb +10 -0
  25. data/app/views/spree/admin/products/_related_products_table.html.erb +53 -0
  26. data/app/views/spree/admin/products/related.html.erb +62 -0
  27. data/app/views/spree/admin/relation_types/_form.html.erb +21 -0
  28. data/app/views/spree/admin/relation_types/edit.html.erb +13 -0
  29. data/app/views/spree/admin/relation_types/index.html.erb +41 -0
  30. data/app/views/spree/admin/relation_types/new.html.erb +13 -0
  31. data/app/views/spree/admin/relations/create.js.erb +5 -0
  32. data/app/views/spree/admin/relations/destroy.js.erb +1 -0
  33. data/app/views/spree/admin/relations/destroy.turbo_stream.erb +1 -0
  34. data/app/views/spree/api/relations/show.v1.rabl +4 -0
  35. data/app/views/spree/products/related.html.erb +6 -0
  36. data/app/views/spree_related_products/_related_products.html.erb +21 -0
  37. data/app/views/spree_related_products/admin/_product_relations_dropdown_item.html.erb +6 -0
  38. data/app/views/spree_related_products/admin/_relation_types_nav_item.html.erb +1 -0
  39. data/ba_spree_related_products.gemspec +35 -0
  40. data/bin/rails +7 -0
  41. data/config/initializers/related_product.rb +21 -0
  42. data/config/locales/bg.yml +18 -0
  43. data/config/locales/cs.yml +18 -0
  44. data/config/locales/de.yml +18 -0
  45. data/config/locales/en.yml +19 -0
  46. data/config/locales/es.yml +18 -0
  47. data/config/locales/fr.yml +18 -0
  48. data/config/locales/it.yml +18 -0
  49. data/config/locales/ja.yml +19 -0
  50. data/config/locales/nl.yml +18 -0
  51. data/config/locales/pl.yml +18 -0
  52. data/config/locales/pt-BR.yml +18 -0
  53. data/config/locales/ru.yml +18 -0
  54. data/config/locales/sv.yml +18 -0
  55. data/config/routes.rb +26 -0
  56. data/db/migrate/20100308090631_create_relation_types.rb +14 -0
  57. data/db/migrate/20100308092101_create_relations.rb +14 -0
  58. data/db/migrate/20100324123835_add_discount_to_relation.rb +9 -0
  59. data/db/migrate/20111129044813_prefixing_tables_with_spree.rb +6 -0
  60. data/db/migrate/20120208144454_update_relation_types.rb +9 -0
  61. data/db/migrate/20120623014337_update_relations.rb +11 -0
  62. data/db/migrate/20130727004612_add_position_to_spree_relations.rb +5 -0
  63. data/db/migrate/20210727141500_update_relations_to_bigint.rb +9 -0
  64. data/gemfiles/spree_3_7.gemfile +9 -0
  65. data/gemfiles/spree_4_0.gemfile +8 -0
  66. data/gemfiles/spree_4_1.gemfile +8 -0
  67. data/gemfiles/spree_4_2.gemfile +8 -0
  68. data/gemfiles/spree_master.gemfile +8 -0
  69. data/lib/ba_spree_related_products.rb +5 -0
  70. data/lib/generators/spree_related_products/install/install_generator.rb +19 -0
  71. data/lib/spree_related_products/engine.rb +29 -0
  72. data/lib/spree_related_products/version.rb +11 -0
  73. data/lib/spree_related_products.rb +7 -0
  74. data/spec/controllers/spree/admin/products_controller_decorator_spec.rb +19 -0
  75. data/spec/controllers/spree/admin/relations_controller_spec.rb +104 -0
  76. data/spec/controllers/spree/api/relations_controller_spec.rb +101 -0
  77. data/spec/factories/relation_factory.rb +7 -0
  78. data/spec/factories/relation_type_factory.rb +6 -0
  79. data/spec/features/spree/admin/product_relation_spec.rb +85 -0
  80. data/spec/features/spree/admin/relation_types_spec.rb +97 -0
  81. data/spec/models/spree/calculator/related_product_discount_spec.rb +86 -0
  82. data/spec/models/spree/product_spec.rb +129 -0
  83. data/spec/models/spree/relation_spec.rb +13 -0
  84. data/spec/models/spree/relation_type_spec.rb +20 -0
  85. data/spec/spec_helper.rb +10 -0
  86. data/spec/support/shoulda_matchers.rb +8 -0
  87. data/spree_related_products.gemspec +32 -0
  88. metadata +254 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 27983d2727dfd792c76ee380f4947523e85093c550c97600c5a14eea49eeb16a
4
+ data.tar.gz: d4be1ae5fa433b553252c7a426bbea8736f4f399cf94fbedcb2eb14f0a0823c6
5
+ SHA512:
6
+ metadata.gz: 91efff6ff8c887c7f46cd8498fac05bdb3c6fbef9a1f63fdc295108fc06eae5438491c22fcdecadc0a409963486537e3cd02504cab5b3c7c99c12c5dc4e66d45
7
+ data.tar.gz: 0dfac40d2d89b52e2afc9607fc474a4218de03f71790177281acd23dd03cd382b47f69a8500b5e2053901b0cbd3a3be856b74016914634f6e94052b3ecfa91a4
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.swp
2
+ .DS_Store
3
+ .rvmrc
4
+ Gemfile.lock
5
+ pkg
6
+ spec/dummy
7
+ *~
8
+ tmp
9
+ .localeapp
10
+ coverage
11
+ .ruby-version
12
+ .ruby-gemset
13
+ .idea
14
+ gemfiles/*.gemfile.lock
data/.hound.yml ADDED
@@ -0,0 +1,25 @@
1
+ ---
2
+ # Too picky.
3
+ LineLength:
4
+ Enabled: false
5
+
6
+ # This should truly be on for well documented gems.
7
+ Documentation:
8
+ Enabled: false
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
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ -r spec_helper
3
+ -f documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ ---
2
+ inherit_from: .hound.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - spec/dummy/**/*
7
+ - bin/*
8
+ - Guardfile
data/.travis.yml ADDED
@@ -0,0 +1,55 @@
1
+ os: linux
2
+ dist: bionic
3
+
4
+ addons:
5
+ apt:
6
+ sources:
7
+ - google-chrome
8
+ packages:
9
+ - google-chrome-stable
10
+
11
+ services:
12
+ - mysql
13
+ - postgresql
14
+
15
+ language: ruby
16
+
17
+ rvm:
18
+ - 2.7
19
+ - 3.0
20
+
21
+ env:
22
+ - DB=mysql
23
+ - DB=postgres
24
+
25
+ gemfile:
26
+ - gemfiles/spree_3_7.gemfile
27
+ - gemfiles/spree_4_0.gemfile
28
+ - gemfiles/spree_4_1.gemfile
29
+ - gemfiles/spree_4_2.gemfile
30
+ - gemfiles/spree_master.gemfile
31
+
32
+ jobs:
33
+ exclude:
34
+ - rvm: 3.0
35
+ gemfile: gemfiles/spree_3_7.gemfile
36
+ - rvm: 3.0
37
+ gemfile: gemfiles/spree_4_0.gemfile
38
+ - rvm: 3.0
39
+ gemfile: gemfiles/spree_4_1.gemfile
40
+ allow_failures:
41
+ - gemfile: gemfiles/spree_master.gemfile
42
+
43
+ before_install:
44
+ - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
45
+
46
+ before_script:
47
+ - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
48
+ - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
49
+ - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
50
+ - unzip chromedriver_linux64.zip -d ~/bin
51
+ - nvm install 14
52
+
53
+ script:
54
+ - bundle exec rake test_app
55
+ - bundle exec rake spec
data/Appraisals ADDED
@@ -0,0 +1,25 @@
1
+ appraise 'spree-3-7' do
2
+ gem 'spree', '~> 3.7.0'
3
+ gem 'rails-controller-testing'
4
+ gem 'sass-rails'
5
+ end
6
+
7
+ appraise 'spree-4-0' do
8
+ gem 'spree', '~> 4.0.0'
9
+ gem 'rails-controller-testing'
10
+ end
11
+
12
+ appraise 'spree-4-1' do
13
+ gem 'spree', '~> 4.1.0'
14
+ gem 'rails-controller-testing'
15
+ end
16
+
17
+ appraise 'spree-4-2' do
18
+ gem 'spree', '~> 4.2.0.rc4'
19
+ gem 'rails-controller-testing'
20
+ end
21
+
22
+ appraise 'spree-master' do
23
+ gem 'spree', github: 'spree/spree', branch: 'master'
24
+ gem 'rails-controller-testing'
25
+ end
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,81 @@
1
+ # Contributing
2
+
3
+ Spree Related Products is an open source project and we encourage contributions. Please see the [contributors guidelines](http://spreecommerce.com/documentation/contributing_to_spree.html) for more information before contributing.
4
+
5
+ In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
6
+
7
+ Here are some ways *you* can contribute:
8
+
9
+ * by using prerelease versions
10
+ * by reporting [bugs][2]
11
+ * by suggesting new features
12
+ * by writing [translations][3]
13
+ * by writing or editing documentation
14
+ * by writing specifications
15
+ * by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
16
+ * by refactoring code
17
+ * by resolving [issues][2]
18
+ * by reviewing patches
19
+
20
+ ---
21
+
22
+ ## Filing an issue
23
+
24
+ When filing an issue on this extension, please first do these things:
25
+
26
+ * Verify you can reproduce this issue in a brand new application.
27
+ * Run through the steps to reproduce the issue again.
28
+
29
+ In the issue itself please provide:
30
+
31
+ * A comprehensive list of steps to reproduce the issue.
32
+ * What you're *expecting* to happen compared with what's *actually* happening.
33
+ * The version of Spree *and* the version of Rails.
34
+ * A list of all extensions.
35
+ * Any relevant stack traces ("Full trace" preferred)
36
+ * Your `Gemfile`
37
+
38
+ In 99% of cases, this information is enough to determine the cause and solution to the problem that is being described.
39
+
40
+ ---
41
+
42
+ ## Pull requests
43
+
44
+ We gladly accept pull requests to fix bugs and, in some circumstances, add new features to this extension.
45
+
46
+ Here's a quick guide:
47
+
48
+ 1. Fork the repo.
49
+
50
+ 2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate.
51
+
52
+ 3. Create new branch then make changes and add tests for your changes. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need tests!
53
+
54
+ 4. Push to your fork and submit a pull request. If the changes will apply cleanly to the latest stable branches and master branch, you will only need to submit one pull request.
55
+
56
+ At this point you're waiting on us. We may suggest some changes or improvements or alternatives.
57
+
58
+ Some things that will increase the chance that your pull request is accepted, taken straight from the Ruby on Rails guide:
59
+
60
+ * Use Rails idioms and helpers.
61
+ * Include tests that fail without your code, and pass with it.
62
+ * Update the documentation, the surrounding one, examples elsewhere, guides, whatever is affected by your contribution.
63
+
64
+ ---
65
+
66
+ ## TL;DR
67
+
68
+ * Fork the repo
69
+ * Clone your repo
70
+ * Run `bundle install`
71
+ * Run `bundle exec rake test_app` to create the test application in `spec/dummy`
72
+ * Make your changes
73
+ * Ensure specs pass by running `bundle exec rspec spec`
74
+ * Ensure all syntax ok by running `rubocop .`
75
+ * Submit your pull request
76
+
77
+ And in case we didn't emphasize it enough: **we love tests!**
78
+
79
+ [1]: http://www.fsf.org/licensing/essays/free-sw.html
80
+ [2]: https://github.com/spree-contrib/spree_related_products/issues
81
+ [3]: https://github.com/spree-contrib/spree_related_products/tree/master/config/locales
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ spree_version = 'master'
4
+ gem 'spree', github: 'spree/spree', branch: spree_version
5
+ gem 'rails-controller-testing'
6
+
7
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
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