GeoNode#project_ids should return nil when have no restrictions

parent 590a21e5
......@@ -109,7 +109,7 @@ class GeoNode < ActiveRecord::Base
end
def project_ids
return [] unless groups.any?
return unless groups.any?
groups.flat_map { |group| group.all_projects.pluck(:id) }.uniq
end
......
......@@ -319,13 +319,13 @@ describe GeoNode, type: :model do
describe '#project_ids' do
context 'without group restriction' do
it 'returns an empty array' do
expect(node.project_ids).to eq([])
it 'returns nil' do
expect(node.project_ids).to be_nil
end
end
context 'with group restrictions' do
it 'returns an array with unique project ids' do
it 'returns an array with unique project ids that belong to the groups' do
group_1 = create(:group)
group_2 = create(:group)
nested_group_1 = create(:group, parent: group_1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment