Skip to content

Commit c450a62

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents 4a499f2 + e67c7bc commit c450a62

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

PULL_REQUEST_TEMPLATE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Closes #{ISSUE_NUMBER}
2+
3+
#### BUG FIX
4+
- [ ] reproduce issue in tests
5+
- [ ] fix issue
6+
- [ ] bump package version
7+
8+
#### FEATURE
9+
- [ ] write tests that address the requirements outlined in the issue
10+
- [ ] fulfill the feature requirements
11+
- [ ] bump package version

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.svg)](https://www.nuget.org/packages/JsonApiDotNetCore/)
66
[![MyGet CI](https://img.shields.io/myget/research-institute/vpre/JsonApiDotNetCore.svg)](https://www.myget.org/feed/research-institute/package/nuget/JsonApiDotNetCore)
77
[![Join the chat at https://gitter.im/json-api-dotnet-core/Lobby](https://badges.gitter.im/json-api-dotnet-core/Lobby.svg)](https://gitter.im/json-api-dotnet-core/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8+
[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
89

910
A framework for building [json:api](http://jsonapi.org/) compliant web APIs. The ultimate goal of this library is to eliminate as much boilerplate as possible by offering out-of-the-box features such as sorting, filtering and pagination. You just need to focus on defining the resources and implementing your custom business logic. This library has been designed around dependency injection making extensibility incredibly easy.
1011

src/JsonApiDotNetCore/Internal/Query/QuerySet.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ private List<FilterQuery> ParseFilterQuery(string key, string value)
101101
return (string.Empty, value);
102102

103103
// remove prefix from value
104+
if(Enum.TryParse(operation[0], out FilterOperations op) == false)
105+
return (string.Empty, value);
106+
104107
var prefix = operation[0];
105-
value = operation[1];
108+
value = string.Join(":", operation.Skip(1));
106109

107110
return (prefix, value);
108111
}

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<VersionPrefix>2.1.2</VersionPrefix>
3+
<VersionPrefix>2.1.3</VersionPrefix>
44
<TargetFrameworks>netstandard1.6</TargetFrameworks>
55
<AssemblyName>JsonApiDotNetCore</AssemblyName>
66
<PackageId>JsonApiDotNetCore</PackageId>

test/UnitTests/Internal/QuerySet_Tests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,60 @@ public void Can_Build_Filters()
4848
Assert.Equal("value", querySet.Filters.Single(f => f.Key == "Key").Value);
4949
}
5050

51+
[Fact]
52+
public void Filters_Properly_Parses_DateTime_With_Operation()
53+
{
54+
// arrange
55+
const string dt = "2017-08-15T22:43:47.0156350-05:00";
56+
var query = new Dictionary<string, StringValues> {
57+
{ "filter[key]", new StringValues("le:" + dt) }
58+
};
59+
60+
_queryCollectionMock
61+
.Setup(m => m.GetEnumerator())
62+
.Returns(query.GetEnumerator());
63+
64+
_jsonApiContextMock
65+
.Setup(m => m.GetControllerAttribute<DisableQueryAttribute>())
66+
.Returns(new DisableQueryAttribute(QueryParams.None));
67+
68+
// act -- ctor calls BuildQuerySet()
69+
var querySet = new QuerySet(
70+
_jsonApiContextMock.Object,
71+
_queryCollectionMock.Object);
72+
73+
// assert
74+
Assert.Equal(dt, querySet.Filters.Single(f => f.Key == "Key").Value);
75+
Assert.Equal("le", querySet.Filters.Single(f => f.Key == "Key").Operation);
76+
}
77+
78+
[Fact]
79+
public void Filters_Properly_Parses_DateTime_Without_Operation()
80+
{
81+
// arrange
82+
const string dt = "2017-08-15T22:43:47.0156350-05:00";
83+
var query = new Dictionary<string, StringValues> {
84+
{ "filter[key]", new StringValues(dt) }
85+
};
86+
87+
_queryCollectionMock
88+
.Setup(m => m.GetEnumerator())
89+
.Returns(query.GetEnumerator());
90+
91+
_jsonApiContextMock
92+
.Setup(m => m.GetControllerAttribute<DisableQueryAttribute>())
93+
.Returns(new DisableQueryAttribute(QueryParams.None));
94+
95+
// act -- ctor calls BuildQuerySet()
96+
var querySet = new QuerySet(
97+
_jsonApiContextMock.Object,
98+
_queryCollectionMock.Object);
99+
100+
// assert
101+
Assert.Equal(dt, querySet.Filters.Single(f => f.Key == "Key").Value);
102+
Assert.Equal(string.Empty, querySet.Filters.Single(f => f.Key == "Key").Operation);
103+
}
104+
51105
[Fact]
52106
public void Can_Disable_Filters()
53107
{

0 commit comments

Comments
 (0)