Merge branch 'markus' into kay.one

pull/4/head
kay.one 13 years ago
commit c92e63b21a

@ -56,6 +56,46 @@ namespace NzbDrone.Core.Test.ProviderTests
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]
public void SaveAll_should_clean_urls_before_updating()
{

@ -101,6 +101,10 @@ namespace NzbDrone.Core.Test.ProviderTests
{
for (int i = 1; i < season.Value.Count; i++)
{
//Skip specials, because someone decided 1,3,4,6,7,21 is how you count...
if (season.Key == 0)
continue;
season.Value.Should().Contain(c => c.EpisodeNumber == i, "Can't find Episode S{0:00}E{1:00}",
season.Value[0].SeasonNumber, i);
}

@ -43,13 +43,13 @@ namespace NzbDrone.Core.Providers.Indexer
{
if (searchModel.SearchType == SearchType.EpisodeSearch)
{
searchUrls.Add(String.Format("{0}&q={1}&season{2}&ep{3}", url,
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season{2}&ep{3}", url,
searchModel.SeriesTitle, searchModel.SeasonNumber, searchModel.EpisodeNumber));
}
if (searchModel.SearchType == SearchType.SeasonSearch)
{
searchUrls.Add(String.Format("{0}&q={1}&season{2}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season{2}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
}
}

@ -37,8 +37,9 @@ namespace NzbDrone.Core.Providers
public virtual int Save(NewznabDefinition definition)
{
//Cleanup the URL
definition.Url = (new Uri(definition.Url).ParentUriString());
//Cleanup the URL if it is not null or whitespace
if (!String.IsNullOrWhiteSpace(definition.Url))
definition.Url = (new Uri(definition.Url).ParentUriString());
if (definition.Id == 0)
{

@ -91,7 +91,7 @@ namespace NzbDrone.Web.Controllers
NzbMatrixEnabled = _indexerProvider.GetSettings(typeof(NzbMatrix)).Enable,
NzbsRUsEnabled = _indexerProvider.GetSettings(typeof(NzbsRUs)).Enable,
NewzbinEnabled = _indexerProvider.GetSettings(typeof(Newzbin)).Enable,
NewznabEnabled = _indexerProvider.GetSettings(typeof(Newzbin)).Enable,
NewznabEnabled = _indexerProvider.GetSettings(typeof(Newznab)).Enable,
NewznabDefinitions = _newznabProvider.All(),
});
@ -299,7 +299,7 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "ok" };
}
public ViewResult AddNewznabProvider()
public PartialViewResult AddNewznabProvider()
{
var newznab = new NewznabDefinition
{
@ -312,7 +312,7 @@ namespace NzbDrone.Web.Controllers
ViewData["ProviderId"] = id;
return View("NewznabProvider", newznab);
return PartialView("NewznabProvider", newznab);
}
public ActionResult GetNewznabProviderView(NewznabDefinition provider)
@ -387,6 +387,10 @@ namespace NzbDrone.Web.Controllers
newzbinSettings.Enable = data.NewzbinEnabled;
_indexerProvider.SaveSettings(newzbinSettings);
var newznabSettings = _indexerProvider.GetSettings(typeof(Newznab));
newznabSettings.Enable = data.NewznabEnabled;
_indexerProvider.SaveSettings(newznabSettings);
_configProvider.NzbsOrgUId = data.NzbsOrgUId;
_configProvider.NzbsOrgHash = data.NzbsOrgHash;

Loading…
Cancel
Save