Replace frequently used code with new `sign_out_if_signed_in` and `signed_in?` methods
The following discussion from gitlab-ce!29937 should be addressed:
-
@mlapierre started a discussion: We do something like this often enough that we could benefit from 2 new methods,
sign_out_if_signed_in
andsigned_in?
.
The code was:
Page::Main::Menu.perform(&:sign_out) if @is_new_session && Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
And we have plenty of similar cases like:
if Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
Page::Main::Menu.perform { |main| main.sign_out }
end
I find myself translating those code fragments in my head and it would be much better if it just read sign_out_if_signed_in
or signed_in?
.