Skip to content

A platform for community discussion. Free, open, simple.

FIX: prevents group show serializer to override basic group serializer (#10326)

Joffrey JAFFEUX11faec71ae7d
diff --git a/app/assets/javascripts/discourse/app/controllers/group-index.js b/app/assets/javascripts/discourse/app/controllers/group-index.js
index c0ab592fdea..6e54304cf42 100644
--- a/app/assets/javascripts/discourse/app/controllers/group-index.js
+++ b/app/assets/javascripts/discourse/app/controllers/group-index.js
@@ -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")
diff --git a/app/assets/javascripts/discourse/app/controllers/group.js b/app/assets/javascripts/discourse/app/controllers/group.js
index bb77f1a632e..9b2f0631286 100644
--- a/app/assets/javascripts/discourse/app/controllers/group.js
+++ b/app/assets/javascripts/discourse/app/controllers/group.js
@@ -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();
diff --git a/app/serializers/group_show_serializer.rb b/app/serializers/group_show_serializer.rb
index d3400df6588..e087b5248a8 100644
--- a/app/serializers/group_show_serializer.rb
+++ b/app/serializers/group_show_serializer.rb
@@ -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?
diff --git a/spec/serializers/group_show_serializer_spec.rb b/spec/serializers/group_show_serializer_spec.rb
index 98e43873794..b781b3121d6 100644
--- a/spec/serializers/group_show_serializer_spec.rb
+++ b/spec/serializers/group_show_serializer_spec.rb
@@ -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
diff --git a/test/javascripts/controllers/group-test.js b/test/javascripts/controllers/group-test.js
deleted file mode 100644
index eaf09be5bec..00000000000
--- a/test/javascripts/controllers/group-test.js
+++ /dev/null
@@ -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"
- );
-});