summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2017-11-13 04:44:41 -0800
committerazul <azul@riseup.net>2017-11-13 04:44:41 -0800
commitf250a11b4fd98bb9f4ef50c501b72f5ae2a97d1d (patch)
treee73c759f133da8bddd68ed8bd8168b1919f67989
parenta20a1c1671d3833c7f26b678f3e476b26126c8ca (diff)
parent028376fe1ea7638f0119ba9614629f66453d206f (diff)
Merge branch 'fix/8796-alternate-email' into 'master'
fix: alternate email dialogue Closes #8796 See merge request leap/webapp!53
-rw-r--r--app/controllers/users_controller.rb8
-rw-r--r--app/views/users/_edit.html.haml3
-rw-r--r--test/integration/browser/alternate_email_test.rb25
3 files changed, 34 insertions, 2 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index da82d1c..b4c98a0 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -31,6 +31,12 @@ class UsersController < ApplicationController
def edit
end
+ def update
+ @user.update_attributes user_params
+ flash[:notice] = I18n.t(:changes_saved) if @user.valid?
+ respond_with @user, location: edit_user_path(@user)
+ end
+
def deactivate
@user.account.disable
flash[:notice] = I18n.t("actions.user_disabled_message", username: @user.username)
@@ -62,7 +68,7 @@ class UsersController < ApplicationController
if admin?
params.require(:user).permit(:effective_service_level)
else
- params.require(:user).permit(:password, :password_confirmation)
+ params.require(:user).permit(:contact_email)
end
end
diff --git a/app/views/users/_edit.html.haml b/app/views/users/_edit.html.haml
index 1d2b68a..8662979 100644
--- a/app/views/users/_edit.html.haml
+++ b/app/views/users/_edit.html.haml
@@ -2,12 +2,13 @@
-# edit user form, used by both show and edit actions.
-#
-# We render a bunch of forms here. Which we use depends upon config settings
--# user_actions and admin_actions. They both include an array of actions
+-# user_actions and admin_actions. They both include an array of actions
-# allowed to users and admins.
-# Possible forms are:
-# 'change_password'
-# 'change_pgp_key'
-# 'change_service_level'
+-# 'contact_email'
-# 'destroy_account'
- actions = APP_CONFIG[admin? ? :admin_actions : :user_actions] || []
- actions.each do |action|
diff --git a/test/integration/browser/alternate_email_test.rb b/test/integration/browser/alternate_email_test.rb
new file mode 100644
index 0000000..fc58fb4
--- /dev/null
+++ b/test/integration/browser/alternate_email_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+
+class AlternateEmailTest < BrowserIntegrationTest
+ test "change alternate email" do
+ username, password = submit_signup
+ click_on 'Account Settings'
+ within(".edit_user") do
+ fill_in 'user_contact_email', with: 'test@leap.se'
+ click_on 'Save'
+ end
+ assert page.has_content?('Changes saved successfully')
+ assert_equal 'test@leap.se',
+ page.find('#user_contact_email').value
+ end
+
+ test "change alternate email to invalid" do
+ username, password = submit_signup
+ click_on 'Account Settings'
+ within(".edit_user") do
+ fill_in 'user_contact_email', with: 'test@invalid'
+ click_on 'Save'
+ assert page.has_content?('is invalid')
+ end
+ end
+end