Maintenance: Ensured HTTP request verbs according to REST paradigm.
This commit is contained in:
parent
f63577633f
commit
a7607f574e
12 changed files with 32 additions and 32 deletions
|
@ -74,7 +74,7 @@ class App.TicketMerge extends App.ControllerModal
|
|||
# merge tickets
|
||||
@ajax(
|
||||
id: 'ticket_merge'
|
||||
type: 'GET'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/ticket_merge/#{@ticket.id}/#{params.master_ticket_number}"
|
||||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
|
|
|
@ -60,9 +60,9 @@ class App.KnowledgeBaseSidebarLinkedTickets extends App.Controller
|
|||
# get data
|
||||
@ajax(
|
||||
id: "links_remove_#{@object.id}_#{@object_type}"
|
||||
type: 'GET'
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/links/remove"
|
||||
data: data
|
||||
data: JSON.stringify(data)
|
||||
processData: true
|
||||
success: @fetch
|
||||
)
|
||||
|
|
|
@ -82,9 +82,9 @@ class App.TicketLinkAdd extends App.ControllerModal
|
|||
# get data
|
||||
@ajax(
|
||||
id: "links_add_#{@object.id}_#{@object_type}"
|
||||
type: 'GET'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/links/add"
|
||||
data:
|
||||
data: JSON.stringify
|
||||
link_type: params['link_type']
|
||||
link_object_target: @link_object
|
||||
link_object_target_value: @object.id
|
||||
|
|
|
@ -52,9 +52,9 @@ class App.WidgetLink extends App.Controller
|
|||
# get data
|
||||
@ajax(
|
||||
id: "links_remove_#{@object.id}_#{@object_type}"
|
||||
type: 'GET'
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/links/remove"
|
||||
data:
|
||||
data: JSON.stringify
|
||||
link_type: link_type
|
||||
link_object_source: link_object_source
|
||||
link_object_source_value: link_object_source_value
|
||||
|
|
|
@ -83,9 +83,9 @@ class App.WidgetLinkKbAnswer extends App.WidgetLink
|
|||
saveToServer: (id) ->
|
||||
@ajax(
|
||||
id: "links_add_#{@object.id}_#{@object_type}"
|
||||
type: 'GET'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/links/add"
|
||||
data:
|
||||
data: JSON.stringify
|
||||
link_type: 'normal'
|
||||
link_object_target: 'Ticket'
|
||||
link_object_target_value: @object.id
|
||||
|
|
|
@ -802,9 +802,9 @@ set new attributes of model (remove already available attributes)
|
|||
|
||||
@tagGet: (id, key, callback) ->
|
||||
App.Ajax.request(
|
||||
id: key
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/tags"
|
||||
id: key
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/tags"
|
||||
data:
|
||||
object: @serverClassName || @className
|
||||
o_id: id
|
||||
|
@ -815,9 +815,9 @@ set new attributes of model (remove already available attributes)
|
|||
|
||||
@tagAdd: (id, item) ->
|
||||
App.Ajax.request(
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/tags/add"
|
||||
data:
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/tags/add"
|
||||
data: JSON.stringify
|
||||
object: @serverClassName || @className
|
||||
o_id: id
|
||||
item: item
|
||||
|
@ -826,9 +826,9 @@ set new attributes of model (remove already available attributes)
|
|||
|
||||
@tagRemove: (id, item) ->
|
||||
App.Ajax.request(
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/tags/remove"
|
||||
data:
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/tags/remove"
|
||||
data: JSON.stringify
|
||||
object: @serverClassName || @className
|
||||
o_id: id
|
||||
item: item
|
||||
|
|
|
@ -31,7 +31,7 @@ class TagsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
# POST /api/v1/tag/add
|
||||
# POST /api/v1/tags/add
|
||||
def add
|
||||
success = Tag.tag_add(
|
||||
object: params[:object],
|
||||
|
@ -45,7 +45,7 @@ class TagsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# DELETE /api/v1/tag/remove
|
||||
# DELETE /api/v1/tags/remove
|
||||
def remove
|
||||
success = Tag.tag_remove(
|
||||
object: params[:object],
|
||||
|
|
|
@ -372,7 +372,7 @@ class TicketsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
# GET /api/v1/ticket_merge/1/1
|
||||
# PUT /api/v1/ticket_merge/1/1
|
||||
def ticket_merge
|
||||
|
||||
# check master ticket
|
||||
|
|
|
@ -3,7 +3,7 @@ Zammad::Application.routes.draw do
|
|||
|
||||
# links
|
||||
match api_path + '/links', to: 'links#index', via: :get
|
||||
match api_path + '/links/add', to: 'links#add', via: :get
|
||||
match api_path + '/links/remove', to: 'links#remove', via: :get
|
||||
match api_path + '/links/add', to: 'links#add', via: :post
|
||||
match api_path + '/links/remove', to: 'links#remove', via: :delete
|
||||
|
||||
end
|
||||
|
|
|
@ -2,8 +2,8 @@ Zammad::Application.routes.draw do
|
|||
api_path = Rails.configuration.api_path
|
||||
|
||||
match api_path + '/tags', to: 'tags#list', via: :get
|
||||
match api_path + '/tags/add', to: 'tags#add', via: :get
|
||||
match api_path + '/tags/remove', to: 'tags#remove', via: :get
|
||||
match api_path + '/tags/add', to: 'tags#add', via: :post
|
||||
match api_path + '/tags/remove', to: 'tags#remove', via: :delete
|
||||
match api_path + '/tag_search', to: 'tags#search', via: :get
|
||||
|
||||
match api_path + '/tag_list', to: 'tags#admin_list', via: :get
|
||||
|
|
|
@ -15,7 +15,7 @@ Zammad::Application.routes.draw do
|
|||
match api_path + '/ticket_customer', to: 'tickets#ticket_customer', via: :get
|
||||
match api_path + '/ticket_related/:ticket_id', to: 'tickets#ticket_related', via: :get
|
||||
match api_path + '/ticket_recent', to: 'tickets#ticket_recent', via: :get
|
||||
match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', to: 'tickets#ticket_merge', via: :get
|
||||
match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', to: 'tickets#ticket_merge', via: :put
|
||||
match api_path + '/ticket_stats', to: 'tickets#stats', via: :get
|
||||
|
||||
# ticket overviews
|
||||
|
|
|
@ -1923,29 +1923,29 @@ RSpec.describe 'Ticket', type: :request do
|
|||
)
|
||||
|
||||
authenticated_as(customer)
|
||||
get "/api/v1/ticket_merge/#{ticket2.id}/#{ticket1.id}", params: {}, as: :json
|
||||
put "/api/v1/ticket_merge/#{ticket2.id}/#{ticket1.id}", params: {}, as: :json
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
|
||||
authenticated_as(agent)
|
||||
get "/api/v1/ticket_merge/#{ticket2.id}/#{ticket1.id}", params: {}, as: :json
|
||||
put "/api/v1/ticket_merge/#{ticket2.id}/#{ticket1.id}", params: {}, as: :json
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json_response).to be_a_kind_of(Hash)
|
||||
expect(json_response['result']).to eq('failed')
|
||||
expect(json_response['message']).to eq('No such master ticket number!')
|
||||
|
||||
get "/api/v1/ticket_merge/#{ticket3.id}/#{ticket1.number}", params: {}, as: :json
|
||||
put "/api/v1/ticket_merge/#{ticket3.id}/#{ticket1.number}", params: {}, as: :json
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
expect(json_response).to be_a_kind_of(Hash)
|
||||
expect(json_response['error']).to eq('Not authorized')
|
||||
expect(json_response['error_human']).to eq('Not authorized')
|
||||
|
||||
get "/api/v1/ticket_merge/#{ticket1.id}/#{ticket3.number}", params: {}, as: :json
|
||||
put "/api/v1/ticket_merge/#{ticket1.id}/#{ticket3.number}", params: {}, as: :json
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
expect(json_response).to be_a_kind_of(Hash)
|
||||
expect(json_response['error']).to eq('Not authorized')
|
||||
expect(json_response['error_human']).to eq('Not authorized')
|
||||
|
||||
get "/api/v1/ticket_merge/#{ticket1.id}/#{ticket2.number}", params: {}, as: :json
|
||||
put "/api/v1/ticket_merge/#{ticket1.id}/#{ticket2.number}", params: {}, as: :json
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json_response).to be_a_kind_of(Hash)
|
||||
expect(json_response['result']).to eq('success')
|
||||
|
@ -1975,7 +1975,7 @@ RSpec.describe 'Ticket', type: :request do
|
|||
agent.group_names_access_map = { group_change_permission.name => %w[read change] }
|
||||
|
||||
authenticated_as(agent)
|
||||
get "/api/v1/ticket_merge/#{ticket1.id}/#{ticket2.number}", params: {}, as: :json
|
||||
put "/api/v1/ticket_merge/#{ticket1.id}/#{ticket2.number}", params: {}, as: :json
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json_response).to be_a_kind_of(Hash)
|
||||
expect(json_response['result']).to eq('success')
|
||||
|
|
Loading…
Reference in a new issue