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

issue: odd behaviour with merge params #139

Closed
wants to merge 1 commit into from
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
6 changes: 5 additions & 1 deletion spec/rails/app/controllers/tables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def show
end

def create
render json: find_table, status: 201
if params[:name].blank? || params[:name] == 'some_invalid_name'
render json: { error: 'invalid name parameter' }, status: 422
else
render json: find_table, status: 201
end
end

def update
Expand Down
26 changes: 23 additions & 3 deletions spec/rails/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,12 @@
}
},
"required": [
"name",
"description",
"database_id"
]
},
"example": {
"name": "k0kubun",
"name": "some_invalid_name",
"description": "description",
"database_id": 2
}
Expand Down Expand Up @@ -303,6 +302,27 @@
}
}
}
},
"422": {
"description": "fails to create a table (2)",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
},
"example": {
"error": "invalid name parameter"
}
}
}
}
}
}
Expand Down Expand Up @@ -784,7 +804,7 @@
"tags": {
"type": "array",
"items": {
}
}
}
},
"required": [
Expand Down
16 changes: 14 additions & 2 deletions spec/rails/doc/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ paths:
database_id:
type: integer
required:
- name
- description
- database_id
example:
name: k0kubun
name: some_invalid_name
description: description
database_id: 2
responses:
Expand Down Expand Up @@ -211,6 +210,19 @@ paths:
storage_size: 12.3
created_at: '2020-07-17T00:00:00+00:00'
updated_at: '2020-07-17T00:00:00+00:00'
'422':
description: fails to create a table (2)
content:
application/json:
schema:
type: object
properties:
error:
type: string
required:
- error
example:
error: invalid name parameter
"/tables/{id}":
get:
summary: show
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@
}.to_json
expect(response.status).to eq(201)
end

it 'fails to create a table' do
post '/tables', headers: { authorization: 'k0kubun', 'Content-Type': 'application/json' }, params: {
description: 'description',
database_id: 2,
}.to_json
expect(response.status).to eq(422)
end

it 'fails to create a table (2)' do
post '/tables', headers: { authorization: 'k0kubun', 'Content-Type': 'application/json' }, params: {
name: 'some_invalid_name',
description: 'description',
database_id: 2,
}.to_json
expect(response.status).to eq(422)
end
end

describe '#update' do
Expand Down
Loading