houdini/spec/lib/query/query_roles_spec.rb

40 lines
1.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
2018-08-15 16:19:49 +00:00
require 'rails_helper'
describe QueryRoles do
include_context :shared_donation_charge_context
let(:nonprofit_admin_role) { force_create(:role, user: user, host: nonprofit, name: :nonprofit_admin) }
let(:other_nonprofit_admin_role) { force_create(:role, user: user, host: other_nonprofit, name: :nonprofit_admin) }
let(:nonprofit_associate_role) { force_create(:role, user: user, host: nonprofit, name: :nonprofit_associate) }
let(:other_nonprofit_associate_role) { force_create(:role, user: user, host: other_nonprofit, name: :nonprofit_associate) }
2018-08-15 16:19:49 +00:00
describe 'is_nonprofit_user?' do
it 'false for no role' do
expect(QueryRoles.is_nonprofit_user?(user.id, nonprofit.id)).to be_falsey
end
it 'false for other nonprofit admin' do
other_nonprofit_admin_role
expect(QueryRoles.is_nonprofit_user?(user.id, nonprofit.id)).to be_falsey
end
it 'false for other nonprofit associate' do
other_nonprofit_associate_role
expect(QueryRoles.is_nonprofit_user?(user.id, nonprofit.id)).to be_falsey
end
it 'true for nonprofit admin' do
nonprofit_admin_role
expect(QueryRoles.is_nonprofit_user?(user.id, nonprofit.id)).to be_truthy
end
it 'true for nonprofit admin' do
nonprofit_associate_role
expect(QueryRoles.is_nonprofit_user?(user.id, nonprofit.id)).to be_truthy
end
end
end