houdini/spec/requests/nonprofits/direct_debit_details_spec.rb
Bradley M. Kuhn 6772312ea7 Relicense all .rb files under new project license.
The primary license of the project is changing to:
  AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later

with some specific files to be licensed under the one of two licenses:
   CC0-1.0
   LGPL-3.0-or-later

This commit is one of the many steps to relicense the entire codebase.

Documentation granting permission for this relicensing (from all past
contributors who hold copyrights) is on file with Software Freedom
Conservancy, Inc.
2018-03-25 15:10:40 -04:00

42 lines
1.2 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", valid_params
assert_response 200
assert_equal nil, JSON.parse(@response.body)["errors"]
end
it 'is not valid without sepa_params' do
post "/sepa", 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", valid_params.except(:supporter_id)
assert_response 422
assert_equal ["supporter_id required"], JSON.parse(@response.body)["errors"]
end
end
end
end