This commit is contained in:
Bernhard Posselt 2013-04-18 17:47:03 +02:00
Родитель 97452a5f5e
Коммит 402c534ee6
16 изменённых файлов: 320 добавлений и 528 удалений

Просмотреть файл

@ -66,8 +66,8 @@ module.exports = (grunt) ->
src: '<%= meta.production %>app.js'
dest: ''
wrapper: [
'(function(angular, $, hex_md5, moment, undefined){\n\n'
'\n})(window.angular, window.jQuery, window.hex_md5, window.moment);'
'(function(angular, $, moment, undefined){\n\n'
'\n})(window.angular, window.jQuery, window.moment);'
]
coffeelint:

Просмотреть файл

@ -92,7 +92,7 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
@_feedModel.update({
id: feedId,
folderId: folderId,
urlHash: feed.urlHash})
url: feed.url})
@_persistence.moveFeed(feedId, folderId)
@ -139,15 +139,13 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
throw new Error('Url must not be empty')
url = url.trim()
urlHash = hex_md5(url)
if @_feedModel.getByUrlHash(urlHash)
if @_feedModel.getByUrl(url)
throw new _ExistsError('Exists already')
feed =
title: url
url: url
urlHash: urlHash
folderId: parentId
unreadCount: 0
faviconLink: 'url('+@_utils.imagePath('core', 'loading.gif')+')'
@ -164,8 +162,8 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
@_persistence.createFeed(url, parentId, success)
markErrorRead: (urlHash) ->
@_feedModel.removeByUrlHash(urlHash)
markErrorRead: (url) ->
@_feedModel.removeByUrl(url)
updateFeeds: ->

Просмотреть файл

@ -27,12 +27,12 @@ angular.module('News').factory 'FeedModel',
class FeedModel extends _Model
constructor: (@_utils) ->
@_urlHash = {}
@_url = {}
super()
clear: ->
@_urlHash = {}
@_url = {}
super()
@ -48,7 +48,7 @@ angular.module('News').factory 'FeedModel',
an id, we have to update the existing item without id
###
item = @_urlHash[data.urlHash]
item = @_url[data.url]
# update in the following cases:
# * the id is defined and the item exists
@ -56,15 +56,15 @@ angular.module('News').factory 'FeedModel',
updateById = angular.isDefined(data.id) and
angular.isDefined(@getById(data.id))
updateByUrlHash = angular.isDefined(item) and
updateByUrl = angular.isDefined(item) and
angular.isUndefined(item.id)
if updateById or updateByUrlHash
if updateById or updateByUrl
@update(data, clearCache)
else
if angular.isDefined(data.urlHash)
if angular.isDefined(data.url)
# if the item is not yet in the name cache it must be added
@_urlHash[data.urlHash] = data
@_url[data.url] = data
# in case there is an id it can go through the normal add method
if angular.isDefined(data.id)
@ -80,8 +80,8 @@ angular.module('News').factory 'FeedModel',
update: (data, clearCache=true) ->
# only when the id on the updated item does not exist we wish
# to update by name, otherwise we always update by id
if angular.isDefined(data.urlHash)
item = @_urlHash[data.urlHash]
if angular.isDefined(data.url)
item = @_url[data.url]
# update by name
if angular.isUndefined(data.id) and angular.isDefined(item)
@ -100,21 +100,21 @@ angular.module('News').factory 'FeedModel',
# we need to fix the name cache if the name was changed
itemWithId = @getById(data.id)
if angular.isDefined(itemWithId) and
itemWithId.urlHash != data.urlHash
delete @_urlHash[itemWithId.urlHash]
@_urlHash[data.urlHash] = itemWithId
itemWithId.url != data.url
delete @_url[itemWithId.url]
@_url[data.url] = itemWithId
super(data, clearCache)
removeById: (id) ->
item = @getById(id)
delete @_urlHash[item.urlHash]
delete @_url[item.url]
super(id)
getByUrlHash: (urlHash) ->
return @_urlHash[urlHash]
getByUrl: (url) ->
return @_url[url]
getUnreadCount: ->
@ -148,21 +148,21 @@ angular.module('News').factory 'FeedModel',
return @get(query)
removeByUrlHash: (urlHash, clearCache=true) ->
removeByUrl: (url, clearCache=true) ->
###
Remove an entry by id
###
# remove from data map
for key, value of @_dataMap
if @_dataMap[key].urlHash == urlHash
if @_dataMap[key].url == url
delete @_dataMap[key]
break
for entry, counter in @_data
if entry.urlHash == urlHash
if entry.url == url
@_data.splice(counter, 1)
delete @_urlHash[urlHash]
delete @_url[url]
if clearCache
@_invalidateCache()

Просмотреть файл

