From 580c57e71bf0a9b5db2bb6611a52e4daac8ba265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Mon, 16 Oct 2017 19:02:27 +0200 Subject: [PATCH] Added officing tests Added new tests to officing section to ensure that multiple sessions (different users) can be initialized at the same time without crashing. --- spec/features/officing_spec.rb | 39 +++++++++++++++++++++++++++++++++- spec/sessions_helper.rb | 8 +++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 spec/sessions_helper.rb diff --git a/spec/features/officing_spec.rb b/spec/features/officing_spec.rb index aff3eac4e..897a26107 100644 --- a/spec/features/officing_spec.rb +++ b/spec/features/officing_spec.rb @@ -1,4 +1,5 @@ require 'rails_helper' +require 'sessions_helper' feature 'Poll Officing' do let(:user) { create(:user) } @@ -106,4 +107,40 @@ feature 'Poll Officing' do expect(page).to_not have_css('#moderation_menu') end -end \ No newline at end of file + scenario 'Officing dashboard available for multiple sessions' do + user1 = create(:user) + user2 = create(:user) + officer1 = create(:poll_officer, user: user1) + officer2 = create(:poll_officer, user: user2) + + in_browser(:one) do + login_as user1 + visit officing_root_path + end + + in_browser(:two) do + login_as user2 + visit officing_root_path + end + + in_browser(:one) do + page.should have_content("Here you can validate user documents and store voting results") + + visit new_officing_residence_path + page.should have_content("Validate document") + + visit final_officing_polls_path + page.should have_content("Polls ready for final recounting") + end + + in_browser(:two) do + page.should have_content("Here you can validate user documents and store voting results") + + visit new_officing_residence_path + page.should have_content("Validate document") + + visit final_officing_polls_path + page.should have_content("Polls ready for final recounting") + end + end +end diff --git a/spec/sessions_helper.rb b/spec/sessions_helper.rb new file mode 100644 index 000000000..fc3fcc2f0 --- /dev/null +++ b/spec/sessions_helper.rb @@ -0,0 +1,8 @@ +def in_browser(name) + old_session = Capybara.session_name + + Capybara.session_name = name + yield + + Capybara.session_name = old_session +end