From 0a12343b9ea12b63bbdf645bb349cefde9d7e7fc Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 10 Dec 2013 18:00:44 -0800 Subject: [PATCH] Tests and cleanup --- src/NzbDrone.Api/Series/SeriesEditorModule.cs | 4 +- .../NzbDrone.Core.Test.csproj | 1 + .../UpdateMultipleSeriesFixture.cs | Bin 0 -> 2396 bytes .../Client/SeriesClient.cs | 7 +++ .../NzbDrone.Integration.Test.csproj | 1 + .../SeriesEditorIntegrationTest.cs | 45 ++++++++++++++++++ .../SeriesIntegrationTest.cs | 2 - .../Series/Editor/SeriesEditorFooterView.js | 20 +++++--- src/UI/Series/Editor/SeriesEditorLayout.js | 5 -- src/UI/Series/SeriesCollection.js | 1 + 10 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs create mode 100644 src/NzbDrone.Integration.Test/SeriesEditorIntegrationTest.cs diff --git a/src/NzbDrone.Api/Series/SeriesEditorModule.cs b/src/NzbDrone.Api/Series/SeriesEditorModule.cs index f64b4098c..75a174b90 100644 --- a/src/NzbDrone.Api/Series/SeriesEditorModule.cs +++ b/src/NzbDrone.Api/Series/SeriesEditorModule.cs @@ -24,7 +24,9 @@ namespace NzbDrone.Api.Series //Read from request var series = Request.Body.FromJson>().InjectTo>(); - return _seriesService.UpdateSeries(series).InjectTo>().AsResponse(); + return _seriesService.UpdateSeries(series) + .InjectTo>() + .AsResponse(HttpStatusCode.Accepted); } } } diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 313d67d3a..42a514e8c 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -212,6 +212,7 @@ + diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs b/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs new file mode 100644 index 0000000000000000000000000000000000000000..9e5c0349aedc607f1209cb8af6ea4958b4c15f1a GIT binary patch literal 2396 zcmeHGO>Y`85bYU>|6p-iq{>n&^^zv2l$I(|$k#%0NUD|D9fBKUZ*A{VsPfBt=uhfj z=*;dyfFy9}sS-XQc4qwE%zNWMzkX*<>N^(BoQDbT7^NWg(rCxOfCek$_x0LZ$%)k8 zm$9y#&##3Ae)=(!DgpbLQ5k68b`ER-w@mcRlmY#R5n84K7`(@4PeE7*44cHH2 z_w$z$;I`iGQ@&#+6QdEKUen0qQV|2&AfUQ_PUVh=I5ar?&1DQls9yV7uQ5C~^x2g^ zd}iTm8A`LEk}->waE=YqM0n_B%F9$i2~?G{14gqDz~LH0tHh}oh$Xc$M;LY@m$fYx zxuUIN3@V~?6M`S4RU;Irn#qk!80NAxXqM=dTw$Qk3XmPK%DJko7VlUnwT zyA>3=N{6?VT179T7{8W&95{B=Vvb*ALPjWWgqB%*{bLpmWJ8z8$MoMu3@=lLFF^G z@yJa*^h|sY7GJrie}~6q{Ux$FGGNxi8Ln{YMzbI%JM#*+M@=kHU$ef%H^t9%45;8g z%vw$urRY>N9fOYSn%t3ek;~FlNl3OxkPFK+Ov$P>zx!8jH|<{OmE@=<;$34ui+H)h vPfV}SpX#|){Y_ZfARZPjqs*Zf))$Xpfxe+6HHgde@M?ed3hWj5KNR>2Cm*P` literal 0 HcmV?d00001 diff --git a/src/NzbDrone.Integration.Test/Client/SeriesClient.cs b/src/NzbDrone.Integration.Test/Client/SeriesClient.cs index 1f0a572f9..01ec8bfc7 100644 --- a/src/NzbDrone.Integration.Test/Client/SeriesClient.cs +++ b/src/NzbDrone.Integration.Test/Client/SeriesClient.cs @@ -19,6 +19,13 @@ namespace NzbDrone.Integration.Test.Client return Get>(request); } + public List Editor(List series) + { + var request = BuildRequest("editor"); + request.AddBody(series); + return Put>(request); + } + public SeriesResource Get(string slug, HttpStatusCode statusCode = HttpStatusCode.OK) { var request = BuildRequest(slug); diff --git a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj index b1ee17afc..c984ef79c 100644 --- a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj +++ b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj @@ -102,6 +102,7 @@ + diff --git a/src/NzbDrone.Integration.Test/SeriesEditorIntegrationTest.cs b/src/NzbDrone.Integration.Test/SeriesEditorIntegrationTest.cs new file mode 100644 index 000000000..c0634ea0c --- /dev/null +++ b/src/NzbDrone.Integration.Test/SeriesEditorIntegrationTest.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(); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs b/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs index df6dce79d..eef706a78 100644 --- a/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs +++ b/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs @@ -45,7 +45,6 @@ namespace NzbDrone.Integration.Test Series.All().Should().BeEmpty(); } - [Test] public void should_be_able_to_find_series_by_id() { @@ -61,7 +60,6 @@ namespace NzbDrone.Integration.Test Series.Get(series.Id).Should().NotBeNull(); } - [Test] public void invalid_id_should_return_404() { diff --git a/src/UI/Series/Editor/SeriesEditorFooterView.js b/src/UI/Series/Editor/SeriesEditorFooterView.js index 27dca0d35..42b2b85f4 100644 --- a/src/UI/Series/Editor/SeriesEditorFooterView.js +++ b/src/UI/Series/Editor/SeriesEditorFooterView.js @@ -94,16 +94,11 @@ define( 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(); + + this.listenTo(SeriesCollection, 'save', this._afterSave); }, _updateInfo: function () { @@ -145,6 +140,17 @@ define( vent.trigger(vent.Commands.CloseModalCommand); this.ui.rootFolder.val(options.model.id); 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); + }); } }); }); diff --git a/src/UI/Series/Editor/SeriesEditorLayout.js b/src/UI/Series/Editor/SeriesEditorLayout.js index c3e134a84..e82149fa9 100644 --- a/src/UI/Series/Editor/SeriesEditorLayout.js +++ b/src/UI/Series/Editor/SeriesEditorLayout.js @@ -99,11 +99,6 @@ define( ] }, - initialize: function () { - this.listenTo(SeriesCollection, 'sync', this._showTable); - this.listenTo(SeriesCollection, 'remove', this._showTable); - }, - onRender: function () { this._showToolbar(); this._showTable(); diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js index 110044110..204a8759b 100644 --- a/src/UI/Series/SeriesCollection.js +++ b/src/UI/Series/SeriesCollection.js @@ -38,6 +38,7 @@ define( this.listenTo(proxy, 'sync', function (proxyModel, models) { this.add(models, { merge: true }); + this.trigger('save', this); }); return proxy.save();