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.
c34a303f0215dc9780dbd9b0da98646d528c5b08 - 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.
97400db1054b2fd765797104eb03f23fb25ec43a - Remove unnecessary include from filter_issues_spec
e1ecc4c7c70baa562af0076098ceb048edf3bb9a - Use a positive assertion for have_no_selector rather than the inverse
a6ec17973871ac33fbca50c5780e938752f8370e - 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.
267d617a36dccf708acce67666b909cc0a1688e9 - Remove unnecessary attributes from factories
77ba187029fde7cacbbae0170794b24c57e9478b - Remove an unnecessary issue creation
This seemed to only exist to increment an issue counter by 1.
aee81c77984a2fc183d4125a77342d6f4d275caa - 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.
93b8e55f3f6e700c879834da2b478d1395218d73 - 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.
e8706aa7f3b2f5cac241a50ddcfa553c66ac6999 - Remove unused labels from filter_issues_spec
8602793d4bb27a422b7be9b09e98aba58c9b08f7 - Remove the top-level closed issue from filter_issues_spec
07e1b66ffc1b4cc84c13817ee26f8cc223b56a47 - Reduce duplication in RSS feed specs for filter_issues_spec
285b1e4080b48609f912b554b5793fae20b3ef7f - Remove unused select_search_at_index helper
let
s, so that labels are grouped
42fd9e295f2f8c8ef0ca117559caaec34639b9fd - Re-order top-level 442db93249a0f8cc5475dbc32909f56f503a91cb - 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.
it
blocks in filter_issues_spec
a45646fdbfaecf0c10ef993fab8da4054163e6ba - Combine multiple 4e0e54ca2546f738642f8e9e1f56282c832d3393 - Turns out that short name was important, who knew!
We now document that fact.