Skip to content

Commit

Permalink
updates CustomField model spec with Community
Browse files Browse the repository at this point in the history
  • Loading branch information
PirunSeng committed Dec 26, 2020
1 parent 1f51ca0 commit ca16102
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions spec/models/custom_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
describe CustomField, 'associations' do
it { is_expected.to have_many(:custom_field_properties).dependent(:restrict_with_error) }
it { is_expected.to have_many(:clients).through(:custom_field_properties).source(:custom_formable) }
it { is_expected.to have_many(:communities).through(:custom_field_properties).source(:custom_formable) }
it { is_expected.to have_many(:families).through(:custom_field_properties).source(:custom_formable) }
it { is_expected.to have_many(:partners).through(:custom_field_properties).source(:custom_formable) }
it { is_expected.to have_many(:users).through(:custom_field_properties).source(:custom_formable) }
Expand Down Expand Up @@ -99,14 +100,26 @@
is_expected.not_to include(other_custom_field)
end
end

context 'community forms' do
let!(:custom_field) { create(:custom_field, form_title: 'Community Form', entity_type: 'Community') }
let!(:other_custom_field) { create(:custom_field, form_title: 'Prison Record', entity_type: 'Partner') }
subject { CustomField.community_forms }
it 'should include forms with community entity type' do
is_expected.to include(custom_field)
end
it 'should not include forms without community entity type' do
is_expected.not_to include(other_custom_field)
end
end
end

describe CustomField, 'CONSTANTS' do
it 'FREQUENCIES' do
expect(CustomField::FREQUENCIES).to eq(['Daily', 'Weekly', 'Monthly', 'Yearly'])
end
it 'ENTITY_TYPES' do
expect(CustomField::ENTITY_TYPES).to eq(['Client', 'Family', 'Partner', 'User'])
expect(CustomField::ENTITY_TYPES).to eq(['Client', 'Community', 'Family', 'Partner', 'User'])
end
end

Expand Down Expand Up @@ -149,4 +162,4 @@
end
end
end
end
end

0 comments on commit ca16102

Please sign in to comment.