workarea-listrak 5.0.1

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 (163) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.json +36 -0
  3. data/.esvmrc +5 -0
  4. data/.gitignore +32 -0
  5. data/CHANGELOG.md +322 -0
  6. data/Gemfile +14 -0
  7. data/README.md +130 -0
  8. data/Rakefile +53 -0
  9. data/app/assets/javascripts/workarea/admin/modules/listrak/list_events_select.js +83 -0
  10. data/app/assets/javascripts/workarea/storefront/listrak/adapters/listrak_adapter.js +110 -0
  11. data/app/assets/javascripts/workarea/storefront/listrak/listrak_config.js.erb +13 -0
  12. data/app/assets/javascripts/workarea/storefront/listrak/modules/listrak.js +64 -0
  13. data/app/controllers/workarea/admin/listrak/configurations_controller.rb +30 -0
  14. data/app/controllers/workarea/admin/listrak/events_controller.rb +17 -0
  15. data/app/helpers/workarea/listrak/analytics/helper.rb +44 -0
  16. data/app/models/workarea/listrak/configuration.rb +19 -0
  17. data/app/queries/workarea/categorization.decorator +7 -0
  18. data/app/services/workarea/listrak/data_api/customers.rb +26 -0
  19. data/app/services/workarea/listrak/data_api/orders.rb +26 -0
  20. data/app/services/workarea/listrak/data_api/products.rb +26 -0
  21. data/app/services/workarea/listrak/data_api.rb +63 -0
  22. data/app/services/workarea/listrak/email_api/contacts.rb +73 -0
  23. data/app/services/workarea/listrak/email_api/events.rb +44 -0
  24. data/app/services/workarea/listrak/email_api/lists.rb +21 -0
  25. data/app/services/workarea/listrak/email_api/messages.rb +50 -0
  26. data/app/services/workarea/listrak/email_api/transactional_messages.rb +32 -0
  27. data/app/services/workarea/listrak/email_api.rb +71 -0
  28. data/app/services/workarea/listrak/models/address.rb +83 -0
  29. data/app/services/workarea/listrak/models/contact.rb +67 -0
  30. data/app/services/workarea/listrak/models/contact_form.rb +24 -0
  31. data/app/services/workarea/listrak/models/customer_form.rb +209 -0
  32. data/app/services/workarea/listrak/models/event.rb +45 -0
  33. data/app/services/workarea/listrak/models/event_form.rb +25 -0
  34. data/app/services/workarea/listrak/models/list.rb +204 -0
  35. data/app/services/workarea/listrak/models/message_form.rb +147 -0
  36. data/app/services/workarea/listrak/models/order_form.rb +352 -0
  37. data/app/services/workarea/listrak/models/order_item.rb +197 -0
  38. data/app/services/workarea/listrak/models/product_form.rb +369 -0
  39. data/app/services/workarea/listrak/models/transactional_message_form.rb +21 -0
  40. data/app/services/workarea/listrak/oauth.rb +45 -0
  41. data/app/services/workarea/listrak/transactional_message.rb +83 -0
  42. data/app/view_models/workarea/admin/listrak_configuration_view_model.rb +17 -0
  43. data/app/views/workarea/admin/listrak/configurations/edit.html.haml +28 -0
  44. data/app/views/workarea/admin/listrak/events/index.json.jbuilder +4 -0
  45. data/app/views/workarea/admin/shared/_listrak_configuration_link.html.haml +1 -0
  46. data/app/views/workarea/storefront/checkouts/_listrak.html.haml +2 -0
  47. data/app/workers/workarea/listrak/customer_exporter.rb +22 -0
  48. data/app/workers/workarea/listrak/order_exporter.rb +22 -0
  49. data/app/workers/workarea/listrak/product_exporter.rb +50 -0
  50. data/app/workers/workarea/listrak/subscribe_email_signup.rb +34 -0
  51. data/app/workers/workarea/listrak/unsubscribe_email_signup.rb +27 -0
  52. data/bin/rails +18 -0
  53. data/bin/rake +16 -0
  54. data/bin/rspec +16 -0
  55. data/bin/rubocop +16 -0
  56. data/config/initializers/append_points.rb +28 -0
  57. data/config/initializers/configuration.rb +8 -0
  58. data/config/locales/en.yml +17 -0
  59. data/config/routes.rb +10 -0
  60. data/docs/Listrak Technical Integration Guide.docx +0 -0
  61. data/lib/generators/workarea/listrak/message/USAGE +9 -0
  62. data/lib/generators/workarea/listrak/message/message_generator.rb +15 -0
  63. data/lib/generators/workarea/listrak/message/templates/message.rb.erb +24 -0
  64. data/lib/workarea/listrak/analytics.rb +17 -0
  65. data/lib/workarea/listrak/bogus_data_api/customers.rb +9 -0
  66. data/lib/workarea/listrak/bogus_data_api/orders.rb +9 -0
  67. data/lib/workarea/listrak/bogus_data_api/products.rb +9 -0
  68. data/lib/workarea/listrak/bogus_data_api/proxy_client.rb +29 -0
  69. data/lib/workarea/listrak/bogus_data_api.rb +46 -0
  70. data/lib/workarea/listrak/bogus_email_api/contacts.rb +8 -0
  71. data/lib/workarea/listrak/bogus_email_api/events.rb +23 -0
  72. data/lib/workarea/listrak/bogus_email_api/lists.rb +63 -0
  73. data/lib/workarea/listrak/bogus_email_api/proxy_client.rb +29 -0
  74. data/lib/workarea/listrak/bogus_email_api/transactional_messages.rb +9 -0
  75. data/lib/workarea/listrak/bogus_email_api.rb +51 -0
  76. data/lib/workarea/listrak/engine.rb +12 -0
  77. data/lib/workarea/listrak/error.rb +39 -0
  78. data/lib/workarea/listrak/version.rb +5 -0
  79. data/lib/workarea/listrak.rb +57 -0
  80. data/readme/listrak-admin.png +0 -0
  81. data/script/admin_ci +9 -0
  82. data/script/ci +11 -0
  83. data/script/core_ci +9 -0
  84. data/script/plugins_ci +9 -0
  85. data/script/storefront_ci +9 -0
  86. data/test/dummy/Rakefile +6 -0
  87. data/test/dummy/bin/bundle +3 -0
  88. data/test/dummy/bin/rails +4 -0
  89. data/test/dummy/bin/rake +4 -0
  90. data/test/dummy/bin/setup +34 -0
  91. data/test/dummy/bin/update +29 -0
  92. data/test/dummy/config/application.rb +18 -0
  93. data/test/dummy/config/boot.rb +5 -0
  94. data/test/dummy/config/cable.yml +9 -0
  95. data/test/dummy/config/environment.rb +5 -0
  96. data/test/dummy/config/environments/development.rb +54 -0
  97. data/test/dummy/config/environments/production.rb +86 -0
  98. data/test/dummy/config/environments/test.rb +43 -0
  99. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  100. data/test/dummy/config/initializers/assets.rb +11 -0
  101. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  102. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  103. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  104. data/test/dummy/config/initializers/inflections.rb +16 -0
  105. data/test/dummy/config/initializers/mime_types.rb +4 -0
  106. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  107. data/test/dummy/config/initializers/session_store.rb +3 -0
  108. data/test/dummy/config/initializers/workarea.rb +5 -0
  109. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  110. data/test/dummy/config/locales/en.yml +23 -0
  111. data/test/dummy/config/puma.rb +47 -0
  112. data/test/dummy/config/routes.rb +5 -0
  113. data/test/dummy/config/secrets.yml +38 -0
  114. data/test/dummy/config/spring.rb +6 -0
  115. data/test/dummy/config.ru +5 -0
  116. data/test/dummy/db/seeds.rb +2 -0
  117. data/test/dummy/public/404.html +67 -0
  118. data/test/dummy/public/422.html +67 -0
  119. data/test/dummy/public/500.html +66 -0
  120. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  121. data/test/dummy/public/apple-touch-icon.png +0 -0
  122. data/test/dummy/public/favicon.ico +0 -0
  123. data/test/factories/workarea/factories/listrak.rb +15 -0
  124. data/test/helpers/workarea/listrak/analytics/helper_test.rb +38 -0
  125. data/test/integration/workarea/admin/listrak/configuration_integration_test.rb +26 -0
  126. data/test/integration/workarea/admin/listrak/events_integration_test.rb +21 -0
  127. data/test/lib/generators/workarea/listrak/message_generator_test.rb +26 -0
  128. data/test/queries/workarea/categorization_test.decorator +15 -0
  129. data/test/services/workarea/listrak/data_api/customers_test.rb +35 -0
  130. data/test/services/workarea/listrak/data_api/orders_test.rb +24 -0
  131. data/test/services/workarea/listrak/data_api/products_test.rb +27 -0
  132. data/test/services/workarea/listrak/email_api/contacts_test.rb +55 -0
  133. data/test/services/workarea/listrak/email_api/events_test.rb +51 -0
  134. data/test/services/workarea/listrak/email_api/lists_test.rb +45 -0
  135. data/test/services/workarea/listrak/email_api/messages_test.rb +28 -0
  136. data/test/services/workarea/listrak/email_api/transactional_messages_test.rb +50 -0
  137. data/test/services/workarea/listrak/oauth_test.rb +27 -0
  138. data/test/services/workarea/listrak/transactional_message_test.rb +48 -0
  139. data/test/support/workarea/listrak/test_order_confirmation_email.rb +116 -0
  140. data/test/support/workarea/listrak/vcr_config.rb +31 -0
  141. data/test/system/workarea/listrak_system_test.rb +75 -0
  142. data/test/test_helper.rb +16 -0
  143. data/test/vcr_cassettes/listrak/data_api/customers_import-successful.yml +88 -0
  144. data/test/vcr_cassettes/listrak/data_api/orders_import-successful.yml +90 -0
  145. data/test/vcr_cassettes/listrak/data_api/products_import-successful.yml +88 -0
  146. data/test/vcr_cassettes/listrak/email_api/contacts_get-successful.yml +87 -0
  147. data/test/vcr_cassettes/listrak/email_api/contacts_upsert-already_unsubscribed.yml +90 -0
  148. data/test/vcr_cassettes/listrak/email_api/contacts_upsert-successful.yml +87 -0
  149. data/test/vcr_cassettes/listrak/email_api/events_create-invalid_parameter.yml +90 -0
  150. data/test/vcr_cassettes/listrak/email_api/events_create-successful.yml +87 -0
  151. data/test/vcr_cassettes/listrak/email_api/events_get-successful.yml +88 -0
  152. data/test/vcr_cassettes/listrak/email_api/lists_all-successful.yml +88 -0
  153. data/test/vcr_cassettes/listrak/email_api/messages_create-successful.yml +88 -0
  154. data/test/vcr_cassettes/listrak/email_api/transactional_messages_create-successful.yml +89 -0
  155. data/test/vcr_cassettes/listrak/oauth-successful.yml +44 -0
  156. data/test/vcr_cassettes/listrak/oauth-unsuccessful.yml +46 -0
  157. data/test/vcr_cassettes/listrak/system_tests/footer_email_signup-successful.yml +171 -0
  158. data/test/vcr_cassettes/listrak/system_tests/footer_email_signup_overrides_unsubscribe.yml +255 -0
  159. data/test/vcr_cassettes/listrak/system_tests/unsubscribing.yml +593 -0
  160. data/test/workers/workarea/listrak/order_exporter_test.rb +31 -0
  161. data/test/workers/workarea/listrak/product_exporter_test.rb +62 -0
  162. data/workarea-listrak.gemspec +16 -0
  163. metadata +223 -0
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,47 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum, this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the number of `workers` to boot in clustered mode.
19
+ # Workers are forked webserver processes. If using threads and workers together
20
+ # the concurrency of the application would be max `threads` * `workers`.
21
+ # Workers do not work on JRuby or Windows (both of which do not support
22
+ # processes).
23
+ #
24
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25
+
26
+ # Use the `preload_app!` method when specifying a `workers` number.
27
+ # This directive tells Puma to first boot the application and load code
28
+ # before forking the application. This takes advantage of Copy On Write
29
+ # process behavior so workers use less memory. If you use this option
30
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
31
+ # block.
32
+ #
33
+ # preload_app!
34
+
35
+ # The code in the `on_worker_boot` will be called if you are using
36
+ # clustered mode by specifying a number of `workers`. After each worker
37
+ # process is booted this block will be run, if you are using `preload_app!`
38
+ # option you will want to use this block to reconnect to any threads
39
+ # or connections that may have been created at application boot, Ruby
40
+ # cannot share connections between processes.
41
+ #
42
+ # on_worker_boot do
43
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44
+ # end
45
+
46
+ # Allow puma to be restarted by `rails restart` command.
47
+ plugin :tmp_restart
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ mount Workarea::Core::Engine => "/"
3
+ mount Workarea::Admin::Engine => "/admin", as: "admin"
4
+ mount Workarea::Storefront::Engine => "/", as: "storefront"
5
+ end
@@ -0,0 +1,38 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: e7027cfa68f62ed7611adaa801f5c49bfd1bcabbaa2849cdc5b08448846b26a9d939598accb724397038fdb17c620a9ed469c84d97a7d3eb858da338528abf96
15
+ listrak:
16
+ analytics:
17
+ merchant_id: your javascript merchant id
18
+ email_capture_ids:
19
+ - name of each email signup field id
20
+ transactional:
21
+ list_id: list id for transactional mails
22
+ username: your listrak API username
23
+ password: your listrak API password
24
+ subscription:
25
+ list_id: list id for general announcement list
26
+ username: your listrak API username
27
+ password: your listrak API password
28
+ export:
29
+ username:
30
+ password:
31
+
32
+ test:
33
+ secret_key_base: f3bcd242d2935534bdd595802b21c40fe801afa2f6595f75909f89910787e5b5e8a394ca91a447c1cb49820cb9490b41a46f3fb039d8bbc59a658737bce1d011
34
+
35
+ # Do not keep production secrets in the repository,
36
+ # instead read values from the environment.
37
+ production:
38
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,6 @@
1
+ %w[
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ].each { |path| Spring.watch(path) }
@@ -0,0 +1,5 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
@@ -0,0 +1,2 @@
1
+ require "workarea/seeds"
2
+ Workarea::Seeds.run
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</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/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</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/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -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,15 @@
1
+ module Workarea
2
+ module Factories
3
+ module Listrak
4
+ Factories.add self
5
+
6
+ def create_listrak_configuration(overrides = {})
7
+ attributes = {
8
+ default_list_id: '349984'
9
+ }.merge overrides
10
+
11
+ Workarea::Listrak::Configuration.create! attributes
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Listrak
5
+ module Analytics
6
+ class HelperTest < Workarea::ViewTest
7
+ include Workarea::ApplicationHelper
8
+ include Workarea::Storefront::AnalyticsHelper
9
+ include TestCase::SearchIndexing
10
+
11
+ setup do
12
+ @order = Storefront::OrderViewModel.wrap create_placed_order
13
+ @item = @order.items.first
14
+ @product = Catalog::Product.find @item.product_id
15
+ end
16
+
17
+ def test_order_analytics_data_extensions
18
+ unless @order.user_id.nil?
19
+ assert_equal @order.user_id, order_analytics_data(@order)[:user_id]
20
+ end
21
+ assert_equal @order.email, order_analytics_data(@order)[:email]
22
+ assert_equal @order.subtotal_price.to_f, order_analytics_data(@order)[:subtotal_price]
23
+ assert_equal @order.shipping_address.first_name, order_analytics_data(@order)[:first_name]
24
+ assert_equal @order.shipping_address.last_name, order_analytics_data(@order)[:last_name]
25
+ end
26
+
27
+ def test_cart_view_analytics_data_extensions
28
+ assert_equal @order.token, cart_view_analytics_data(@order)[:payload][:token]
29
+ end
30
+
31
+ def test_order_item_analytics_data_extensions
32
+ assert_match %r{/product_images/placeholder}, order_item_analytics_data(@item)[:image_url]
33
+ assert_equal @item.product.to_param, order_item_analytics_data(@item)[:slug]
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ module Listrak
6
+ class ConfigurationIntegrationTest < Workarea::IntegrationTest
7
+ include Admin::IntegrationTest
8
+
9
+ def test_update
10
+ create_listrak_configuration
11
+
12
+ patch admin.listrak_configuration_path, params: { default_list_id: 1234 }
13
+ assert_equal t('workarea.admin.listrak_configuration.edit.flash_messages.updated'), flash[:success]
14
+ assert_redirected_to admin.edit_listrak_configuration_path
15
+ end
16
+
17
+ def test_update_with_invalid_params
18
+ create_listrak_configuration
19
+
20
+ patch admin.listrak_configuration_path, params: { default_list_id: nil }
21
+ assert_equal "422", response.code
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ module Listrak
6
+ class EventsIntegrationTest < Workarea::IntegrationTest
7
+ include Admin::IntegrationTest
8
+
9
+ def test_index
10
+ get admin.listrak_list_events_path list_id: "1234", format: :json
11
+ assert response.ok?
12
+
13
+ expected_json = {
14
+ "results" => [{ "label" => "Test", "value" => 12714 }, { "label" => "footer signup", "value" => 12715 }]
15
+ }
16
+ assert_equal expected_json, JSON.parse(response.body)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ require "test_helper"
2
+ require "generators/workarea/listrak/message/message_generator"
3
+
4
+ module Workarea
5
+ module Listrak
6
+ class MessageGeneratorTest < Rails::Generators::TestCase
7
+ tests MessageGenerator
8
+ destination Dir.mktmpdir
9
+
10
+ MESSAGE_NAME = "OrderConfirmation".freeze
11
+ MESSAGE_PATH = "app/messages/workarea/order_confirmation_message.rb".freeze
12
+
13
+ setup do
14
+ prepare_destination
15
+ run_generator [MESSAGE_NAME]
16
+ end
17
+
18
+ def test_generates_message_type_class
19
+ assert_file MESSAGE_PATH do |message|
20
+ assert_match "class OrderConfirmationMessage", message
21
+ assert_match "include Listrak::TransactionalMessage", message
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ decorate CategorizationTest, with: :listrak do
5
+ def test_secondary
6
+ product = create_product name: 'foo'
7
+ categorization = Categorization.new(product)
8
+ create_category product_ids: [product.id], created_at: 1.day.ago
9
+ category_two = create_category product_ids: [product.id], created_at: 2.hours.ago
10
+ create_category product_ids: [product.id]
11
+
12
+ assert_equal category_two, categorization.secondary_model
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Listrak
5
+ class DataApi::CustomersTest < TestCase
6
+ def test_import
7
+ VCR.use_cassette 'listrak/data_api/customers_import-successful' do
8
+ user = create_user(addresses: [
9
+ {
10
+ first_name: 'Ben',
11
+ last_name: 'Crouse',
12
+ street: '22 S. 3rd St.',
13
+ street_2: 'Second Floor',
14
+ city: 'Philadelphia',
15
+ region: 'PA',
16
+ postal_code: '19106',
17
+ country: 'US'
18
+ }
19
+ ])
20
+
21
+ customer_form = Listrak::Models::CustomerForm.new(user)
22
+
23
+ data_api.customers.import [customer_form]
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def data_api
30
+ @data_api ||= Listrak::DataApi.new client_id: 'a',
31
+ client_secret: 'ZMOhwRN2MhkP0xicWzcu1rtEY9sjDUq/reVovZOY41U'
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Listrak
5
+ class DataApi::OrdersTest < TestCase
6
+ def test_import
7
+ VCR.use_cassette 'listrak/data_api/orders_import-successful' do
8
+ order = create_placed_order
9
+
10
+ order_form = Listrak::Models::OrderForm.new(order)
11
+
12
+ data_api.orders.import [order_form]
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def data_api
19
+ @data_api ||= Listrak::DataApi.new client_id: 'a',
20
+ client_secret: 'ZMOhwRN2MhkP0xicWzcu1rtEY9sjDUq/reVovZOY41U'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Listrak
5
+ class DataApi::ProductsTest < TestCase
6
+ def test_import
7
+ VCR.use_cassette 'listrak/data_api/products_import-successful' do
8
+ product = create_product
9
+
10
+ product_forms = product.skus.map do |sku|
11
+ create_inventory id: sku
12
+ Listrak::Models::ProductForm.new(product, sku)
13
+ end
14
+
15
+ data_api.products.import product_forms
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def data_api
22
+ @data_api ||= Listrak::DataApi.new client_id: 'a',
23
+ client_secret: 'ZMOhwRN2MhkP0xicWzcu1rtEY9sjDUq/reVovZOY41U'
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,55 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Listrak
5
+ class EmailApi::ContactsTest < TestCase
6
+ def test_upsert
7
+ VCR.use_cassette 'listrak/email_api/contacts_upsert-successful' do
8
+ contact = Listrak::Models::ContactForm.new(
9
+ email: 'customer+new@workarea.com',
10
+ subscription_state: 'Subscribed'
11
+ )
12
+
13
+ email_api.contacts.upsert(349984, contact)
14
+ end
15
+ end
16
+
17
+ def test_upsert_already_unsubscribed
18
+ VCR.use_cassette 'listrak/email_api/contacts_upsert-already_unsubscribed' do
19
+ contact = Listrak::Models::ContactForm.new(
20
+ email: 'customer@workarea.com',
21
+ subscription_state: 'Subscribed'
22
+ )
23
+
24
+ error = assert_raises Workarea::Listrak::HttpError do
25
+ email_api.contacts.upsert(349984, contact)
26
+ end
27
+
28
+ assert_equal "ERROR_UNSUBSCRIBED_EMAIL_ADDRESS", error.error_code
29
+ assert_equal "The emailAddress has already been unsubscribed from the list.", error.api_message
30
+ end
31
+ end
32
+
33
+ def test_get
34
+ VCR.use_cassette 'listrak/email_api/contacts_get-successful' do
35
+ contact = email_api.contacts.get(349984, "customer@workarea.com")
36
+
37
+ assert_equal "customer@workarea.com", contact.email_address
38
+ assert_equal "E423056525030584442F94FD29", contact.email_key
39
+ assert_equal "Unsubscribed", contact.subscription_state
40
+ assert_equal DateTime.parse("2018-12-14T14:31:55", "%FT%T"), contact.subscribe_date
41
+ assert_nil contact.subscribe_method
42
+ assert_equal DateTime.parse("2018-12-15T13:15:01", "%FT%T"), contact.unsubscribe_date
43
+ assert_equal "Administrator", contact.unsubscribe_method
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def email_api
50
+ @email_api ||= Listrak::EmailApi.new client_id: 'doyfni0aw64ogd84ld6t',
51
+ client_secret: 'LxdEE4Gu4aSJv5tS9osd8WudjGbJ+EIPYvZBS7bc5JU'
52
+ end
53
+ end
54
+ end
55
+ end