Skip to content

fixed ToArray issue on dynamic object #943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public object OnReturnRelationship(object resourceOrResources)
if (resourceOrResources is IEnumerable)
{
dynamic resources = resourceOrResources;
return _resourceHookExecutor.OnReturn(resources, ResourcePipeline.GetRelationship).ToArray();
return Enumerable.ToArray(_resourceHookExecutor.OnReturn(resources, ResourcePipeline.GetRelationship));
}

if (resourceOrResources is IIdentifiable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,42 @@ public async Task Article_Through_Secondary_Endpoint_Is_Hidden()
Assert.DoesNotContain(toBeExcluded, body);
}

[Fact]
public async Task Tag_HashSet_Through_Secondary_Endpoint_Is_Hidden()
{
// Arrange
var article = _articleFaker.Generate();
var tags = _tagFaker.Generate(2);
string toBeExcluded = "This should not be included";
tags[0].Name = toBeExcluded;

var articleTags = new[]
{
new ArticleTag
{
Article = article,
Tag = tags[0]
},
new ArticleTag
{
Article = article,
Tag = tags[1]
}
};
_dbContext.ArticleTags.AddRange(articleTags);
await _dbContext.SaveChangesAsync();

var route = $"/api/v1/articles/{article.Id}/tags";

// Act
var response = await _client.GetAsync(route);

// Assert
var body = await response.Content.ReadAsStringAsync();
Assert.True(HttpStatusCode.OK == response.StatusCode, $"{route} returned {response.StatusCode} status code with body: {body}");
Assert.DoesNotContain(toBeExcluded, body);
}

[Fact]
public async Task Passport_Through_Secondary_Endpoint_Is_Hidden()
{
Expand Down