Add Null email driver (support workaround for #224)
This commit is contained in:
parent
7006d573b4
commit
043a0af9f2
4 changed files with 59 additions and 2 deletions
|
@ -46,7 +46,9 @@
|
|||
<div class="action-block action-block--flex">
|
||||
<div class="horizontal">
|
||||
<h3><%- @Icon('status', channel.status_in + " inline") %> <%- @T('Inbound') %></h3>
|
||||
<% if channel.preferences.editable isnt false: %>
|
||||
<div class="js-editInbound btn btn--text space-left"><%- @T('Edit') %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<table class="key-value">
|
||||
<tr>
|
||||
|
@ -89,7 +91,9 @@
|
|||
<div class="action-block action-block--flex">
|
||||
<div class="horizontal">
|
||||
<h3><%- @Icon('status', channel.status_out + " inline") %> <%- @T('Outbound') %></h3>
|
||||
<% if channel.preferences.editable isnt false: %>
|
||||
<div class="js-editOutbound btn btn--text space-left"><%- @T('Edit') %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<table class="key-value">
|
||||
<% if channel.options.outbound && channel.options.outbound.options: %>
|
||||
|
|
22
app/models/channel/driver/null.rb
Normal file
22
app/models/channel/driver/null.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||
class Channel::Driver::Null
|
||||
def fetchable?(_channel)
|
||||
false
|
||||
end
|
||||
|
||||
def fetch(*)
|
||||
{
|
||||
result: 'ok',
|
||||
fetched: 0,
|
||||
notice: '',
|
||||
}
|
||||
end
|
||||
|
||||
def disconnect
|
||||
true
|
||||
end
|
||||
|
||||
def self.streamable?
|
||||
false
|
||||
end
|
||||
end
|
|
@ -8,6 +8,20 @@ FactoryBot.define do
|
|||
updated_by_id 1
|
||||
created_by_id 1
|
||||
|
||||
factory :email_channel do
|
||||
area 'Email::Account'
|
||||
options do
|
||||
{
|
||||
inbound: {
|
||||
adapter: 'null', options: {}
|
||||
},
|
||||
outbound: {
|
||||
adapter: 'sendmail'
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
factory :twitter_channel do
|
||||
transient do
|
||||
custom_options { {} }
|
||||
|
|
17
spec/system/admin/channel/email_spec.rb
Normal file
17
spec/system/admin/channel/email_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Panel > Channels > Email', type: :system, authenticated: true do
|
||||
# https://github.com/zammad/zammad/issues/224
|
||||
it 'hides "Edit" links when Channel#preferences[:editable] == false' do
|
||||
# ensure that the only existing email channel
|
||||
# has preferences == { editable: false }
|
||||
Channel.destroy_all
|
||||
create(:email_channel, preferences: { editable: false })
|
||||
|
||||
visit '/#channels/email'
|
||||
expect(page).to have_css('#c-account h3', text: 'Inbound') # Wait for frontend to load
|
||||
expect(page).to have_css('#c-account h3', text: 'Outbound') # Wait for frontend to load
|
||||
|
||||
expect(page).not_to have_css('.js-editInbound, .js-editOutbound', text: 'Edit')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue