workarea-shipping_message 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.github/workflows/ci.yml +54 -0
  7. data/.gitignore +13 -0
  8. data/.rubocop.yml +3 -0
  9. data/CHANGELOG.md +42 -0
  10. data/CODE_OF_CONDUCT.md +3 -0
  11. data/CONTRIBUTING.md +3 -0
  12. data/Gemfile +9 -0
  13. data/LICENSE.md +3 -0
  14. data/README.md +40 -0
  15. data/Rakefile +42 -0
  16. data/app/controllers/workarea/admin/pricing_discounts_controller.decorator +8 -0
  17. data/app/models/workarea/pricing/discount/message.rb +15 -0
  18. data/app/models/workarea/pricing/discount/shipping.decorator +11 -0
  19. data/app/seeds/workarea/free_shipping_promo_seeds.rb +24 -0
  20. data/app/view_models/workarea/storefront/cart_view_model.decorator +49 -0
  21. data/app/views/workarea/admin/pricing_discounts/_message_card.haml +22 -0
  22. data/app/views/workarea/admin/pricing_discounts/message.haml +49 -0
  23. data/app/views/workarea/storefront/carts/_shipping_message.html.haml +2 -0
  24. data/bin/rails +18 -0
  25. data/config/initializers/appends.rb +11 -0
  26. data/config/initializers/seeds.rb +3 -0
  27. data/config/locales/en.yml +23 -0
  28. data/config/routes.rb +11 -0
  29. data/lib/workarea/shipping_message.rb +12 -0
  30. data/lib/workarea/shipping_message/engine.rb +8 -0
  31. data/lib/workarea/shipping_message/version.rb +5 -0
  32. data/test/dummy/Rakefile +6 -0
  33. data/test/dummy/app/assets/config/manifest.js +4 -0
  34. data/test/dummy/app/assets/images/.keep +0 -0
  35. data/test/dummy/app/assets/javascripts/application.js +13 -0
  36. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  37. data/test/dummy/app/controllers/application_controller.rb +3 -0
  38. data/test/dummy/app/controllers/concerns/.keep +0 -0
  39. data/test/dummy/app/helpers/application_helper.rb +2 -0
  40. data/test/dummy/app/jobs/application_job.rb +2 -0
  41. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  42. data/test/dummy/app/models/concerns/.keep +0 -0
  43. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  44. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  45. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  46. data/test/dummy/bin/bundle +3 -0
  47. data/test/dummy/bin/rails +4 -0
  48. data/test/dummy/bin/rake +4 -0
  49. data/test/dummy/bin/setup +34 -0
  50. data/test/dummy/bin/update +29 -0
  51. data/test/dummy/config.ru +5 -0
  52. data/test/dummy/config/application.rb +26 -0
  53. data/test/dummy/config/boot.rb +5 -0
  54. data/test/dummy/config/cable.yml +9 -0
  55. data/test/dummy/config/environment.rb +5 -0
  56. data/test/dummy/config/environments/development.rb +54 -0
  57. data/test/dummy/config/environments/production.rb +86 -0
  58. data/test/dummy/config/environments/test.rb +43 -0
  59. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  60. data/test/dummy/config/initializers/assets.rb +11 -0
  61. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  62. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  63. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  64. data/test/dummy/config/initializers/inflections.rb +16 -0
  65. data/test/dummy/config/initializers/mime_types.rb +4 -0
  66. data/test/dummy/config/initializers/new_framework_defaults.rb +17 -0
  67. data/test/dummy/config/initializers/workarea.rb +5 -0
  68. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  69. data/test/dummy/config/locales/en.yml +23 -0
  70. data/test/dummy/config/puma.rb +47 -0
  71. data/test/dummy/config/routes.rb +5 -0
  72. data/test/dummy/config/secrets.yml +22 -0
  73. data/test/dummy/config/spring.rb +6 -0
  74. data/test/dummy/lib/assets/.keep +0 -0
  75. data/test/dummy/log/.keep +0 -0
  76. data/test/dummy/public/404.html +67 -0
  77. data/test/dummy/public/422.html +67 -0
  78. data/test/dummy/public/500.html +66 -0
  79. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  80. data/test/dummy/public/apple-touch-icon.png +0 -0
  81. data/test/dummy/public/favicon.ico +0 -0
  82. data/test/system/workarea/admin/free_shipping_message_system_test.rb +49 -0
  83. data/test/system/workarea/storefront/free_shipping_message_on_cart_system_test.rb +60 -0
  84. data/test/test_helper.rb +14 -0
  85. data/test/view_models/workarea/storefront/cart_view_model_test.rb +56 -0
  86. data/workarea-shipping_message.gemspec +17 -0
  87. metadata +142 -0
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1,49 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Admin
5
+ class FreeShippingMessageSettingsSystemTest < Workarea::SystemTest
6
+ include Admin::IntegrationTest
7
+
8
+ setup :create_discount_with_message
9
+
10
+ def create_discount_with_message
11
+ shipping_method = create_shipping_service
12
+ @discount = create_shipping_discount(
13
+ name: "Shipping Discount",
14
+ shipping_service: shipping_method,
15
+ amount: 0.to_m,
16
+ order_total_operator: :greater_than,
17
+ order_total: 1.to_m,
18
+ message_active: true,
19
+ message_applied: "You got FREE SHIPPING!",
20
+ message: "You're only {amount} away from FREE SHIPPING!"
21
+ )
22
+ end
23
+
24
+ def test_managing_discount_messages
25
+ visit admin.pricing_discounts_path
26
+
27
+ click_link("Shipping Discount")
28
+
29
+ assert(page.has_content?(t("workarea.admin.pricing_discounts.cards.message.header")))
30
+ click_link(t("workarea.admin.pricing_discounts.cards.message.header"))
31
+
32
+ fill_in "discount[message_applied]", with: "Discount Applied"
33
+ fill_in "discount[message]", with: "Before amount {amount} after amount"
34
+
35
+ click_button "save_discount_message"
36
+ assert(page.has_content?("Success"))
37
+ end
38
+
39
+ def test_card_is_only_displayed_for_discounts_with_messaging_included
40
+ visit admin.pricing_discount_path(@discount)
41
+ assert(page.has_content?(t("workarea.admin.pricing_discounts.cards.message.header")))
42
+
43
+ invalid_discount = create_quantity_fixed_price_discount()
44
+ visit admin.pricing_discount_path(invalid_discount)
45
+ refute(page.has_content?(t("workarea.admin.pricing_discounts.cards.message.header")))
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,60 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class FreeShippingMessageOnCartSystemTest < Workarea::SystemTest
6
+ include Storefront::SystemTest
7
+ setup :set_product
8
+ setup :set_discount
9
+
10
+ def set_product
11
+ @product = create_product(
12
+ name: "Integration Product",
13
+ variants: [
14
+ { name: "SKU1", sku: "SKU1", regular: 1.to_m },
15
+ { name: "SKU2", sku: "SKU2", regular: 2.to_m }
16
+ ]
17
+ )
18
+ end
19
+
20
+ def set_discount
21
+ shipping_method = create_shipping_service(
22
+ rates: [
23
+ { price: 2.to_m }
24
+ ]
25
+ )
26
+
27
+ discount = create_shipping_discount(
28
+ shipping_service: shipping_method,
29
+ amount: 0.to_m,
30
+ order_total_operator: :greater_than,
31
+ order_total: 2.to_m,
32
+ message_active: true,
33
+ message_applied: "You got FREE SHIPPING!",
34
+ message: "You're only {amount} away from FREE SHIPPING!"
35
+ )
36
+ end
37
+
38
+ def test_user_does_not_meet_criteria_for_free_shipping
39
+ visit storefront.product_path(@product)
40
+ select @product.skus.first, from: "sku"
41
+ click_button t("workarea.storefront.products.add_to_cart")
42
+
43
+ assert(page.has_content?("Success"))
44
+
45
+ click_link t("workarea.storefront.carts.view_cart")
46
+
47
+ assert(page.has_content?("You're only $1.00 away from FREE SHIPPING!"))
48
+ end
49
+
50
+ def test_user_meets_criteria_for_free_shipping
51
+ visit storefront.product_path(@product)
52
+ select @product.skus.last, from: "sku"
53
+ click_button t("workarea.storefront.products.add_to_cart")
54
+ click_link t("workarea.storefront.carts.view_cart")
55
+
56
+ assert(page.has_content?("You got FREE SHIPPING!"))
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,14 @@
1
+ require "simplecov"
2
+
3
+ SimpleCov.start "rails" do
4
+ add_filter "lib/workarea/shipping_message/version.rb"
5
+ add_filter %r{seeds}
6
+ end
7
+
8
+ ENV["RAILS_ENV"] = "test"
9
+
10
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
11
+ require "rails/test_help"
12
+ require "workarea/test_help"
13
+
14
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
@@ -0,0 +1,56 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class CartViewModelTest < Workarea::TestCase
6
+ setup :create_discount
7
+
8
+ def create_discount
9
+ @discount = create_shipping_discount(
10
+ amount: 0.to_m,
11
+ order_total_operator: :greater_than,
12
+ order_total: 2.to_m,
13
+ message_active: true,
14
+ message_applied: "You got FREE SHIPPING!",
15
+ message: "You're only {amount} away from FREE SHIPPING!"
16
+ )
17
+ end
18
+
19
+ def test_amount_away_from_free_shipping_is_nil_if_the_free_shipping_discount_is_not_active
20
+ @discount.update_attributes(active: false)
21
+
22
+ view_model = CartViewModel.new(Order.new)
23
+
24
+ assert_nil(view_model.amount_away_from_free_shipping)
25
+ end
26
+
27
+ def test_amount_away_from_free_shipping_is_zero_when_the_discount_qualifying_total_is_met
28
+ view_model = CartViewModel.new(Order.new(subtotal_price: 2.to_m))
29
+ assert_equal(0.to_m, view_model.amount_away_from_free_shipping)
30
+ end
31
+
32
+ def test_amount_away_from_free_shipping_is_negative_if_order_total_greater_than_the_discount_qualifying_total
33
+ view_model = CartViewModel.new(Order.new(subtotal_price: 3.to_m))
34
+ assert_equal(-1.to_m, view_model.amount_away_from_free_shipping)
35
+ end
36
+
37
+ def test_amount_away_from_free_shipping_is_correct_if_qualifying_total_is_not_met
38
+ view_model = CartViewModel.new(Order.new(subtotal_price: 1.to_m))
39
+
40
+ assert_equal(1.to_m, view_model.amount_away_from_free_shipping)
41
+ end
42
+
43
+ def test_free_shipping_message_includes_amount_left_to_apply
44
+ view_model = CartViewModel.new(Order.new(subtotal_price: 1.to_m))
45
+
46
+ assert_equal("You're only $1.00 away from FREE SHIPPING!", view_model.free_shipping_message)
47
+ end
48
+
49
+ def test_free_message_applied_returned_if_discount_is_applied
50
+ view_model = CartViewModel.new(Order.new(subtotal_price: 2.to_m))
51
+
52
+ assert_equal("You got FREE SHIPPING!", view_model.free_shipping_message)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,17 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ require "workarea/shipping_message/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "workarea-shipping_message"
7
+ s.version = Workarea::ShippingMessage::VERSION
8
+ s.authors = ["Mike Dalton"]
9
+ s.email = ["mdalton@workarea.com"]
10
+ s.homepage = "https://github.com/workarea-commerce/workarea-shipping-message"
11
+ s.summary = "Shipping Message plugin for the WebLinc ecommerce platform"
12
+ s.description = "Plugin to display free shipping message on the cart for the WebLinc ecommerce platform"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+
16
+ s.add_dependency "workarea", '>= 3.5.x'
17
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workarea-shipping_message
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Dalton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: workarea
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.5.x
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.5.x
27
+ description: Plugin to display free shipping message on the cart for the WebLinc ecommerce
28
+ platform
29
+ email:
30
+ - mdalton@workarea.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".editorconfig"
36
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
37
+ - ".github/ISSUE_TEMPLATE/documentation-request.md"
38
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
39
+ - ".github/workflows/ci.yml"
40
+ - ".gitignore"
41
+ - ".rubocop.yml"
42
+ - CHANGELOG.md
43
+ - CODE_OF_CONDUCT.md
44
+ - CONTRIBUTING.md
45
+ - Gemfile
46
+ - LICENSE.md
47
+ - README.md
48
+ - Rakefile
49
+ - app/controllers/workarea/admin/pricing_discounts_controller.decorator
50
+ - app/models/workarea/pricing/discount/message.rb
51
+ - app/models/workarea/pricing/discount/shipping.decorator
52
+ - app/seeds/workarea/free_shipping_promo_seeds.rb
53
+ - app/view_models/workarea/storefront/cart_view_model.decorator
54
+ - app/views/workarea/admin/pricing_discounts/_message_card.haml
55
+ - app/views/workarea/admin/pricing_discounts/message.haml
56
+ - app/views/workarea/storefront/carts/_shipping_message.html.haml
57
+ - bin/rails
58
+ - config/initializers/appends.rb
59
+ - config/initializers/seeds.rb
60
+ - config/locales/en.yml
61
+ - config/routes.rb
62
+ - lib/workarea/shipping_message.rb
63
+ - lib/workarea/shipping_message/engine.rb
64
+ - lib/workarea/shipping_message/version.rb
65
+ - test/dummy/Rakefile
66
+ - test/dummy/app/assets/config/manifest.js
67
+ - test/dummy/app/assets/images/.keep
68
+ - test/dummy/app/assets/javascripts/application.js
69
+ - test/dummy/app/assets/stylesheets/application.css
70
+ - test/dummy/app/controllers/application_controller.rb
71
+ - test/dummy/app/controllers/concerns/.keep
72
+ - test/dummy/app/helpers/application_helper.rb
73
+ - test/dummy/app/jobs/application_job.rb
74
+ - test/dummy/app/mailers/application_mailer.rb
75
+ - test/dummy/app/models/concerns/.keep
76
+ - test/dummy/app/views/layouts/application.html.erb
77
+ - test/dummy/app/views/layouts/mailer.html.erb
78
+ - test/dummy/app/views/layouts/mailer.text.erb
79
+ - test/dummy/bin/bundle
80
+ - test/dummy/bin/rails
81
+ - test/dummy/bin/rake
82
+ - test/dummy/bin/setup
83
+ - test/dummy/bin/update
84
+ - test/dummy/config.ru
85
+ - test/dummy/config/application.rb
86
+ - test/dummy/config/boot.rb
87
+ - test/dummy/config/cable.yml
88
+ - test/dummy/config/environment.rb
89
+ - test/dummy/config/environments/development.rb
90
+ - test/dummy/config/environments/production.rb
91
+ - test/dummy/config/environments/test.rb
92
+ - test/dummy/config/initializers/application_controller_renderer.rb
93
+ - test/dummy/config/initializers/assets.rb
94
+ - test/dummy/config/initializers/backtrace_silencers.rb
95
+ - test/dummy/config/initializers/cookies_serializer.rb
96
+ - test/dummy/config/initializers/filter_parameter_logging.rb
97
+ - test/dummy/config/initializers/inflections.rb
98
+ - test/dummy/config/initializers/mime_types.rb
99
+ - test/dummy/config/initializers/new_framework_defaults.rb
100
+ - test/dummy/config/initializers/workarea.rb
101
+ - test/dummy/config/initializers/wrap_parameters.rb
102
+ - test/dummy/config/locales/en.yml
103
+ - test/dummy/config/puma.rb
104
+ - test/dummy/config/routes.rb
105
+ - test/dummy/config/secrets.yml
106
+ - test/dummy/config/spring.rb
107
+ - test/dummy/lib/assets/.keep
108
+ - test/dummy/log/.keep
109
+ - test/dummy/public/404.html
110
+ - test/dummy/public/422.html
111
+ - test/dummy/public/500.html
112
+ - test/dummy/public/apple-touch-icon-precomposed.png
113
+ - test/dummy/public/apple-touch-icon.png
114
+ - test/dummy/public/favicon.ico
115
+ - test/system/workarea/admin/free_shipping_message_system_test.rb
116
+ - test/system/workarea/storefront/free_shipping_message_on_cart_system_test.rb
117
+ - test/test_helper.rb
118
+ - test/view_models/workarea/storefront/cart_view_model_test.rb
119
+ - workarea-shipping_message.gemspec
120
+ homepage: https://github.com/workarea-commerce/workarea-shipping-message
121
+ licenses: []
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 3.0.6
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Shipping Message plugin for the WebLinc ecommerce platform
142
+ test_files: []