Skip to content
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

WEOS-1234: View functionality fix #52

Merged
merged 1 commit into from
Jan 20, 2022
Merged
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
5 changes: 5 additions & 0 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ paths:
name: If-None-Match
schema:
type: string
- in: query
name: use_entity_id
schema:
type: boolean

summary: Get blog category by title
responses:
200:
Expand Down
5 changes: 3 additions & 2 deletions controllers/rest/controller_standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (c *StandardControllers) View(app model.Service, spec *openapi3.Swagger, pa

sequenceString, _ := newContext.Value("sequence_no").(string)
etag, _ := newContext.Value("If-None-Match").(string)
entityID, _ := newContext.Value("use_entity_id").(string)
entityID, _ := newContext.Value("use_entity_id").(bool)

var sequence int
if sequenceString != "" {
Expand All @@ -344,10 +344,11 @@ func (c *StandardControllers) View(app model.Service, spec *openapi3.Swagger, pa
var err error

//get by keys
if sequence == 0 && etag == "" && entityID != "true" {
if sequence == 0 && etag == "" && !entityID {
for _, projection := range app.Projections() {
if projection != nil {
result, err = projection.GetByKey(ctxt.Request().Context(), *cType, identifiers)
break
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions features/view-content.feature
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Feature: View content
"""
And the service is running
And blogs in the api
| id | weos_id | sequence no | title | description |
| id | weos_id | sequence_no | title | description |
| 1234 | 22xu1Xa5CS3DK1Om2tB7OBDfWAF | 2 | Blog 1 | Some Blog |
| 4567 | 22xu4iw0bWMwxqbrUvjqEqu5dof | 1 | Blog 2 | Some Blog 2 |

Expand Down Expand Up @@ -223,13 +223,13 @@ Feature: View content
And a blog should be returned
| id | title | description |
| 4567 | Blog 2 | Some Blog 2 |
And the "ETag" header should be "22xu4iw0bWMwxqbrUvjqEqu5dof.2"
And the "ETag" header should be "22xu4iw0bWMwxqbrUvjqEqu5dof.1"

Scenario: Check if new version of an item is available

Check if version is the latest version https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Given a header "If-None-Match" with value "22xu1Xa5CS3DK1Om2tB7OBDfWAF.2"
Given a header "If-None-Match" with value "22xu1Xa5CS3DK1Om2tB7OBDfWAF.3"
When the "GET" endpoint "/blogs/1234" is hit
Then a 304 response should be returned

Expand Down