Tests and cleanup

pull/2/head
Mark McDowall 11 years ago
parent a9ece10144
commit 0a12343b9e

@ -24,7 +24,9 @@ namespace NzbDrone.Api.Series
//Read from request //Read from request
var series = Request.Body.FromJson<List<SeriesResource>>().InjectTo<List<Core.Tv.Series>>(); var series = Request.Body.FromJson<List<SeriesResource>>().InjectTo<List<Core.Tv.Series>>();
return _seriesService.UpdateSeries(series).InjectTo<List<SeriesResource>>().AsResponse(); return _seriesService.UpdateSeries(series)
.InjectTo<List<SeriesResource>>()
.AsResponse(HttpStatusCode.Accepted);
} }
} }
} }

@ -212,6 +212,7 @@
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" /> <Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
<Compile Include="SeriesStatsTests\SeriesStatisticsFixture.cs" /> <Compile Include="SeriesStatsTests\SeriesStatisticsFixture.cs" />
<Compile Include="TvTests\SeriesRepositoryTests\QualityProfileRepositoryFixture.cs" /> <Compile Include="TvTests\SeriesRepositoryTests\QualityProfileRepositoryFixture.cs" />
<Compile Include="TvTests\SeriesServiceTests\UpdateMultipleSeriesFixture.cs" />
<Compile Include="TvTests\SeriesServiceTests\UpdateSeriesFixture.cs" /> <Compile Include="TvTests\SeriesServiceTests\UpdateSeriesFixture.cs" />
<Compile Include="UpdateTests\UpdateServiceFixture.cs" /> <Compile Include="UpdateTests\UpdateServiceFixture.cs" />
<Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" /> <Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />

@ -19,6 +19,13 @@ namespace NzbDrone.Integration.Test.Client
return Get<List<SeriesResource>>(request); return Get<List<SeriesResource>>(request);
} }
public List<SeriesResource> Editor(List<SeriesResource> series)
{
var request = BuildRequest("editor");
request.AddBody(series);
return Put<List<SeriesResource>>(request);
}
public SeriesResource Get(string slug, HttpStatusCode statusCode = HttpStatusCode.OK) public SeriesResource Get(string slug, HttpStatusCode statusCode = HttpStatusCode.OK)
{ {
var request = BuildRequest(slug); var request = BuildRequest(slug);

@ -102,6 +102,7 @@
<Compile Include="Client\ReleaseClient.cs" /> <Compile Include="Client\ReleaseClient.cs" />
<Compile Include="Client\SeriesClient.cs" /> <Compile Include="Client\SeriesClient.cs" />
<Compile Include="CommandIntegerationTests.cs" /> <Compile Include="CommandIntegerationTests.cs" />
<Compile Include="SeriesEditorIntegrationTest.cs" />
<Compile Include="HistoryIntegrationTest.cs" /> <Compile Include="HistoryIntegrationTest.cs" />
<Compile Include="NamingConfigTests.cs" /> <Compile Include="NamingConfigTests.cs" />
<Compile Include="EpisodeIntegrationTests.cs" /> <Compile Include="EpisodeIntegrationTests.cs" />

@ -0,0 +1,45 @@
using System;
using System.Net;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Api.Series;
using System.Linq;
using NzbDrone.Test.Common;
namespace NzbDrone.Integration.Test
{
[TestFixture]
public class SeriesEditorIntegrationTest : IntegrationTest
{
private void GivenExistingSeries()
{
foreach (var title in new[] { "90210", "Dexter" })
{
var newSeries = Series.Lookup(title).First();
newSeries.QualityProfileId = 1;
newSeries.Path = String.Format(@"C:\Test\{0}", title).AsOsAgnostic();
Series.Post(newSeries);
}
}
[Test]
public void should_be_able_to_update_multiple_series()
{
GivenExistingSeries();
var series = Series.All();
foreach (var s in series)
{
s.QualityProfileId = 2;
}
var result = Series.Editor(series);
result.Should().HaveCount(2);
result.TrueForAll(s => s.QualityProfileId == 2).Should().BeTrue();
}
}
}

@ -45,7 +45,6 @@ namespace NzbDrone.Integration.Test
Series.All().Should().BeEmpty(); Series.All().Should().BeEmpty();
} }
[Test] [Test]
public void should_be_able_to_find_series_by_id() public void should_be_able_to_find_series_by_id()
{ {
@ -61,7 +60,6 @@ namespace NzbDrone.Integration.Test
Series.Get(series.Id).Should().NotBeNull(); Series.Get(series.Id).Should().NotBeNull();
} }
[Test] [Test]
public void invalid_id_should_return_404() public void invalid_id_should_return_404()
{ {

@ -94,16 +94,11 @@ define(
model.set('rootFolderPath', rootFolderPath.get('path')); model.set('rootFolderPath', rootFolderPath.get('path'));
} }
model.trigger('backgrid:select', model, false);
}); });
this.ui.monitored.val('noChange');
this.ui.qualityProfile.val('noChange');
this.ui.seasonFolder.val('noChange');
this.ui.rootFolder.val('noChange');
SeriesCollection.save(); SeriesCollection.save();
this.listenTo(SeriesCollection, 'save', this._afterSave);
}, },
_updateInfo: function () { _updateInfo: function () {
@ -145,6 +140,17 @@ define(
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
this.ui.rootFolder.val(options.model.id); this.ui.rootFolder.val(options.model.id);
this._rootFolderChanged(); this._rootFolderChanged();
},
_afterSave: function () {
this.ui.monitored.val('noChange');
this.ui.qualityProfile.val('noChange');
this.ui.seasonFolder.val('noChange');
this.ui.rootFolder.val('noChange');
SeriesCollection.each(function (model) {
model.trigger('backgrid:select', model, false);
});
} }
}); });
}); });

@ -99,11 +99,6 @@ define(
] ]
}, },
initialize: function () {
this.listenTo(SeriesCollection, 'sync', this._showTable);
this.listenTo(SeriesCollection, 'remove', this._showTable);
},
onRender: function () { onRender: function () {
this._showToolbar(); this._showToolbar();
this._showTable(); this._showTable();

@ -38,6 +38,7 @@ define(
this.listenTo(proxy, 'sync', function (proxyModel, models) { this.listenTo(proxy, 'sync', function (proxyModel, models) {
this.add(models, { merge: true }); this.add(models, { merge: true });
this.trigger('save', this);
}); });
return proxy.save(); return proxy.save();

Loading…
Cancel
Save