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

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

diff --git a/app/assets/javascripts/discourse/app/controllers/group-index.js b/app/assets/javascripts/discourse/app/controllers/group-index.js
index c0ab592..6e54304 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 bb77f1a..9b2f063 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 d3400df..e087b52 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 98e4387..b781b31 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 eaf09be..0000000
--- 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"
-  );
-});

GitHub sha: 11faec71

1 Like

This commit appears in #10326 which was approved by eviltrout. It was merged by jjaffeux.

I believe this may be what’s causing the issue here: https://meta.discourse.org/t/api-is-group-owner-returning-null/161262