workarea-product_videos 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +16 -0
  3. data/.eslintrc +27 -0
  4. data/.gitignore +19 -0
  5. data/.rails-rubocop.yml +119 -0
  6. data/.rubocop.yml +7 -0
  7. data/.scss-lint.yml +192 -0
  8. data/CHANGELOG.md +92 -0
  9. data/Gemfile +16 -0
  10. data/README.md +87 -0
  11. data/Rakefile +60 -0
  12. data/app/assets/images/workarea/admin/icons/video.svg +1 -0
  13. data/app/assets/images/workarea/storefront/icons/video_play.svg +1 -0
  14. data/app/assets/javascripts/workarea/storefront/product_videos/modules/vimeo_api.js +81 -0
  15. data/app/assets/javascripts/workarea/storefront/product_videos/modules/youtube_api.js +124 -0
  16. data/app/assets/stylesheets/workarea/storefront/product_videos/components/_product_video.scss +37 -0
  17. data/app/controllers/workarea/admin/catalog_product_videos_controller.rb +52 -0
  18. data/app/controllers/workarea/storefront/products_controller.decorator +19 -0
  19. data/app/models/workarea/catalog/product.decorator +7 -0
  20. data/app/models/workarea/catalog/product_video.rb +32 -0
  21. data/app/services/workarea/video_embed_parser.rb +54 -0
  22. data/app/view_models/workarea/storefront/product_video_view_model.rb +84 -0
  23. data/app/view_models/workarea/storefront/product_view_model.decorator +9 -0
  24. data/app/views/workarea/admin/catalog_product_videos/edit.html.haml +76 -0
  25. data/app/views/workarea/admin/catalog_product_videos/index.html.haml +46 -0
  26. data/app/views/workarea/admin/catalog_product_videos/new.html.haml +57 -0
  27. data/app/views/workarea/admin/catalog_products/_product_videos_card.html.haml +21 -0
  28. data/app/views/workarea/storefront/products/_video_link.html.haml +8 -0
  29. data/app/views/workarea/storefront/products/_video_thumbnail.html.haml +12 -0
  30. data/app/views/workarea/storefront/products/video.html.haml +3 -0
  31. data/bin/rails +20 -0
  32. data/config/initializers/appends.rb +37 -0
  33. data/config/initializers/product_videos.rb +5 -0
  34. data/config/initializers/workarea.rb +3 -0
  35. data/config/locales/en.yml +41 -0
  36. data/config/routes.rb +15 -0
  37. data/lib/workarea/product_videos/engine.rb +8 -0
  38. data/lib/workarea/product_videos/version.rb +5 -0
  39. data/lib/workarea/product_videos.rb +11 -0
  40. data/script/admin_ci +9 -0
  41. data/script/ci +11 -0
  42. data/script/core_ci +9 -0
  43. data/script/plugins_ci +9 -0
  44. data/script/storefront_ci +9 -0
  45. data/test/dummy/Rakefile +6 -0
  46. data/test/dummy/app/assets/config/manifest.js +4 -0
  47. data/test/dummy/app/assets/images/.keep +0 -0
  48. data/test/dummy/app/assets/javascripts/application.js +13 -0
  49. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  50. data/test/dummy/app/controllers/application_controller.rb +3 -0
  51. data/test/dummy/app/controllers/concerns/.keep +0 -0
  52. data/test/dummy/app/helpers/application_helper.rb +2 -0
  53. data/test/dummy/app/jobs/application_job.rb +2 -0
  54. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  55. data/test/dummy/app/models/concerns/.keep +0 -0
  56. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  57. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  58. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  59. data/test/dummy/bin/bundle +3 -0
  60. data/test/dummy/bin/rails +4 -0
  61. data/test/dummy/bin/rake +4 -0
  62. data/test/dummy/bin/setup +38 -0
  63. data/test/dummy/bin/update +29 -0
  64. data/test/dummy/bin/yarn +11 -0
  65. data/test/dummy/config/application.rb +29 -0
  66. data/test/dummy/config/boot.rb +5 -0
  67. data/test/dummy/config/cable.yml +10 -0
  68. data/test/dummy/config/environment.rb +5 -0
  69. data/test/dummy/config/environments/development.rb +54 -0
  70. data/test/dummy/config/environments/production.rb +91 -0
  71. data/test/dummy/config/environments/test.rb +44 -0
  72. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  73. data/test/dummy/config/initializers/assets.rb +14 -0
  74. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  75. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  76. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  77. data/test/dummy/config/initializers/inflections.rb +16 -0
  78. data/test/dummy/config/initializers/mime_types.rb +4 -0
  79. data/test/dummy/config/initializers/new_framework_defaults.rb +23 -0
  80. data/test/dummy/config/initializers/session_store.rb +3 -0
  81. data/test/dummy/config/initializers/workarea.rb +5 -0
  82. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  83. data/test/dummy/config/locales/en.yml +33 -0
  84. data/test/dummy/config/puma.rb +56 -0
  85. data/test/dummy/config/routes.rb +5 -0
  86. data/test/dummy/config/secrets.yml +32 -0
  87. data/test/dummy/config/spring.rb +6 -0
  88. data/test/dummy/config.ru +5 -0
  89. data/test/dummy/db/seeds.rb +2 -0
  90. data/test/dummy/lib/assets/.keep +0 -0
  91. data/test/dummy/log/.keep +0 -0
  92. data/test/dummy/package.json +5 -0
  93. data/test/factories/embed_codes.rb +15 -0
  94. data/test/integration/workarea/admin/product_videos_integration_test.rb +59 -0
  95. data/test/integration/workarea/storefront/product_videos_integration_test.rb +30 -0
  96. data/test/services/workarea/video_embedder_test.rb +27 -0
  97. data/test/system/workarea/admin/product_videos_system_test.rb +58 -0
  98. data/test/system/workarea/storefront/product_videos_system_test.rb +60 -0
  99. data/test/teaspoon_env.rb +6 -0
  100. data/test/test_helper.rb +10 -0
  101. data/test/view_models/workarea/storefront/product_video_view_model_test.rb +46 -0
  102. data/workarea-product_videos.gemspec +19 -0
  103. metadata +157 -0
