Add Null email driver (support workaround for #224)

This commit is contained in:
Ryan Lue 2019-01-15 14:11:57 +01:00 committed by Thorsten Eckel
parent 7006d573b4
commit 043a0af9f2
4 changed files with 59 additions and 2 deletions

View file

@ -46,7 +46,9 @@
<div class="action-block action-block--flex"> <div class="action-block action-block--flex">
<div class="horizontal"> <div class="horizontal">
<h3><%- @Icon('status', channel.status_in + " inline") %> <%- @T('Inbound') %></h3> <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> <div class="js-editInbound btn btn--text space-left"><%- @T('Edit') %></div>
<% end %>
</div> </div>
<table class="key-value"> <table class="key-value">
<tr> <tr>
@ -89,7 +91,9 @@
<div class="action-block action-block--flex"> <div class="action-block action-block--flex">
<div class="horizontal"> <div class="horizontal">
<h3><%- @Icon('status', channel.status_out + " inline") %> <%- @T('Outbound') %></h3> <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> <div class="js-editOutbound btn btn--text space-left"><%- @T('Edit') %></div>
<% end %>
</div> </div>
<table class="key-value"> <table class="key-value">
<% if channel.options.outbound && channel.options.outbound.options: %> <% if channel.options.outbound && channel.options.outbound.options: %>

View 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

View file

@ -8,6 +8,20 @@ FactoryBot.define do
updated_by_id 1 updated_by_id 1
created_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 factory :twitter_channel do
transient do transient do
custom_options { {} } custom_options { {} }

View 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