Patch #31399 » 0002-changes-my-account-html-form-to-put.patch
| app/controllers/my_controller.rb | ||
|---|---|---|
|
def account
|
||
|
@user = User.current
|
||
|
@pref = @user.pref
|
||
|
if request.post? || request.put?
|
||
|
if request.put?
|
||
|
@user.safe_attributes = params[:user]
|
||
|
@user.pref.safe_attributes = params[:pref]
|
||
|
if @user.save
|
||
| app/views/my/account.html.erb | ||
|---|---|---|
|
<%= labelled_form_for :user, @user,
|
||
|
:url => { :action => "account" },
|
||
|
:html => { :id => 'my_account_form',
|
||
|
:method => :post, :multipart => true } do |f| %>
|
||
|
:method => :put, :multipart => true } do |f| %>
|
||
|
<div class="splitcontent">
|
||
|
<div class="splitcontentleft">
|
||
|
<fieldset class="box tabular">
|
||
| config/routes.rb | ||
|---|---|---|
|
match '/imports/:id/mapping', :to => 'imports#mapping', :via => [:get, :post], :as => 'import_mapping'
|
||
|
match '/imports/:id/run', :to => 'imports#run', :via => [:get, :post], :as => 'import_run'
|
||
|
match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post, :put]
|
||
|
match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :put]
|
||
|
match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
|
||
|
match 'my/page', :controller => 'my', :action => 'page', :via => :get
|
||
|
post 'my/page', :to => 'my#update_page'
|
||
| test/functional/my_controller_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_update_account
|
||
|
post :account, :params => {
|
||
|
put :account, :params => {
|
||
|
:user => {
|
||
|
:firstname => "Joe",
|
||
|
:login => "root",
|
||
| ... | ... | |
|
def test_update_account_should_send_security_notification
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
post :account, :params => {
|
||
|
put :account, :params => {
|
||
|
:user => {
|
||
|
:mail => 'foobar@example.com'
|
||