houdini/spec/requests/nonprofits/direct_debit_details_spec.rb
Luis Castro 57125774ef
test(params): fix HttpPositionalArguments
Automatic run with `bundle exec rubocop --rails --only HttpPositionalArguments --auto-correct`
2019-08-02 19:07:26 +02:00

42 lines
1.3 KiB
Ruby

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
require 'rails_helper'
describe DirectDebitDetailsController, type: :request do
describe 'POST /sepa' do
let!(:nonprofit) { Nonprofit.create(name: "new", city: "NY", state_code: "NY") }
let(:supporter) { Supporter.create(nonprofit: nonprofit) }
let(:valid_params) do {
supporter_id: supporter.id,
sepa_params: {
iban: "iban",
bic: "bic",
name: "name"
}
}
end
describe 'requires params' do
it 'is valid when sepa_params, donation_id and supporter_id are present' do
post "/sepa", params: valid_params
assert_response 200
assert_equal nil, JSON.parse(@response.body)["errors"]
end
it 'is not valid without sepa_params' do
post "/sepa", params: valid_params.except(:sepa_params)
assert_response 422
assert_equal ["sepa_params required"], JSON.parse(@response.body)["errors"]
end
it 'is not valid without supporter_id' do
post "/sepa", params: valid_params.except(:supporter_id)
assert_response 422
assert_equal ["supporter_id required"], JSON.parse(@response.body)["errors"]
end
end
end
end