This repository was archived by the owner on Oct 12, 2023. It is now read-only.
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
99 lines (85 loc) · 2.65 KB
/
zanox_spec.rb
File metadata and controls
99 lines (85 loc) · 2.65 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
RSpec.describe Rack::Tracker::Zanox do
describe Rack::Tracker::Zanox::Track 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
def env
{}
end
it 'will be placed in the body by default' do
expect(described_class.position).to eq({ body: :append })
expect(described_class.new(env).position).to eq({ body: :append })
expect(described_class.new(env, position: { head: :append }).position).to eq({ head: :append })
end
describe '#render a sale #tracking_event' do
context 'with events' do
let(:env) {
{
'tracker' => {
'zanox' =>
[
{
'CustomerID' => '123456',
'OrderId' => 'DEFC-4321',
'CurrencySymbol' => 'EUR',
'TotalPrice' => '150.00',
'class_name' => 'Track'
}
]
}
}
}
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]]&CustomerID=[[123456]]&OrderId=[[DEFC-4321]]&CurrencySymbol=[[EUR]]&TotalPrice=[[150.00]]"
end
end
end
describe '#render a lead #tracking_event' do
context 'with events' do
let(:env) {
{
'tracker' => {
'zanox' =>
[
{
'OrderId' => 'DEFC-4321',
'class_name' => 'Track'
}
]
}
}
}
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'
}
]
}
}
}
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"});'
end
end
end
end