@ -36,7 +36,6 @@ files = [
'vendor/angular/angular.js',
'vendor/angular/angular-mocks.js',
'vendor/angular-ui/angular-ui.js',
'vendor/md5js/md5.js',
'vendor/momentjs/moment.js',
'../../appframework/js/tests/stubs/owncloud.js',
'../../appframework/js/public/app.js',

Просмотреть файл

@ -1,4 +1,4 @@
(function(angular, $, hex_md5, moment, undefined){
(function(angular, $, moment, undefined){
/**
* ownCloud News App - v0.0.1
@ -794,7 +794,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._feedModel.update({
id: feedId,
folderId: folderId,
urlHash: feed.urlHash
url: feed.url
});
return this._persistence.moveFeed(feedId, folderId);
}
@ -837,7 +837,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
};
FeedBusinessLayer.prototype.create = function(url, parentId, onSuccess, onFailure) {
var feed, success, urlHash,
var feed, success,
_this = this;
if (parentId == null) {
@ -856,14 +856,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
throw new Error('Url must not be empty');
}
url = url.trim();
urlHash = hex_md5(url);
if (this._feedModel.getByUrlHash(urlHash)) {
if (this._feedModel.getByUrl(url)) {
throw new _ExistsError('Exists already');
}
feed = {
title: url,
url: url,
urlHash: urlHash,
folderId: parentId,
unreadCount: 0,
faviconLink: 'url(' + this._utils.imagePath('core', 'loading.gif') + ')'
@ -880,8 +878,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this._persistence.createFeed(url, parentId, success);
};
FeedBusinessLayer.prototype.markErrorRead = function(urlHash) {
return this._feedModel.removeByUrlHash(urlHash);
FeedBusinessLayer.prototype.markErrorRead = function(url) {
return this._feedModel.removeByUrl(url);
};
FeedBusinessLayer.prototype.updateFeeds = function() {
@ -1598,17 +1596,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
function FeedModel(_utils) {
this._utils = _utils;
this._urlHash = {};
this._url = {};
FeedModel.__super__.constructor.call(this);
}
FeedModel.prototype.clear = function() {
this._urlHash = {};
this._url = {};
return FeedModel.__super__.clear.call(this);
};
FeedModel.prototype.add = function(data, clearCache) {
var item, updateById, updateByUrlHash;
var item, updateById, updateByUrl;
if (clearCache == null) {
clearCache = true;
@ -1624,14 +1622,14 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
an id, we have to update the existing item without id
*/
item = this._urlHash[data.urlHash];
item = this._url[data.url];
updateById = angular.isDefined(data.id) && angular.isDefined(this.getById(data.id));
updateByUrlHash = angular.isDefined(item) && angular.isUndefined(item.id);
if (updateById || updateByUrlHash) {
updateByUrl = angular.isDefined(item) && angular.isUndefined(item.id);
if (updateById || updateByUrl) {
return this.update(data, clearCache);
} else {
if (angular.isDefined(data.urlHash)) {
this._urlHash[data.urlHash] = data;
if (angular.isDefined(data.url)) {
this._url[data.url] = data;
if (angular.isDefined(data.id)) {
return FeedModel.__super__.add.call(this, data, clearCache);
} else {
@ -1650,8 +1648,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
if (clearCache == null) {
clearCache = true;
}
if (angular.isDefined(data.urlHash)) {
item = this._urlHash[data.urlHash];
if (angular.isDefined(data.url)) {
item = this._url[data.url];
}
if (angular.isUndefined(data.id) && angular.isDefined(item)) {
return angular.extend(item, data);
@ -1661,9 +1659,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._dataMap[data.id] = item;
}
itemWithId = this.getById(data.id);
if (angular.isDefined(itemWithId) && itemWithId.urlHash !== data.urlHash) {
delete this._urlHash[itemWithId.urlHash];
this._urlHash[data.urlHash] = itemWithId;
if (angular.isDefined(itemWithId) && itemWithId.url !== data.url) {
delete this._url[itemWithId.url];
this._url[data.url] = itemWithId;
}
return FeedModel.__super__.update.call(this, data, clearCache);
}
@ -1673,12 +1671,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
var item;
item = this.getById(id);
delete this._urlHash[item.urlHash];
delete this._url[item.url];
return FeedModel.__super__.removeById.call(this, id);
};
FeedModel.prototype.getByUrlHash = function(urlHash) {
return this._urlHash[urlHash];
FeedModel.prototype.getByUrl = function(url) {
return this._url[url];
};
FeedModel.prototype.getUnreadCount = function() {
@ -1725,7 +1723,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this.get(query);
};
FeedModel.prototype.removeByUrlHash = function(urlHash, clearCache) {
FeedModel.prototype.removeByUrl = function(url, clearCache) {
var counter, entry, key, value, _i, _len, _ref, _ref1, _results;
if (clearCache == null) {
@ -1738,7 +1736,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
_ref = this._dataMap;
for (key in _ref) {
value = _ref[key];
if (this._dataMap[key].urlHash === urlHash) {
if (this._dataMap[key].url === url) {
delete this._dataMap[key];
break;
}
@ -1747,9 +1745,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
_results = [];
for (counter = _i = 0, _len = _ref1.length; _i < _len; counter = ++_i) {
entry = _ref1[counter];
if (entry.urlHash === urlHash) {
if (entry.url === url) {
this._data.splice(counter, 1);
delete this._urlHash[urlHash];
delete this._url[url];
if (clearCache) {
this._invalidateCache();
}
@ -2977,4 +2975,4 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
})(window.angular, window.jQuery, window.hex_md5, window.moment);
})(window.angular, window.jQuery, window.moment);

186
js/test-results.xml Normal file
Просмотреть файл

@ -0,0 +1,186 @@
<?xml version="1.0"?>
<testsuites>
<testsuite name="PhantomJS 1.9 (Linux)" package="undefined" timestamp="2013-04-18T14:48:48" id="0" hostname="archtop" tests="175" errors="0" failures="0" time="0.409">
<properties>
<property name="browser.fullName" value="Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.0 Safari/534.34"/>
</properties>
<testcase name="isAddingFolder should return false in the beginning" time="0.023" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="isAddingFeed should return false in the beginning" time="0.003" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should make unreadCountFormatter available" time="0.002" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should make FeedBusinessLayer available" time="0.002" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should make FolderBusinessLayer available" time="0.008" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should make SubscriptionsBusinessLayer available" time="0.002" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should make StarredBusinessLayer available" time="0.002" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should not add folders that have no name" time="0.003" classname="PhantomJS 1.9 (Linux).FeedController"/>
<testcase name="should make ItemBusinessLayer availabe" time="0.002" classname="PhantomJS 1.9 (Linux).ItemController"/>
<testcase name="should make FeedBusinessLayer availabe" time="0.002" classname="PhantomJS 1.9 (Linux).ItemController"/>
<testcase name="should make FeedBl available" time="0.002" classname="PhantomJS 1.9 (Linux).SettingsController"/>
<testcase name="should show an error if the xml import failed" time="0.003" classname="PhantomJS 1.9 (Linux).SettingsController"/>
<testcase name="should set showall to true if importing" time="0.002" classname="PhantomJS 1.9 (Linux).SettingsController"/>
<testcase name="should be Subscriptions by default" time="0.001" classname="PhantomJS 1.9 (Linux).ActiveFeed"/>
<testcase name="should set the correct feed id" time="0.001" classname="PhantomJS 1.9 (Linux).ActiveFeed"/>
<testcase name="should set the correct feed type" time="0.001" classname="PhantomJS 1.9 (Linux).ActiveFeed"/>
<testcase name="should reset the item cache when a different feed is being loaded" time="0.002" classname="PhantomJS 1.9 (Linux).BusinessLayer"/>
<testcase name="should send a get all items query when feed changed" time="0.003" classname="PhantomJS 1.9 (Linux).BusinessLayer"/>
<testcase name="should be active when its selected" time="0.001" classname="PhantomJS 1.9 (Linux).BusinessLayer"/>
<testcase name="should delete feeds" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return the number of unread feeds" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return all feeds of a folder" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should get the correct unread count for folders" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should mark feed as read" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should mark feed as read and set 0 if as highest id if its not active" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should mark all as read" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should get the correct unread count for subscribtions" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return the correct number of feeds" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should be visible if its active" time="0.008" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should be visible if show all is true" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should be visible if unreadcount bigger than 0" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should not move the feed to a new folder" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should not move the feed to the same folder" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should set the show all setting" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should set the hide read setting" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return all feeds" time="0.001" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return if ShowAll is set" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return all feeds of a folder" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should return the correct feed link" time="0.001" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should not create a feed if it already exists" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should not create feeds that are empty" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should create a feed before theres a response from the server" time="0.001" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should set a title and an url hash to the newly crated feed" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should make a create feed request" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should call the onSuccess function on response status ok" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should call the handle a response error when creating a folder" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should mark a feed error as read by removing it" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should update all feeds" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should not update feeds without ids" time="0.002" classname="PhantomJS 1.9 (Linux).FeedBusinessLayer"/>
<testcase name="should delete folders" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should return true when folder has feeds" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should toggle folder" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should mark folder as read" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should get the correct unread count" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should be visible if show all is true" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should be visible if its active" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should be visible if one of its subfeeds is active" time="0.009" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should be visible if showAll is false and it has unread items" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should return all folders" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should not create a folder if it already exists" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should not create folders that are empty" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should create a folder before theres a response from the server" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should make a create folder request" time="0.001" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should call the onSuccess function on response status ok" time="0.001" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should call the handle a response error when creating a folder" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should mark a folder error as read by removing it" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should return the corret folder for id" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should open a folder" time="0.002" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should not import on empty opml" time="0.006" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should import a folder" time="0.004" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should import a feed" time="0.003" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should import nested folders" time="0.004" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should use an existing folder when importing a folder" time="0.003" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should not import a feed if it already exists" time="0.004" classname="PhantomJS 1.9 (Linux).FolderBusinessLayer"/>
<testcase name="should return all items" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should tell if no feed is active" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should return the correct feed title" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should set an item unstarred" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should set an item starred" time="0.001" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should set an item read" time="0.001" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should not set an item read if its kept unread" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should no set an item read if its already read" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should return false when item kept unread does not exist" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should return false if an item is not kept unread" time="0.001" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should toggle an item as kept unread" time="0.011" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should set an item as unread" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should not set an item as unread if its unread" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should set item as unread if kept unread is toggled and it is read" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should lower the unread count of a feed when its items get read" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should increase the unread count of a feed when its items get unread" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should load the next items" time="0.002" classname="PhantomJS 1.9 (Linux).ItemBusinessLayer"/>
<testcase name="should not be visible if starredCount is 0" time="0.002" classname="PhantomJS 1.9 (Linux).StarredBusinessLayer"/>
<testcase name="should always be visible if its the active feed" time="0.002" classname="PhantomJS 1.9 (Linux).StarredBusinessLayer"/>
<testcase name="should get the correct unread count" time="0.002" classname="PhantomJS 1.9 (Linux).StarredBusinessLayer"/>
<testcase name="should increase the starred count" time="0.001" classname="PhantomJS 1.9 (Linux).StarredBusinessLayer"/>
<testcase name="should decrease the starred count" time="0.001" classname="PhantomJS 1.9 (Linux).StarredBusinessLayer"/>
<testcase name="should be visible shows all items is set to true and there are feeds" time="0.003" classname="PhantomJS 1.9 (Linux).SubscriptionsBusinessLayer"/>
<testcase name="should not be visible if there are no feeds" time="0.002" classname="PhantomJS 1.9 (Linux).SubscriptionsBusinessLayer"/>
<testcase name="should not be visible if showall is false + there are no unread" time="0.002" classname="PhantomJS 1.9 (Linux).SubscriptionsBusinessLayer"/>
<testcase name="should always be visible if its the active feed" time="0.002" classname="PhantomJS 1.9 (Linux).SubscriptionsBusinessLayer"/>
<testcase name="should mark all feeds as read" time="0.002" classname="PhantomJS 1.9 (Linux).SubscriptionsBusinessLayer"/>
<testcase name="should get the correct unread count" time="0.005" classname="PhantomJS 1.9 (Linux).SubscriptionsBusinessLayer"/>
<testcase name="should have the correct folder number" time="0.002" classname="PhantomJS 1.9 (Linux).FeedType"/>
<testcase name="should have the correct folder number" time="0.002" classname="PhantomJS 1.9 (Linux).FeedType"/>
<testcase name="should have the correct folder number" time="0.001" classname="PhantomJS 1.9 (Linux).FeedType"/>
<testcase name="should have the correct folder number" time="0.002" classname="PhantomJS 1.9 (Linux).FeedType"/>
<testcase name="should have the correct folder number" time="0.001" classname="PhantomJS 1.9 (Linux).FeedType"/>
<testcase name="should be en by default" time="0.002" classname="PhantomJS 1.9 (Linux).Language"/>
<testcase name="should set the correct language" time="0.007" classname="PhantomJS 1.9 (Linux).Language"/>
<testcase name="should only set the first part of the language if not available" time="0.003" classname="PhantomJS 1.9 (Linux).Language"/>
<testcase name="should default to en" time="0.001" classname="PhantomJS 1.9 (Linux).Language"/>
<testcase name="should support languages" time="0.002" classname="PhantomJS 1.9 (Linux).Language"/>
<testcase name="should extend _Model" time="0.002" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should bind an imagepath to the item if the url is empty" time="0.001" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should add feeds without id" time="0.002" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should clear the url cache" time="0.001" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should delete items from the fodername cache" time="0.002" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should update the id if an update comes in with an id" time="0.002" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should update normally" time="0.001" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should clear invalidate the query cache on adding folder with name" time="0.002" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should only update feeds that contain only an id but no url" time="0.001" classname="PhantomJS 1.9 (Linux).FeedModel"/>
<testcase name="should extend model" time="0.001" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should add folders without id but name if they dont exist yet" time="0.002" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should clear the fodername cache" time="0.001" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should delete items from the fodername cache" time="0.002" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should update by foldername" time="0.001" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should update the id if an update comes in with an id" time="0.012" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should update normally" time="0.002" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should clear invalidate the query cache on adding folder with name" time="0.001" classname="PhantomJS 1.9 (Linux).FolderModel"/>
<testcase name="should extend model" time="0.002" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should also update items with the same feed id and guidhash" time="0.002" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should also remove the feed from the url cache when its removed" time="0.002" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should bind the correct isRead() method to the item" time="0.001" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should bind the correct set unread method to the item" time="0.001" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should bind the correct set starred method to the item" time="0.002" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should bind the correct set unstarred method to the item" time="0.001" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should return the lowest id" time="0.002" classname="PhantomJS 1.9 (Linux).ItemModel"/>
<testcase name="should return only the root folder when parsing empty OPML" time="0.004" classname="PhantomJS 1.9 (Linux).OPMLParser"/>
<testcase name="should parse folders" time="0.003" classname="PhantomJS 1.9 (Linux).OPMLParser"/>
<testcase name="should parse feeds" time="0.003" classname="PhantomJS 1.9 (Linux).OPMLParser"/>
<testcase name="should nest feeds" time="0.004" classname="PhantomJS 1.9 (Linux).OPMLParser"/>
<testcase name="should send a autopaging request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should send a load newest items request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct get starred items request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct star item request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct unstar item request" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct read item request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct unread item request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should get all feeds" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="create a correct request for moving a feed" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="shoud send a correct request for marking all items read" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct feed update request" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct get active feed request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct feed delete request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct feed create request" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper get all folders request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct collapse folder request" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="send a correct open folder request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper folder create request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper folder delete request" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper folder rename request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should have an export request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper get user settings read request" time="0.001" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper user settings read show request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper user settings read hide request" time="0.002" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should do a proper user settings language request" time="0.011" classname="PhantomJS 1.9 (Linux).Persistence"/>
<testcase name="should be false by default" time="0.002" classname="PhantomJS 1.9 (Linux).ShowAll"/>
<testcase name="should set the correct ShowAll value" time="0.001" classname="PhantomJS 1.9 (Linux).ShowAll"/>
<testcase name="should provide a set Showall setter" time="0.001" classname="PhantomJS 1.9 (Linux).ShowAll"/>
<testcase name="should be 0 by default" time="0.002" classname="PhantomJS 1.9 (Linux).StarredCount"/>
<testcase name="should set the correct StarredCount count" time="0.001" classname="PhantomJS 1.9 (Linux).StarredCount"/>
<testcase name="should provide a setter" time="0.001" classname="PhantomJS 1.9 (Linux).StarredCount"/>
<testcase name="should have the correct status flags" time="0.002" classname="PhantomJS 1.9 (Linux).StatusFlag"/>
<testcase name="should return the normal count if its below 999" time="0.001" classname="PhantomJS 1.9 (Linux).unreadCountFormatter"/>
<testcase name="should set the count to 999+ if the count is over 999" time="0.001" classname="PhantomJS 1.9 (Linux).unreadCountFormatter"/>
<system-out><![CDATA[
]]></system-out>
<system-err/>
</testsuite>
</testsuites>

Просмотреть файл

@ -58,16 +58,16 @@ describe 'FeedBusinessLayer', ->
it 'should return the number of unread feeds', =>
@FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'})
@FeedModel.add({id: 3, unreadCount:134, url: 'a1'})
count = @FeedBusinessLayer.getUnreadCount(3)
expect(count).toBe(134)
it 'should return all feeds of a folder', =>
feed1 = {id: 3, unreadCount:134, urlHash: 'a1', folderId: 3}
feed2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 2}
feed3 = {id: 5, unreadCount:134, urlHash: 'a3', folderId: 3}
feed1 = {id: 3, unreadCount:134, url: 'a1', folderId: 3}
feed2 = {id: 4, unreadCount:134, url: 'a2', folderId: 2}
feed3 = {id: 5, unreadCount:134, url: 'a3', folderId: 3}
@FeedModel.add(feed1)
@FeedModel.add(feed2)
@FeedModel.add(feed3)
@ -79,10 +79,10 @@ describe 'FeedBusinessLayer', ->
it 'should get the correct unread count for folders', =>
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 5, urlHash: 'a3'})
@FeedModel.add({id: 2, unreadCount:35, folderId: 3, urlHash: 'a4'})
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 5, url: 'a3'})
@FeedModel.add({id: 2, unreadCount:35, folderId: 3, url: 'a4'})
count = @FeedBusinessLayer.getFolderUnreadCount(3)
expect(count).toBe(169)
@ -91,7 +91,7 @@ describe 'FeedBusinessLayer', ->
it 'should mark feed as read', =>
@ActiveFeed.handle({type: @FeedType.Feed, id: 5})
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'})
@ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'})
@ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'})
@ -106,7 +106,7 @@ describe 'FeedBusinessLayer', ->
it 'should mark feed as read and set 0 if as highest id if its not active',=>
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'})
@ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'})
@ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'})
@ -121,9 +121,9 @@ describe 'FeedBusinessLayer', ->
it 'should mark all as read', =>
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 3, urlHash: 'a3'})
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 3, url: 'a3'})
@FeedBusinessLayer.markAllRead()
@ -133,16 +133,16 @@ describe 'FeedBusinessLayer', ->
it 'should get the correct unread count for subscribtions', =>
@FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, urlHash: 'a2'})
@FeedModel.add({id: 3, unreadCount:134, url: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, url: 'a2'})
count = @FeedBusinessLayer.getAllUnreadCount()
expect(count).toBe(136)
it 'should return the correct number of feeds', =>
@FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, urlHash: 'a2'})
@FeedModel.add({id: 3, unreadCount:134, url: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, url: 'a2'})
count = @FeedBusinessLayer.getNumberOfFeeds()
expect(count).toBe(2)
@ -161,13 +161,13 @@ describe 'FeedBusinessLayer', ->
it 'should be visible if unreadcount bigger than 0', =>
@FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1'})
@FeedModel.add({id: 2, unreadCount:134, url: 'a1'})
expect(@FeedBusinessLayer.isVisible(2)).toBe(true)
it 'should not move the feed to a new folder', =>
@persistence.moveFeed = jasmine.createSpy('Move feed')
@FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1', folderId: 3})
@FeedModel.add({id: 2, unreadCount:134, url: 'a1', folderId: 3})
@FeedBusinessLayer.move(2, 4)
expect(@persistence.moveFeed).toHaveBeenCalledWith(2, 4)
@ -176,7 +176,7 @@ describe 'FeedBusinessLayer', ->
it 'should not move the feed to the same folder', =>
@persistence.moveFeed = jasmine.createSpy('Move feed')
@FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1', folderId: 3})
@FeedModel.add({id: 2, unreadCount:134, url: 'a1', folderId: 3})
@FeedBusinessLayer.move(2, 3)
expect(@persistence.moveFeed).not.toHaveBeenCalled()
@ -198,8 +198,8 @@ describe 'FeedBusinessLayer', ->
it 'should return all feeds', =>
item1 = {id: 2, unreadCount:134, urlHash: 'a1', folderId: 3}
item2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 3}
item1 = {id: 2, unreadCount:134, url: 'a1', folderId: 3}
item2 = {id: 4, unreadCount:134, url: 'a2', folderId: 3}
@FeedModel.add(item1)
@FeedModel.add(item2)
@ -216,9 +216,9 @@ describe 'FeedBusinessLayer', ->
it 'should return all feeds of a folder', =>
item1 = {id: 2, unreadCount:134, urlHash: 'a1', folderId: 3}
item2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 2}
item3 = {id: 5, unreadCount:134, urlHash: 'a3', folderId: 3}
item1 = {id: 2, unreadCount:134, url: 'a1', folderId: 3}
item2 = {id: 4, unreadCount:134, url: 'a2', folderId: 2}
item3 = {id: 5, unreadCount:134, url: 'a3', folderId: 3}
@FeedModel.add(item1)
@FeedModel.add(item2)
@FeedModel.add(item3)
@ -233,7 +233,7 @@ describe 'FeedBusinessLayer', ->
item2 =
id: 4,
unreadCount:134,
urlHash: 'a2',
url: 'a2',
folderId: 3,
link: 'test.com'
@FeedModel.add(item2)
@ -243,7 +243,7 @@ describe 'FeedBusinessLayer', ->
it 'should not create a feed if it already exists', =>
item1 = {urlHash: hex_md5('john')}
item1 = {url: 'john'}
@FeedModel.add(item1)
expect =>
@ -269,13 +269,11 @@ describe 'FeedBusinessLayer', ->
it 'should set a title and an url hash to the newly crated feed', =>
url = 'www.google.de'
@FeedBusinessLayer.create(url)
hash = hex_md5(url)
feed = @FeedModel.getByUrlHash(hash)
feed = @FeedModel.getByUrl(url)
expect(feed.title).toBe('www.google.de')
expect(feed.url).toBe(url)
expect(feed.urlHash).toBe(hash)
expect(feed.folderId).toBe(0)
expect(feed.unreadCount).toBe(0)
expect(@imagePath).toHaveBeenCalledWith('core', 'loading.gif')
@ -318,22 +316,22 @@ describe 'FeedBusinessLayer', ->
expect(onSuccess).not.toHaveBeenCalled()
expect(onFailure).toHaveBeenCalled()
expect(@FeedModel.getByUrlHash(hex_md5('johns')).error).toBe(
expect(@FeedModel.getByUrl('johns').error).toBe(
@response.msg)
it 'should mark a feed error as read by removing it', =>
@FeedModel.add({id: 3, urlHash: 'john'})
@FeedModel.add({id: 3, url: 'john'})
@FeedBusinessLayer.markErrorRead('john')
expect(@FeedModel.size()).toBe(0)
expect(@FeedModel.getByUrlHash('john')).toBe(undefined)
expect(@FeedModel.getByUrl('john')).toBe(undefined)
it 'should update all feeds', =>
@persistence.updateFeed = jasmine.createSpy('update')
@FeedModel.add({id: 3, urlHash: 'john'})
@FeedModel.add({id: 3, url: 'john'})
@FeedBusinessLayer.updateFeeds()
@ -342,7 +340,7 @@ describe 'FeedBusinessLayer', ->
it 'should not update feeds without ids', =>
@persistence.updateFeed = jasmine.createSpy('update')
@FeedModel.add({urlHash: 'john'})
@FeedModel.add({url: 'john'})
@FeedBusinessLayer.updateFeeds()

Просмотреть файл

@ -54,10 +54,10 @@ describe 'FolderBusinessLayer', ->
it 'should return true when folder has feeds', =>
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
expect(@FolderBusinessLayer.hasFeeds(3)).toBeFalsy()
@FeedModel.add({id: 2, unreadCount:35, folderId: 3, urlHash: 'a2'})
@FeedModel.add({id: 2, unreadCount:35, folderId: 3, url: 'a2'})
expect(@FolderBusinessLayer.hasFeeds(3)).toBeTruthy()
@ -80,9 +80,9 @@ describe 'FolderBusinessLayer', ->
it 'should mark folder as read', =>
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 3, urlHash: 'a3'})
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 3, url: 'a3'})
@FolderBusinessLayer.markFolderRead(3)
@ -92,9 +92,9 @@ describe 'FolderBusinessLayer', ->
it 'should get the correct unread count', =>
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
@FeedModel.add({id: 6, unreadCount:3, folderId: 3, urlHash: 'a2'})
@FeedModel.add({id: 7, unreadCount:4, folderId: 2, urlHash: 'a3'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@FeedModel.add({id: 6, unreadCount:3, folderId: 3, url: 'a2'})
@FeedModel.add({id: 7, unreadCount:4, folderId: 2, url: 'a3'})
expect(@FolderBusinessLayer.getUnreadCount(2)).toBe(6)
@ -112,18 +112,18 @@ describe 'FolderBusinessLayer', ->
it 'should be visible if one of its subfeeds is active', =>
@FeedModel.add({id: 5, unreadCount:0, folderId: 2, urlHash: 'a1'})
@FeedModel.add({id: 6, unreadCount:0, folderId: 3, urlHash: 'a2'})
@FeedModel.add({id: 7, unreadCount:0, folderId: 2, urlHash: 'a3'})
@FeedModel.add({id: 5, unreadCount:0, folderId: 2, url: 'a1'})
@FeedModel.add({id: 6, unreadCount:0, folderId: 3, url: 'a2'})
@FeedModel.add({id: 7, unreadCount:0, folderId: 2, url: 'a3'})
@ActiveFeed.handle({type: @FeedType.Feed, id:6})
expect(@FolderBusinessLayer.isVisible(3)).toBe(true)
it 'should be visible if showAll is false and it has unread items', =>
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
@FeedModel.add({id: 6, unreadCount:3, folderId: 3, urlHash: 'a2'})
@FeedModel.add({id: 7, unreadCount:4, folderId: 2, urlHash: 'a3'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@FeedModel.add({id: 6, unreadCount:3, folderId: 3, url: 'a2'})
@FeedModel.add({id: 7, unreadCount:4, folderId: 2, url: 'a3'})
@ActiveFeed.handle({type: @FeedType.Folder, id:2})
expect(@FolderBusinessLayer.isVisible(3)).toBe(true)
@ -415,7 +415,7 @@ describe 'FolderBusinessLayer', ->
@persistence.createFolder = jasmine.createSpy('create folder')
@persistence.createFeed = jasmine.createSpy('create feed')
@FeedModel.add({urlHash: hex_md5('http://worrydream.com/feed.xml')})
@FeedModel.add({url: 'http://worrydream.com/feed.xml'})
xml = '<?xml version="1.0" ?>
<opml version="1.1">

Просмотреть файл

@ -33,7 +33,7 @@ describe 'ItemBusinessLayer', ->
beforeEach inject (@ItemModel, @ItemBusinessLayer, @StatusFlag, @ActiveFeed
@FeedType, @FeedModel, @StarredBusinessLayer) =>
@item1 = {id: 5, title: 'hi', unreadCount:134, urlHash: 'a3', folderId: 3}
@item1 = {id: 5, title: 'hi', unreadCount:134, url: 'a3', folderId: 3}
@FeedModel.add(@item1)
@ActiveFeed.handle({type: @FeedType.Feed, id: 3})

Просмотреть файл

@ -40,7 +40,7 @@ describe 'SubscriptionsBusinessLayer', ->
it 'should be visible shows all items is set to true and there are feeds', =>
@FeedModel.add({id: 3, unreadCount: 5, urlHash: 'hi'})
@FeedModel.add({id: 3, unreadCount: 5, url: 'hi'})
expect(@SubscriptionsBusinessLayer.isVisible()).toBe(true)
@ -66,7 +66,7 @@ describe 'SubscriptionsBusinessLayer', ->
it 'should mark all feeds as read', =>
item = {id: 3, unreadCount: 132, urlHash: 'hi'}
item = {id: 3, unreadCount: 132, url: 'hi'}
@FeedModel.add(item)
@SubscriptionsBusinessLayer.markAllRead()
@ -76,8 +76,8 @@ describe 'SubscriptionsBusinessLayer', ->
it 'should get the correct unread count', =>
@FeedModel.add({id: 3, unreadCount: 132, urlHash: 'hoho'})
@FeedModel.add({id: 4, unreadCount: 12, urlHash: 'hohod'})
@FeedModel.add({id: 3, unreadCount: 132, url: 'hoho'})
@FeedModel.add({id: 4, unreadCount: 12, url: 'hohod'})
expect(@SubscriptionsBusinessLayer.getUnreadCount()).toBe(144)

Просмотреть файл

@ -45,7 +45,7 @@ describe 'FeedModel', ->
item =
id: 3
faviconLink: null
urlHash: 'hi'
url: 'hi'
@FeedModel.add(item)
@ -53,82 +53,82 @@ describe 'FeedModel', ->
it 'should add feeds without id', =>
item = {faviconLink: null, urlHash: 'hi'}
item = {faviconLink: null, url: 'hi'}
@FeedModel.add(item)
item2 = {faviconLink: null, urlHash: 'his'}
item2 = {faviconLink: null, url: 'his'}
@FeedModel.add(item2)
expect(@FeedModel.getByUrlHash('hi')).toBe(item)
expect(@FeedModel.getByUrl('hi')).toBe(item)
expect(@FeedModel.size()).toBe(2)
it 'should clear the url hash cache', =>
item = {faviconLink: null, urlHash: 'hi'}
it 'should clear the url cache', =>
item = {faviconLink: null, url: 'hi'}
@FeedModel.add(item)
@FeedModel.clear()
expect(@FeedModel.getByUrlHash('hi')).toBe(undefined)
expect(@FeedModel.getByUrl('hi')).toBe(undefined)
expect(@FeedModel.size()).toBe(0)
it 'should delete items from the fodername cache', =>
item = {id:3, faviconLink: null, urlHash: 'hi'}
item = {id:3, faviconLink: null, url: 'hi'}
@FeedModel.add(item)
expect(@FeedModel.size()).toBe(1)
@FeedModel.removeById(3)
expect(@FeedModel.getByUrlHash('hi')).toBe(undefined)
expect(@FeedModel.getByUrl('hi')).toBe(undefined)
expect(@FeedModel.size()).toBe(0)
it 'should update the id if an update comes in with an id', =>
item = {faviconLink: null, urlHash: 'hi', test: 'heheh'}
item = {faviconLink: null, url: 'hi', test: 'heheh'}
@FeedModel.add(item)
item2 = {id: 3, faviconLink: null, urlHash: 'hi', test: 'hoho'}
item2 = {id: 3, faviconLink: null, url: 'hi', test: 'hoho'}
@FeedModel.add(item2)
expect(@FeedModel.getByUrlHash('hi').id).toBe(3)
expect(@FeedModel.getByUrlHash('hi').test).toBe('hoho')
expect(@FeedModel.getByUrl('hi').id).toBe(3)
expect(@FeedModel.getByUrl('hi').test).toBe('hoho')
expect(@FeedModel.getById(3).id).toBe(3)
expect(@FeedModel.getById(3).test).toBe('hoho')
expect(@FeedModel.size()).toBe(1)
it 'should update normally', =>
item = {id: 3, faviconLink: null, urlHash: 'hi', test: 'heheh'}
item = {id: 3, faviconLink: null, url: 'hi', test: 'heheh'}
@FeedModel.add(item)
item2 = {id: 3, faviconLink: null, urlHash: 'his', test: 'hoho'}
item2 = {id: 3, faviconLink: null, url: 'his', test: 'hoho'}
@FeedModel.add(item2)
expect(@FeedModel.getByUrlHash('hi')).toBe(undefined)
expect(@FeedModel.getByUrlHash('his').id).toBe(3)
expect(@FeedModel.getByUrlHash('his').test).toBe('hoho')
expect(@FeedModel.getByUrl('hi')).toBe(undefined)
expect(@FeedModel.getByUrl('his').id).toBe(3)
expect(@FeedModel.getByUrl('his').test).toBe('hoho')
expect(@FeedModel.getById(3).test).toBe('hoho')
expect(@FeedModel.size()).toBe(1)
it 'should clear invalidate the query cache on adding folder with name', =>
item = {faviconLink: null, urlHash: 'hi', test: 'heheh', folderId: 0}
item = {faviconLink: null, url: 'hi', test: 'heheh', folderId: 0}
expect(@FeedModel.getAllOfFolder(0).length).toBe(0)
@FeedModel.add(item, false)
expect(@FeedModel.getAllOfFolder(0).length).toBe(0)
item2 = {faviconLink: null, urlHash: 'his', test: 'heheh', folderId: 0}
item2 = {faviconLink: null, url: 'his', test: 'heheh', folderId: 0}
@FeedModel.add(item2)
expect(@FeedModel.getAllOfFolder(0).length).toBe(2)
it 'should only update feeds that contain only an id but no url hash', =>
it 'should only update feeds that contain only an id but no url', =>
item = {id: 3, unreadCount: 232}
@FeedModel.add(item)
expect(@FeedModel.size()).toBe(0)
item2 = {id: 3, unreadCount: 2, faviconLink: null, urlHash: 'his'}
item2 = {id: 3, unreadCount: 2, faviconLink: null, url: 'his'}
@FeedModel.add(item2)
@FeedModel.add(item)

Просмотреть файл

@ -57,7 +57,7 @@ describe 'ItemModel', ->
expect(@ItemModel.size()).toBe(2)
it 'should also remove the feed from the urlHash cache when its removed', =>
it 'should also remove the feed from the url cache when its removed', =>
item = {id: 4, guidHash: 'abc', feedId: 3}
@ItemModel.add(item)

379
js/vendor/md5js/md5.js поставляемый
Просмотреть файл

@ -1,379 +0,0 @@
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s) { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
function b64_md5(s) { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
function hex_hmac_md5(k, d)
{ return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
function b64_hmac_md5(k, d)
{ return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
function any_hmac_md5(k, d, e)
{ return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s)
{
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac_md5(key, data)
{
var bkey = rstr2binl(key);
if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input)
{
try { hexcase } catch(e) { hexcase=0; }
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var output = "";
var x;
for(var i = 0; i < input.length; i++)
{
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F)
+ hex_tab.charAt( x & 0x0F);
}
return output;
}
/*
* Convert a raw string to a base-64 string
*/
function rstr2b64(input)
{
try { b64pad } catch(e) { b64pad=''; }
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var output = "";
var len = input.length;
for(var i = 0; i < len; i += 3)
{
var triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > input.length * 8) output += b64pad;
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
}
}
return output;
}
/*
* Convert a raw string to an arbitrary string encoding
*/
function rstr2any(input, encoding)
{
var divisor = encoding.length;
var i, j, q, x, quotient;
/* Convert to an array of 16-bit big-endian values, forming the dividend */
var dividend = Array(Math.ceil(input.length / 2));
for(i = 0; i < dividend.length; i++)
{
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
}
/*
* Repeatedly perform a long division. The binary array forms the dividend,
* the length of the encoding is the divisor. Once computed, the quotient
* forms the dividend for the next step. All remainders are stored for later
* use.
*/
var full_length = Math.ceil(input.length * 8 /
(Math.log(encoding.length) / Math.log(2)));
var remainders = Array(full_length);
for(j = 0; j < full_length; j++)
{
quotient = Array();
x = 0;
for(i = 0; i < dividend.length; i++)
{
x = (x << 16) + dividend[i];
q = Math.floor(x / divisor);
x -= q * divisor;
if(quotient.length > 0 || q > 0)
quotient[quotient.length] = q;
}
remainders[j] = x;
dividend = quotient;
}
/* Convert the remainders to the output string */
var output = "";
for(i = remainders.length - 1; i >= 0; i--)
output += encoding.charAt(remainders[i]);
return output;
}
/*
* Encode a string as utf-8.
* For efficiency, this assumes the input is valid utf-16.
*/
function str2rstr_utf8(input)
{
var output = "";
var i = -1;
var x, y;
while(++i < input.length)
{
/* Decode utf-16 surrogate pairs */
x = input.charCodeAt(i);
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
{
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i++;
}
/* Encode output as utf-8 */
if(x <= 0x7F)
output += String.fromCharCode(x);
else if(x <= 0x7FF)
output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
0x80 | ( x & 0x3F));
else if(x <= 0xFFFF)
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
0x80 | ((x >>> 6 ) & 0x3F),
0x80 | ( x & 0x3F));
else if(x <= 0x1FFFFF)
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
0x80 | ((x >>> 12) & 0x3F),
0x80 | ((x >>> 6 ) & 0x3F),
0x80 | ( x & 0x3F));
}
return output;
}
/*
* Encode a string as utf-16
*/
function str2rstr_utf16le(input)
{
var output = "";
for(var i = 0; i < input.length; i++)
output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
(input.charCodeAt(i) >>> 8) & 0xFF);
return output;
}
function str2rstr_utf16be(input)
{
var output = "";
for(var i = 0; i < input.length; i++)
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
input.charCodeAt(i) & 0xFF);
return output;
}
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input)
{
var output = Array(input.length >> 2);
for(var i = 0; i < output.length; i++)
output[i] = 0;
for(var i = 0; i < input.length * 8; i += 8)
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
return output;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input)
{
var output = "";
for(var i = 0; i < input.length * 32; i += 8)
output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
return output;
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}

