forked from railsbridge/bridge_troll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organization_policy_spec.rb
46 lines (36 loc) · 1.12 KB
/
organization_policy_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true
require 'rails_helper'
describe OrganizationPolicy do
describe '#manage_organization?' do
let(:user) { create(:user) }
let(:organization) { create(:organization) }
it 'is false for logged-out users' do
expect(described_class.new(nil, organization)).not_to be_manage_organization
end
it 'is false for users that do not manage the organization' do
expect(described_class.new(user, organization)).not_to be_manage_organization
end
context 'for users that do manage the organization' do
before do
organization.leaders << user
end
it 'is true' do
expect(described_class.new(user, organization)).to be_manage_organization
end
end
end
describe 'create?' do
describe 'for regular users' do
let(:user) { create(:user) }
it 'is false' do
expect(described_class.new(user, nil)).not_to be_create
end
end
describe 'for admins' do
let(:admin) { create(:user, admin: true) }
it 'is true' do
expect(described_class.new(admin, nil)).to be_create
end
end
end
end