Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Add non_automatic group type param to groups index API

Angus McLeod516e7e392b6e
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 75be316516a..ef917fafa10 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -34,6 +34,9 @@ class GroupsController < ApplicationController
},
automatic: Proc.new { |groups|
groups.where(automatic: true)
+ },
+ non_automatic: Proc.new { |groups|
+ groups.where(automatic: false)
}
}
ADD_MEMBERS_LIMIT = 1000
@@ -82,6 +85,8 @@ class GroupsController < ApplicationController
type_filters = type_filters - [:my, :owner]
end
+ type_filters.delete(:non_automatic)
+
# count the total before doing pagination
total = groups.count
diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb
index 5bbdba1e2b3..a977d77378d 100644
--- a/spec/requests/groups_controller_spec.rb
+++ b/spec/requests/groups_controller_spec.rb
@@ -172,7 +172,7 @@ describe GroupsController do
expect(body["load_more_groups"]).to eq("/groups?page=1")
expect(body["total_rows_groups"]).to eq(1)
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
@@ -288,7 +288,7 @@ describe GroupsController do
expect(body["total_rows_groups"]).to eq(10)
expect(body["extras"]["type_filters"].map(&:to_sym)).to eq(
- described_class::TYPE_FILTERS.keys
+ described_class::TYPE_FILTERS.keys - [:non_automatic]
)
end
@@ -330,6 +330,16 @@ describe GroupsController do
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
it 'should return the right response' do
group2 = Fabricate(:group, public_admission: true)