From 5673d460d09de96f06b88f5e0753d7d2c7203cd2 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 19 May 2017 11:21:37 +0200 Subject: [PATCH] Some bugfixes, Closes #50, Closes #49 --- src/Squidex.Write/Apps/AppCommandHandler.cs | 2 +- .../app/shared/components/assets-editor.component.ts | 2 +- tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Squidex.Write/Apps/AppCommandHandler.cs b/src/Squidex.Write/Apps/AppCommandHandler.cs index b8befd932..d6ea0c2aa 100644 --- a/src/Squidex.Write/Apps/AppCommandHandler.cs +++ b/src/Squidex.Write/Apps/AppCommandHandler.cs @@ -85,7 +85,7 @@ namespace Squidex.Write.Apps a.AssignContributor(command); - if (a.ContributorCount > oldContributors && a.ContributorCount > maxContributors) + if (maxContributors > 0 && a.ContributorCount > oldContributors && a.ContributorCount > maxContributors) { var error = new ValidationError("You have reached your max number of contributors"); diff --git a/src/Squidex/app/shared/components/assets-editor.component.ts b/src/Squidex/app/shared/components/assets-editor.component.ts index b79c95436..f96015f6c 100644 --- a/src/Squidex/app/shared/components/assets-editor.component.ts +++ b/src/Squidex/app/shared/components/assets-editor.component.ts @@ -73,7 +73,7 @@ export class AssetsEditorComponent extends AppComponentBase implements ControlVa public writeValue(value: any) { this.oldAssets = ImmutableArray.empty(); - if (value) { + if (value && value.length > 0) { this.appNameOnce() .switchMap(app => this.assetsService.getAssets(app, 10000, 0, undefined, undefined, value)) .subscribe(dtos => { diff --git a/tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs b/tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs index fdfacd2b3..d4b596cd0 100644 --- a/tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs +++ b/tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs @@ -42,8 +42,6 @@ namespace Squidex.Write.Apps public AppCommandHandlerTests() { - appLimitsProvider.Setup(x => x.GetPlan(0)).Returns(new ConfigAppLimitsPlan { MaxContributors = 2 }); - app = new AppDomainObject(AppId, -1); sut = new AppCommandHandler(Handler, appRepository.Object, appLimitsProvider.Object, userRepository.Object, keyGenerator.Object); @@ -101,6 +99,8 @@ namespace Squidex.Write.Apps [Fact] public async Task AssignContributor_throw_if_reached_max_contributor_size() { + appLimitsProvider.Setup(x => x.GetPlan(0)).Returns(new ConfigAppLimitsPlan { MaxContributors = 2 }); + CreateApp() .AssignContributor(CreateCommand(new AssignContributor { ContributorId = "1" })) .AssignContributor(CreateCommand(new AssignContributor { ContributorId = "2" })); @@ -133,6 +133,8 @@ namespace Squidex.Write.Apps [Fact] public async Task AssignContributor_should_assign_if_user_found() { + appLimitsProvider.Setup(x => x.GetPlan(0)).Returns(new ConfigAppLimitsPlan { MaxContributors = -1 }); + CreateApp(); var context = CreateContextForCommand(new AssignContributor { ContributorId = contributorId });