Skip to content

Commit

Permalink
CV2-4072: test coverage and add medias_count to PublicTeamType
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Jan 31, 2024
1 parent 4236be7 commit a8bcefa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/graph/types/public_team_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11134,6 +11134,7 @@ type PublicTeam implements Node {
dbid: Int
description: String
id: ID!
medias_count: Int
name: String!
permissions: String
private: Boolean
Expand Down
14 changes: 14 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion test/controllers/graphql_controller_12_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/controllers/graphql_controller_8_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ def setup
}
public_team {
id
medias_count
trash_count
unconfirmed_count
spam_count
Expand Down

0 comments on commit a8bcefa

Please sign in to comment.