Reduce duration and complexity of spec/features/issues/filtered_search/filter_issues_spec.rb
This spec takes 15+ minutes on CI. Numbers below are local.
Before:
Finished in 4 minutes 38.6 seconds (files took 0.88514 seconds to load)
67 examples, 0 failures
4796 / 109633 LOC (4.37%) covered
After:
Finished in 2 minutes 25.9 seconds (files took 0.86223 seconds to load)
36 examples, 0 failures
4855 / 109556 LOC (4.43%) covered
I refactored this spec pretty methodically; I recommend viewing it commit-by-commit, which I've included below.
c34a303f - Remove redundant specs from filter_issues_spec
While testing the various search tokens, we would add the token and a search term, then verify the correct issues were returned. Then we'd add a new token, search again, and verify again. Then another, and another.
This was entirely redundant. If the search with higher specificity returned the same results as the search with lower specificity, we can be sure the lower specificity searches also worked without actually testing them.
Because this entire spec performs very extensive setup, it's important to limit the number of times we perform that setup.
97400db1 - Remove unnecessary include from filter_issues_spec
e1ecc4c7 - Use a positive assertion for have_no_selector rather than the inverse
a6ec1797 - Scope group creation to the specs that actually require it
Only one context tested group behavior, but we were performing group and membership creation on every example unnecessarily.
267d617a - Remove unnecessary attributes from factories
77ba1870 - Remove an unnecessary issue creation
This seemed to only exist to increment an issue counter by 1.
aee81c77 - Clean up the still-way-too-complex filter_issues_spec setup
Removes unnecessary let!
usage since we explicitly access these in the
`before.
Re-uses user2
as the author for issues we otherwise don't care about
the author for, to avoid creating a new user in each one.
Makes use of the labeled_issue
factory to avoid assigning variables
just so we can add labels to an issue.
93b8e55f - Reduce issues and milestones created in global filter_issues_spec setup
Three issues were only used in one test each, and one milestone with its accompanying issue were only used in one test, so we now scope those locally.
e8706aa7 - Remove unused labels from filter_issues_spec
8602793d - Remove the top-level closed issue from filter_issues_spec
07e1b66f - Reduce duplication in RSS feed specs for filter_issues_spec
285b1e40 - Remove unused select_search_at_index helper
42fd9e29 - Re-order top-level let
s, so that labels are grouped
442db932 - Remove more redundant specs in filter_issues_spec
We were essentially testing "all of the filters" four times, so now we just do it once at the top level.
a45646fd - Combine multiple it
blocks in filter_issues_spec
4e0e54ca - Turns out that short name was important, who knew!
We now document that fact.