mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed: History Repo GetById not always ordered by Date
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
@@ -57,5 +59,58 @@ namespace NzbDrone.Core.Test.HistoryTests
|
||||
|
||||
downloadHistory.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_movie_history()
|
||||
{
|
||||
var historyMovie1 = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 12)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
.BuildNew();
|
||||
|
||||
var historyMovie2 = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 13)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
.BuildNew();
|
||||
|
||||
Subject.Insert(historyMovie1);
|
||||
Subject.Insert(historyMovie2);
|
||||
|
||||
var movieHistory = Subject.GetByMovieId(12, null);
|
||||
|
||||
movieHistory.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_sort_movie_history_by_date()
|
||||
{
|
||||
var historyFirst = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 12)
|
||||
.With(c => c.EventType = HistoryEventType.MovieFileRenamed)
|
||||
.With(c => c.Date = DateTime.UtcNow)
|
||||
.BuildNew();
|
||||
|
||||
var historySecond = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.With(c => c.MovieId = 12)
|
||||
.With(c => c.EventType = HistoryEventType.Grabbed)
|
||||
.With(c => c.Date = DateTime.UtcNow.AddMinutes(10))
|
||||
.BuildNew();
|
||||
|
||||
Subject.Insert(historyFirst);
|
||||
Subject.Insert(historySecond);
|
||||
|
||||
var movieHistory = Subject.GetByMovieId(12, null);
|
||||
|
||||
movieHistory.Should().HaveCount(2);
|
||||
movieHistory.First().EventType.Should().Be(HistoryEventType.Grabbed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -66,9 +66,7 @@ namespace NzbDrone.Core.History
|
||||
query = query.Where(h => h.EventType == eventType).ToList();
|
||||
}
|
||||
|
||||
query.OrderByDescending(h => h.Date);
|
||||
|
||||
return query;
|
||||
return query.OrderByDescending(h => h.Date).ToList();
|
||||
}
|
||||
|
||||
public void DeleteForMovie(int movieId)
|
||||
|
Reference in New Issue
Block a user