Fix missing photos in the single post view

closes #7545
This commit is contained in:
Steffen van Bergerem 2017-08-17 01:02:06 +02:00 committed by Benjamin Neff
parent b49b33675f
commit 4cb365a6f4
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
2 changed files with 10 additions and 5 deletions

View file

@ -17,15 +17,14 @@ app.views.Content = app.views.Base.extend({
largePhoto : function() {
var photos = this.model.get("photos");
if(!photos || photos.length === 0) { return }
if (!photos || photos.length === 0) { return false; }
return photos[0];
},
smallPhotos : function() {
var photos = this.model.get("photos");
if(!photos || photos.length < 2) { return }
photos.splice(0, 1); // remove first photo as it is already shown as largePhoto
return photos;
if (!photos || photos.length < 2) { return false; }
return photos.slice(1); // remove first photo as it is already shown as largePhoto
},
expandPost: function(evt) {

View file

@ -4,11 +4,17 @@ describe("app.views.Content", function(){
this.view = new app.views.Content({model : this.post});
});
describe("rendering", function(){
describe("smallPhotos", function() {
it("should return all but the first photo from the post", function() {
this.post.set({photos : [1,2]}); // set 2 Photos
expect(this.view.smallPhotos().length).toEqual(1);
});
it("shouldn't change the photos array", function() {
this.post.set({photos: [1, 2]}); // set 2 Photos
this.view.smallPhotos();
expect(this.post.get("photos").length).toEqual(2);
});
});
describe("presenter", function(){