Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
esbanarango committed Apr 22, 2016
1 parent 5f4505d commit d5e66f6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
11 changes: 11 additions & 0 deletions app/controllers/abstract-paged-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ export default Ember.Controller.extend(PaginationProps, ProgressDialog, UserSess
return (!Ember.isEmpty(this.get('previousStartKey')) || !Ember.isEmpty(this.get('nextStartKey')));
}.property('nextStartKey', 'previousStartKey'),

hasRecords: Ember.computed('model.length', {
get() {
let model = this.get('model');
if (!Ember.isEmpty(model)) {
return (model.get('length') > 0);
} else {
return false;
}
}
}),

actions: {
nextPage: function() {
var key = this.get('nextStartKey'),
Expand Down
3 changes: 0 additions & 3 deletions app/routes/abstract-index-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ export default Ember.Route.extend(PouchDbMixin, ProgressDialog, AuthenticatedRou
setupController: function(controller, model) {
var props = this.getProperties('firstKey', 'nextStartKey');
controller.setProperties(props);
if (!Ember.isEmpty(model)) {
controller.set('hasRecords', (model.get('length') > 0));
}
var sectionDetails = {
currentScreenTitle: this.get('pageTitle')
};
Expand Down
22 changes: 22 additions & 0 deletions tests/acceptance/inventory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ test('Adding a new inventory item', (assert) => {
});
});

test('Deleting the last inventory item', (assert) => {
runWithPouchDump('inventory', function() {
authenticateUser();
visit('/inventory/listing');

andThen(function() {
assert.equal(currentURL(), '/inventory/listing');
click('button:contains(Delete)');
waitToAppear('.modal-dialog');
andThen(() => {
assert.equal(find('.modal-title').text(), 'Delete Item', 'Deleting confirmation.');
});
click('.modal-content button:contains(Delete)');
andThen(function() {
assert.equal(currentURL(), '/inventory');
findWithAssert('p:contains(No requests found. )');
findWithAssert('a:contains(Create a new request?)');
});
});
});
});

test('Creating a new inventory request', function(assert) {
runWithPouchDump('inventory', function() {
authenticateUser();
Expand Down

0 comments on commit d5e66f6

Please sign in to comment.