# Building Tests for New discourse\_api Endpoints

**URL:** <https://meta.discourse.org/t/building-tests-for-new-discourse-api-endpoints/118639>\
**Category:** Development\
**Created:** [May 24, 2019, 10:21pm UTC](https://meta.discourse.org/t/building-tests-for-new-discourse-api-endpoints/118639 "2019-05-24T22:21:24Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)\
**Post date:** [May 28, 2019, 6:00pm UTC](https://meta.discourse.org/t/building-tests-for-new-discourse-api-endpoints/118639/4 "2019-05-28T18:00:44Z")

</div>

Glad you got the tests working. They can be tricky sometimes because if the request doesn’t match exactly it will try and create an actual request rather that using the stubbed request.

I think the urls are okay. It would be nice not to use such a high post\_id, but I’m not concerned about that. And ALL the tests need to have `http://localhost:3000` extracted out into a common variable, but that should probably be done in a separate commit. Whenever you are ready you can go ahead and submit a pr and I can review it.

One thing I did notice though is I that passing in the `api_username` as a parameter is no longer supported.

> [@kimardenmiller](#):
>
> .optional(:opts, :api\_username)

This is because the discourse\_api gem now only passes in the auth via the headers, and discourse core ignores any auth credentials in the body if the header is already being used for auth.

---

_[View the full topic](https://meta.discourse.org/t/building-tests-for-new-discourse-api-endpoints/118639)._
