Fix route for "go public" button on the account edit page

This commit is contained in:
Tom Hughes 2022-01-28 12:35:57 +00:00
parent a26100c7ec
commit 81c58571c5
2 changed files with 25 additions and 1 deletions

View file

@ -61,5 +61,5 @@
<a name="public"></a>
<h2><%= t ".public editing note.heading" %></h2>
<%= 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 %>

View file

@ -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