Skip to content

Commit

Permalink
mark items on page 2+ read as well, update tests
Browse files Browse the repository at this point in the history
Update integration tests, to ensure that all articles are marked read,
instead of only visible.
  • Loading branch information
mkresin committed Apr 7, 2015
1 parent 13aaf5f commit ee98a62
Show file tree
Hide file tree
Showing 14 changed files with 2,342 additions and 193 deletions.
32 changes: 16 additions & 16 deletions assets/js/all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Miniflux.Event = (function() {
currentItem && Miniflux.Item.DownloadContent(currentItem);
break;
case 'mark-all-read':
Miniflux.Item.MarkListingAsRead("?action=unread");
Miniflux.Item.MarkAllAsRead('?action=unread');
break;
case 'mark-feed-read':
Miniflux.Item.MarkFeedAsRead(e.target.getAttribute("data-feed-id"));
Expand Down
13 changes: 3 additions & 10 deletions assets/js/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,15 @@ Miniflux.Item = (function() {
request.open("POST", "?action=download-item&id=" + item_id, true);
request.send();
},
MarkListingAsRead: function(redirect) {
var articles = document.getElementsByTagName("article");
var listing = [];

for (var i = 0, ilen = articles.length; i < ilen; i++) {
listing.push(getItemID(articles[i]));
}

MarkAllAsRead: function(redirect) {
var request = new XMLHttpRequest();

request.onload = function() {
window.location.href = redirect;
};

request.open("POST", "?action=mark-items-as-read", true);
request.send(JSON.stringify(listing));
request.open("POST", "?action=mark-all-read", true);
request.send();
},
MarkFeedAsRead: function(feed_id) {
var request = new XMLHttpRequest();
Expand Down
16 changes: 8 additions & 8 deletions controllers/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,19 @@
});

// Mark all unread items as read
Router\get_action('mark-as-read', function() {
Router\get_action('mark-all-read', function() {

Model\Item\mark_all_as_read();
Response\redirect('?action=unread');
});

// Mark all unread items as read (Ajax request)
Router\post_action('mark-all-read', function(){

Model\Item\mark_all_as_read();
Response\json(array('OK'));
});

// Mark all unread items as read for a specific feed
Router\get_action('mark-feed-as-read', function() {

Expand All @@ -187,13 +194,6 @@
Response\raw($nb_items);
});

// Mark sent items id as read (Ajax request)
Router\post_action('mark-items-as-read', function(){

Model\Item\mark_items_as_read(Request\values());
Response\json(array('OK'));
});

// Mark item as read and redirect to the listing page
Router\get_action('mark-item-read', function() {

Expand Down
8 changes: 6 additions & 2 deletions docs/tests.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@ The following `phpunit.xml` is used to run phpunit on a linux system with apache

```

You can run the tests by executing phpunit within the Miniflux directory:
Some tests don't run with every browser. You have to exclude those tests by using the ```--exclude-group``` commandline parameter. The following exclude groups exists:

* moz_unsupported (Due to https://github.com/SeleniumHQ/selenium/issues/386)
* ie_unsupported (Due to https://code.google.com/p/selenium/issues/detail?id=4973)

You can run the tests by executing phpunit within the Miniflux directory:

```bash
/usr/local/bin/phpunit
/usr/local/bin/phpunit --exclude-group ie_unsupported

PHPUnit 4.4.0 by Sebastian Bergmann.

Expand Down
12 changes: 0 additions & 12 deletions models/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,6 @@ function mark_all_as_removed()
->save(array('status' => 'removed', 'content' => ''));
}

// Mark only specified items as read
function mark_items_as_read(array $items_id)
{
Database::get('db')->startTransaction();

foreach ($items_id as $id) {
set_read($id);
}

Database::get('db')->closeTransaction();
}

// Mark all items of a feed as read
function mark_feed_as_read($feed_id)
{
Expand Down
4 changes: 2 additions & 2 deletions templates/unread_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a href="?action=unread&amp;order=updated&amp;direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= tne('sort by date %s(%s)%s', '<span class="hide-mobile">',$direction == 'desc' ? t('older first') : t('most recent first'), '</span>') ?></a>
</li>
<li>
<a href="?action=mark-as-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
<a href="?action=mark-all-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
</li>
</ul>
</div>
Expand All @@ -28,7 +28,7 @@
<?php endforeach ?>

<div id="bottom-menu">
<a href="?action=mark-as-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
<a href="?action=mark-all-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
</div>

<?= \PicoFarad\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
Expand Down
Loading

0 comments on commit ee98a62

Please sign in to comment.