zammad/spec/requests/channel_admin/base_examples.rb
Mantas Masalskis 1615e3c995 Maintenance: Improve configuration details returned by the server.
Co-authored-by: Dusan Vuckovic <dv@zammad.com>
Co-authored-by: Florian Liebe <fl@zammad.com>
Co-authored-by: Mantas Masalskis <mm@zammad.com>
Co-authored-by: Marcel Bialas <mb@zammad.com>
Co-authored-by: Martin Gruner <mg@zammad.com>
2026-03-04 08:07:54 +01:00

56 lines
1.5 KiB
Ruby

# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
RSpec.shared_examples 'base channel management' do |factory:, path:|
describe "GET /api/v1/channels_admin/#{path}" do
let(:channel) { create(factory) }
before { channel }
it 'lists channels', aggregate_failures: true do
get "/api/v1/channels/admin/#{path}", as: :json
expect(json_response).to include(
'channel_ids' => [channel.id],
'assets' => be_present
)
expect(response.body).to include(SensitiveParamsHelper::SENSITIVE_MASK)
end
end
describe "GET /api/v1/channels_admin/#{path}/ID/enable" do
let(:channel) { create(factory, active: false) }
before { channel }
it 'enables channel' do
expect { post "/api/v1/channels/admin/#{path}/#{channel.id}/enable", as: :json }
.to change { channel.reload.active }
.to true
end
end
describe "GET /api/v1/channels_admin/#{path}/ID/disable" do
let(:channel) { create(factory, active: true) }
before { channel }
it 'disables channel' do
expect { post "/api/v1/channels/admin/#{path}/#{channel.id}/disable", as: :json }
.to change { channel.reload.active }
.to false
end
end
describe "GET /api/v1/channels_admin/#{path}/ID/destroy" do
let(:channel) { create(factory, active: true) }
before { channel }
it 'deletes channel' do
expect { delete "/api/v1/channels/admin/#{path}/#{channel.id}", as: :json }
.to change { Channel.exists? channel.id }
.to false
end
end
end