FIX: everyone is not a visible group

This commit is contained in:
Sam 2016-10-24 13:03:22 +11:00
parent f083994f5a
commit 9a94d1b212
4 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)