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 for each method in Search API #2072

Closed
grvsachdeva opened this issue Jan 22, 2018 · 3 comments
Closed

Add more functional tests for each method in Search API #2072

grvsachdeva opened this issue Jan 22, 2018 · 3 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

@grvsachdeva
Copy link
Member

grvsachdeva commented Jan 22, 2018

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!

@grvsachdeva grvsachdeva added testing issues are usually for adding unit tests, integration tests or any other tests for a feature 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 labels Jan 22, 2018
@jywarren
Copy link
Member

This is looking good, @Gauravano ! Maybe a little more formatting with headers, perhaps? Thank you!

@biswesh456
Copy link
Contributor

Can I claim this?

@grvsachdeva
Copy link
Member Author

yes, that would be great.

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

3 participants