Fixes #3842 - Removing tags from tickets return HTTP 201
This commit is contained in:
parent
1d2549b41f
commit
92cd364ec2
2 changed files with 33 additions and 5 deletions
|
@ -53,7 +53,7 @@ class TagsController < ApplicationController
|
|||
item: params[:item],
|
||||
)
|
||||
if success
|
||||
render json: success, status: :created
|
||||
render json: success
|
||||
else
|
||||
render json: success.errors, status: :unprocessable_entity
|
||||
end
|
||||
|
|
|
@ -4,15 +4,43 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe Tag, type: :request do
|
||||
|
||||
describe 'request handling' do
|
||||
describe 'request handling', authenticated_as: :agent do
|
||||
|
||||
let(:agent) { create(:agent) }
|
||||
|
||||
context 'tag search' do
|
||||
before do
|
||||
authenticated_as(agent)
|
||||
context 'tag adding' do
|
||||
it 'returns created' do
|
||||
post '/api/v1/tags/add', params: { object: 'Foo', item: 'bar', o_id: 1 }
|
||||
|
||||
expect(response).to have_http_status(:created)
|
||||
end
|
||||
|
||||
it 'deletes tag' do
|
||||
post '/api/v1/tags/add', params: { object: 'Foo', item: 'bar', o_id: 1 }
|
||||
|
||||
expect(described_class.tag_list({ object: 'Foo', item: 'bar', o_id: 1 })).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'tag removal', authenticated_as: :agent do
|
||||
before do
|
||||
described_class.tag_add(object: 'Foo', item: 'bar', o_id: 1, created_by_id: 1)
|
||||
end
|
||||
|
||||
it 'returns ok' do
|
||||
delete '/api/v1/tags/remove', params: { object: 'Foo', item: 'bar', o_id: 1 }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
it 'deletes tag' do
|
||||
delete '/api/v1/tags/remove', params: { object: 'Foo', item: 'bar', o_id: 1 }
|
||||
|
||||
expect(described_class.tag_list({ object: 'Foo', item: 'bar', o_id: 1 })).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'tag search' do
|
||||
let!(:tags) do
|
||||
[
|
||||
Tag::Item.lookup_by_name_and_create('foobar'),
|
||||
|
|
Loading…
Reference in a new issue