Group related specs together
This commit is contained in:
@@ -20,61 +20,61 @@ feature 'Legislation Proposals' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Each user has a different and consistent random proposals order', :js do
|
feature "Random pagination" do
|
||||||
create_list(:legislation_proposal, 10, process: process)
|
before do
|
||||||
|
create_list(
|
||||||
|
:legislation_proposal,
|
||||||
|
(Legislation::Proposal.default_per_page + 2),
|
||||||
|
process: process
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
in_browser(:one) do
|
scenario 'Each user has a different and consistent random proposals order', :js do
|
||||||
|
in_browser(:one) do
|
||||||
|
login_as user
|
||||||
|
visit legislation_process_proposals_path(process)
|
||||||
|
@first_user_proposals_order = legislation_proposals_order
|
||||||
|
end
|
||||||
|
|
||||||
|
in_browser(:two) do
|
||||||
|
login_as user2
|
||||||
|
visit legislation_process_proposals_path(process)
|
||||||
|
@second_user_proposals_order = legislation_proposals_order
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(@first_user_proposals_order).not_to eq(@second_user_proposals_order)
|
||||||
|
|
||||||
|
in_browser(:one) do
|
||||||
|
visit legislation_process_proposals_path(process)
|
||||||
|
expect(legislation_proposals_order).to eq(@first_user_proposals_order)
|
||||||
|
end
|
||||||
|
|
||||||
|
in_browser(:two) do
|
||||||
|
visit legislation_process_proposals_path(process)
|
||||||
|
expect(legislation_proposals_order).to eq(@second_user_proposals_order)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Random order maintained with pagination', :js do
|
||||||
login_as user
|
login_as user
|
||||||
visit legislation_process_proposals_path(process)
|
visit legislation_process_proposals_path(process)
|
||||||
@first_user_proposals_order = legislation_proposals_order
|
first_page_proposals_order = legislation_proposals_order
|
||||||
|
|
||||||
|
click_link 'Next'
|
||||||
|
expect(page).to have_content "You're on page 2"
|
||||||
|
|
||||||
|
click_link 'Previous'
|
||||||
|
expect(page).to have_content "You're on page 1"
|
||||||
|
|
||||||
|
expect(legislation_proposals_order).to eq(first_page_proposals_order)
|
||||||
end
|
end
|
||||||
|
|
||||||
in_browser(:two) do
|
scenario 'Does not crash when the seed is not a number' do
|
||||||
login_as user2
|
login_as user
|
||||||
visit legislation_process_proposals_path(process)
|
visit legislation_process_proposals_path(process, random_seed: "Spoof")
|
||||||
@second_user_proposals_order = legislation_proposals_order
|
|
||||||
|
expect(page).to have_content "You're on page 1"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(@first_user_proposals_order).not_to eq(@second_user_proposals_order)
|
|
||||||
|
|
||||||
in_browser(:one) do
|
|
||||||
visit legislation_process_proposals_path(process)
|
|
||||||
expect(legislation_proposals_order).to eq(@first_user_proposals_order)
|
|
||||||
end
|
|
||||||
|
|
||||||
in_browser(:two) do
|
|
||||||
visit legislation_process_proposals_path(process)
|
|
||||||
expect(legislation_proposals_order).to eq(@second_user_proposals_order)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Random order maintained with pagination', :js do
|
|
||||||
create_list(:legislation_proposal, (Kaminari.config.default_per_page + 2), process: process)
|
|
||||||
|
|
||||||
login_as user
|
|
||||||
visit legislation_process_proposals_path(process)
|
|
||||||
first_page_proposals_order = legislation_proposals_order
|
|
||||||
|
|
||||||
click_link 'Next'
|
|
||||||
expect(page).to have_content "You're on page 2"
|
|
||||||
|
|
||||||
click_link 'Previous'
|
|
||||||
expect(page).to have_content "You're on page 1"
|
|
||||||
|
|
||||||
expect(legislation_proposals_order).to eq(first_page_proposals_order)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Does not crash when the seed is not a number' do
|
|
||||||
create_list(
|
|
||||||
:legislation_proposal,
|
|
||||||
(Legislation::Proposal.default_per_page + 2),
|
|
||||||
process: process
|
|
||||||
)
|
|
||||||
|
|
||||||
login_as user
|
|
||||||
visit legislation_process_proposals_path(process, random_seed: "Spoof")
|
|
||||||
|
|
||||||
expect(page).to have_content "You're on page 1"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Selected filter' do
|
context 'Selected filter' do
|
||||||
|
|||||||
Reference in New Issue
Block a user