소스 검색

make it not return http 400 when passing and empty source argument (#12259)

* make it not return http 400 when passing and empty source argument

* create a spec for the empty source hash bug

* compact checks for nil, empty? parameters

* use nil.blank? instead checking for nil
master^2
Jennifer Glauche 4 년 전
committed by Eugen Rochko
부모
커밋
fd93a9c871
2개의 변경된 파일14개의 추가작업 그리고 1개의 파일을 삭제
  1. +1
    -1
      app/controllers/api/v1/accounts/credentials_controller.rb
  2. +13
    -0
      spec/controllers/api/v1/accounts/credentials_controller_spec.rb

+ 1
- 1
app/controllers/api/v1/accounts/credentials_controller.rb 파일 보기

@@ -25,7 +25,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
end

def user_settings_params
return nil unless params.key?(:source)
return nil if params[:source].blank?

source_params = params.require(:source)



+ 13
- 0
spec/controllers/api/v1/accounts/credentials_controller_spec.rb 파일 보기

@@ -59,6 +59,19 @@ describe Api::V1::Accounts::CredentialsController do
end
end

describe 'with empty source list' do
before do
patch :update, params: {
display_name: "I'm a cat",
source: {},
}, as: :json
end

it 'returns http success' do
expect(response).to have_http_status(200)
end
end

describe 'with invalid data' do
before do
patch :update, params: { note: 'This is too long. ' * 30 }


불러오는 중...
취소
저장