Reduce the number of proposals in pagination spec #3687
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Background
We're getting a failure on Travis in one of these tests. Debugging shows the AJAX request rendering the first page (after clicking the "Previous" link) takes too long and sometimes it exceeds Capybara's timeout.
Objectives
Make the test faster so we don't reach Capybara's timeout.
Notes
After running the test thousands of times, the only way I've found to clearly reduce the number of times the test fails (reducing the time of the request by 0.4 seconds on average) is to reduce the number of records shown on the first page. Other experiments, like adding an
includes(:author)
to the query getting the proposals in the controller, or addingauthor: user
to thecreate_list
part of the test (so only one author needs to be fetched when rendering the proposals) show inconsistent results regarding performance.Of course improving the performance of the partial rendering legislation proposals would be a better solution. However, after some debugging I wasn't able to find a clear bottleneck, so speeding up this part would be a complex task.
The test failed with the following message: