Fixed Series Relations Schema (#1654)
* Bump loader-utils from 2.0.2 to 2.0.3 in /UI/Web Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/webpack/loader-utils/releases) - [Changelog](https://github.com/webpack/loader-utils/blob/v2.0.3/CHANGELOG.md) - [Commits](https://github.com/webpack/loader-utils/compare/v2.0.2...v2.0.3) --- updated-dependencies: - dependency-name: loader-utils dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Fixed is want to read coming back as a string and not working correctly. * Changed from to Continue to be more explicit * Added the first migration which exports data as a csv in temp/. This is the backup in case data is lost in the migration. * Note for later * Fixed the migration for the series relation so when deleting any series on any edge of the relationship, the SeriesRelation row deletes. * Change buttons back to titles on series detail page * Wrote the code to import relations from the backup. * Added an additional version check to avoid file io on migration. * Code cleanup Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
d5a7c31c7d
commit
15e09a0cf1
18 changed files with 2111 additions and 83 deletions
|
@ -1240,6 +1240,113 @@ public class SeriesServiceTests
|
|||
Assert.Empty(series1.Relations.Where(s => s.TargetSeriesId == 2));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateRelatedSeries_DeleteTargetSeries_ShouldSucceed()
|
||||
{
|
||||
await ResetDb();
|
||||
_context.Library.Add(new Library()
|
||||
{
|
||||
AppUsers = new List<AppUser>()
|
||||
{
|
||||
new AppUser()
|
||||
{
|
||||
UserName = "majora2007"
|
||||
}
|
||||
},
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Series A",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Series B",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related);
|
||||
// Add relations
|
||||
var addRelationDto = CreateRelationsDto(series1);
|
||||
addRelationDto.Adaptations.Add(2);
|
||||
await _seriesService.UpdateRelatedSeries(addRelationDto);
|
||||
Assert.Equal(2, series1.Relations.Single(s => s.TargetSeriesId == 2).TargetSeriesId);
|
||||
|
||||
_context.Series.Remove(await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(2));
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Assert.Fail("Delete of Target Series Failed");
|
||||
}
|
||||
|
||||
// Remove relations
|
||||
Assert.Empty((await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related)).Relations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateRelatedSeries_DeleteSourceSeries_ShouldSucceed()
|
||||
{
|
||||
await ResetDb();
|
||||
_context.Library.Add(new Library()
|
||||
{
|
||||
AppUsers = new List<AppUser>()
|
||||
{
|
||||
new AppUser()
|
||||
{
|
||||
UserName = "majora2007"
|
||||
}
|
||||
},
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Series A",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Series B",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related);
|
||||
// Add relations
|
||||
var addRelationDto = CreateRelationsDto(series1);
|
||||
addRelationDto.Adaptations.Add(2);
|
||||
await _seriesService.UpdateRelatedSeries(addRelationDto);
|
||||
Assert.Equal(2, series1.Relations.Single(s => s.TargetSeriesId == 2).TargetSeriesId);
|
||||
|
||||
_context.Series.Remove(await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1));
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Assert.Fail("Delete of Target Series Failed");
|
||||
}
|
||||
|
||||
// Remove relations
|
||||
Assert.Empty((await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(2, SeriesIncludes.Related)).Relations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateRelatedSeries_ShouldNotAllowDuplicates()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue