referer_tracking 4.4.0 → 4.5.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.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -3
  3. data/app/models/referer_tracking/tracking.rb +2 -2
  4. data/lib/referer_tracking/controller_addons.rb +9 -8
  5. data/lib/referer_tracking/version.rb +1 -1
  6. data/test/dummy/app/assets/config/manifest.js +1 -0
  7. data/test/dummy/app/controllers/users_controller.rb +1 -1
  8. data/test/dummy/app/views/layouts/application.html.erb +2 -2
  9. data/test/dummy/config/application.rb +2 -2
  10. data/test/dummy/db/test.sqlite3 +0 -0
  11. data/test/dummy/log/test.log +19071 -0
  12. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/CS/CS8nEse4iNQsIQp6JJMkrfiNOJ0C4AsDb2TR7hOGIH0.cache +1 -0
  13. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Dm/DmmfrCpXtt74Hr6NO54lxyOCDv6klnDyBqeDFR7oDU8.cache +3 -0
  14. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Ka/KagYVzDXOrwIV8OqoCjrLu5kwqlqtzrwhLbuOdO_Lrs.cache +1 -0
  15. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/U6/U6ujBBtVuScKUBOvp2wmpQO2qYG5QMZj9oFkEoWtF6E.cache +0 -0
  16. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/UZ/UZ_c1KkSJaaNhwYwe1v-89WvyVGicihlY6Zp1bXhq3M.cache +0 -0
  17. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/V-/V-CNkRRDXuu8o_FKw6oQPptxNYchi36Ctond2A9pFCM.cache +0 -0
  18. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/WI/WIhdpx5T1Wxi7u_C-fCzIVkEYsWzm9hcfsoi-hotpdE.cache +0 -0
  19. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Z4/Z41nxEwpWQWFoc3tdahPn8d-nQygg6rN5wPU0iWRYrA.cache +1 -0
  20. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/bP/bPBEsM47rrracC6h0DUpa76b38d_hdPadAGWeHXJIj8.cache +3 -0
  21. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/cG/cGfnqX6g3P0WuiBZ7nc-f8N13CSgrV163hKk2ry0-n8.cache +1 -0
  22. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/dz/dzSD3sm4znNDRdp04nrjxADibaOAuBl1B_WUyfsaNac.cache +1 -0
  23. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/i1/i1DwWMZeHC_QdByjF6bFQ3-UXJyXEvY7zJfsvk6rSl4.cache +1 -0
  24. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/iD/iDTnVSbZnIij5Xm4jkwCyIXAPDn8RwaRe5Ja8YPKibw.cache +3 -0
  25. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/l8/l8s8Rg4fjDwXddzNqmy9aLM9gcOiiuYpZZbbreeV7Xk.cache +2 -0
  26. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/m5/m52gbfVbAznVnzdJcivzel9TPhOOLSbJ8Rp4PByLHeo.cache +0 -0
  27. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/qp/qpYHEqUJcqJpx4Zm9PbO4LVVjAqI1wQUcy83KPrUK7M.cache +1 -0
  28. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/r6/r6KjMmQ9n_jOrJlySdyY3ghq7-QyiM3ai5wHX6eTp-g.cache +1 -0
  29. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/rb/rb_u_gHDnEZUoDZl9KxS9eteCoe-SaXymHkbl47PpVs.cache +1 -0
  30. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/ty/tyrbLxvr3XORxAaPLnpHstJahZsB9CS5tJAB3BiKaII.cache +0 -0
  31. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/wX/wXZYB3qZL8CcqH7bLqFclD7G1KHZdxh-PxR2zVSSQe0.cache +1 -0
  32. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/wn/wnvJ74QIdj8tSD10cXmY9KyXCpaQIv0FfZJWw-EudW8.cache +2 -0
  33. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/xP/xPMfTXGxxCCgIip6XsG-paelKjnDzbpAYugLmUfykPs.cache +2 -0
  34. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/yw/ywTOTWuvOMHV0wh02S8szPOIWIaS_244Z0lUeU8Dstw.cache +1 -0
  35. data/test/integration/referer_tracking/referer_session_test.rb +16 -0
  36. data/test/test_helper.rb +1 -1
  37. data/test/tracking_test.rb +21 -3
  38. metadata +250 -203
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=df21cedf5c076ad230f056a5c4a18223ecb59d20cce688c3c2cdb5505ac5242c:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"6file-digest://app/assets/stylesheets/scaffold.css;TTF
@@ -0,0 +1 @@
1
+ "%��A�I8���߅�u7�!��H���j���\��|x
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/users.css?type=text/css&pipeline=self&id=12a0a025bee7b6c0775f47da5959c9b7d81b52ca144340e110b957f600bc60f2:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"0file-digest://app/assets/config/manifest.js;TTF
@@ -0,0 +1 @@
1
+ I"}app/assets/config/manifest.js?type=application/javascript&id=96c2df0017491eafb55fb7e2f788a1973899ae13c0635d0d5bad071778f2da39:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=a65253230ad4b2a0794169089fa585ecf231dc15af74cf6c80bc0a2e2886c0af:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/config/manifest.js?type=application/javascript&pipeline=self&id=7ca5d7b067545f9ea3db0d2d0521c464159c5096c8546c0ed15b4129d9418b97:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"3file-digest://app/assets/stylesheets/users.css;TTF
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"0file-digest://app/assets/config/manifest.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTF
@@ -0,0 +1 @@
1
+ "%֧�NTZq�בH�L��#p3��Jg!��)
@@ -0,0 +1 @@
1
+ "%9�#�U�-���Jnݶ�W��Gx5>T�u�\x��:�
@@ -0,0 +1 @@
1
+ "%u�0b��^�#�ߜj�E�b��/��e�=
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/scaffold.css?type=text/css&pipeline=self&id=bd3274ddee93013d3d6d96e79334a08b2a6a305c44a0acb4be9780665d121b24:ET
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"9file-digest://app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI")file-digest://app/assets/stylesheets;TTI"6file-digest://app/assets/stylesheets/scaffold.css;TTI"3file-digest://app/assets/stylesheets/users.css;TTF
@@ -0,0 +1 @@
1
+ "%Ȥ���o�A�$w�NN�Dj�mJ�8��ӌ�~�w
@@ -133,6 +133,22 @@ class RefererSessionTest < ActionDispatch::IntegrationTest
133
133
  assert_equal 1, RefererTracking::Tracking.count, "should create one item"
