Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more functional tests to each method in Search API #1418

Closed
5 tasks
jywarren opened this issue May 14, 2017 · 17 comments
Closed
5 tasks

Add more functional tests to each method in Search API #1418

jywarren opened this issue May 14, 2017 · 17 comments
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute Ruby testing issues are usually for adding unit tests, integration tests or any other tests for a feature

Comments

@jywarren
Copy link
Member

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!

@jywarren jywarren added first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute Ruby testing issues are usually for adding unit tests, integration tests or any other tests for a feature labels May 14, 2017
@mlendale
Copy link

Hi,
Is it ok if I take this one?

@jywarren
Copy link
Member Author

jywarren commented May 25, 2017 via email

@puan0601
Copy link

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

@mlendale
Copy link

mlendale commented May 31, 2017 via email

@jywarren
Copy link
Member Author

jywarren commented May 31, 2017 via email

@DoReMiFaSoLaTiDo
Copy link

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

@wizofe
Copy link

wizofe commented Aug 10, 2017

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

@jywarren
Copy link
Member Author

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!

@jywarren
Copy link
Member Author

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

@jywarren
Copy link
Member Author

jywarren commented Sep 9, 2017 via email

@jywarren
Copy link
Member Author

jywarren commented Dec 14, 2017 via email

@SidharthBansal
Copy link
Member

OK I will try to add

@grvsachdeva
Copy link
Member

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

@jywarren
Copy link
Member Author

jywarren commented Jan 22, 2018 via email

@jywarren
Copy link
Member Author

jywarren commented Jan 22, 2018 via email

@grvsachdeva
Copy link
Member

Moved to #2072 for first-timers

@jywarren
Copy link
Member Author

:-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute Ruby testing issues are usually for adding unit tests, integration tests or any other tests for a feature
Projects
None yet
Development

No branches or pull requests

8 participants