Browse Source

Some bugfixes, Closes #50, Closes #49

pull/65/head
Sebastian Stehle 9 years ago
parent
commit
5673d460d0
  1. 2
      src/Squidex.Write/Apps/AppCommandHandler.cs
  2. 2
      src/Squidex/app/shared/components/assets-editor.component.ts
  3. 6
      tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs

2
src/Squidex.Write/Apps/AppCommandHandler.cs

@ -85,7 +85,7 @@ namespace Squidex.Write.Apps
a.AssignContributor(command); 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"); var error = new ValidationError("You have reached your max number of contributors");

2
src/Squidex/app/shared/components/assets-editor.component.ts

@ -73,7 +73,7 @@ export class AssetsEditorComponent extends AppComponentBase implements ControlVa
public writeValue(value: any) { public writeValue(value: any) {
this.oldAssets = ImmutableArray.empty<AssetDto>(); this.oldAssets = ImmutableArray.empty<AssetDto>();
if (value) { if (value && value.length > 0) {
this.appNameOnce() this.appNameOnce()
.switchMap(app => this.assetsService.getAssets(app, 10000, 0, undefined, undefined, value)) .switchMap(app => this.assetsService.getAssets(app, 10000, 0, undefined, undefined, value))
.subscribe(dtos => { .subscribe(dtos => {

6
tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs

@ -42,8 +42,6 @@ namespace Squidex.Write.Apps
public AppCommandHandlerTests() public AppCommandHandlerTests()
{ {
appLimitsProvider.Setup(x => x.GetPlan(0)).Returns(new ConfigAppLimitsPlan { MaxContributors = 2 });
app = new AppDomainObject(AppId, -1); app = new AppDomainObject(AppId, -1);
sut = new AppCommandHandler(Handler, appRepository.Object, appLimitsProvider.Object, userRepository.Object, keyGenerator.Object); sut = new AppCommandHandler(Handler, appRepository.Object, appLimitsProvider.Object, userRepository.Object, keyGenerator.Object);
@ -101,6 +99,8 @@ namespace Squidex.Write.Apps
[Fact] [Fact]
public async Task AssignContributor_throw_if_reached_max_contributor_size() public async Task AssignContributor_throw_if_reached_max_contributor_size()
{ {
appLimitsProvider.Setup(x => x.GetPlan(0)).Returns(new ConfigAppLimitsPlan { MaxContributors = 2 });
CreateApp() CreateApp()
.AssignContributor(CreateCommand(new AssignContributor { ContributorId = "1" })) .AssignContributor(CreateCommand(new AssignContributor { ContributorId = "1" }))
.AssignContributor(CreateCommand(new AssignContributor { ContributorId = "2" })); .AssignContributor(CreateCommand(new AssignContributor { ContributorId = "2" }));
@ -133,6 +133,8 @@ namespace Squidex.Write.Apps
[Fact] [Fact]
public async Task AssignContributor_should_assign_if_user_found() public async Task AssignContributor_should_assign_if_user_found()
{ {
appLimitsProvider.Setup(x => x.GetPlan(0)).Returns(new ConfigAppLimitsPlan { MaxContributors = -1 });
CreateApp(); CreateApp();
var context = CreateContextForCommand(new AssignContributor { ContributorId = contributorId }); var context = CreateContextForCommand(new AssignContributor { ContributorId = contributorId });

Loading…
Cancel
Save