Added NewzbinId and Blacklisted to History.
HistoryProvider can check for blacklist via NzbTitle or NewzbinId.
This commit is contained in:
parent
2bf97fd76f
commit
b45b8f2e47
|
@ -191,5 +191,113 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
history.Quality.Should().Be(storedHistory.First().Quality);
|
||||
history.IsProper.Should().Be(storedHistory.First().IsProper);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_nzbTitle_doesnt_exist()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted("Not a Real NZB Title");
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_nzbTitle_is_not_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NzbTitle);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_true_if_nzbTitle_is_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NzbTitle);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_newzbinId_doesnt_exist()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(555);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_newzbinId_is_not_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NewzbinId);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_true_if_newzbinId_is_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NewzbinId);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20120127)]
|
||||
public class Migration20120127 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("History", "NewzbinId", DbType.Int32, ColumnProperty.Null);
|
||||
Database.AddColumn("History", "Blacklisted", DbType.Boolean, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -212,6 +212,7 @@
|
|||
<Compile Include="Datastore\MigrationLogger.cs" />
|
||||
<Compile Include="Datastore\MigrationsHelper.cs" />
|
||||
<Compile Include="Datastore\CustomeMapper.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120127.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120123.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120118.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20111125.cs" />
|
||||
|
|
|
@ -68,5 +68,15 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
_database.Delete<History>(historyId);
|
||||
}
|
||||
|
||||
public virtual bool IsBlacklisted(string nzbTitle)
|
||||
{
|
||||
return _database.Exists<History>("WHERE Blacklisted = 1 AND NzbTitle = @0", nzbTitle);
|
||||
}
|
||||
|
||||
public virtual bool IsBlacklisted(int newzbinId)
|
||||
{
|
||||
return _database.Exists<History>("WHERE Blacklisted = 1 AND NewzbinId = @0", newzbinId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@ namespace NzbDrone.Core.Repository
|
|||
public DateTime Date { get; set; }
|
||||
public bool IsProper { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public int NewzbinId { get; set; }
|
||||
public bool Blacklisted { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public Episode Episode { get; set; }
|
||||
|
|
Loading…
Reference in New Issue