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.rbindex 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 < ApplicationControllertype_filters = type_filters - [:my, :owner]end+ type_filters.delete(:non_automatic)+# count the total before doing paginationtotal = groups.countdiff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rbindex 5bbdba1e2b3..a977d77378d 100644--- a/spec/requests/groups_controller_spec.rb+++ b/spec/requests/groups_controller_spec.rb@@ -172,7 +172,7 @@ describe GroupsController doexpect(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 doexpect(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 doendend+ 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' doit 'should return the right response' dogroup2 = Fabricate(:group, public_admission: true)