From a8bcefa6fb4cfb48089b19f85537c0012d2d3dc0 Mon Sep 17 00:00:00 2001 From: Sawy Date: Wed, 31 Jan 2024 07:54:41 +0200 Subject: [PATCH] CV2-4072: test coverage and add medias_count to PublicTeamType --- app/graph/types/public_team_type.rb | 6 ++++++ app/models/user.rb | 2 +- lib/relay.idl | 1 + public/relay.json | 14 ++++++++++++++ test/controllers/graphql_controller_12_test.rb | 4 +++- test/controllers/graphql_controller_8_test.rb | 1 + 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/graph/types/public_team_type.rb b/app/graph/types/public_team_type.rb index a7c9794d66..0ed13cf45d 100644 --- a/app/graph/types/public_team_type.rb +++ b/app/graph/types/public_team_type.rb @@ -17,6 +17,12 @@ def pusher_channel Team.find(object.id).pusher_channel end + field :medias_count, GraphQL::Types::Int, null: true + + def medias_count + archived_count(object) ? 0 : object.medias_count + end + field :trash_count, GraphQL::Types::Int, null: true def trash_count diff --git a/app/models/user.rb b/app/models/user.rb index dfc8320e07..bfa2050daa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -96,7 +96,7 @@ def self.from_token(token) end def me - self + User.current&.id == self.id ? self : nil end def set_source_image diff --git a/lib/relay.idl b/lib/relay.idl index 22ac832d7a..fa71d480af 100644 --- a/lib/relay.idl +++ b/lib/relay.idl @@ -11134,6 +11134,7 @@ type PublicTeam implements Node { dbid: Int description: String id: ID! + medias_count: Int name: String! permissions: String private: Boolean diff --git a/public/relay.json b/public/relay.json index f035b73e3f..a7bf508144 100644 --- a/public/relay.json +++ b/public/relay.json @@ -58676,6 +58676,20 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "medias_count", + "description": null, + "args": [ + + ], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "name", "description": null, diff --git a/test/controllers/graphql_controller_12_test.rb b/test/controllers/graphql_controller_12_test.rb index 4e55f9ca00..5a39021fdf 100644 --- a/test/controllers/graphql_controller_12_test.rb +++ b/test/controllers/graphql_controller_12_test.rb @@ -280,7 +280,9 @@ def teardown test "should return me type after update user" do user = create_user authenticate_with_user(user) - id = user.graphql_id + post :create, params: { query: 'query Query { me { id } }' } + assert_response :success + id = JSON.parse(@response.body)['data']['me']['id'] query = 'mutation { updateUser(input: { clientMutationId: "1", id: "' + id + '", name: "update name" }) { user { dbid }, me { dbid } } }' post :create, params: { query: query } assert_response :success diff --git a/test/controllers/graphql_controller_8_test.rb b/test/controllers/graphql_controller_8_test.rb index a186f3f6fc..b7ed4ff6f8 100644 --- a/test/controllers/graphql_controller_8_test.rb +++ b/test/controllers/graphql_controller_8_test.rb @@ -538,6 +538,7 @@ def setup } public_team { id + medias_count trash_count unconfirmed_count spam_count