spree_gtm 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a516b43e5dbb9521e988c5b3895cce4f7f06e69f
4
- data.tar.gz: 3ae83ff5718c00da516054d8bd46e9f9c89d834a
3
+ metadata.gz: 9d389c929db476554208a92e885b42f92d0641e5
4
+ data.tar.gz: 2b69982eda13e74b1ccf392f72b359b39bc95f13
5
5
  SHA512:
6
- metadata.gz: e2f2a9b1b9d6c8d1d13f1f6ad269a62593adf234ac123176894499f87aa004ebbb3efe39597b317271f42c6f7747b3540c45fded8d00587f3d66f402375f6024
7
- data.tar.gz: 44e23203d43166e2b3c4cbe10ffc20fd64aa3716e2951eb28e1425526b7664da1082113f84e0ed1aaa33eea3a7081900b581ba06ea4d54f8e5aad01b4b7991d7
6
+ metadata.gz: 6b854a1f76bffcd3fb174ffcffe58c014f899bfd6face06645714523c1f964a6b044bfc2cf02fa944bdfbdf3f2b7f6a052d75cc4d061210845a0d948e6cd0905
7
+ data.tar.gz: 0681127c8da864b8f2d30904556e3ebc250adf50151f1d8c29e31a8b9f92b6367235ef617aadf3455120e161562813c8e120a3f2b5d8de15f60ca813d3af40f8
@@ -16,9 +16,19 @@
16
16
  dataLayer.push({'transactionEmail': '<%= @order.email %>'});
17
17
  <% end %>
18
18
 
19
-
20
- <% if @product %>
21
- dataLayer.push({'product': [
19
+ <% if current_page?('/cart') %>
20
+ dataLayer.push({'cart': [
21
+ <%=raw @order.line_items.map { |line_item| "{ 'sku': '#{h line_item.variant.sku}',
22
+ 'name': '#{h line_item.variant.product.name}',
23
+ 'category': '',
24
+ 'price': #{h line_item.price},
25
+ 'quantity': #{h line_item.quantity}}" } .join(",") %>
26
+ ]
27
+ });
28
+ <% end %>
29
+
30
+ <% if current_page?('/products') %>
31
+ dataLayer.push({'products': [
22
32
  'name': '<%= @product.name %>',
23
33
  'sku': '<%= @product.sku %>',
24
34
  'price': '<%= @product.price %>'
@@ -30,7 +40,7 @@
30
40
  dataLayer.push({'userid': '<%= @order.user.id %>'});
31
41
  <% end %>
32
42
 
33
- <% if @order.present? && @order.bill_address.present? %>
43
+ <% if current_page?('/order') %>
34
44
 
35
45
  dataLayer.push({
36
46
  'transactionId': '<%= @order.number %>',
@@ -1,20 +1,45 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "GTM value set in controller" do
4
- context "value set in controller " do
5
- it "should render tag" do
6
- user = create(:admin_user, :email => "test@example.com", :password => "spree123")
7
- sign_in_as!(user)
8
- visit spree.admin_path
9
- click_link "Configurations"
10
- click_link "Google Tag Manager"
11
- fill_in('Gtm accountid', :with => 'bag')
12
- click_button "Save"
13
- page.should have_content("Gtm has been successfully")
14
- visit ('/')
15
- page.all('body script', visible: false).each do |script|
16
- script.text == "dataLayer, bag"
3
+ describe "Tag implementation on the pages" do
4
+
5
+ context "gtm id implement in tag " do
6
+ it "should render tag with gtm id" do
7
+ fill_in_gtm_id
8
+ visit ('/')
9
+ page.all('body script', visible: false).each do |script|
10
+ script.text == "dataLayer, bag"
11
+ end
12
+ end
13
+ end
14
+
15
+
16
+ context "tag present on cart page " do
17
+ it "should render tag" do
18
+ fill_in_gtm_id
19
+ visit ('/cart')
20
+ page.all('body script', visible: false).each do |script|
21
+ script.text == "dataLayer, cart"
22
+ end
23
+ end
24
+ end
25
+
26
+ context "tag present on product page " do
27
+ it "should render tag on product page" do
28
+ fill_in_gtm_id
29
+ visit ('/products')
30
+ page.all('body script', visible: false).each do |script|
31
+ script.text == "dataLayer, product"
32
+ end
33
+ end
34
+ end
35
+
36
+ context "tag present on order page " do
37
+ it "should render tag on order page" do
38
+ fill_in_gtm_id
39
+ visit ('/order')
40
+ page.all('body script', visible: false).each do |script|
41
+ script.text == "dataLayer, order"
42
+ end
17
43
  end
18
44
  end
19
- end
20
45
  end
@@ -6,4 +6,15 @@ module AuthenticationHelpers
6
6
  click_button "Login"
7
7
  page.should have_content("Logged in successfully")
8
8
  end
9
+
10
+ def fill_in_gtm_id
11
+ user = create(:admin_user, :email => "test@example.com", :password => "spree123")
12
+ sign_in_as!(user)
13
+ visit spree.admin_path
14
+ click_link "Configurations"
15
+ click_link "Google Tag Manager"
16
+ fill_in('Gtm accountid', :with => 'bag')
17
+ click_button "Save"
18
+ page.should have_content("Gtm has been successfully")
19
+ end
9
20
  end
data/spree_gtm.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_gtm'
5
- s.version = '0.0.18'
5
+ s.version = '0.0.19'
6
6
  s.summary = 'some summary here'
7
7
  s.description = 'some gem description here'
8
8
  s.required_ruby_version = '>= 2.1.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_gtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav O. Pogrebnyak
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-29 00:00:00.000000000 Z
12
+ date: 2016-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core