From d36e47c74024e1b68e09f4c3d031d759ca2d75d1 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 31 Oct 2017 18:50:00 +0100 Subject: [PATCH] Add legislation proposal spec, with random list order scenario --- spec/features/legislation/proposals_spec.rb | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/features/legislation/proposals_spec.rb b/spec/features/legislation/proposals_spec.rb index 2c47bd54b..17d3eb28c 100644 --- a/spec/features/legislation/proposals_spec.rb +++ b/spec/features/legislation/proposals_spec.rb @@ -1,8 +1,10 @@ require 'rails_helper' +require 'sessions_helper' feature 'Legislation Proposals' do let(:user) { create(:user) } + let(:user2) { create(:user) } let(:process) { create(:legislation_process) } let(:proposal) { create(:legislation_proposal) } @@ -18,6 +20,34 @@ feature 'Legislation Proposals' do end end + scenario 'Each user as a different and consistent random proposals order', :js do + create_list(:legislation_proposal, 10, process: process) + + in_browser(:one) do + login_as user + visit legislation_process_proposals_path(process) + @first_user_proposals_order = all("[id^='legislation_proposal_']").collect { |e| e[:id] } + end + + in_browser(:two) do + login_as user2 + visit legislation_process_proposals_path(process) + @second_user_proposals_order = all("[id^='legislation_proposal_']").collect { |e| e[:id] } + end + + expect(@first_user_proposals_order).not_to eq(@second_user_proposals_order) + + in_browser(:one) do + visit legislation_process_proposals_path(process) + expect(all("[id^='legislation_proposal_']").collect { |e| e[:id] }).to eq(@first_user_proposals_order) + end + + in_browser(:two) do + visit legislation_process_proposals_path(process) + expect(all("[id^='legislation_proposal_']").collect { |e| e[:id] }).to eq(@second_user_proposals_order) + end + end + scenario "Create a legislation proposal with an image", :js do create(:legislation_proposal, process: process)