Просмотреть файл

@ -5,7 +5,6 @@
\OCP\Util::addScript('appframework', 'vendor/angular/angular');
\OCP\Util::addScript('appframework', 'public/app');
\OCP\Util::addScript('news', 'vendor/md5js/md5');
\OCP\Util::addScript('news', 'vendor/angular-ui/angular-ui');
\OCP\Util::addScript('news', 'public/app');

Просмотреть файл

@ -36,20 +36,17 @@
<button class="svg action mark-read-icon"
ng-show="feedBusinessLayer.getUnreadCount(feed.id) > 0 && feed.id"
ng-click="feedBusinessLayer.markFeedRead(feed.id)"
title="<?php p($l->t('Mark all read')); ?>"
oc-tipsy="{gravity: 's'}"> </button>
title="<?php p($l->t('Mark all read')); ?>"> </button>
<button ng-click="feedBusinessLayer.delete(feed.id)"
class="svg action delete-icon"
title="<?php p($l->t('Delete feed')); ?>"
ng-show="feed.id"
oc-tipsy="{gravity: 's'}"></button>
ng-show="feed.id"></button>
<button class="svg action delete-icon"
ng-click="feedBusinessLayer.markErrorRead(feed.urlHash)"
title="<?php p($l->t('Delete website')); ?>"
ng-show="feed.error"
oc-tipsy="{gravity: 's'}"></button>
ng-show="feed.error"></button>
</span>
<div class="message" ng-show="feed.error">{{ feed.error }}</div>

