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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96ea26a2ffcda7b08aaaee34af1ea8c7e53b592a
4
- data.tar.gz: 7264ed4ca578d4bda270c3adcb36c34699f33c7e
3
+ metadata.gz: 93ddc3baec8a82c8c825ca814f3f200616fa832a
4
+ data.tar.gz: 4edbd555eab633ea6c745c7bc76c6ca721158dfa
5
5
  SHA512:
6
- metadata.gz: 89141a73848288473d97d2dbe3ab1290f44532fc5657ba74e892206fbc0ee053f3741f21fda3dc97b1852e974a51145c4bb042cba9da7b79c07e3d73e18b77f9
7
- data.tar.gz: c2b9a32cad0360b9afc5a16485f3af1523dc639cb62aa2a0df1177da2a1b33fe24137108ee08b02b442aa2e8fd45d42ef5747f0f88e2de05ac4fffb4119d9e99
6
+ metadata.gz: 85c93d08f15abd364558dba7aa121bb616c88d123a84740f135ef5291b22df256d820824a10c4b6e78b07139c4cd727aa5785d0587ebd379dcb155928b1b7973
7
+ data.tar.gz: 3bf5fcf603a4df08c8c3a6efc5a4633937e5f73f75f85a3130cfc4172b3140fb781811818488318abd402104208014cb6bd2b5471aab5aaf960589211a3951dc
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -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.3.0 ruby lib
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.3.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"]
@@ -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
- utm_content: 'test_content' }
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.content'].must_equal "test_content"
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
- utm_content: 'test_content' }
41
+ utm_medium: 'test_medium' }
41
42
 
42
43
  get '/', params
43
44
  end
44
45
 
45
- rack_mock_session.cookie_jar["utm_source"].must_equal "testing"
46
- rack_mock_session.cookie_jar["utm_campaign"].must_equal "email"
47
- rack_mock_session.cookie_jar["utm_content"].must_equal "test_content"
48
- rack_mock_session.cookie_jar["utm_time"].must_equal "#{@time.to_i}"
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
- set_cookie("utm_source=testing")
56
- set_cookie("utm_campaign=email")
57
- set_cookie("utm_content=test_content")
58
- set_cookie("utm_time=#{@time.to_i}")
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.content'].must_equal "test_content"
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.content'].must_equal "test_content"
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["utm_source"].must_equal "testing"
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
- utm_content: 'test_content' }
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
- rack_mock_session.cookie_jar["utm_source"].must_equal "cool_source"
99
+ cookie_params["source"].must_equal "cool_source"
98
100
  end
99
101
  end
100
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-ga-track
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Nolan