Skip to content

Commit

Permalink
fixes testcases
Browse files Browse the repository at this point in the history
and some cleanup
  • Loading branch information
Schlaefer committed Nov 8, 2013
1 parent 971090a commit e8e994d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 65 deletions.
2 changes: 1 addition & 1 deletion app/Controller/SaitosController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function status() {
'lastShoutId' => $this->Shout->findLastId()
];
$data = json_encode($data);
if($this->request->accepts('text/event-streams')) {
if ($this->request->accepts('text/event-streams')) {
return $this->_statusAsEventStream($data);
} else {
return $this->_statusAsJson($data);
Expand Down
8 changes: 4 additions & 4 deletions app/webroot/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/webroot/js/models/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define([
this.commands = Vent.commands;
this.reqres = Vent.reqres;
this.settings = new AppSettingModel();
this.status = new AppStatusModel({settings: this.settings});
this.status = new AppStatusModel({}, {settings: this.settings});
this.currentUser = new CurrentUserModel();
}

Expand Down
30 changes: 17 additions & 13 deletions app/webroot/js/models/appStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define([

stream: null,

initialize: function(options) {
initialize: function(attributes, options) {
this.settings = options.settings;
this.methodToCakePhpUrl = _.clone(this.methodToCakePhpUrl);
this.methodToCakePhpUrl.read = 'status/';
Expand Down Expand Up @@ -63,7 +63,7 @@ define([
*
* @private
*/
_poll: function () {
_poll: function() {
var resetRefreshTime,
updateAppStatus,
setTimer,
Expand All @@ -73,33 +73,37 @@ define([
refreshTimeBase = 10000,
refreshTimeMax = 90000;

stopTimer = function () {
stopTimer = function() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
};

resetRefreshTime = function () {
resetRefreshTime = function() {
stopTimer();
refreshTimeAct = refreshTimeBase;
};

setTimer = function () {
setTimer = function() {
timerId = setTimeout(
updateAppStatus,
refreshTimeAct
);
};

updateAppStatus = _.bind(function () {
updateAppStatus = _.bind(function() {
setTimer();
this.fetch();
refreshTimeAct = Math.floor(
refreshTimeAct * (1 + refreshTimeAct / 40000)
);
if (refreshTimeAct > refreshTimeMax) {
refreshTimeAct = refreshTimeMax;
}
this.fetch({
success: function() {
refreshTimeAct = Math.floor(
refreshTimeAct * (1 + refreshTimeAct / 40000)
);
if (refreshTimeAct > refreshTimeMax) {
refreshTimeAct = refreshTimeMax;
}
},
error: stopTimer
});
}, this);

this.listenTo(this, 'change', function() {
Expand Down
1 change: 0 additions & 1 deletion app/webroot/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require(['lib/bootstrapHelper', 'common', 'tests/jasmineBootstrapHelper'], funct
'models/AppStatusModelSpec.js',
'models/BookmarkModelSpec.js',
'models/SlidetabModelSpec.js',
'models/StatusModelSpec.js',
'models/UploadModelSpec.js',
'lib/MarkItUpSpec.js',
'lib/jquery.i18n.extendSpec.js',
Expand Down
11 changes: 7 additions & 4 deletions app/webroot/js/tests/models/AppStatusModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ define([], function() {
this.server = sinon.fakeServer.create();

require(['models/appStatus', 'models/app'], _.bind(function(Model, App) {
that.model = new Model();
that.model.setWebroot(this.webroot);
flag = true;
var webroot = this.webroot;
that.model = new Model({}, {settings: {
get: function() { return webroot; }
}});
flag = true;
}, this));

waitsFor(function() {
Expand All @@ -24,11 +26,12 @@ define([], function() {
});

afterEach(function() {
delete(this.model);
this.server.restore();
});

it('fetches data from saitos/status/', function() {
this.model.fetch();
this.model.start();
expect(this.server.requests.length)
.toEqual(1);
expect(this.server.requests[0].method)
Expand Down
41 changes: 0 additions & 41 deletions app/webroot/js/tests/models/StatusModelSpec.js

This file was deleted.

2 changes: 2 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Please fill bugs and make pull requests at [github][saito-github].

To setup the full the development environment install [npm][npm] and execute `grunt dev-setup`. Compile the files for a release with `grunt release`.

You have to install `phpcs` and the [CakePHP Codesniffer](https://github.com/cakephp/cakephp-codesniffer) manually.

# Conventions #

The git branching is following the [gitflow][gitflow] model.
Expand Down

0 comments on commit e8e994d

Please sign in to comment.