134
134
  end
135
135
 
136
+ test "custom referer_tracking save work with too long user agent" do
137
+ RefererTracking.save_cookies = true
138
+
139
+ too_long_user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D100 [FBAN/MessengerForiOS; ... #{(0...400).map { (65+rand(26)).chr }.join}"
140
+ post '/users/create_with_custom_saving', params: {:user => {:name => 'test name'}},
141
+ headers: {"HTTP_USER_AGENT" => (@user_agent = too_long_user_agent)}
142
+ assert_equal 1, RefererTracking::Tracking.count, "should create one item"
143
+
144
+ assert too_long_user_agent.size > 400
145
+ rt = RefererTracking::Tracking.last
146
+ assert_equal too_long_user_agent.first(100), rt.user_agent.first(100)
147
+ assert rt.user_agent.size < 255, "should handle db limits" # testing manually because sqlite does not enforce limits same way as mysql
148
+ end
149
+
150
+
151
+
136
152
  test "custom referer_tracking save should not save if item itself is not saved" do
137
153
  RefererTracking.save_cookies = true
138
154
 
data/test/test_helper.rb CHANGED
@@ -4,7 +4,7 @@ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
4
4
  ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
5
5
  ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
6
6
  require "rails/test_help"
7
- require "mocha/setup"
7
+ require 'mocha/minitest'
8
8
 
9
9
  # Filter out Minitest backtrace while allowing backtrace from other libraries
10
10
  # to be shown.
@@ -22,8 +22,26 @@ class TrackingTest < ActiveSupport::TestCase
22
22
 
23
23
  assert (log = RefererTracking::Tracking.last.log)
24
24
  assert_equal 2, log.to_s.lines.count
25
- assert_match /#{Date.today.to_s(:db)}.*: first_line$/, log.lines.first
26
- assert_match /#{Date.today.to_s(:db)}.*: second line/, log.lines.last
25
+ assert_match(/#{Date.today.to_s(:db)}.*: first_line$/, log.lines.first)
26
+ assert_match(/#{Date.today.to_s(:db)}.*: second line/, log.lines.last)
27
+ end
28
+
29
+ test "add_log_line should not save if new record" do
30
+ rt = RefererTracking::Tracking.new
31
+
32
+ assert rt.new_record?
33
+ rt.add_log_line 'first_line'
34
+ assert rt.new_record?
35
+ assert rt.changed?
36
+
37
+ rt.save!
38
+ rt.add_log_line "second\nline"
39
+ assert !rt.changed?
40
+
41
+ assert (log = RefererTracking::Tracking.last.log)
42
+ assert_equal 2, log.to_s.lines.count
43
+ assert_match(/#{Date.today.to_s(:db)}.*: first_line$/, log.lines.first)
44
+ assert_match(/#{Date.today.to_s(:db)}.*: second line/, log.lines.last)
27
45
  end
28
46
 
29
47
  test "status_without_save" do
@@ -41,7 +59,7 @@ class TrackingTest < ActiveSupport::TestCase
41
59
  rt = RefererTracking::Tracking.last
42
60
  assert_equal 'active', rt.status
43
61
  assert_equal 1, rt.log.lines.count
44
- assert_match /#{Date.today.to_s(:db)}.*: status active$/, rt.log
62
+ assert_match(/#{Date.today.to_s(:db)}.*: status active$/, rt.log)
45
63
 
46
64
  rt.update_status 'active'
47
65
  assert_equal 1, rt.log.lines.count, "should not alter anything if status stays the same"