workarea-product_quickview 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintrc +24 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  5. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  6. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  7. data/.gitignore +15 -0
  8. data/.scss-lint.yml +192 -0
  9. data/CHANGELOG.md +153 -0
  10. data/CODE_OF_CONDUCT.md +3 -0
  11. data/CONTRIBUTING.md +3 -0
  12. data/Gemfile +9 -0
  13. data/LICENSE +52 -0
  14. data/README.md +68 -0
  15. data/Rakefile +43 -0
  16. data/app/assets/javascripts/workarea/storefront/product_quickview/modules/quickview_button_placeholders.js +47 -0
  17. data/app/assets/javascripts/workarea/storefront/product_quickview/templates/quickview_button.jst.ejs +3 -0
  18. data/app/assets/stylesheets/workarea/storefront/product_quickview/components/_quickview_button.scss +20 -0
  19. data/app/controllers/workarea/storefront/products_controller.decorator +10 -0
  20. data/app/helpers/workarea/storefront/product_quickview_helper.rb +19 -0
  21. data/app/models/workarea/catalog/product.decorator +13 -0
  22. data/app/views/workarea/storefront/products/_quickview_button_placeholder.html.haml +2 -0
  23. data/app/views/workarea/storefront/products/quickview.html.haml +3 -0
  24. data/bin/rails +18 -0
  25. data/config/initializers/appends.rb +21 -0
  26. data/config/initializers/configuration.rb +10 -0
  27. data/config/locales/en.yml +6 -0
  28. data/config/routes.rb +2 -0
  29. data/lib/workarea/product_quickview.rb +11 -0
  30. data/lib/workarea/product_quickview/engine.rb +12 -0
  31. data/lib/workarea/product_quickview/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 +18 -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 +83 -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/session_store.rb +3 -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/lib/assets/.keep +0 -0
  74. data/test/dummy/log/.keep +0 -0
  75. data/test/helpers/workarea/storefront/product_quickview_helper_test.rb +33 -0
  76. data/test/models/workarea/product_quickview_test.rb +20 -0
  77. data/test/system/workarea/storefront/analytics_system_test.decorator +31 -0
  78. data/test/system/workarea/storefront/products_quickview_system_test.rb +65 -0
  79. data/test/test_helper.rb +10 -0
  80. data/workarea-product_quickview.gemspec +24 -0
  81. metadata +136 -0
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,5 @@
1
+ Workarea.configure do |config|
2
+ # Basic site info
3
+ config.site_name = 'Workarea Product Quickview'
4
+ config.host = 'www.example.com'
5
+ end
@@ -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,22 @@
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: f15cbdafb7351f10cac83e6e60b3a3616d7614f39e63127cdd2089438ddf9191667a1126940948a51d58453163a7f48cd651227affe1160c5f25b2536ea8f1b1
15
+
16
+ test:
17
+ secret_key_base: dd88d023b21313d0d4bf63e01d17ec3e737f3fb67040ae7ca36850a5b3d1aeb22652ca72a06cc2c759e6e2ca40fb8bae4dce26cbd1282801b240306c461cea25
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
File without changes
File without changes
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class ProductQuickviewHelperTest < ViewTest
6
+ include Workarea::Storefront::Engine.routes.url_helpers
7
+ include AnalyticsHelper
8
+ include Workarea::TestCase::SearchIndexing
9
+
10
+ def test_quickview_button_data
11
+ model = create_product
12
+ view_model = ProductViewModel.wrap(model)
13
+
14
+ result = quickview_button_data(view_model)
15
+
16
+ assert_includes(result, :url)
17
+ assert_includes(result, :analytics_data)
18
+ assert_includes(result.to_s, view_model.id)
19
+ end
20
+
21
+ def test_product_quickview_analytics_data
22
+ model = create_product
23
+ view_model = ProductViewModel.wrap(model)
24
+
25
+ result = product_quickview_analytics_data(view_model)
26
+
27
+ assert_includes(result, :event)
28
+ assert_includes(result, :payload)
29
+ assert_includes(result.to_s, view_model.id)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ class ProductQuickviewTest < TestCase
5
+ def test_quickview
6
+ Workarea.with_config do |config|
7
+ config.product_templates = %i(generic package)
8
+ config.product_quickview_templates = %i(generic)
9
+
10
+ product = create_product
11
+
12
+ product.template = 'generic'
13
+ assert product.quickview?
14
+
15
+ product.template = 'package'
16
+ refute product.quickview?
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ decorate Storefront::AnalyticsSystemTest, with: :product_quickview do
5
+ def test_announcing_product_quickview_event
6
+ Workarea.with_config do |config|
7
+ config.product_quickview_templates = %i(
8
+ generic
9
+ test_product
10
+ )
11
+
12
+ visit storefront.category_path(@category)
13
+
14
+ first('.product-summary').hover
15
+ click_link t('workarea.storefront.products.quick_view')
16
+
17
+ wait_for_xhr
18
+
19
+ events = find_analytics_events(for_event: 'productQuickview')
20
+ assert_equal(1, events.count)
21
+ payload = events.first['arguments'].first
22
+ assert_equal('PROD2', payload['id'])
23
+ assert_equal('Test Product 2', payload['name'])
24
+ assert_equal(false, payload['sale'])
25
+ assert_equal(12, payload['price'])
26
+ assert_equal('Test Category', payload['category'])
27
+ assert_page_view
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class ProductQuickviewSystemTest < Workarea::SystemTest
6
+ include Storefront::SystemTest
7
+
8
+ setup :set_products
9
+ setup :set_category
10
+
11
+ def set_products
12
+ @products = [
13
+ create_product(
14
+ id: 'PROD1',
15
+ name: 'Test Product 1',
16
+ variants: [{ sku: 'SKU1', regular: 10.to_m }],
17
+ filters: { 'Size' => 'Medium', 'Color' => 'Blue' }
18
+ ),
19
+ create_product(
20
+ id: 'PROD2',
21
+ name: 'Test Product 2',
22
+ variants: [{ sku: 'SKU2', regular: 12.to_m }],
23
+ filters: {
24
+ 'Size' => ['Medium', 'Small'],
25
+ 'Color' => ['Blue', 'Green']
26
+ }
27
+ )
28
+ ]
29
+ end
30
+
31
+ def set_category
32
+ @category = create_category(
33
+ name: 'Test Category',
34
+ product_ids: [@products.second.id, @products.first.id]
35
+ )
36
+ end
37
+
38
+ def test_opening_product_quickview
39
+ Workarea.with_config do |config|
40
+ config.product_quickview_templates = [@products.first.template.to_sym]
41
+ visit storefront.category_path(@category)
42
+
43
+ first('.product-summary').hover
44
+
45
+ assert_text t('workarea.storefront.products.quick_view')
46
+
47
+ click_link t('workarea.storefront.products.quick_view')
48
+ wait_for_xhr
49
+ assert_selector('.ui-dialog')
50
+ end
51
+ end
52
+
53
+ def test_disabled_product_quickview
54
+ Workarea.with_config do |config|
55
+ config.product_quickview_templates = []
56
+ visit storefront.category_path(@category)
57
+
58
+ first('.product-summary').hover
59
+
60
+ refute_text t('workarea.storefront.products.quick_view')
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,10 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+
4
+ require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
5
+ require 'rails/test_help'
6
+ require 'workarea/test_help'
7
+
8
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
9
+ # to be shown.
10
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
@@ -0,0 +1,24 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'workarea/product_quickview/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'workarea-product_quickview'
9
+ s.version = Workarea::ProductQuickview::VERSION
10
+ s.authors = ['Jordan Stewart']
11
+ s.email = ['jstewart@weblinc.com']
12
+ s.homepage = 'https://github.com/workarea-commerce/workarea-product-quickview'
13
+ s.summary = 'Product Quickview'
14
+ s.description = 'Adds product quickview button to product summaries'
15
+ s.files = `git ls-files`.split("\n")
16
+ s.license = 'Business Software License'
17
+ # s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
18
+ # s.license = 'Business Software License'
19
+
20
+ s.required_ruby_version = '>= 2.3.0'
21
+
22
+ s.add_dependency 'workarea', '~> 3.x'
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workarea-product_quickview
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Stewart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-23 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.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.x
27
+ description: Adds product quickview button to product summaries
28
+ email:
29
+ - jstewart@weblinc.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".editorconfig"
35
+ - ".eslintrc"
36
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
37
+ - ".github/ISSUE_TEMPLATE/documentation-request.md"
38
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
39
+ - ".gitignore"
40
+ - ".scss-lint.yml"
41
+ - CHANGELOG.md
42
+ - CODE_OF_CONDUCT.md
43
+ - CONTRIBUTING.md
44
+ - Gemfile
45
+ - LICENSE
46
+ - README.md
47
+ - Rakefile
48
+ - app/assets/javascripts/workarea/storefront/product_quickview/modules/quickview_button_placeholders.js
49
+ - app/assets/javascripts/workarea/storefront/product_quickview/templates/quickview_button.jst.ejs
50
+ - app/assets/stylesheets/workarea/storefront/product_quickview/components/_quickview_button.scss
51
+ - app/controllers/workarea/storefront/products_controller.decorator
52
+ - app/helpers/workarea/storefront/product_quickview_helper.rb
53
+ - app/models/workarea/catalog/product.decorator
54
+ - app/views/workarea/storefront/products/_quickview_button_placeholder.html.haml
55
+ - app/views/workarea/storefront/products/quickview.html.haml
56
+ - bin/rails
57
+ - config/initializers/appends.rb
58
+ - config/initializers/configuration.rb
59
+ - config/locales/en.yml
60
+ - config/routes.rb
61
+ - lib/workarea/product_quickview.rb
62
+ - lib/workarea/product_quickview/engine.rb
63
+ - lib/workarea/product_quickview/version.rb
64
+ - test/dummy/Rakefile
65
+ - test/dummy/app/assets/config/manifest.js
66
+ - test/dummy/app/assets/images/.keep
67
+ - test/dummy/app/assets/javascripts/application.js
68
+ - test/dummy/app/assets/stylesheets/application.css
69
+ - test/dummy/app/controllers/application_controller.rb
70
+ - test/dummy/app/controllers/concerns/.keep
71
+ - test/dummy/app/helpers/application_helper.rb
72
+ - test/dummy/app/jobs/application_job.rb
73
+ - test/dummy/app/mailers/application_mailer.rb
74
+ - test/dummy/app/models/concerns/.keep
75
+ - test/dummy/app/views/layouts/application.html.erb
76
+ - test/dummy/app/views/layouts/mailer.html.erb
77
+ - test/dummy/app/views/layouts/mailer.text.erb
78
+ - test/dummy/bin/bundle
79
+ - test/dummy/bin/rails
80
+ - test/dummy/bin/rake
81
+ - test/dummy/bin/setup
82
+ - test/dummy/bin/update
83
+ - test/dummy/config.ru
84
+ - test/dummy/config/application.rb
85
+ - test/dummy/config/boot.rb
86
+ - test/dummy/config/cable.yml
87
+ - test/dummy/config/environment.rb
88
+ - test/dummy/config/environments/development.rb
89
+ - test/dummy/config/environments/production.rb
90
+ - test/dummy/config/environments/test.rb
91
+ - test/dummy/config/initializers/application_controller_renderer.rb
92
+ - test/dummy/config/initializers/assets.rb
93
+ - test/dummy/config/initializers/backtrace_silencers.rb
94
+ - test/dummy/config/initializers/cookies_serializer.rb
95
+ - test/dummy/config/initializers/filter_parameter_logging.rb
96
+ - test/dummy/config/initializers/inflections.rb
97
+ - test/dummy/config/initializers/mime_types.rb
98
+ - test/dummy/config/initializers/session_store.rb
99
+ - test/dummy/config/initializers/workarea.rb
100
+ - test/dummy/config/initializers/wrap_parameters.rb
101
+ - test/dummy/config/locales/en.yml
102
+ - test/dummy/config/puma.rb
103
+ - test/dummy/config/routes.rb
104
+ - test/dummy/config/secrets.yml
105
+ - test/dummy/lib/assets/.keep
106
+ - test/dummy/log/.keep
107
+ - test/helpers/workarea/storefront/product_quickview_helper_test.rb
108
+ - test/models/workarea/product_quickview_test.rb
109
+ - test/system/workarea/storefront/analytics_system_test.decorator
110
+ - test/system/workarea/storefront/products_quickview_system_test.rb
111
+ - test/test_helper.rb
112
+ - workarea-product_quickview.gemspec
113
+ homepage: https://github.com/workarea-commerce/workarea-product-quickview
114
+ licenses:
115
+ - Business Software License
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 2.3.0
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.0.6
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Product Quickview
136
+ test_files: []