Plots2: Add more functional tests to each method in Search API

Created on 14 May 2017  Â·  17Comments  Â·  Source: publiclab/plots2

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

The problem

Tests help us ensure that the site behaves as we expect it to -- and that as new features are added, they don't break existing functions. We're working to get to near 100% "coverage" -- which would mean all our code is covered by tests.

We have good tests written for the typeahead API, here: https://github.com/publiclab/plots2/blob/master/test/functional/typeahead_api_test.rb

This tests each method in: https://github.com/publiclab/plots2/blob/master/app/api/srch/typeahead.rb

But we should have similar ones for the search API, for each of the methods in: https://github.com/publiclab/plots2/blob/master/app/api/srch/search.rb

(Note that these draw heavily on this file, in turn -- in case you want to know how they're generated: https://github.com/publiclab/plots2/blob/master/app/services/search_service.rb)

Solution

In #1409, a first-time contributor recently created a new test file, and a single test, which you can find at test/functional/search_api_test.rb:

  test 'search notes functionality' do
    get '/api/srch/notes?srchString=Blog'
    assert last_response.ok?
    # more stuff after this

This is a basic test that the response is "ok" and then it goes on to test what's in the response. See how it uses a URL to access the notes method on this line:

So, copy it, and follow the provided URL examples in search.rb to create a new test for a different method. For example, profiles: https://github.com/publiclab/plots2/blob/master/app/api/srch/search.rb#L30

Start by just asserting last_response.ok? as above; we can add more substantive tests later.

You can try running this with rake test or (just to run the functional tests only) rake test TEST=test/functional/search_api_test.rb -- hopefully it will pass!

But you can also just open a pull request (see below) and our automated test system will run it, and you'll be able to see the output there.

If you can help with this, please open a pull request with this test added, and let's see how it goes -- even if it doesn't pass, we can help you with the next steps.

Steps to Fix

  • [ ] claim this issue with a comment here, below, and ask any clarifying questions you need
  • [ ] set up a repository locally following the README instructions, and make sure that all tests pass
  • [ ] try to fix the issue following the steps above, but even before you're done, you can:
  • [ ] commit your changes and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
  • [ ] alert someone via the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!

Please email the developers list (see https://publiclab.org/wiki/developers) or go to the chatroom if you have questions, and take a look at our first-timers landing page for more information!

Ruby first-timers-only help wanted testing

Most helpful comment

ah, i mean super to open a first-timers issue. Thanks!

On Mon, Jan 22, 2018 at 3:44 PM, Jeffrey Warren jeff@unterbahn.com wrote:

That sounds super!

On Mon, Jan 22, 2018 at 2:02 PM, Gaurav Sachdeva <[email protected]

wrote:

Hey, @jywarren https://github.com/jywarren I can open new first-timers
from this or I can solve this too.What you say?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-359529357,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ_csWSSweRNU2w9SBbIKSqFbneWjks5tNNthgaJpZM4NabjY
.

All 17 comments

Hi,
Is it ok if I take this one?

Yes please, and we're happy to help you out with it!

On May 25, 2017 11:28 AM, "mlendale" notifications@github.com wrote:

Hi,
Is it ok if I take this one?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-304039821,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ35WhQCdUU1q-7_RpXC0jEze31d2ks5r9Z4NgaJpZM4NabjY
.

I'd also like to help unless you're almost finished

You are welcome to help as I will be out for a couple of days.

2017-06-01 0:48 GMT+02:00 Anton Pugach notifications@github.com:

I'd also like to help unless you're almost finished

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-305340183,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJ_54Baai3l-xLkBBbPo8spgQAqi3--vks5r_e5agaJpZM4NabjY
.

Yes, I've made a couple suggestions and I think it's possible to open a
pull request against the existing pull request. Happy to help you do this!

On May 31, 2017 7:10 PM, "mlendale" notifications@github.com wrote:

You are welcome to help as I will be out for a couple of days.

2017-06-01 0:48 GMT+02:00 Anton Pugach notifications@github.com:

I'd also like to help unless you're almost finished

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/publiclab/plots2/issues/1418#issuecomment-305340183
,
or mute the thread
xLkBBbPo8spgQAqi3--vks5r_e5agaJpZM4NabjY>
.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-305343989,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ7Ls8r4kyphhvcQLkEcc7sGxgRJ6ks5r_fNcgaJpZM4NabjY
.

Hello:

Seems all the search endpoints [:all, :profiles, :notes, :questions, :tags] have been tested. Is there any new functionality in the pipeline or anything else to do here? Thanks

I am interested in helping as it still seems open but I see no activity. Still anything I can do? ta

Hi! Well, the PR in #1437 is not quite there, and we could definitely use help getting it finalized. If you could work starting from the commits in that PR, and follow some of the suggestions I've left in that file, you could open a new PR based on that commit and we can move forward with it.

https://github.com/publiclab/plots2/pull/1437/files#diff-ae2647e0aa24f1474d9192f6cedc811eR10

If you need assistance with any of these steps, we can help!

Thank you!

Also I was hoping @ananyo2012 and @ryzokuken might be able to assist while I'm less available this week; if so, thank you!

Yes please! We're happy to help you along too.

On Sep 8, 2017 10:10 PM, "majdeddine" notifications@github.com wrote:

Hi,
I am interested in helping also, can i give it a try ?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-328247922,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ0ZR-cjY8rrHAJv6AH2ArR_ZTbOzks5sgfOBgaJpZM4NabjY
.

yes please! there's quite a bit of progress in an existing PR that i think
is linked to from here, see https://github.com/publiclab/plots2/pulls if
not. It'd be great to build on this!

On Thu, Dec 14, 2017 at 5:20 AM, Sidharth Bansal notifications@github.com
wrote:

Hi @jywarren https://github.com/jywarren can I try this?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-351669229,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJwaknBnoEwH0XevCGPxbWCeZEmNgks5tAPZ9gaJpZM4NabjY
.

OK I will try to add

Hey, @jywarren I can open new first-timers from this or I can solve this too.What you say?

That sounds super!

On Mon, Jan 22, 2018 at 2:02 PM, Gaurav Sachdeva notifications@github.com
wrote:

Hey, @jywarren https://github.com/jywarren I can open new first-timers
from this or I can solve this too.What you say?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-359529357,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ_csWSSweRNU2w9SBbIKSqFbneWjks5tNNthgaJpZM4NabjY
.

ah, i mean super to open a first-timers issue. Thanks!

On Mon, Jan 22, 2018 at 3:44 PM, Jeffrey Warren jeff@unterbahn.com wrote:

That sounds super!

On Mon, Jan 22, 2018 at 2:02 PM, Gaurav Sachdeva <[email protected]

wrote:

Hey, @jywarren https://github.com/jywarren I can open new first-timers
from this or I can solve this too.What you say?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1418#issuecomment-359529357,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ_csWSSweRNU2w9SBbIKSqFbneWjks5tNNthgaJpZM4NabjY
.

Moved to #2072 for first-timers

:-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keshavsethi picture keshavsethi  Â·  3Comments

first-timers[bot] picture first-timers[bot]  Â·  3Comments

shapironick picture shapironick  Â·  3Comments

keshavsethi picture keshavsethi  Â·  3Comments

grvsachdeva picture grvsachdeva  Â·  3Comments