summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-31 09:06:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-31 09:06:29 +0000
commit6026bddcd51eca573c530240c421392045172b89 (patch)
tree30cb1134ac00a336e6cfaa81bbafe6cd1360f58f /qa
parentb7c776f95d5f41ac00986073563ad0c1de4bad44 (diff)
downloadgitlab-ce-6026bddcd51eca573c530240c421392045172b89.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/runtime/browser.rb6
-rw-r--r--qa/spec/spec_helper.rb18
2 files changed, 24 insertions, 0 deletions
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb
index 4789b380377..c914526002c 100644
--- a/qa/qa/runtime/browser.rb
+++ b/qa/qa/runtime/browser.rb
@@ -19,6 +19,12 @@ module QA
self.class.configure!
end
+ def self.blank_page?
+ ['', 'about:blank', 'data:,'].include?(Capybara.current_session.driver.browser.current_url)
+ rescue
+ true
+ end
+
##
# Visit a page that belongs to a GitLab instance under given address.
#
diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb
index 363980acc33..ed29bfa41dd 100644
--- a/qa/spec/spec_helper.rb
+++ b/qa/spec/spec_helper.rb
@@ -23,6 +23,24 @@ RSpec.configure do |config|
QA::Runtime::Logger.debug("Starting test: #{example.full_description}") if QA::Runtime::Env.debug?
end
+ config.after(:context) do
+ if !QA::Runtime::Browser.blank_page? && QA::Page::Main::Menu.perform(&:signed_in?)
+ QA::Page::Main::Menu.perform(&:sign_out)
+ raise(
+ <<~ERROR
+ The test left the browser signed in.
+
+ Usually, Capybara prevents this from happening but some things can
+ interfere. For example, if it has an `after(:context)` block that logs
+ in, the browser will stay logged in and this will cause the next test
+ to fail.
+
+ Please make sure the test does not leave the browser signed in.
+ ERROR
+ )
+ end
+ end
+
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end