Просмотреть файл

@ -28,8 +28,7 @@
<button ng-click="folderBusinessLayer.delete(folder.id)"
ng-hide="folderBusinessLayer.hasFeeds(folder.id) || !folder.id"
class="svg action delete-icon"
title="<?php p($l->t('Delete folder')); ?>"
oc-tipsy="{gravity: 's'}"></button>
title="<?php p($l->t('Delete folder')); ?>"></button>
<span class="unread-counter"
ng-show="folderBusinessLayer.getUnreadCount(folder.id) > 0">
@ -39,18 +38,15 @@
<button class="svg action mark-read-icon"
ng-show="folderBusinessLayer.getUnreadCount(folder.id) > 0 && folder.id"
ng-click="folderBusinessLayer.markFolderRead(folder.id)"
title="<?php p($l->t('Mark all read')); ?>"
oc-tipsy="{gravity: 's'}"></button>
title="<?php p($l->t('Mark all read')); ?>"></button>
<button class="svg action delete-icon"
ng-click="folderBusinessLayer.markErrorRead(folder.name)"
title="<?php p($l->t('Delete folder')); ?>"
ng-show="folder.error"
oc-tipsy="{gravity: 's'}"></button>
ng-show="folder.error"></button>
<!-- <button class="svg action edit-icon"
ng-click="renameFolder(folder.id)"
oc-tipsy
title="<?php p($l->t('Rename folder')); ?>"></button>
-->