Retrospect: Rspec does not pass locally but passes on CI
Background
Today, we (@mikegreiling, @jschatz1, @rspeicher, @jivanvl and I) discovered that Rspec tests were not passing locally but were passing on CI (https://gitlab.com/gitlab-org/gitlab-ce/issues/42450)
Investigation
After going through live_debug
, we determined that the webpack scripts were not being loaded in rspec tests. Further investigation determined that this was caused by changes made to the app/helpers/webpack_helper.rb
in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16459/ Specifically, the addition of force_same_domain
.
Local rspec tests utilize the webpack dev server (a different domain), which requires force_same_domain
to be set to false
. Since https://gitlab.com/gitlab-org/gitlab-ce/commit/e79db43d2cf269beec700353e776e92b15ac9af9#b32d21ed5fd31e3e4cb0cec016d821c33c8f4c2f_6_5 was doing the following
javascript_include_tag(*gitlab_webpack_asset_paths(bundle, force_same_domain: true))
It was setting all scripts to use the same domain, which resulted in all local rspec's failing because of it's reliance on a different domain to host webpack files.
Solution
We are going to make the following change:
javascript_include_tag(*gitlab_webpack_asset_paths(bundle, force_same_domain: true))
to
javascript_include_tag(*gitlab_webpack_asset_paths(bundle, force_same_domain: force_same_domain))
This should enable all rspec that is run locally to mimic rspec run on CI.
How we can improve
- @mikegreiling should go over all webpack related changes
- We need to investigate why rubocop didn't warn about the unused argument found in https://gitlab.com/gitlab-org/gitlab-ce/commit/e79db43d2cf269beec700353e776e92b15ac9af9#b32d21ed5fd31e3e4cb0cec016d821c33c8f4c2f_6_4
- Cleanup webpack helper as it is getting hacky.