Skip to content

Commit

Permalink
feat: Adding investments to member serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomas committed Dec 31, 2024
1 parent d335527 commit 80c1994
Show file tree
Hide file tree
Showing 9 changed files with 1,765 additions and 172 deletions.
1 change: 1 addition & 0 deletions backend/app/serializers/api/v1/member_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class MemberSerializer < BaseSerializer
belongs_to_restricted :funder

has_many_restricted :projects
has_many_restricted :investments
end
end
end
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"data": {
"id": "f5f720f9-2896-4583-b63a-d61bb98e5e96",
"id": "56509b92-d99e-407a-a21c-5d7f15f45864",
"type": "member",
"attributes": {
"first_name": "Dawna"
},
"relationships": {
"funder": {
"data": {
"id": "8ff19280-2af6-4a2c-be00-ba5fbea69263",
"id": "23968c74-570b-47ab-944a-9dde5d93b425",
"type": "funder"
}
}
}
},
"included": [
{
"id": "8ff19280-2af6-4a2c-be00-ba5fbea69263",
"id": "23968c74-570b-47ab-944a-9dde5d93b425",
"type": "funder",
"attributes": {
"name": "Otha Kemmer",
Expand Down Expand Up @@ -58,21 +58,21 @@
"demographics_other": "Enim repellat pariatur est.",
"contact_email": "[email protected]",
"logo": {
"small": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxrWTJNMVpUZzFOaTFtTm1NNExUUTROMlV0T1RrNU5TMWtaVEl4WkdKaE0ySTJPV0VHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--6ebae4c6f2260e3a7353702f52289ee02cc113ad/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERJd01IZ3lNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--8673702c2d856505736727890dcac6a632977811/picture.jpg",
"medium": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxrWTJNMVpUZzFOaTFtTm1NNExUUTROMlV0T1RrNU5TMWtaVEl4WkdKaE0ySTJPV0VHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--6ebae4c6f2260e3a7353702f52289ee02cc113ad/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERnd01IZzRNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--e82a96c0eabd93d914de4ef37febd98c36e0e275/picture.jpg",
"original": "http://localhost:4000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxrWTJNMVpUZzFOaTFtTm1NNExUUTROMlV0T1RrNU5TMWtaVEl4WkdKaE0ySTJPV0VHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--6ebae4c6f2260e3a7353702f52289ee02cc113ad/picture.jpg"
"small": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt3TVdRd1l6RmhNQzFpWkdFd0xUUXhaV0l0T1RCbU1DMDNZV1ZoTURreVl6ZzNaR1lHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--bdd22797fd75130b557ebffef7ccc86c50d065a2/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERJd01IZ3lNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--8673702c2d856505736727890dcac6a632977811/picture.jpg",
"medium": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt3TVdRd1l6RmhNQzFpWkdFd0xUUXhaV0l0T1RCbU1DMDNZV1ZoTURreVl6ZzNaR1lHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--bdd22797fd75130b557ebffef7ccc86c50d065a2/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERnd01IZzRNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--e82a96c0eabd93d914de4ef37febd98c36e0e275/picture.jpg",
"original": "http://localhost:4000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt3TVdRd1l6RmhNQzFpWkdFd0xUUXhaV0l0T1RCbU1DMDNZV1ZoTURreVl6ZzNaR1lHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--bdd22797fd75130b557ebffef7ccc86c50d065a2/picture.jpg"
}
},
"relationships": {
"primary_office_state": {
"data": {
"id": "8382f3a9-e384-4716-8675-a428592c41f8",
"id": "24a6d4ee-664f-4ff7-9d7e-a17bea71fb9c",
"type": "subgeographic"
}
},
"primary_office_country": {
"data": {
"id": "7c156964-9f67-4333-8160-3b9728840bd5",
"id": "5e5760e1-60d2-45cf-bfff-dff3c1bc60aa",
"type": "subgeographic"
}
},
Expand All @@ -88,7 +88,10 @@
},
"projects": {
"data": [

{
"id": "93d5f6a8-0267-42cb-97b5-f0fa19d5dec8",
"type": "project"
}
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"data": {
"id": "c0843a5d-8672-4a7f-9692-f92dbc9fc5c6",
"id": "80b40ae3-bb46-434e-802f-2a5c9e47b14c",
"type": "member",
"attributes": {
"first_name": "Dawna",
Expand Down
20 changes: 14 additions & 6 deletions backend/spec/fixtures/snapshots/api/v1/get-member.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
{
"data": {
"id": "eb537b37-145c-450b-a104-ecf6408c6c74",
"id": "474d2da4-5f0b-4aab-ad7c-3ef61b8579aa",
"type": "member",
"attributes": {
"id": "eb537b37-145c-450b-a104-ecf6408c6c74",
"id": "474d2da4-5f0b-4aab-ad7c-3ef61b8579aa",
"email": "[email protected]",
"first_name": "Dawna",
"last_name": "Block",
"created_at": "2024-12-31T13:58:30.926Z",
"updated_at": "2024-12-31T13:58:30.926Z"
"created_at": "2024-12-31T16:18:24.048Z",
"updated_at": "2024-12-31T16:18:24.048Z"
},
"relationships": {
"funder": {
"data": {
"id": "867ec08e-8b20-4929-b36d-09afaca5629c",
"id": "e82b1248-4b0c-4332-8e71-453bb211e145",
"type": "funder"
}
},
"projects": {
"data": [
{
"id": "74eab1c7-8b40-46ac-a056-010f457e285e",
"id": "bf35d0a0-a4dd-4062-8fac-9951e71a6dd2",
"type": "project"
}
]
},
"investments": {
"data": [
{
"id": "2f777635-0c71-4ec7-9f70-a93404562a7e",
"type": "investment"
}
]
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions backend/spec/fixtures/snapshots/api/v1/update-member.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
{
"data": {
"id": "74892a95-b875-4873-8fc3-c6dad4f57308",
"id": "5a7c2bdc-952a-453f-baa2-2b5543f4931f",
"type": "member",
"attributes": {
"id": "74892a95-b875-4873-8fc3-c6dad4f57308",
"id": "5a7c2bdc-952a-453f-baa2-2b5543f4931f",
"email": "[email protected]",
"first_name": "New",
"last_name": "Name",
"created_at": "2024-12-31T13:58:31.203Z",
"updated_at": "2024-12-31T13:58:31.207Z"
"created_at": "2024-12-31T16:18:23.885Z",
"updated_at": "2024-12-31T16:18:23.890Z"
},
"relationships": {
"funder": {
"data": {
"id": "61d024ef-7570-49cb-bb32-26ab42f07b21",
"id": "4d27782d-d4d3-4ee7-8a4f-125ed236e150",
"type": "funder"
}
},
"projects": {
"data": [

]
},
"investments": {
"data": [

]
}
}
Expand Down
1 change: 0 additions & 1 deletion backend/spec/requests/api/v1/members/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

include_context "with authorization"


parameter name: "page[number]", in: :query, type: :integer, description: "Page number. Default: 1", required: false
parameter name: "page[size]", in: :query, type: :integer, description: "Per page items. Default: 10", required: false
parameter name: :disable_pagination, in: :query, type: :boolean, description: "Turn off pagination", required: false
Expand Down
1 change: 1 addition & 0 deletions backend/spec/requests/api/v1/members_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

let(:member) { create :member }
let!(:project) { create :project, member: member }
let!(:investment) { create :investment, funder: member.funder }
let(:Authorization) { "Bearer #{JWTAuth.encode(member)}" }

run_test!
Expand Down
3 changes: 2 additions & 1 deletion backend/spec/swagger_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
type: :object,
properties: {
funder: {"$ref" => "#/components/schemas/response_relation"},
projects: {"$ref" => "#/components/schemas/response_relations"}
projects: {"$ref" => "#/components/schemas/response_relations"},
investments: {"$ref" => "#/components/schemas/response_relations"}
}
}
},
Expand Down
Loading

0 comments on commit 80c1994

Please sign in to comment.