FEATURE: Add non_automatic group type param to groups index API
This commit is contained in:
parent
dc2f5064e2
commit
516e7e392b
|
@ -34,6 +34,9 @@ class GroupsController < ApplicationController
|
||||||
},
|
},
|
||||||
automatic: Proc.new { |groups|
|
automatic: Proc.new { |groups|
|
||||||
groups.where(automatic: true)
|
groups.where(automatic: true)
|
||||||
|
},
|
||||||
|
non_automatic: Proc.new { |groups|
|
||||||
|
groups.where(automatic: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ADD_MEMBERS_LIMIT = 1000
|
ADD_MEMBERS_LIMIT = 1000
|
||||||
|
@ -82,6 +85,8 @@ class GroupsController < ApplicationController
|
||||||
type_filters = type_filters - [:my, :owner]
|
type_filters = type_filters - [:my, :owner]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
type_filters.delete(:non_automatic)
|
||||||
|
|
||||||
# count the total before doing pagination
|
# count the total before doing pagination
|
||||||
total = groups.count
|
total = groups.count
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ describe GroupsController do
|
||||||
expect(body["load_more_groups"]).to eq("/groups?page=1")
|
expect(body["load_more_groups"]).to eq("/groups?page=1")
|
||||||
expect(body["total_rows_groups"]).to eq(1)
|
expect(body["total_rows_groups"]).to eq(1)
|
||||||
expect(body["extras"]["type_filters"].map(&:to_sym)).to eq(
|
expect(body["extras"]["type_filters"].map(&:to_sym)).to eq(
|
||||||
described_class::TYPE_FILTERS.keys - [:my, :owner, :automatic]
|
described_class::TYPE_FILTERS.keys - [:my, :owner, :automatic, :non_automatic]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ describe GroupsController do
|
||||||
expect(body["total_rows_groups"]).to eq(10)
|
expect(body["total_rows_groups"]).to eq(10)
|
||||||
|
|
||||||
expect(body["extras"]["type_filters"].map(&:to_sym)).to eq(
|
expect(body["extras"]["type_filters"].map(&:to_sym)).to eq(
|
||||||
described_class::TYPE_FILTERS.keys
|
described_class::TYPE_FILTERS.keys - [:non_automatic]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -330,6 +330,16 @@ describe GroupsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'non automatic groups' do
|
||||||
|
it 'should return the right response' do
|
||||||
|
group2 = Fabricate(:group)
|
||||||
|
expect_type_to_return_right_groups(
|
||||||
|
'non_automatic',
|
||||||
|
[group.id, group2.id]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'public groups' do
|
describe 'public groups' do
|
||||||
it 'should return the right response' do
|
it 'should return the right response' do
|
||||||
group2 = Fabricate(:group, public_admission: true)
|
group2 = Fabricate(:group, public_admission: true)
|
||||||
|
|
Loading…
Reference in New Issue