houdini/spec/lib/fetch/fetch_misc_nonprofit_settings_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

39 lines
No EOL
1.3 KiB
Ruby

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
require 'rails_helper'
describe FetchMiscellaneousNpInfo do
describe '.fetch' do
describe 'validates params' do
it 'with empty args' do
expect { FetchMiscellaneousNpInfo.fetch(nil) }.to(raise_error {|error|
expect(error).to be_a ParamValidation::ValidationError
expect_validation_errors(error.data, [{key: :np_id, name: :required},
{key: :np_id, name: :is_integer}])
})
end
it 'with invalid np' do
expect { FetchMiscellaneousNpInfo.fetch(50) }.to(raise_error {|error|
expect(error).to be_a ParamValidation::ValidationError
expect_validation_errors(error.data, [{key: :np_id}])
})
end
end
describe 'with valid nonprofit' do
before(:each) do
@np = force_create(:nonprofit)
end
it 'returns hash with empty misc settings' do
expect(FetchMiscellaneousNpInfo.fetch(@np.id).attributes).to eq(MiscellaneousNpInfo.new.attributes)
end
it 'returns the misc if already there' do
a = force_create(:miscellaneous_np_info, :nonprofit => @np, :donate_again_url => 'http://donateagain.url')
expect(FetchMiscellaneousNpInfo.fetch(@np.id)).to eq(a)
end
end
end
end