From 9a94d1b2126a8722089114ff67b82f2d0564f5ce Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Oct 2016 13:03:22 +1100 Subject: [PATCH] FIX: everyone is not a visible group --- app/controllers/admin/groups_controller.rb | 2 +- app/models/group.rb | 1 + db/fixtures/002_groups.rb | 1 + spec/models/group_spec.rb | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 81923258be7..7bd066ddba5 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -1,7 +1,7 @@ class Admin::GroupsController < Admin::AdminController def index - groups = Group.order(:name) + groups = Group.order(:name).where("name <> 'everyone'") if search = params[:search] search = search.to_s diff --git a/app/models/group.rb b/app/models/group.rb index 772f689f066..37eaa32410d 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -160,6 +160,7 @@ class Group < ActiveRecord::Base # the everyone group is special, it can include non-users so there is no # way to have the membership in a table if name == :everyone + group.visible = false group.save! return group end diff --git a/db/fixtures/002_groups.rb b/db/fixtures/002_groups.rb index 154c76bba9b..94757078a7d 100644 --- a/db/fixtures/002_groups.rb +++ b/db/fixtures/002_groups.rb @@ -2,3 +2,4 @@ Group.ensure_automatic_groups! if g = Group.find_by(name: 'trust_level_5', id: 15) g.destroy! end +Group.where(name: 'everyone').update_all(visible: false) diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index b651342ef12..dfc54ba1a87 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -154,6 +154,11 @@ describe Group do end + it "makes sure the everyone group is not visible" do + g = Group.refresh_automatic_group!(:everyone) + expect(g.visible).to eq(false) + end + it "Correctly handles removal of primary group" do group = Fabricate(:group) user = Fabricate(:user)