FIX: Can't update Groups#allow_membership_requests in admin.

This commit is contained in:
Guo Xiang Tan 2016-12-20 15:14:35 +08:00
parent c15bf62b43
commit 7c7c233c1c
3 changed files with 13 additions and 2 deletions

View File

@ -71,6 +71,10 @@ class Admin::GroupsController < Admin::AdminController
group.bio_raw = group_params[:bio_raw] if group_params[:bio_raw]
group.full_name = group_params[:full_name] if group_params[:full_name]
if group_params[:allow_membership_requests]
group.allow_membership_requests = group_params[:allow_membership_requests]
end
if group.save
Group.reset_counters(group.id, :group_users)

View File

@ -88,14 +88,19 @@ describe Admin::GroupsController do
it "ignore name change on automatic group" do
expect do
xhr :put, :update, { id: 1, group: { name: "WAT", visible: "true" } }
end.to_not change { GroupHistory.count }
xhr :put, :update, { id: 1, group: {
name: "WAT",
visible: "true",
allow_membership_requests: "true"
} }
end.to change { GroupHistory.count }.by(1)
expect(response).to be_success
group = Group.find(1)
expect(group.name).not_to eq("WAT")
expect(group.visible).to eq(true)
expect(group.allow_membership_requests).to eq(true)
end
it "doesn't launch the 'automatic group membership' job when it's not retroactive" do

View File

@ -84,6 +84,8 @@ describe "Groups" do
end
it "should be able update the group" do
group.update!(allow_membership_requests: false)
expect do
xhr :put, "/groups/#{group.id}", { group: {
flair_bg_color: 'FFF',