Browse Source

Always use POST for dry_run

Akinori MUSHA 9 years ago
parent
commit
8eaaff410a

+ 1 - 1
app/assets/javascripts/components/utils.js.coffee

@@ -34,7 +34,7 @@ class @Utils
     body?(modal.querySelector('.modal-body'))
     $(modal).modal('show')
 
-  @handleDryRunButton: (button, data = $(button.form).serialize()) ->
+  @handleDryRunButton: (button, data = if button.form then $(':input[name!="_method"]', button.form).serialize() else '') ->
     $(button).prop('disabled', true)
     $('body').css(cursor: 'progress')
     $.ajax type: 'POST', url: $(button).data('action-url'), dataType: 'json', data: data

+ 1 - 1
app/controllers/agents_controller.rb

@@ -37,7 +37,7 @@ class AgentsController < ApplicationController
   def dry_run
     attrs = params[:agent] || {}
     if agent = current_user.agents.find_by(id: params[:id])
-      # PUT /agents/:id/dry_run
+      # POST /agents/:id/dry_run
       if attrs.present?
         type = agent.type
         agent = Agent.build_for_type(type, current_user, attrs)

+ 1 - 1
app/views/agents/_action_menu.html.erb

@@ -7,7 +7,7 @@
 
   <% if agent.can_dry_run? %>
     <li>
-      <%= link_to icon_tag('glyphicon-refresh') + ' Dry Run', '#', 'data-action-url' => dry_run_agent_path(agent), tabindex: "-1", onclick: "Utils.handleDryRunButton(this, '_method=PUT')" %>
+      <%= link_to icon_tag('glyphicon-refresh') + ' Dry Run', '#', 'data-action-url' => dry_run_agent_path(agent), tabindex: "-1", onclick: "Utils.handleDryRunButton(this)" %>
     </li>
   <% end %>
 

+ 1 - 1
config/routes.rb

@@ -2,7 +2,7 @@ Huginn::Application.routes.draw do
   resources :agents do
     member do
       post :run
-      put :dry_run
+      post :dry_run
       post :handle_details_post
       put :leave_scenario
       delete :remove_events