diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-11-28 17:00:11 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-11-29 09:05:37 +0100 |
commit | 45812f1cab3431df35ec89c4d39df72f94c334f2 (patch) | |
tree | 39b02d10d393cc93ab2cf2cbb8ea79b7ed397fbc /spec/features/projects/environments/environment_spec.rb | |
parent | c07183f0d3ce24e8cfcb93e71ae950d7067a8ce1 (diff) | |
download | gitlab-ce-45812f1cab3431df35ec89c4d39df72f94c334f2.tar.gz |
Fix Environment terminal specs for EE
In EE we redefine Environment#terminals, which makes it impossible to
use `allow_any_instance_of(Environment)` or
`expect_any_instance_of(Environment)`. Other approaches of stubbing
this class, such as by stubbing `new`, only result in spec failures.
To solve this issue, we add a simple `defined?(EE)` check in the tests
to change the thing that we are testing. This is rather obnoxious,
because it requires EE knowledge in CE, and can break if
`EE::Environment` is removed without updating CE. Unfortunately, it
appears to be the only solution we have apart from modifying these tests
in EE (which would cause merge conflicts).
Diffstat (limited to 'spec/features/projects/environments/environment_spec.rb')
-rw-r--r-- | spec/features/projects/environments/environment_spec.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index 9772a7bacac..a8a3b6910fb 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -165,8 +165,14 @@ describe 'Environment' do context 'web terminal', :js do before do - # Stub #terminals as it causes js-enabled feature specs to render the page incorrectly - allow_any_instance_of(Environment).to receive(:terminals) { nil } + # Stub #terminals as it causes js-enabled feature specs to + # render the page incorrectly + # + # In EE we have to stub EE::Environment since it overwrites + # the "terminals" method. + allow_any_instance_of(defined?(EE) ? EE::Environment : Environment) + .to receive(:terminals) { nil } + visit terminal_project_environment_path(project, environment) end |