@@ -0,0 +1,60 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class ProductVideosSystemTest < Workarea::SystemTest
6
+ include Storefront::SystemTest
7
+
8
+ def test_showing_embedded_videos_on_product_detail_page
9
+ product = create_product(
10
+ name: "Awesome Product with embedded video",
11
+ videos: [{ embed_code: youtube_embed, display_option: "embedded" }]
12
+ )
13
+
14
+ visit storefront.product_path(product)
15
+
16
+ assert(page.has_selector?("iframe.product-video__iframe"))
17
+ end
18
+
19
+ def test_showing_dialog_videos_on_product_detail_page
20
+ product = create_product(
21
+ name: "Awesome Product with dialog video",
22
+ videos: [{ embed_code: youtube_embed, display_option: "dialog" }]
23
+ )
24
+
25
+ visit storefront.product_path(product)
26
+
27
+ assert(page.has_content?(t("workarea.storefront.products.watch_this_video")))
28
+
29
+ click_link t("workarea.storefront.products.watch_this_video")
30
+ wait_for_xhr
31
+
32
+ assert(page.has_selector?("iframe.product-video__iframe"))
33
+ end
34
+
35
+ def test_showing_thumbnail_videos_on_product_detail_page
36
+ product = create_product(
37
+ name: "Awesome Product with thumbnail video",
38
+ videos: [{ embed_code: youtube_embed, display_option: "thumbnail" }]
39
+ )
40
+
41
+ product.images.build(image: product_image_file_path, option: "green", position: 0).save
42
+ product.images.build(image: product_image_file_path, option: "red", position: 1).save
43
+ product.save
44
+
45
+ visit storefront.product_path(product)
46
+
47
+ assert(page.has_selector?(".product-video__thumbnail"))
48
+ refute(page.has_selector?("iframe.product-video__iframe"))
49
+
50
+ within ".product-details__alt-images" do
51
+ page.find(".product-video--thumbnail").click
52
+ end
53
+
54
+ wait_for_xhr
55
+
56
+ assert(page.has_selector?("iframe.product-video__iframe"))
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,6 @@
1
+ require "workarea/testing/teaspoon"
2
+
3
+ Teaspoon.configure do |config|
4
+ config.root = Workarea::ProductVideos::Engine.root
5
+ Workarea::Teaspoon.apply(config)
6
+ 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,46 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class ProductVideoViewModelTest < TestCase
6
+ def test_iframe_attrs_for_all_videos
7
+ @product = create_product(
8
+ name: "test",
9
+ videos: [{ embed_code: youtube_embed, display_option: "embedded" }]
10
+ )
11
+
12
+ view_model = ProductVideoViewModel.wrap(@product.videos.first)
13
+ assert_equal("youtube-rSGnNMnvM6M", view_model.iframe_attrs[:id])
14
+ assert_equal("0", view_model.iframe_attrs[:frameborder])
15
+ assert_equal("padding-bottom: 56.25%", view_model.iframe_attrs[:container_style])
16
+ assert_equal("", view_model.iframe_attrs[:allowfullscreen])
17
+ end
18
+
19
+ def test_iframe_attrs_for_youtube_videos
20
+ @product = create_product(
21
+ name: "test",
22
+ videos: [{ embed_code: youtube_embed, display_option: "embedded" }]
23
+ )
24
+
25
+ view_model = ProductVideoViewModel.wrap(@product.videos.first)
26
+ assert_equal("https://www.youtube.com/embed/rSGnNMnvM6M?enablejsapi=1&autoplay=0&loop=0&videoId=youtube-rSGnNMnvM6M", view_model.iframe_attrs[:src])
27
+ assert(view_model.iframe_attrs[:data].key?(:youtube_api))
28
+ end
29
+
30
+ def test_iframe_attrs_for_youtube_video
31
+ @product = create_product(
32
+ name: "vimeo test",
33
+ videos: [{ embed_code: vimeo_embed, display_option: "embedded" }]
34
+ )
35
+
36
+ view_model = ProductVideoViewModel.wrap(@product.videos.first)
37
+ assert_equal("153825647", view_model.iframe_attrs[:id])
38
+ assert_equal("padding-bottom: 56.25%", view_model.iframe_attrs[:container_style])
39
+ assert_equal("https://player.vimeo.com/video/153825647?api=1&autoplay&loop&player_id=153825647", view_model.iframe_attrs[:src])
40
+ assert_equal("", view_model.iframe_attrs[:webkitallowfullscreen])
41
+ assert_equal("", view_model.iframe_attrs[:mozallowfullscreen])
42
+ assert(view_model.iframe_attrs[:data].key?(:vimeo_api))
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "workarea/product_videos/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "workarea-product_videos"
9
+ s.version = Workarea::ProductVideos::VERSION
10
+ s.authors = ["F.M. Bonnevier"]
11
+ s.email = ["fbonnevier@weblinc.com"]
12
+ s.homepage = "https://stash.tools.weblinc.com/projects/WP/repos/workarea-product-videos/browse"
13
+ s.summary = "Product Videos for the Workarea Ecommerce platform"
14
+ s.description = "Adds youtube and vimeo video embedding to products."
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+
18
+ s.add_dependency "workarea", "~> 3.x"
19
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workarea-product_videos
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.2
5
+ platform: ruby
6
+ authors:
7
+ - F.M. Bonnevier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-21 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 youtube and vimeo video embedding to products.
28
+ email:
29
+ - fbonnevier@weblinc.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".editorconfig"
35
+ - ".eslintrc"
36
+ - ".gitignore"
37
+ - ".rails-rubocop.yml"
38
+ - ".rubocop.yml"
39
+ - ".scss-lint.yml"
40
+ - CHANGELOG.md
41
+ - Gemfile
42
+ - README.md
43
+ - Rakefile
44
+ - app/assets/images/workarea/admin/icons/video.svg
45
+ - app/assets/images/workarea/storefront/icons/video_play.svg
46
+ - app/assets/javascripts/workarea/storefront/product_videos/modules/vimeo_api.js
47
+ - app/assets/javascripts/workarea/storefront/product_videos/modules/youtube_api.js
48
+ - app/assets/stylesheets/workarea/storefront/product_videos/components/_product_video.scss
49
+ - app/controllers/workarea/admin/catalog_product_videos_controller.rb
50
+ - app/controllers/workarea/storefront/products_controller.decorator
51
+ - app/models/workarea/catalog/product.decorator
52
+ - app/models/workarea/catalog/product_video.rb
53
+ - app/services/workarea/video_embed_parser.rb
54
+ - app/view_models/workarea/storefront/product_video_view_model.rb
55
+ - app/view_models/workarea/storefront/product_view_model.decorator
56
+ - app/views/workarea/admin/catalog_product_videos/edit.html.haml
57
+ - app/views/workarea/admin/catalog_product_videos/index.html.haml
58
+ - app/views/workarea/admin/catalog_product_videos/new.html.haml
59
+ - app/views/workarea/admin/catalog_products/_product_videos_card.html.haml
60
+ - app/views/workarea/storefront/products/_video_link.html.haml
61
+ - app/views/workarea/storefront/products/_video_thumbnail.html.haml
62
+ - app/views/workarea/storefront/products/video.html.haml
63
+ - bin/rails
64
+ - config/initializers/appends.rb
65
+ - config/initializers/product_videos.rb
66
+ - config/initializers/workarea.rb
67
+ - config/locales/en.yml
68
+ - config/routes.rb
69
+ - lib/workarea/product_videos.rb
70
+ - lib/workarea/product_videos/engine.rb
71
+ - lib/workarea/product_videos/version.rb
72
+ - script/admin_ci
73
+ - script/ci
74
+ - script/core_ci
75
+ - script/plugins_ci
76
+ - script/storefront_ci
77
+ - test/dummy/Rakefile
78
+ - test/dummy/app/assets/config/manifest.js
79
+ - test/dummy/app/assets/images/.keep
80
+ - test/dummy/app/assets/javascripts/application.js
81
+ - test/dummy/app/assets/stylesheets/application.css
82
+ - test/dummy/app/controllers/application_controller.rb
83
+ - test/dummy/app/controllers/concerns/.keep
84
+ - test/dummy/app/helpers/application_helper.rb
85
+ - test/dummy/app/jobs/application_job.rb
86
+ - test/dummy/app/mailers/application_mailer.rb
87
+ - test/dummy/app/models/concerns/.keep
88
+ - test/dummy/app/views/layouts/application.html.erb
89
+ - test/dummy/app/views/layouts/mailer.html.erb
90
+ - test/dummy/app/views/layouts/mailer.text.erb
91
+ - test/dummy/bin/bundle
92
+ - test/dummy/bin/rails
93
+ - test/dummy/bin/rake
94
+ - test/dummy/bin/setup
95
+ - test/dummy/bin/update
96
+ - test/dummy/bin/yarn
97
+ - test/dummy/config.ru
98
+ - test/dummy/config/application.rb
99
+ - test/dummy/config/boot.rb
100
+ - test/dummy/config/cable.yml
101
+ - test/dummy/config/environment.rb
102
+ - test/dummy/config/environments/development.rb
103
+ - test/dummy/config/environments/production.rb
104
+ - test/dummy/config/environments/test.rb
105
+ - test/dummy/config/initializers/application_controller_renderer.rb
106
+ - test/dummy/config/initializers/assets.rb
107
+ - test/dummy/config/initializers/backtrace_silencers.rb
108
+ - test/dummy/config/initializers/cookies_serializer.rb
109
+ - test/dummy/config/initializers/filter_parameter_logging.rb
110
+ - test/dummy/config/initializers/inflections.rb
111
+ - test/dummy/config/initializers/mime_types.rb
112
+ - test/dummy/config/initializers/new_framework_defaults.rb
113
+ - test/dummy/config/initializers/session_store.rb
114
+ - test/dummy/config/initializers/workarea.rb
115
+ - test/dummy/config/initializers/wrap_parameters.rb
116
+ - test/dummy/config/locales/en.yml
117
+ - test/dummy/config/puma.rb
118
+ - test/dummy/config/routes.rb
119
+ - test/dummy/config/secrets.yml
120
+ - test/dummy/config/spring.rb
121
+ - test/dummy/db/seeds.rb
122
+ - test/dummy/lib/assets/.keep
123
+ - test/dummy/log/.keep
124
+ - test/dummy/package.json
125
+ - test/factories/embed_codes.rb
126
+ - test/integration/workarea/admin/product_videos_integration_test.rb
127
+ - test/integration/workarea/storefront/product_videos_integration_test.rb
128
+ - test/services/workarea/video_embedder_test.rb
129
+ - test/system/workarea/admin/product_videos_system_test.rb
130
+ - test/system/workarea/storefront/product_videos_system_test.rb
131
+ - test/teaspoon_env.rb
132
+ - test/test_helper.rb
133
+ - test/view_models/workarea/storefront/product_video_view_model_test.rb
134
+ - workarea-product_videos.gemspec
135
+ homepage: https://stash.tools.weblinc.com/projects/WP/repos/workarea-product-videos/browse
136
+ licenses: []
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubygems_version: 3.0.4
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Product Videos for the Workarea Ecommerce platform
157
+ test_files: []