FIX: prevents group show serializer to override basic group serializer (#10326)
This commit is contained in:
parent
4e317e7aca
commit
11faec71ae
|
@ -1,5 +1,5 @@
|
|||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { gt, readOnly } from "@ember/object/computed";
|
||||
import { gt } from "@ember/object/computed";
|
||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import discourseDebounce from "discourse/lib/debounce";
|
||||
|
@ -16,7 +16,6 @@ export default Controller.extend({
|
|||
filterInput: null,
|
||||
|
||||
loading: false,
|
||||
isOwner: readOnly("model.is_group_owner"),
|
||||
showActions: false,
|
||||
|
||||
@observes("filterInput")
|
||||
|
|
|
@ -91,11 +91,6 @@ export default Controller.extend({
|
|||
return isGroupUser || (this.currentUser && this.currentUser.admin);
|
||||
},
|
||||
|
||||
@discourseComputed("model.is_group_owner", "model.automatic")
|
||||
canEditGroup(isGroupOwner, automatic) {
|
||||
return !automatic && isGroupOwner;
|
||||
},
|
||||
|
||||
@discourseComputed("model.displayName", "model.full_name")
|
||||
groupName(displayName, fullName) {
|
||||
return (fullName || displayName).capitalize();
|
||||
|
|
|
@ -16,7 +16,7 @@ class GroupShowSerializer < BasicGroupSerializer
|
|||
end
|
||||
|
||||
def is_group_owner
|
||||
scope.is_admin? || fetch_group_user&.owner
|
||||
fetch_group_user&.owner
|
||||
end
|
||||
|
||||
def include_is_group_owner_display?
|
||||
|
|
|
@ -13,7 +13,7 @@ describe GroupShowSerializer do
|
|||
it 'should return the right attributes' do
|
||||
json = GroupShowSerializer.new(group, scope: Guardian.new(user)).as_json
|
||||
|
||||
expect(json[:group_show][:is_group_owner]).to eq(true)
|
||||
expect(json[:group_show][:is_group_owner]).to eq(false)
|
||||
expect(json[:group_show][:is_group_user]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
moduleFor("controller:group", {
|
||||
needs: ["controller:application"]
|
||||
});
|
||||
|
||||
QUnit.test("canEditGroup", function(assert) {
|
||||
const GroupController = this.subject();
|
||||
|
||||
GroupController.setProperties({
|
||||
model: { is_group_owner: true, automatic: true }
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
GroupController.get("canEditGroup"),
|
||||
false,
|
||||
"automatic groups cannot be edited"
|
||||
);
|
||||
|
||||
GroupController.set("model.automatic", false);
|
||||
|
||||
assert.equal(
|
||||
GroupController.get("canEditGroup"),
|
||||
true,
|
||||
"owners can edit groups"
|
||||
);
|
||||
|
||||
GroupController.set("model.is_group_owner", false);
|
||||
|
||||
assert.equal(
|
||||
GroupController.get("canEditGroup"),
|
||||
false,
|
||||
"normal users cannot edit groups"
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue