rack-ga-track 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/rack-ga-track.gemspec +2 -2
- data/spec/rack_ga_track_spec.rb +21 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93ddc3baec8a82c8c825ca814f3f200616fa832a
|
4
|
+
data.tar.gz: 4edbd555eab633ea6c745c7bc76c6ca721158dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85c93d08f15abd364558dba7aa121bb616c88d123a84740f135ef5291b22df256d820824a10c4b6e78b07139c4cd727aa5785d0587ebd379dcb155928b1b7973
|
7
|
+
data.tar.gz: 3bf5fcf603a4df08c8c3a6efc5a4633937e5f73f75f85a3130cfc4172b3140fb781811818488318abd402104208014cb6bd2b5471aab5aaf960589211a3951dc
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/rack-ga-track.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rack-ga-track 0.
|
5
|
+
# stub: rack-ga-track 0.4.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rack-ga-track"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.4.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/spec/rack_ga_track_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
describe "RackGaTrack" do
|
4
5
|
before :each do
|
@@ -21,14 +22,14 @@ describe "RackGaTrack" do
|
|
21
22
|
@time = Time.now
|
22
23
|
params = { utm_source: 'testing',
|
23
24
|
utm_campaign: 'email',
|
24
|
-
|
25
|
+
utm_medium: 'test_medium' }
|
25
26
|
|
26
27
|
get '/', params
|
27
28
|
end
|
28
29
|
|
29
30
|
last_request.env['ga_track.source'].must_equal "testing"
|
30
31
|
last_request.env['ga_track.campaign'].must_equal "email"
|
31
|
-
last_request.env['ga_track.
|
32
|
+
last_request.env['ga_track.medium'].must_equal "test_medium"
|
32
33
|
last_request.env['ga_track.time'].must_equal @time.to_i
|
33
34
|
end
|
34
35
|
|
@@ -37,25 +38,28 @@ describe "RackGaTrack" do
|
|
37
38
|
@time = Time.now
|
38
39
|
params = { utm_source: 'testing',
|
39
40
|
utm_campaign: 'email',
|
40
|
-
|
41
|
+
utm_medium: 'test_medium' }
|
41
42
|
|
42
43
|
get '/', params
|
43
44
|
end
|
44
45
|
|
45
|
-
rack_mock_session.cookie_jar["
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
cookie_params = JSON.parse(rack_mock_session.cookie_jar["ga_track"])
|
47
|
+
|
48
|
+
cookie_params["source"].must_equal "testing"
|
49
|
+
cookie_params["campaign"].must_equal "email"
|
50
|
+
cookie_params["medium"].must_equal "test_medium"
|
51
|
+
cookie_params["time"].must_equal @time.to_i
|
49
52
|
end
|
50
53
|
|
51
54
|
describe "when cookie exists" do
|
52
55
|
before :each do
|
53
56
|
@time = Time.now
|
54
57
|
clear_cookies
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
@params = { source: 'testing',
|
59
|
+
campaign: 'email',
|
60
|
+
medium: 'test_medium',
|
61
|
+
time: @time.to_i }
|
62
|
+
rack_mock_session.cookie_jar["ga_track"] = @params.to_json
|
59
63
|
end
|
60
64
|
|
61
65
|
it "should restore GA Campaign params from cookie" do
|
@@ -65,7 +69,7 @@ describe "RackGaTrack" do
|
|
65
69
|
|
66
70
|
last_request.env['ga_track.source'].must_equal "testing"
|
67
71
|
last_request.env['ga_track.campaign'].must_equal "email"
|
68
|
-
last_request.env['ga_track.
|
72
|
+
last_request.env['ga_track.medium'].must_equal "test_medium"
|
69
73
|
last_request.env['ga_track.time'].must_equal @time.to_i
|
70
74
|
end
|
71
75
|
|
@@ -76,25 +80,23 @@ describe "RackGaTrack" do
|
|
76
80
|
|
77
81
|
last_request.env['ga_track.source'].must_equal "testing"
|
78
82
|
last_request.env['ga_track.campaign'].must_equal "email"
|
79
|
-
last_request.env['ga_track.
|
83
|
+
last_request.env['ga_track.medium'].must_equal "test_medium"
|
80
84
|
last_request.env['ga_track.time'].must_equal @time.to_i
|
81
85
|
|
82
|
-
rack_mock_session.cookie_jar["
|
83
|
-
rack_mock_session.cookie_jar["utm_campaign"].must_equal "email"
|
84
|
-
rack_mock_session.cookie_jar["utm_content"].must_equal "test_content"
|
85
|
-
rack_mock_session.cookie_jar["utm_time"].must_equal "#{@time.to_i}"
|
86
|
+
rack_mock_session.cookie_jar["ga_track"].must_equal JSON.generate(@params)
|
86
87
|
end
|
87
88
|
|
88
89
|
it 'should update existing cookie if utm_source is present in url params' do
|
89
90
|
Timecop.freeze(60*60*24) do
|
90
91
|
params = { utm_source: 'cool_source',
|
91
92
|
utm_campaign: 'email',
|
92
|
-
|
93
|
+
utm_medium: 'test_medium' }
|
93
94
|
|
94
95
|
get '/', params
|
95
96
|
end
|
97
|
+
cookie_params = JSON.parse(rack_mock_session.cookie_jar["ga_track"])
|
96
98
|
|
97
|
-
|
99
|
+
cookie_params["source"].must_equal "cool_source"
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|