auto-session-timeout 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmRiNTA2ODE4NzJiMDc3Zjg2MjM1YTgzMGFmZGQ1YWI4ZjhiOTY0MA==
4
+ MzgzYWM4ODdjNTcwYWI5MmMxZDA0ZDc3NjBjYzRlNmJiN2Q4ZDk3OQ==
5
5
  data.tar.gz: !binary |-
6
- NjhjNzcyOGY0YWZlNDI2MGM1YWMzYmJjMThhZTA5ODA5NDEwZmY1Nw==
6
+ ZTU4MzEyZDc4OTE4YmVmZWM2NmUwY2EwYTI2YjcxZjU1NzRiZDM4NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWZkZmIyNGQzNmFmNTM5Nzg5MmM4YWU4Yjg0MGFhODQ0NjdlODg5ZWFlYmVh
10
- ZTQyYjQ5MTBiMTU5MmY3NDQyNTExNjBiZDllNWU3ZTk5ODNjNjQ1M2UxOTli
11
- ZjI0ZTQ4N2UyZGUzZGEwNjhhN2QzZThlNWU3MDA2YzE4YjA2Mzc=
9
+ MmFiZGY1NjI4M2M2ZTUzNTZlNmM3OTY5ZjBjM2QyNjA2ZDZkZjE0ODIyYzg1
10
+ MDhhZjQ1MmE4Y2RmMTYxNzQwMDMxZWI1NzhjYmYzMmZiNTYyZjI0M2NiNWFi
11
+ MDdjZmUzMTlmOTliODc3OTAxNTExOTdjYTExOTY0ODk2ZTcyYTU=
12
12
  data.tar.gz: !binary |-
13
- N2I1YzhiYzMzNTQ2YTkwMDJkZjE0OTA3MDIyM2E2NmY4NmM3N2Y0NTNkMjM5
14
- NjE2OWIxOWYwZmUxNWE2MDYxYzYxM2M2NTY3MWVmYTcyMTAxNTBhZGZmMDQ2
15
- YzY1YzY0MmU5YmIzNDlkYzBiOTVmYmUyYzdlYmQwOGI3ZjIyMzM=
13
+ ZGZkMjVmNjA5ZjU0YjYxMmJhMjZhYTI3ZTU4YjZlYzRhZjQ5YTNlODkzNmY4
14
+ NjQyZmM4YzI5Mjk3MmIxOGMxYWU1NmI1NDc3OWFiZjJmZWMwNGI4ZjA4NDI0
15
+ NDZlNGJjZDQ5NmFjNThmM2RkZDg5ZmU5NzBkOGVmZGRhNmMyYzg=
data/README.md CHANGED
@@ -84,7 +84,7 @@ seconds. The following example checks the server every 15 seconds:
84
84
  <head>...</head>
85
85
  <body>
86
86
  <% if current_user %>
87
- <%= auto_session_timeout_js :frequency => 15 %>
87
+ <%= auto_session_timeout_js frequency: 15 %>
88
88
  <% end %>
89
89
  ...
90
90
  </body>
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
3
3
  require 'rdoc/task'
4
4
  require 'bundler/gem_tasks'
5
5
 
6
- task :default => :test
6
+ task default: :test
7
7
 
8
8
  Rake::TestTask.new('test') do |t|
9
9
  t.pattern = 'test/*_test.rb'
@@ -1,7 +1,7 @@
1
1
  module Auto
2
2
  module Session
3
3
  module Timeout
4
- VERSION = "0.9.1"
4
+ VERSION = "0.9.2"
5
5
  end
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ module AutoSessionTimeout
12
12
  c.send :reset_session
13
13
  else
14
14
  unless c.url_for(c.params).start_with?(c.send(:active_url))
15
- offset = seconds || current_user.try(:auto_timeout)
15
+ offset = seconds || (current_user.respond_to?(:auto_timeout) ? current_user.auto_timeout : nil)
16
16
  c.session[:auto_session_expires_at] = Time.now + offset if offset && offset > 0
17
17
  end
18
18
  end
@@ -27,7 +27,7 @@ module AutoSessionTimeout
27
27
 
28
28
  def render_session_status
29
29
  response.headers["Etag"] = "" # clear etags to prevent caching
30
- render :text => !!current_user, :status => 200
30
+ render text: !!current_user, status: 200
31
31
  end
32
32
 
33
33
  def render_session_timeout
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ describe AutoSessionTimeoutHelper do
4
+
5
+ subject { Class.new(ActionView::Base).new }
6
+
7
+ describe "#auto_session_timeout_js" do
8
+ it "returns correct JS" do
9
+ assert_equal "<script type=\"text/javascript\">
10
+ //<![CDATA[
11
+ if (typeof(Ajax) != 'undefined') {
12
+ new Ajax.PeriodicalUpdater('', '/active', {frequency:60, method:'get', onSuccess: function(e) {
13
+ if (e.responseText == 'false') window.location.href = '/timeout';
14
+ }});
15
+ } else {
16
+ $.PeriodicalUpdater('/active', {minTimeout:60000, multiplier:0, method:'get', verbose:2}, function(remoteData, success) {
17
+ if (success == 'success' && remoteData == 'false')
18
+ window.location.href = '/timeout';
19
+ });
20
+ }
21
+
22
+ //]]>
23
+ </script>", subject.auto_session_timeout_js
24
+ end
25
+
26
+ it "uses custom frequency when given" do
27
+ assert_match /frequency:120/, subject.auto_session_timeout_js(frequency: 120)
28
+ end
29
+
30
+ it "uses 60 when custom frequency is nil" do
31
+ assert_match /frequency:60/, subject.auto_session_timeout_js(frequency: nil)
32
+ end
33
+ end
34
+
35
+ end
@@ -2,4 +2,4 @@ require 'rubygems'
2
2
  require 'minitest/autorun'
3
3
  require 'action_controller'
4
4
 
5
- require File.expand_path(File.dirname(__FILE__) + '/../lib/auto_session_timeout')
5
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/auto-session-timeout')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto-session-timeout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Bass
@@ -85,6 +85,7 @@ files:
85
85
  - lib/auto/session/timeout/version.rb
86
86
  - lib/auto_session_timeout.rb
87
87
  - lib/auto_session_timeout_helper.rb
88
+ - test/auto_session_timeout_helper_test.rb
88
89
  - test/auto_session_timeout_test.rb
89
90
  - test/test_helper.rb
90
91
  homepage: http://github.com/pelargir/auto-session-timeout
@@ -112,5 +113,6 @@ signing_key:
112
113
  specification_version: 4
113
114
  summary: Provides automatic session timeout in a Rails application.
114
115
  test_files:
116
+ - test/auto_session_timeout_helper_test.rb
115
117
  - test/auto_session_timeout_test.rb
116
118
  - test/test_helper.rb