|
|
@ -70,6 +70,12 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
A.CallTo(() => urlGenerator.AssetContent(assetId)) |
|
|
A.CallTo(() => urlGenerator.AssetContent(assetId)) |
|
|
.Returns("asset-content-url"); |
|
|
.Returns("asset-content-url"); |
|
|
|
|
|
|
|
|
|
|
|
A.CallTo(() => urlGenerator.AssetContent(appId, assetId.ToString())) |
|
|
|
|
|
.Returns("asset-content-app-url"); |
|
|
|
|
|
|
|
|
|
|
|
A.CallTo(() => urlGenerator.AssetContent(appId, "file-name")) |
|
|
|
|
|
.Returns("asset-content-slug-url"); |
|
|
|
|
|
|
|
|
A.CallTo(() => user.Id) |
|
|
A.CallTo(() => user.Id) |
|
|
.Returns("user123"); |
|
|
.Returns("user123"); |
|
|
|
|
|
|
|
|
@ -301,6 +307,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
"Download at ${assetContentUrl()}", |
|
|
"Download at ${assetContentUrl()}", |
|
|
"Download at {{event.id | assetContentUrl}}" |
|
|
"Download at {{event.id | assetContentUrl}}" |
|
|
)] |
|
|
)] |
|
|
|
|
|
[InlineData("Liquid(Download at {{event | assetContentUrl}})")] |
|
|
public async Task Should_format_asset_content_url_from_event(string script) |
|
|
public async Task Should_format_asset_content_url_from_event(string script) |
|
|
{ |
|
|
{ |
|
|
var @event = new EnrichedAssetEvent { Id = assetId }; |
|
|
var @event = new EnrichedAssetEvent { Id = assetId }; |
|
|
@ -317,6 +324,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
"Download at ${assetContentUrl()}", |
|
|
"Download at ${assetContentUrl()}", |
|
|
"Download at {{event.id | assetContentUrl | default: 'null'}}" |
|
|
"Download at {{event.id | assetContentUrl | default: 'null'}}" |
|
|
)] |
|
|
)] |
|
|
|
|
|
[InlineData("Liquid(Download at {{event | assetContentUrl | default: 'null'}})")] |
|
|
public async Task Should_return_null_when_asset_content_url_not_found(string script) |
|
|
public async Task Should_return_null_when_asset_content_url_not_found(string script) |
|
|
{ |
|
|
{ |
|
|
var @event = new EnrichedContentEvent(); |
|
|
var @event = new EnrichedContentEvent(); |
|
|
@ -326,6 +334,74 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Assert.Equal("Download at null", result); |
|
|
Assert.Equal("Download at null", result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[Expressions( |
|
|
|
|
|
"Download at $ASSET_CONTENT_APP_URL", |
|
|
|
|
|
null, |
|
|
|
|
|
"Download at ${assetContentAppUrl()}", |
|
|
|
|
|
"Download at {{event.id | assetContentAppUrl | default: 'null'}}" |
|
|
|
|
|
)] |
|
|
|
|
|
[InlineData("Liquid(Download at {{event | assetContentAppUrl | default: 'null'}})")] |
|
|
|
|
|
public async Task Should_format_asset_content_app_url_from_event(string script) |
|
|
|
|
|
{ |
|
|
|
|
|
var @event = new EnrichedAssetEvent { AppId = appId, Id = assetId, FileName = "File Name" }; |
|
|
|
|
|
|
|
|
|
|
|
var result = await sut.FormatAsync(script, @event); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("Download at asset-content-app-url", result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[Expressions( |
|
|
|
|
|
"Download at $ASSET_CONTENT_APP_URL", |
|
|
|
|
|
null, |
|
|
|
|
|
"Download at ${assetContentAppUrl()}", |
|
|
|
|
|
"Download at {{event.id | assetContentAppUrl | default: 'null'}}" |
|
|
|
|
|
)] |
|
|
|
|
|
[InlineData("Liquid(Download at {{event | assetContentAppUrl | default: 'null'}})")] |
|
|
|
|
|
public async Task Should_return_null_when_asset_content_app_url_not_found(string script) |
|
|
|
|
|
{ |
|
|
|
|
|
var @event = new EnrichedContentEvent(); |
|
|
|
|
|
|
|
|
|
|
|
var result = await sut.FormatAsync(script, @event); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("Download at null", result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[Expressions( |
|
|
|
|
|
"Download at $ASSET_CONTENT_SLUG_URL", |
|
|
|
|
|
null, |
|
|
|
|
|
"Download at ${assetContentSlugUrl()}", |
|
|
|
|
|
"Download at {{event.fileName | assetContentSlugUrl | default: 'null'}}" |
|
|
|
|
|
)] |
|
|
|
|
|
[InlineData("Liquid(Download at {{event | assetContentSlugUrl | default: 'null'}})")] |
|
|
|
|
|
public async Task Should_format_asset_content_slug_url_from_event(string script) |
|
|
|
|
|
{ |
|
|
|
|
|
var @event = new EnrichedAssetEvent { AppId = appId, Id = assetId, FileName = "File Name" }; |
|
|
|
|
|
|
|
|
|
|
|
var result = await sut.FormatAsync(script, @event); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("Download at asset-content-slug-url", result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[Expressions( |
|
|
|
|
|
"Download at $ASSET_CONTENT_SLUG_URL", |
|
|
|
|
|
null, |
|
|
|
|
|
"Download at ${assetContentSlugUrl()}", |
|
|
|
|
|
"Download at {{event.id | assetContentSlugUrl | default: 'null'}}" |
|
|
|
|
|
)] |
|
|
|
|
|
[InlineData("Liquid(Download at {{event | assetContentSlugUrl | default: 'null'}})")] |
|
|
|
|
|
public async Task Should_return_null_when_asset_content_slug_url_not_found(string script) |
|
|
|
|
|
{ |
|
|
|
|
|
var @event = new EnrichedContentEvent(); |
|
|
|
|
|
|
|
|
|
|
|
var result = await sut.FormatAsync(script, @event); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("Download at null", result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[Expressions( |
|
|
[Expressions( |
|
|
"Go to $CONTENT_URL", |
|
|
"Go to $CONTENT_URL", |
|
|
|