Authorize resource after authenticating user

Just like it's done everywhere else in the application. Not doing so
means users who aren't logged in receive a "you aren't authorized"
message when they try to create a new legislation proposal instead of
being redirected to the login page.
This commit is contained in:
Javi Martín
2018-09-21 21:04:36 +02:00
parent 8064b53aad
commit ec18743251
2 changed files with 13 additions and 3 deletions

View File

@@ -255,6 +255,16 @@ feature '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
end