Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
grbsk committed Dec 16, 2016
2 parents d7cbd35 + 96fc541 commit 7072c91
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 26 deletions.
10 changes: 5 additions & 5 deletions angular-idle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*** Directives and services for responding to idle users in AngularJS
* @author Mike Grabski <me@mikegrabski.com>
* @version v1.3.1
* @version v1.3.2
* @link https://github.com/HackedByChinese/ng-idle.git
* @license MIT
*/
Expand Down Expand Up @@ -42,17 +42,17 @@ angular.module('ngIdle.keepalive', [])
ping: null
};

function handleResponse(data, status) {
$rootScope.$broadcast('KeepaliveResponse', data, status);
function handleResponse(response) {
$rootScope.$broadcast('KeepaliveResponse', response.data, response.status);
}

function ping() {
$rootScope.$broadcast('Keepalive');

if (angular.isObject(options.http)) {
$http(options.http)
.success(handleResponse)
.error(handleResponse);
.then(handleResponse)
.catch(handleResponse);
}
}

Expand Down
2 changes: 1 addition & 1 deletion angular-idle.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions angular-idle.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-idle",
"version": "1.3.1",
"version": "1.3.2",
"homepage": "https://github.com/HackedByChinese/ng-idle",
"description": "Responding to idle users in AngularJS",
"main": "angular-idle.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-idle",
"version": "1.3.1",
"version": "1.3.2",
"description": "Directives and services for responding to idle users in AngularJS",
"keywords": [
"angularjs",
Expand Down
8 changes: 4 additions & 4 deletions src/keepalive/keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ angular.module('ngIdle.keepalive', [])
ping: null
};

function handleResponse(data, status) {
$rootScope.$broadcast('KeepaliveResponse', data, status);
function handleResponse(response) {
$rootScope.$broadcast('KeepaliveResponse', response.data, response.status);
}

function ping() {
$rootScope.$broadcast('Keepalive');

if (angular.isObject(options.http)) {
$http(options.http)
.success(handleResponse)
.error(handleResponse);
.then(handleResponse)
.catch(handleResponse);
}
}

Expand Down
13 changes: 1 addition & 12 deletions src/keepalive/keepalive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('ngIdle', function() {

beforeEach(function() {
Keepalive = create();
spyOn($rootScope, '$broadcast');
});

afterEach(function() {
Expand All @@ -116,22 +117,18 @@ describe('ngIdle', function() {
expect(create()._options().interval).toBe(100);
});
it('start() after a new LONGER timeout should NOT broadcast Keepalive when the default timeout expires', function() {
spyOn($rootScope, '$broadcast');
Keepalive.setInterval(100 * 60);
Keepalive.start();
$interval.flush(DEFAULTKEEPALIVEINTERVAL);
expect($rootScope.$broadcast).not.toHaveBeenCalledWith('Keepalive');
});
it('start() after a new LONGER timeout should broadcast Keepalive when the new LONGER expires', function() {
spyOn($rootScope, '$broadcast');
Keepalive.setInterval(100);
Keepalive.start();
$interval.flush(100 * 1000);
expect($rootScope.$broadcast).toHaveBeenCalledWith('Keepalive');
});
it('start() should schedule ping timeout that broadcasts Keepalive event when it expires.', function() {
spyOn($rootScope, '$broadcast');

Keepalive.start();

$interval.flush(DEFAULTKEEPALIVEINTERVAL);
Expand All @@ -140,8 +137,6 @@ describe('ngIdle', function() {
});

it('stop() should cancel ping timeout.', function() {
spyOn($rootScope, '$broadcast');

Keepalive.start();
Keepalive.stop();

Expand All @@ -151,8 +146,6 @@ describe('ngIdle', function() {
});

it('ping() should immediately broadcast Keepalive event', function() {
spyOn($rootScope, '$broadcast');

Keepalive.ping();

$interval.flush(DEFAULTKEEPALIVEINTERVAL);
Expand All @@ -161,8 +154,6 @@ describe('ngIdle', function() {
});

it('should invoke a URL when pinged and broadcast KeepaliveResponse on success.', function() {
spyOn($rootScope, '$broadcast');

Keepalive = create('/path/to/keepalive');

Keepalive.start();
Expand All @@ -178,8 +169,6 @@ describe('ngIdle', function() {
});

it('should invoke a URL when pinged and broadcast KeepaliveResponse on error.', function() {
spyOn($rootScope, '$broadcast');

Keepalive = create('/path/to/keepalive');

Keepalive.start();
Expand Down

0 comments on commit 7072c91

Please sign in to comment.