<% if current_user.blocks.exists? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index df3ae37f5..3055905ca 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -239,6 +239,38 @@ en:
entry:
comment: Comment
full: Full note
+ accounts:
+ edit:
+ title: "Edit account"
+ my settings: My Settings
+ current email address: "Current Email Address"
+ external auth: "External Authentication"
+ openid:
+ link: "https://wiki.openstreetmap.org/wiki/OpenID"
+ link text: "what is this?"
+ public editing:
+ heading: "Public editing"
+ enabled: "Enabled. Not anonymous and can edit data."
+ enabled link: "https://wiki.openstreetmap.org/wiki/Anonymous_edits"
+ enabled link text: "what is this?"
+ disabled: "Disabled and cannot edit data, all previous edits are anonymous."
+ disabled link text: "why can't I edit?"
+ public editing note:
+ heading: "Public editing"
+ html: "Currently your edits are anonymous and people cannot send you messages or see your location. To show what you edited and allow people to contact you through the website, click the button below. Since the 0.6 API changeover, only public users can edit map data. (find out why).
Your email address will not be revealed by becoming public.
This action cannot be reversed and all new users are now public by default.
"
+ contributor terms:
+ heading: "Contributor Terms"
+ agreed: "You have agreed to the new Contributor Terms."
+ not yet agreed: "You have not yet agreed to the new Contributor Terms."
+ review link text: "Please follow this link at your convenience to review and accept the new Contributor Terms."
+ agreed_with_pd: "You have also declared that you consider your edits to be in the Public Domain."
+ link: "https://www.osmfoundation.org/wiki/License/Contributor_Terms"
+ link text: "what is this?"
+ save changes button: Save Changes
+ make edits public button: Make all my edits public
+ update:
+ success_confirm_needed: "User information updated successfully. Check your email for a note to confirm your new email address."
+ success: "User information updated successfully."
browse:
created: "Created"
closed: "Closed"
@@ -2561,36 +2593,6 @@ en:
delete_user: "Delete this User"
confirm: "Confirm"
report: Report this User
- account:
- title: "Edit account"
- my settings: My Settings
- current email address: "Current Email Address"
- external auth: "External Authentication"
- openid:
- link: "https://wiki.openstreetmap.org/wiki/OpenID"
- link text: "what is this?"
- public editing:
- heading: "Public editing"
- enabled: "Enabled. Not anonymous and can edit data."
- enabled link: "https://wiki.openstreetmap.org/wiki/Anonymous_edits"
- enabled link text: "what is this?"
- disabled: "Disabled and cannot edit data, all previous edits are anonymous."
- disabled link text: "why can't I edit?"
- public editing note:
- heading: "Public editing"
- html: "Currently your edits are anonymous and people cannot send you messages or see your location. To show what you edited and allow people to contact you through the website, click the button below. Since the 0.6 API changeover, only public users can edit map data. (find out why).
Your email address will not be revealed by becoming public.
This action cannot be reversed and all new users are now public by default.
"
- contributor terms:
- heading: "Contributor Terms"
- agreed: "You have agreed to the new Contributor Terms."
- not yet agreed: "You have not yet agreed to the new Contributor Terms."
- review link text: "Please follow this link at your convenience to review and accept the new Contributor Terms."
- agreed_with_pd: "You have also declared that you consider your edits to be in the Public Domain."
- link: "https://www.osmfoundation.org/wiki/License/Contributor_Terms"
- link text: "what is this?"
- save changes button: Save Changes
- make edits public button: Make all my edits public
- flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address."
- flash update success: "User information updated successfully."
set_home:
flash success: "Home location saved successfully"
go_public:
diff --git a/config/routes.rb b/config/routes.rb
index f4c19f88c..2983fea55 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -237,9 +237,10 @@ OpenStreetMap::Application.routes.draw do
# user pages
resources :users, :path => "user", :param => :display_name, :only => [:show, :destroy]
- match "/user/:display_name/account" => "users#account", :via => [:get, :post], :as => "user_account"
+ get "/user/:display_name/account", :to => redirect(:path => "/account/edit")
post "/user/:display_name/set_status" => "users#set_status", :as => :set_status_user
+ resource :account, :only => [:edit, :update]
resource :dashboard, :only => [:show]
resource :preferences, :only => [:show, :edit, :update]
resource :profile, :only => [:edit, :update]
diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb
new file mode 100644
index 000000000..7e8cd7cc2
--- /dev/null
+++ b/test/controllers/accounts_controller_test.rb
@@ -0,0 +1,128 @@
+require "test_helper"
+
+class AccountsControllerTest < ActionDispatch::IntegrationTest
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/account/edit", :method => :get },
+ { :controller => "accounts", :action => "edit" }
+ )
+ assert_routing(
+ { :path => "/account", :method => :put },
+ { :controller => "accounts", :action => "update" }
+ )
+ end
+
+ def test_account
+ # Get a user to work with - note that this user deliberately
+ # conflicts with uppercase_user in the email and display name
+ # fields to test that we can change other fields without any
+ # validation errors being reported
+ user = create(:user, :languages => [])
+ _uppercase_user = build(:user, :email => user.email.upcase, :display_name => user.display_name.upcase).tap { |u| u.save(:validate => 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
+
+ # Updating the description using GET should fail
+ user.description = "new description"
+ user.preferred_editor = "default"
+ get edit_account_path, :params => { :user => user.attributes }
+ assert_response :success
+ assert_template :edit
+ assert_not_equal user.description, User.find(user.id).description
+
+ # Adding external authentication should redirect to the auth provider
+ put account_path, :params => { :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }
+ assert_response :redirect
+ assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/account")
+
+ # Changing name to one that exists should fail
+ new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name)
+ put account_path, :params => { :user => new_attributes }
+ assert_response :success
+ assert_template :edit
+ assert_select ".notice", false
+ assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name"
+
+ # Changing name to one that exists should fail, regardless of case
+ new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name.upcase)
+ put account_path, :params => { :user => new_attributes }
+ assert_response :success
+ assert_template :edit
+ assert_select ".notice", false
+ assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name"
+
+ # Changing name to one that doesn't exist should work
+ new_attributes = user.attributes.dup.merge(:display_name => "new tester")
+ put account_path, :params => { :user => new_attributes }
+ assert_response :redirect
+ assert_redirected_to edit_account_url
+ get edit_account_path
+ assert_response :success
+ assert_template :edit
+ assert_select ".notice", /^User information updated successfully/
+ assert_select "form#accountForm > div.form-group > input#user_display_name[value=?]", "new tester"
+
+ # Record the change of name
+ user.display_name = "new tester"
+
+ # Changing email to one that exists should fail
+ user.new_email = create(:user).email
+ assert_no_difference "ActionMailer::Base.deliveries.size" do
+ perform_enqueued_jobs do
+ put account_path, :params => { :user => user.attributes }
+ end
+ end
+ assert_response :success
+ assert_template :edit
+ assert_select ".notice", false
+ assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email"
+
+ # Changing email to one that exists should fail, regardless of case
+ user.new_email = create(:user).email.upcase
+ assert_no_difference "ActionMailer::Base.deliveries.size" do
+ perform_enqueued_jobs do
+ put account_path, :params => { :user => user.attributes }
+ end
+ end
+ assert_response :success
+ assert_template :edit
+ assert_select ".notice", false
+ assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email"
+
+ # Changing email to one that doesn't exist should work
+ user.new_email = "new_tester@example.com"
+ assert_difference "ActionMailer::Base.deliveries.size", 1 do
+ perform_enqueued_jobs do
+ put account_path, :params => { :user => user.attributes }
+ end
+ end
+ assert_response :redirect
+ assert_redirected_to edit_account_url
+ get edit_account_path
+ assert_response :success
+ assert_template :edit
+ assert_select ".notice", /^User information updated successfully/
+ assert_select "form#accountForm > div.form-group > input#user_new_email[value=?]", user.new_email
+ email = ActionMailer::Base.deliveries.first
+ assert_equal 1, email.to.count
+ assert_equal user.new_email, email.to.first
+ ActionMailer::Base.deliveries.clear
+ end
+end
diff --git a/test/controllers/confirmations_controller_test.rb b/test/controllers/confirmations_controller_test.rb
index f583e5e39..9c6e91afe 100644
--- a/test/controllers/confirmations_controller_test.rb
+++ b/test/controllers/confirmations_controller_test.rb
@@ -283,7 +283,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
post user_confirm_email_path, :params => { :confirm_string => confirm_string }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
assert_match(/Confirmed your change of email address/, flash[:notice])
end
@@ -293,7 +293,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
post user_confirm_email_path, :params => { :confirm_string => confirm_string }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
assert_match(/already been confirmed/, flash[:error])
end
@@ -317,7 +317,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_not user.image_use_gravatar
post user_confirm_email_path, :params => { :confirm_string => confirm_string }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
assert_match(/Confirmed your change of email address/, flash[:notice])
# gravatar use should now be enabled
assert User.find(user.id).image_use_gravatar
@@ -332,7 +332,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert user.image_use_gravatar
post user_confirm_email_path, :params => { :confirm_string => confirm_string }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
assert_match(/Confirmed your change of email address/, flash[:notice])
# gravatar use should now be disabled
assert_not User.find(user.id).image_use_gravatar
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
index 44b5471ac..0a9a82f1c 100644
--- a/test/controllers/users_controller_test.rb
+++ b/test/controllers/users_controller_test.rb
@@ -39,15 +39,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
{ :controller => "users", :action => "show", :display_name => "username" }
)
- assert_routing(
- { :path => "/user/username/account", :method => :get },
- { :controller => "users", :action => "account", :display_name => "username" }
- )
- assert_routing(
- { :path => "/user/username/account", :method => :post },
- { :controller => "users", :action => "account", :display_name => "username" }
- )
-
assert_routing(
{ :path => "/user/username/set_status", :method => :post },
{ :controller => "users", :action => "set_status", :display_name => "username" }
@@ -358,7 +349,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
get user_terms_path
assert_response :redirect
- assert_redirected_to :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
end
def test_terms_not_seen_without_referer
@@ -372,7 +363,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
post user_save_path, :params => { :user => { :consider_pd => true }, :read_ct => 1, :read_tou => 1 }
assert_response :redirect
- assert_redirected_to :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
user.reload
@@ -409,9 +400,9 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = create(:user, :terms_seen => false, :terms_agreed => nil)
session_for(user)
- get user_account_path(user)
+ get edit_account_path
assert_response :redirect
- assert_redirected_to :action => :terms, :referer => "/user/#{ERB::Util.u(user.display_name)}/account"
+ assert_redirected_to :controller => :users, :action => :terms, :referer => "/account/edit"
end
def test_terms_not_logged_in
@@ -427,127 +418,10 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
post user_go_public_path
assert_response :redirect
- assert_redirected_to :action => :account, :display_name => user.display_name
+ assert_redirected_to edit_account_path
assert User.find(user.id).data_public
end
- def test_account
- # Get a user to work with - note that this user deliberately
- # conflicts with uppercase_user in the email and display name
- # fields to test that we can change other fields without any
- # validation errors being reported
- user = create(:user, :languages => [])
- _uppercase_user = build(:user, :email => user.email.upcase, :display_name => user.display_name.upcase).tap { |u| u.save(:validate => false) }
-
- # Make sure that you are redirected to the login page when
- # you are not logged in
- get user_account_path(user)
- assert_response :redirect
- assert_redirected_to login_path(:referer => "/user/#{ERB::Util.u(user.display_name)}/account")
-
- # Make sure that you are blocked when not logged in as the right user
- session_for(create(:user))
- get user_account_path(user)
- assert_response :forbidden
-
- # Make sure we get the page when we are logged in as the right user
- session_for(user)
- get user_account_path(user)
- assert_response :success
- assert_template :account
- assert_select "form#accountForm" do |form|
- assert_equal "post", form.attr("method").to_s
- assert_select "input[name='_method']", false
- assert_equal "/user/#{ERB::Util.u(user.display_name)}/account", form.attr("action").to_s
- end
-
- # Updating the description using GET should fail
- user.description = "new description"
- user.preferred_editor = "default"
- get user_account_path(user), :params => { :user => user.attributes }
- assert_response :success
- assert_template :account
- assert_not_equal user.description, User.find(user.id).description
-
- # Adding external authentication should redirect to the auth provider
- post user_account_path(user), :params => { :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }
- assert_response :redirect
- assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{ERB::Util.u(user.display_name)}/account")
-
- # Changing name to one that exists should fail
- new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name)
- post user_account_path(user), :params => { :user => new_attributes }
- assert_response :success
- assert_template :account
- assert_select ".notice", false
- assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name"
-
- # Changing name to one that exists should fail, regardless of case
- new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name.upcase)
- post user_account_path(user), :params => { :user => new_attributes }
- assert_response :success
- assert_template :account
- assert_select ".notice", false
- assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name"
-
- # Changing name to one that doesn't exist should work
- new_attributes = user.attributes.dup.merge(:display_name => "new tester")
- post user_account_path(user), :params => { :user => new_attributes }
- assert_response :redirect
- assert_redirected_to user_account_url(:display_name => "new tester")
- get user_account_path(:display_name => "new tester")
- assert_response :success
- assert_template :account
- assert_select ".notice", /^User information updated successfully/
- assert_select "form#accountForm > div.form-group > input#user_display_name[value=?]", "new tester"
-
- # Record the change of name
- user.display_name = "new tester"
-
- # Changing email to one that exists should fail
- user.new_email = create(:user).email
- assert_no_difference "ActionMailer::Base.deliveries.size" do
- perform_enqueued_jobs do
- post user_account_path(user), :params => { :user => user.attributes }
- end
- end
- assert_response :success
- assert_template :account
- assert_select ".notice", false
- assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email"
-
- # Changing email to one that exists should fail, regardless of case
- user.new_email = create(:user).email.upcase
- assert_no_difference "ActionMailer::Base.deliveries.size" do
- perform_enqueued_jobs do
- post user_account_path(user), :params => { :user => user.attributes }
- end
- end
- assert_response :success
- assert_template :account
- assert_select ".notice", false
- assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email"
-
- # Changing email to one that doesn't exist should work
- user.new_email = "new_tester@example.com"
- assert_difference "ActionMailer::Base.deliveries.size", 1 do
- perform_enqueued_jobs do
- post user_account_path(user), :params => { :user => user.attributes }
- end
- end
- assert_response :redirect
- assert_redirected_to user_account_url(user)
- get user_account_path(user)
- assert_response :success
- assert_template :account
- assert_select ".notice", /^User information updated successfully/
- assert_select "form#accountForm > div.form-group > input#user_new_email[value=?]", user.new_email
- email = ActionMailer::Base.deliveries.first
- assert_equal 1, email.to.count
- assert_equal user.new_email, email.to.first
- ActionMailer::Base.deliveries.clear
- end
-
# Check that the user account page will display and contains some relevant
# information for the user
def test_show
@@ -617,7 +491,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "a[href='/traces/mine']", 1
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 1
+ assert_select "a[href='/account/edit']", 1
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
@@ -634,7 +508,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
+ assert_select "a[href='/account/edit']", 0
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1
diff --git a/test/integration/client_applications_test.rb b/test/integration/client_applications_test.rb
index 269d3633d..0ac15759e 100644
--- a/test/integration/client_applications_test.rb
+++ b/test/integration/client_applications_test.rb
@@ -17,9 +17,9 @@ class ClientApplicationsTest < ActionDispatch::IntegrationTest
follow_redirect!
assert_response :success
assert_template "users/show"
- get "/user/#{ERB::Util.u(user.display_name)}/account"
+ get "/account/edit"
assert_response :success
- assert_template "users/account"
+ assert_template "accounts/edit"
# check that the form to allow new client application creations exists
assert_in_heading do