0002-changes-my-account-html-form-to-put.patch

Jens Krämer, 2019-06-11 08:55

Download (3.02 KB)

View differences:

app/controllers/my_controller.rb
51 51
  def account
52 52
    @user = User.current
53 53
    @pref = @user.pref
54
    if request.post? || request.put?
54
    if request.put?
55 55
      @user.safe_attributes = params[:user]
56 56
      @user.pref.safe_attributes = params[:pref]
57 57
      if @user.save
app/views/my/account.html.erb
14 14
<%= labelled_form_for :user, @user,
15 15
                     :url => { :action => "account" },
16 16
                     :html => { :id => 'my_account_form',
17
                                :method => :post, :multipart => true } do |f| %>
17
                                :method => :put, :multipart => true } do |f| %>
18 18
<div class="splitcontent">
19 19
<div class="splitcontentleft">
20 20
<fieldset class="box tabular">
config/routes.rb
71 71
  match '/imports/:id/mapping', :to => 'imports#mapping', :via => [:get, :post], :as => 'import_mapping'
72 72
  match '/imports/:id/run', :to => 'imports#run', :via => [:get, :post], :as => 'import_run'
73 73

  
74
  match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post, :put]
74
  match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :put]
75 75
  match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
76 76
  match 'my/page', :controller => 'my', :action => 'page', :via => :get
77 77
  post 'my/page', :to => 'my#update_page'
test/functional/my_controller_test.rb
354 354
  end
355 355

  
356 356
  def test_update_account
357
    post :account, :params => {
357
    put :account, :params => {
358 358
        :user => {
359 359
          :firstname => "Joe",
360 360
          :login => "root",
......
379 379

  
380 380
  def test_update_account_should_send_security_notification
381 381
    ActionMailer::Base.deliveries.clear
382
    post :account, :params => {
382
    put :account, :params => {
383 383
        :user => {
384 384
          :mail => 'foobar@example.com'
385 385

  
386
-