mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-20 21:16:56 +00:00
Fixed adding of Newznab provider.
This commit is contained in:
parent
e35a4bf8ac
commit
5ad11ba728
4 changed files with 46 additions and 5 deletions
|
@ -56,6 +56,46 @@ public void Save_should_clean_url_before_updating()
|
||||||
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Save_should_clean_url_before_inserting_when_url_is_not_empty()
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "" };
|
||||||
|
var expectedUrl = "";
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<NewznabProvider>().Save(newznab);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Save_should_clean_url_before_updating_when_url_is_not_empty()
|
||||||
|
{
|
||||||
|
//Setup
|
||||||
|
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "http://www.nzbdrone.com" };
|
||||||
|
var expectedUrl = "";
|
||||||
|
var newUrl = "";
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
newznab.Id = Convert.ToInt32(db.Insert(newznab));
|
||||||
|
newznab.Url = newUrl;
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<NewznabProvider>().Save(newznab);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SaveAll_should_clean_urls_before_updating()
|
public void SaveAll_should_clean_urls_before_updating()
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,8 +37,9 @@ public virtual List<NewznabDefinition> All()
|
||||||
|
|
||||||
public virtual int Save(NewznabDefinition definition)
|
public virtual int Save(NewznabDefinition definition)
|
||||||
{
|
{
|
||||||
//Cleanup the URL
|
//Cleanup the URL if it is not null or whitespace
|
||||||
definition.Url = (new Uri(definition.Url).ParentUriString());
|
if (!String.IsNullOrWhiteSpace(definition.Url))
|
||||||
|
definition.Url = (new Uri(definition.Url).ParentUriString());
|
||||||
|
|
||||||
if (definition.Id == 0)
|
if (definition.Id == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -299,7 +299,7 @@ public JsonResult DeleteQualityProfile(int profileId)
|
||||||
return new JsonResult { Data = "ok" };
|
return new JsonResult { Data = "ok" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewResult AddNewznabProvider()
|
public PartialViewResult AddNewznabProvider()
|
||||||
{
|
{
|
||||||
var newznab = new NewznabDefinition
|
var newznab = new NewznabDefinition
|
||||||
{
|
{
|
||||||
|
@ -312,7 +312,7 @@ public ViewResult AddNewznabProvider()
|
||||||
|
|
||||||
ViewData["ProviderId"] = id;
|
ViewData["ProviderId"] = id;
|
||||||
|
|
||||||
return View("NewznabProvider", newznab);
|
return PartialView("NewznabProvider", newznab);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult GetNewznabProviderView(NewznabDefinition provider)
|
public ActionResult GetNewznabProviderView(NewznabDefinition provider)
|
||||||
|
|
|
@ -974,4 +974,4 @@ xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\x
|
||||||
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
|
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
|
||||||
xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
|
xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in a new issue