From abd6a1971fdf16fe2718e8a46ebd96aa885ae9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 27 Mar 2021 20:19:30 +0100 Subject: [PATCH] Move redirection test to controller specs We make the test faster and avoid a strange issue with `current_path` in JavaScript tests. We should probably have done this in commit ec1874325. --- .../legislation/proposals_controller_spec.rb | 11 +++++++++++ spec/system/legislation/processes_spec.rb | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 spec/controllers/legislation/proposals_controller_spec.rb diff --git a/spec/controllers/legislation/proposals_controller_spec.rb b/spec/controllers/legislation/proposals_controller_spec.rb new file mode 100644 index 000000000..f9cbe2c50 --- /dev/null +++ b/spec/controllers/legislation/proposals_controller_spec.rb @@ -0,0 +1,11 @@ +require "rails_helper" + +describe Legislation::ProposalsController do + describe "GET new" do + it "redirects to register path if user is not logged in" do + get :new, params: { process_id: create(:legislation_process, :in_proposals_phase).id } + + expect(response).to redirect_to new_user_session_path + end + end +end diff --git a/spec/system/legislation/processes_spec.rb b/spec/system/legislation/processes_spec.rb index 2ebe7c229..fbbabea77 100644 --- a/spec/system/legislation/processes_spec.rb +++ b/spec/system/legislation/processes_spec.rb @@ -387,16 +387,6 @@ describe "Legislation" do expect(page).to have_content("There are no proposals") end - scenario "create proposal button redirects to register path if user is not logged in" do - process = create(:legislation_process, :in_proposals_phase) - - visit legislation_process_proposals_path(process) - click_link "Create a proposal" - - expect(page).to have_current_path new_user_session_path - expect(page).to have_content "You must sign in or register to continue" - end - include_examples "not published permissions", :legislation_process_proposals_path end