From: Tom Hughes Date: Fri, 28 Jan 2022 12:35:57 +0000 (+0000) Subject: Fix route for "go public" button on the account edit page X-Git-Tag: live~1242 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/81c58571c5b9170e8b82ab0ef78aa8970da0e676 Fix route for "go public" button on the account edit page --- diff --git a/app/views/accounts/edit.html.erb b/app/views/accounts/edit.html.erb index ba809d16a..0dcab17b0 100644 --- a/app/views/accounts/edit.html.erb +++ b/app/views/accounts/edit.html.erb @@ -61,5 +61,5 @@

<%= t ".public editing note.heading" %>

<%= t ".public editing note.html" %> - <%= button_to t(".make edits public button"), :action => :go_public %> + <%= button_to t(".make edits public button"), user_go_public_path %> <% end %> diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb index 27e05379c..173bcf22c 100644 --- a/test/controllers/accounts_controller_test.rb +++ b/test/controllers/accounts_controller_test.rb @@ -128,4 +128,28 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_equal user.new_email, email.to.first ActionMailer::Base.deliveries.clear end + + def test_private_account + user = create(:user, :data_public => false) + + # Make sure that you are redirected to the login page when + # you are not logged in + get edit_account_path + assert_response :redirect + assert_redirected_to login_path(:referer => "/account/edit") + + # Make sure we get the page when we are logged in as the right user + session_for(user) + get edit_account_path + assert_response :success + assert_template :edit + assert_select "form#accountForm" do |form| + assert_equal "post", form.attr("method").to_s + assert_select "input[name='_method']", true + assert_equal "/account", form.attr("action").to_s + end + + # Make sure we have a button to "go public" + assert_select "form.button_to[action='/user/go_public']", true + end end