forked from railslove/rack-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzanox_spec.rb
More file actions
112 lines (94 loc) · 3.19 KB
/
zanox_spec.rb
File metadata and controls
112 lines (94 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
RSpec.describe Rack::Tracker::Zanox do
describe Rack::Tracker::Zanox::Sale do
subject { described_class.new(order_i_d: 'DEFC-4321', currency_symbol: 'EUR', total_price: '150.00') }
describe '#write' do
specify { expect(subject.write).to eq "OrderID=[[DEFC-4321]]&CurrencySymbol=[[EUR]]&TotalPrice=[[150.00]]" }
end
end
describe Rack::Tracker::Zanox::Mastertag do
subject { described_class.new(id: "25GHTE9A07DF67DFG90T", category: 'Swimming', amount: '3.50', products: [{amount: '5', currency: 'EUR'}, {amount: '6', currency: 'USD'}]) }
describe '#write' do
specify { expect(subject.write).to eq "var zx_category = \"Swimming\";\nvar zx_amount = \"3.50\";\nvar zx_products = [{\"amount\":\"5\",\"currency\":\"EUR\"},{\"amount\":\"6\",\"currency\":\"USD\"}];"}
end
end
def env
{}
end
it 'will be placed in the body' do
expect(described_class.position).to eq(:body)
expect(described_class.new(env).position).to eq(:body)
end
describe '#render #sale_events' do
context 'with events' do
let(:env) {
{
'tracker' => {
'zanox' =>
[
{
'CustomerID' => '123456',
'OrderId' => 'DEFC-4321',
'CurrencySymbol' => 'EUR',
'TotalPrice' => '150.00',
'class_name' => 'Sale',
}
]
}
}
}
subject { described_class.new(env, options).render }
let(:options) { { account_id: '123456H123456' } }
it 'will display the correct tracking events' do
expect(subject).to include "https://ad.zanox.com/pps/?123456H123456&mode=[[1]]&CustomerID=[[123456]]&OrderId=[[DEFC-4321]]&CurrencySymbol=[[EUR]]&TotalPrice=[[150.00]]"
end
end
end
describe '#render #lead_events' do
context 'with events' do
let(:env) {
{
'tracker' => {
'zanox' =>
[
{
'OrderId' => 'DEFC-4321',
'class_name' => 'Lead'
}
]
}
}
}
subject { described_class.new(env, options).render }
let(:options) { { account_id: '123456H123456' } }
it 'will display the correct tracking events' do
expect(subject).to include "https://ad.zanox.com/ppl/?123456H123456&mode=[[1]]&OrderId=[[DEFC-4321]]"
end
end
end
describe '#render a #mastertag event' do
context 'with events' do
let(:env) {
{
'tracker' => {
'zanox' =>
[
{
'id' => '12345678D2345',
'class_name' => 'Mastertag',
'category' => 'Sewing',
'identifier' => '234',
'amount' => '5.90'
}
]
}
}
}
subject { described_class.new(env, options).render }
let(:options) { { account_id: '123456H123456' } }
it 'will display the correct tracking events' do
expect(subject).to include 'window._zx.push({"id": "12345678D2345"});'
expect(subject).to include "var zx_category = \"Sewing\";\nvar zx_identifier = \"234\";\nvar zx_amount = \"5.90\";\n"
end
end
end
end