@@ -77,6 +77,25 @@ func TestNonexistingBudgetEnvelopes404(t *testing.T) {
7777 test .AssertHTTPStatus (t , http .StatusNotFound , & recorder )
7878}
7979
80+ // TestEnvelopeParentChecked is a regression test for https://github.com/envelope-zero/backend/issues/90.
81+ //
82+ // It verifies that the envelope details endpoint for a category only returns envelopes that belong to the
83+ // category.
84+ func TestEnvelopeParentChecked (t * testing.T ) {
85+ r := test .Request (t , "POST" , "/v1/budgets/1/categories" , `{ "name": "Testing category" }` )
86+ test .AssertHTTPStatus (t , http .StatusCreated , & r )
87+
88+ var category CategoryDetailResponse
89+ test .DecodeResponse (t , & r , & category )
90+
91+ path := fmt .Sprintf ("/v1/budgets/1/categories/%v" , category .Data .ID )
92+ r = test .Request (t , "GET" , path + "/envelopes/1" , "" )
93+ test .AssertHTTPStatus (t , http .StatusNotFound , & r )
94+
95+ r = test .Request (t , "DELETE" , path , "" )
96+ test .AssertHTTPStatus (t , http .StatusNoContent , & r )
97+ }
98+
8099func TestCreateEnvelope (t * testing.T ) {
81100 recorder := test .Request (t , "POST" , "/v1/budgets/1/categories/1/envelopes" , `{ "name": "New Envelope", "note": "More tests something something" }` )
82101 test .AssertHTTPStatus (t , http .StatusCreated , & recorder )
0 commit comments