+<% end %>
\ No newline at end of file
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 3ce8a35ac..3635bfbbb 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -15,7 +15,19 @@
You must <%= link_to "upgrade your account", upgrade_information_users_path %> to request a name change
<% end %>
- <%= f.input :email, :required => Danbooru.config.enable_email_verification?, :hint => "Used for messages and for password resets", :as => :email %>
+
+
+
+
+ <% if CurrentUser.user.email.present? %>
+ <%= CurrentUser.user.email %>
+ <% else %>
+ blank
+ <% end %>
+ –
+ <%= link_to "Change your email", new_maintenance_user_email_change_path %>
+
+
<%= f.input :time_zone, :include_blank => false %>
<%= f.input :receive_email_notifications, :as => :select, :include_blank => false %>
<%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %>
@@ -52,7 +64,7 @@
diff --git a/config/routes.rb b/config/routes.rb
index f132fd5ed..f59b353f3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -48,6 +48,7 @@ Danbooru::Application.routes.draw do
resource :password_reset, :only => [:new, :create, :edit, :update]
resource :login_reminder, :only => [:new, :create]
resource :deletion, :only => [:show, :destroy]
+ resource :email_change, :only => [:new, :create]
end
end
diff --git a/test/functional/maintenance/user/email_changes_controller_test.rb b/test/functional/maintenance/user/email_changes_controller_test.rb
new file mode 100644
index 000000000..bb5f6c0b6
--- /dev/null
+++ b/test/functional/maintenance/user/email_changes_controller_test.rb
@@ -0,0 +1,42 @@
+require "test_helper"
+
+module Maintenance
+ module User
+ class EmailChangesControllerTest < ActionController::TestCase
+ context "in all cases" do
+ setup do
+ @user = FactoryGirl.create(:user, :email => "bob@ogres.net")
+ CurrentUser.user = @user
+ CurrentUser.ip_addr = "127.0.0.1"
+ end
+
+ context "#new" do
+ should "render" do
+ get :new, {}, {:user_id => @user.id}
+ assert_response :success
+ end
+ end
+
+ context "#create" do
+ context "with the correct password" do
+ should "work" do
+ post :create, {:email_change => {:password => "password", :email => "abc@ogres.net"}}, {:user_id => @user.id}
+ assert_redirected_to(edit_user_path(@user))
+ @user.reload
+ assert_equal("abc@ogres.net", @user.email)
+ end
+ end
+
+ context "with the incorrect password" do
+ should "not work" do
+ post :create, {:email_change => {:password => "passwordx", :email => "abc@ogres.net"}}, {:user_id => @user.id}
+ assert_response :success
+ @user.reload
+ assert_equal("bob@ogres.net", @user.email)
+ end
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file