Maintenance: RSpec attachments simulating cleanup
This commit is contained in:
parent
6e42aeb1ee
commit
8671aea0b4
5 changed files with 24 additions and 44 deletions
|
@ -289,15 +289,4 @@ RSpec.describe 'Ticket Shared Drafts Start API endpoints', authenticated_as: :ag
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach(id:, object_name: 'UploadCache')
|
|
||||||
Store.add(
|
|
||||||
object: object_name,
|
|
||||||
o_id: id,
|
|
||||||
data: File.binread(Rails.root.join('test/data/image/1x1.png')),
|
|
||||||
filename: '1x1.png',
|
|
||||||
preferences: {},
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -222,15 +222,4 @@ RSpec.describe 'Ticket Shared Drafts Zoom API endpoints', authenticated_as: :age
|
||||||
put "/api/v1/tickets/#{ticket_id}", params: params, as: :json
|
put "/api/v1/tickets/#{ticket_id}", params: params, as: :json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach(id:, object_name: 'UploadCache')
|
|
||||||
Store.add(
|
|
||||||
object: object_name,
|
|
||||||
o_id: id,
|
|
||||||
data: File.binread(Rails.root.join('test/data/image/1x1.png')),
|
|
||||||
filename: '1x1.png',
|
|
||||||
preferences: {},
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
24
spec/support/store_helper.rb
Normal file
24
spec/support/store_helper.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||||
|
|
||||||
|
module ZammadStoreHelper
|
||||||
|
# Add attachment to Store
|
||||||
|
#
|
||||||
|
# @param id [Integer] ID of the owner object
|
||||||
|
# @param object_name [String] class name of the owner object
|
||||||
|
# @param filename [String] filename (including path) to file to use as a test.
|
||||||
|
#
|
||||||
|
def attach(id:, object_name: 'UploadCache', filename: 'test/data/image/1x1.png')
|
||||||
|
Store.add(
|
||||||
|
object: object_name,
|
||||||
|
o_id: id,
|
||||||
|
data: File.binread(Rails.root.join(filename)),
|
||||||
|
filename: Pathname.new(filename).basename,
|
||||||
|
preferences: {},
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.include ZammadStoreHelper
|
||||||
|
end
|
|
@ -249,15 +249,4 @@ RSpec.describe 'Ticket Shared Draft Start', type: :system, authenticated_as: :au
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach(id:, object_name: 'UploadCache')
|
|
||||||
Store.add(
|
|
||||||
object: object_name,
|
|
||||||
o_id: id,
|
|
||||||
data: File.binread(Rails.root.join('test/data/image/1x1.png')),
|
|
||||||
filename: '1x1.png',
|
|
||||||
preferences: {},
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -249,15 +249,4 @@ RSpec.describe 'Ticket Shared Draft Zoom', type: :system, authenticated_as: :aut
|
||||||
expect(page).to have_text('1x1.png')
|
expect(page).to have_text('1x1.png')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach(id:, object_name: 'UploadCache')
|
|
||||||
Store.add(
|
|
||||||
object: object_name,
|
|
||||||
o_id: id,
|
|
||||||
data: File.binread(Rails.root.join('test/data/image/1x1.png')),
|
|
||||||
filename: '1x1.png',
|
|
||||||
preferences: {},
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue