Maintenance: Bump rubocop-rspec from 2.4.0 to 2.5.0

This commit is contained in:
Martin Gruner 2021-09-22 08:53:16 +02:00
parent afd8557427
commit 183f89f810
21 changed files with 89 additions and 87 deletions

View file

@ -520,9 +520,8 @@ GEM
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0) rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.4.0) rubocop-rspec (2.5.0)
rubocop (~> 1.0) rubocop (~> 1.19)
rubocop-ast (>= 1.1.0)
ruby-progressbar (1.11.0) ruby-progressbar (1.11.0)
ruby-saml (1.12.2) ruby-saml (1.12.2)
nokogiri (>= 1.10.5) nokogiri (>= 1.10.5)
@ -613,7 +612,7 @@ GEM
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.7) unf_ext (0.0.7.7)
unicode-display_width (2.0.0) unicode-display_width (2.1.0)
unicorn (6.0.0) unicorn (6.0.0)
kgio (~> 2.6) kgio (~> 2.6)
raindrops (~> 0.7) raindrops (~> 0.7)

View file

@ -17,7 +17,7 @@ RSpec.describe Issue3446Microsoft365Tenants, type: :db_migration do
.to('app_tenant') .to('app_tenant')
end end
it 'changes form fields count from 2 to 3 ' do it 'changes form fields count from 2 to 3' do
expect { migrate } expect { migrate }
.to change { setting.reload.options['form'].count } .to change { setting.reload.options['form'].count }
.from(2) .from(2)

View file

@ -120,7 +120,7 @@ RSpec.describe HasActiveJobLock, type: :job do
end end
end end
context "when ActiveRecord::SerializationFailure 'PG::TRSerializationFailure: ERROR: could not serialize access due to concurrent update' is raised" do context "when ActiveRecord::SerializationFailure 'PG::TRSerializationFailure: ERROR: could not serialize access due to concurrent update' is raised" do
it 'retries execution until succeed' do it 'retries execution until succeed' do
allow(ActiveRecord::Base.connection).to receive(:open_transactions).and_return(0) allow(ActiveRecord::Base.connection).to receive(:open_transactions).and_return(0)

View file

@ -1492,7 +1492,7 @@ RSpec.describe String do
TEXT TEXT
end end
it 'places marker before quoted replys "Von:" header (as <p> with parent <div>)' do it 'places marker before quoted replys "Von:" header (as <p> with parent <div>)' do
expect(<<~HTML.chomp.html2html_strict).to eq(<<~TEXT.chomp) expect(<<~HTML.chomp.html2html_strict).to eq(<<~TEXT.chomp)
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"> <div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b><span style="font-family:Calibri;color:black">Von: <p class="MsoNormal" style="margin-left:35.4pt"><b><span style="font-family:Calibri;color:black">Von:
@ -1872,32 +1872,32 @@ RSpec.describe String do
describe '#utf8_encode' do describe '#utf8_encode' do
context 'on valid, UTF-8-encoded strings' do context 'on valid, UTF-8-encoded strings' do
let(:subject) { 'hello' } subject(:string) { 'hello' }
it 'returns an identical copy' do it 'returns an identical copy' do
expect(subject.utf8_encode).to eq(subject) expect(string.utf8_encode).to eq(string)
expect(subject.utf8_encode.encoding).to be(subject.encoding) expect(string.utf8_encode.encoding).to be(string.encoding)
expect(subject.utf8_encode).not_to be(subject) expect(string.utf8_encode).not_to be(string)
end end
context 'which are incorrectly set to other, technically valid encodings' do context 'which are incorrectly set to other, technically valid encodings' do
let(:subject) { described_class.new('ö', encoding: 'tis-620') } subject(:string) { described_class.new('ö', encoding: 'tis-620') }
it 'sets input encoding to UTF-8 instead of attempting conversion' do it 'sets input encoding to UTF-8 instead of attempting conversion' do
expect(subject.utf8_encode).to eq(subject.dup.force_encoding('utf-8')) expect(string.utf8_encode).to eq(string.dup.force_encoding('utf-8'))
end end
end end
end end
context 'on strings in other encodings' do context 'on strings in other encodings' do
let(:subject) { original_string.encode(input_encoding) } subject(:string) { original_string.encode(input_encoding) }
context 'with no from: option' do context 'with no from: option' do
let(:original_string) { 'Tschüss!' } let(:original_string) { 'Tschüss!' }
let(:input_encoding) { Encoding::ISO_8859_2 } let(:input_encoding) { Encoding::ISO_8859_2 }
it 'detects the input encoding' do it 'detects the input encoding' do
expect(subject.utf8_encode).to eq(original_string) expect(string.utf8_encode).to eq(original_string)
end end
end end
@ -1906,11 +1906,11 @@ RSpec.describe String do
let(:input_encoding) { Encoding::ISO_8859_2 } let(:input_encoding) { Encoding::ISO_8859_2 }
it 'uses the specified input encoding' do it 'uses the specified input encoding' do
expect(subject.utf8_encode(from: 'iso-8859-2')).to eq(original_string) expect(string.utf8_encode(from: 'iso-8859-2')).to eq(original_string)
end end
it 'uses any valid input encoding, even if not correct' do it 'uses any valid input encoding, even if not correct' do
expect(subject.utf8_encode(from: 'gb18030')).to eq('Tsch黶s!') expect(string.utf8_encode(from: 'gb18030')).to eq('Tsch黶s!')
end end
end end
@ -1919,21 +1919,21 @@ RSpec.describe String do
let(:input_encoding) { Encoding::GB18030 } let(:input_encoding) { Encoding::GB18030 }
it 'does not try it' do it 'does not try it' do
expect { subject.encode('utf-8', 'gb2312') } expect { string.encode('utf-8', 'gb2312') }
.to raise_error(Encoding::InvalidByteSequenceError) .to raise_error(Encoding::InvalidByteSequenceError)
expect { subject.utf8_encode(from: 'gb2312') } expect { string.utf8_encode(from: 'gb2312') }
.not_to raise_error .not_to raise_error
end end
it 'uses the detected input encoding instead' do it 'uses the detected input encoding instead' do
expect(subject.utf8_encode(from: 'gb2312')).to eq(original_string) expect(string.utf8_encode(from: 'gb2312')).to eq(original_string)
end end
end end
end end
context 'performance' do context 'performance' do
let(:subject) { original_string.encode(input_encoding) } subject(:string) { original_string.encode(input_encoding) }
context 'with utf8_encode in iso-8859-1' do context 'with utf8_encode in iso-8859-1' do
let(:original_string) { 'äöü0' * 999_999 } let(:original_string) { 'äöü0' * 999_999 }
@ -1941,7 +1941,7 @@ RSpec.describe String do
it 'detects the input encoding' do it 'detects the input encoding' do
Timeout.timeout(1) do Timeout.timeout(1) do
expect(subject.utf8_encode(from: 'iso-8859-1')).to eq(original_string) expect(string.utf8_encode(from: 'iso-8859-1')).to eq(original_string)
end end
end end
end end
@ -1952,7 +1952,7 @@ RSpec.describe String do
it 'detects the input encoding' do it 'detects the input encoding' do
Timeout.timeout(1) do Timeout.timeout(1) do
expect(subject.utf8_encode(from: 'utf-8')).to eq(original_string) expect(string.utf8_encode(from: 'utf-8')).to eq(original_string)
end end
end end
end end
@ -1963,7 +1963,7 @@ RSpec.describe String do
it 'detects the input encoding' do it 'detects the input encoding' do
Timeout.timeout(18) do Timeout.timeout(18) do
expect(subject.utf8_encode(from: 'utf-8')).to eq(original_string) expect(string.utf8_encode(from: 'utf-8')).to eq(original_string)
end end
end end
end end

View file

@ -7,7 +7,8 @@ RSpec.describe Import::Exchange::Folder do
# see https://github.com/zammad/zammad/issues/2152 # see https://github.com/zammad/zammad/issues/2152
describe '#display_path (#2152)', :use_vcr do describe '#display_path (#2152)', :use_vcr do
let(:subject) { described_class.new(ews_connection) } subject(:folder) { described_class.new(ews_connection) }
let(:ews_connection) { Viewpoint::EWSClient.new(endpoint, user, pass) } let(:ews_connection) { Viewpoint::EWSClient.new(endpoint, user, pass) }
let(:endpoint) { 'https://exchange.example.com/EWS/Exchange.asmx' } let(:endpoint) { 'https://exchange.example.com/EWS/Exchange.asmx' }
let(:user) { 'user@example.com' } let(:user) { 'user@example.com' }
@ -18,24 +19,24 @@ RSpec.describe Import::Exchange::Folder do
context 'when server returns valid UTF-8' do context 'when server returns valid UTF-8' do
context 'and target folder is in root directory' do context 'and target folder is in root directory' do
it 'returns the display name of the folder' do it 'returns the display name of the folder' do
expect(subject.display_path(child_of_root)) expect(folder.display_path(child_of_root))
.to eq('Top of Information Store') .to eq('Top of Information Store')
end end
end end
context 'and target folder is in subfolder of root' do context 'and target folder is in subfolder of root' do
it 'returns the full path from root to target' do it 'returns the full path from root to target' do
expect(subject.display_path(grandchild_of_root)) expect(folder.display_path(grandchild_of_root))
.to eq('Top of Information Store -> Inbox') .to eq('Top of Information Store -> Inbox')
end end
end end
context 'and walking up directory tree raises EwsError' do context 'and walking up directory tree raises EwsError' do
it 'returns the partial path from error to target folder' do it 'returns the partial path from error to target folder' do
allow(subject) allow(folder)
.to receive(:id_folder_map).with(any_args).and_raise(Viewpoint::EWS::EwsError) .to receive(:id_folder_map).with(any_args).and_raise(Viewpoint::EWS::EwsError)
expect(subject.display_path(grandchild_of_root)) expect(folder.display_path(grandchild_of_root))
.to eq('Inbox') .to eq('Inbox')
end end
end end
@ -47,7 +48,7 @@ RSpec.describe Import::Exchange::Folder do
allow(child_of_root) allow(child_of_root)
.to receive(:display_name).and_return('你好'.b) .to receive(:display_name).and_return('你好'.b)
expect { subject.display_path(child_of_root).to_json }.not_to raise_error expect { folder.display_path(child_of_root).to_json }.not_to raise_error
end end
end end
@ -56,7 +57,7 @@ RSpec.describe Import::Exchange::Folder do
allow(grandchild_of_root) allow(grandchild_of_root)
.to receive(:display_name).and_return('你好'.b) .to receive(:display_name).and_return('你好'.b)
expect { subject.display_path(grandchild_of_root).to_json }.not_to raise_error expect { folder.display_path(grandchild_of_root).to_json }.not_to raise_error
end end
end end
@ -64,10 +65,10 @@ RSpec.describe Import::Exchange::Folder do
it 'returns the partial path from error to target folder in valid UTF-8' do it 'returns the partial path from error to target folder in valid UTF-8' do
allow(grandchild_of_root) allow(grandchild_of_root)
.to receive(:display_name).and_return('你好'.b) .to receive(:display_name).and_return('你好'.b)
allow(subject) allow(folder)
.to receive(:id_folder_map).with(any_args).and_raise(Viewpoint::EWS::EwsError) .to receive(:id_folder_map).with(any_args).and_raise(Viewpoint::EWS::EwsError)
expect { subject.display_path(grandchild_of_root).to_json }.not_to raise_error expect { folder.display_path(grandchild_of_root).to_json }.not_to raise_error
end end
end end
end end

View file

@ -218,8 +218,9 @@ RSpec.describe Ldap::User do
end end
describe 'attributes' do describe 'attributes' do
let(:subject) { described_class.new(config, ldap: ldap) } subject(:user) { described_class.new(config, ldap: ldap) }
let(:ldap) { Ldap.new(config) }
let(:ldap) { Ldap.new(config) }
let(:config) do let(:config) do
{ 'host_url' => 'ldap://localhost', { 'host_url' => 'ldap://localhost',
'options' => { 'dc=example,dc=org' => 'dc=example,dc=org' }, 'options' => { 'dc=example,dc=org' => 'dc=example,dc=org' },
@ -240,7 +241,7 @@ RSpec.describe Ldap::User do
# ActiveRecord::Store would convert them to binary (ASCII-8BIT) strings, # ActiveRecord::Store would convert them to binary (ASCII-8BIT) strings,
# which would then break #to_json with an Encoding::UndefinedConversion error. # which would then break #to_json with an Encoding::UndefinedConversion error.
it 'skips binary attributes (#2140)' do it 'skips binary attributes (#2140)' do
Setting.set('ldap_config', subject.attributes) Setting.set('ldap_config', user.attributes)
expect { Setting.get('ldap_config').to_json } expect { Setting.get('ldap_config').to_json }
.not_to raise_error .not_to raise_error

View file

@ -90,7 +90,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Agent, sequencer: :sequ
expect(User.last.roles.sort.map(&:name)).to eq ['Agent'] expect(User.last.roles.sort.map(&:name)).to eq ['Agent']
end end
it 'sets user groups correctly ' do it 'sets user groups correctly' do
process(process_payload) process(process_payload)
expect(User.last.groups_access('full').sort).to eq groups expect(User.last.groups_access('full').sort).to eq groups
end end

View file

@ -80,7 +80,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Conversation, sequencer
expect { process(process_payload) }.to change(Ticket::Article, :count).by(1) expect { process(process_payload) }.to change(Ticket::Article, :count).by(1)
end end
it 'correct attributes for added article ' do it 'correct attributes for added article' do
process(process_payload) process(process_payload)
expect(Ticket::Article.last).to have_attributes( expect(Ticket::Article.last).to have_attributes(
to: 'info@zammad.org', to: 'info@zammad.org',

View file

@ -174,7 +174,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Ticket, sequencer: :seq
expect { process(process_payload) }.to change(Ticket::Article, :count).by(1) expect { process(process_payload) }.to change(Ticket::Article, :count).by(1)
end end
it 'correct attributes for added article ' do it 'correct attributes for added article' do
process(process_payload) process(process_payload)
expect(Ticket::Article.last).to have_attributes( expect(Ticket::Article.last).to have_attributes(
to: 'info@zammad.org', to: 'info@zammad.org',

View file

@ -55,7 +55,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::TimeEntry, sequencer: :
expect { process(process_payload) }.to change(Ticket::TimeAccounting, :count).by(1) expect { process(process_payload) }.to change(Ticket::TimeAccounting, :count).by(1)
end end
it 'correct attributes for added time entry ' do it 'correct attributes for added time entry' do
process(process_payload) process(process_payload)
expect(Ticket::TimeAccounting.last).to have_attributes(imported_time_entry) expect(Ticket::TimeAccounting.last).to have_attributes(imported_time_entry)
end end

View file

@ -139,7 +139,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Zendesk::User, sequencer: :sequenc
expect(User.last.roles.sort.map(&:name)).to eq ['Agent'] expect(User.last.roles.sort.map(&:name)).to eq ['Agent']
end end
it 'sets user groups correctly ' do it 'sets user groups correctly' do
process(process_payload) process(process_payload)
expect(User.last.groups_access('full').sort).to eq groups expect(User.last.groups_access('full').sort).to eq groups
end end

View file

@ -3,7 +3,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassigned, sequencer: :unit do RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassigned, sequencer: :unit do
let(:subject) { process(parameters) } subject(:unit) { process(parameters) }
let(:parameters) do let(:parameters) do
{ resource: resource, { resource: resource,
@ -44,7 +44,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
before { instance.update(active: true) } before { instance.update(active: true) }
it 'deactivates user (with action: :deactivated)' do it 'deactivates user (with action: :deactivated)' do
expect(subject).to include(action: :deactivated) expect(unit).to include(action: :deactivated)
expect(instance.reload.active).to be(false) expect(instance.reload.active).to be(false)
end end
end end
@ -53,7 +53,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
before { instance.update(active: false) } before { instance.update(active: false) }
it 'skips user (with action: :skipped)' do it 'skips user (with action: :skipped)' do
expect(subject).to include(action: :skipped) expect(unit).to include(action: :skipped)
expect(instance.reload.active).to be(false) expect(instance.reload.active).to be(false)
end end
end end
@ -63,7 +63,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
let(:instance) { nil } let(:instance) { nil }
it 'skips user (with action: :skipped)' do it 'skips user (with action: :skipped)' do
expect(subject).to include(action: :skipped) expect(unit).to include(action: :skipped)
end end
end end
@ -74,7 +74,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
before { parameters[:dn_roles].clear } before { parameters[:dn_roles].clear }
it 'skips user (with NO action)' do it 'skips user (with NO action)' do
expect(subject).to include(action: nil) expect(unit).to include(action: nil)
expect(instance).not_to have_received(:update) expect(instance).not_to have_received(:update)
end end
end end
@ -83,7 +83,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
before { parameters[:mapped].merge!(role_ids: [2]) } before { parameters[:mapped].merge!(role_ids: [2]) }
it 'skips user (with NO action)' do it 'skips user (with NO action)' do
expect(subject).to include(action: nil) expect(unit).to include(action: nil)
expect(instance).not_to have_received(:update) expect(instance).not_to have_received(:update)
end end
end end
@ -92,7 +92,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
before { parameters[:ldap_config].merge!(unassigned_users: 'sigup_roles') } before { parameters[:ldap_config].merge!(unassigned_users: 'sigup_roles') }
it 'skips user (with NO action)' do it 'skips user (with NO action)' do
expect(subject).to include(action: nil) expect(unit).to include(action: nil)
expect(instance).not_to have_received(:update) expect(instance).not_to have_received(:update)
end end
end end

View file

@ -4,7 +4,8 @@ require 'rails_helper'
RSpec.describe Sessions::Backend::ActivityStream do RSpec.describe Sessions::Backend::ActivityStream do
context 'when async processes affect associated objects / DB records (#2066)' do context 'when async processes affect associated objects / DB records (#2066)' do
let(:subject) { described_class.new(user, {}) } subject(:activity_stream) { described_class.new(user, {}) }
let(:user) { create(:agent, groups: [group]) } let(:user) { create(:agent, groups: [group]) }
let(:group) { Group.find_by(name: 'Users') } let(:group) { Group.find_by(name: 'Users') }
let(:associated_tickets) { create_list(:ticket, ticket_count, group: group) } let(:associated_tickets) { create_list(:ticket, ticket_count, group: group) }
@ -20,7 +21,7 @@ RSpec.describe Sessions::Backend::ActivityStream do
it 'manages race condition' do it 'manages race condition' do
thread = Thread.new { associated_tickets.each(&:destroy) } thread = Thread.new { associated_tickets.each(&:destroy) }
expect { subject.load }.not_to raise_error expect { activity_stream.load }.not_to raise_error
thread.join thread.join
end end
end end

View file

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe UploadCache do RSpec.describe UploadCache do
let(:subject) { described_class.new(1337) } subject(:upload_cache) { described_class.new(1337) }
# required for adding items to the Store # required for adding items to the Store
before { UserInfo.current_user_id = 1 } before { UserInfo.current_user_id = 1 }
@ -20,7 +20,7 @@ RSpec.describe UploadCache do
it 'adds a Store item' do it 'adds a Store item' do
expect do expect do
subject.add( upload_cache.add(
data: 'content_file3_normally_should_be_an_image', data: 'content_file3_normally_should_be_an_image',
filename: 'some_file3.jpg', filename: 'some_file3.jpg',
preferences: { preferences: {
@ -36,7 +36,7 @@ RSpec.describe UploadCache do
describe '#attachments' do describe '#attachments' do
before do before do
subject.add( upload_cache.add(
data: 'hello world', data: 'hello world',
filename: 'some.txt', filename: 'some.txt',
preferences: { preferences: {
@ -46,7 +46,7 @@ RSpec.describe UploadCache do
end end
it 'returns all Store items' do it 'returns all Store items' do
attachments = subject.attachments attachments = upload_cache.attachments
expect(attachments.count).to be(1) expect(attachments.count).to be(1)
expect(attachments).to include(Store.last) expect(attachments).to include(Store.last)
@ -56,7 +56,7 @@ RSpec.describe UploadCache do
describe '#destroy' do describe '#destroy' do
before do before do
subject.add( upload_cache.add(
data: 'hello world', data: 'hello world',
filename: 'some.txt', filename: 'some.txt',
preferences: { preferences: {
@ -64,7 +64,7 @@ RSpec.describe UploadCache do
}, },
) )
subject.add( upload_cache.add(
data: 'hello other world', data: 'hello other world',
filename: 'another_some.txt', filename: 'another_some.txt',
preferences: { preferences: {
@ -74,14 +74,14 @@ RSpec.describe UploadCache do
end end
it 'removes all added Store items' do it 'removes all added Store items' do
expect { subject.destroy }.to change(Store, :count).by(-2) expect { upload_cache.destroy }.to change(Store, :count).by(-2)
end end
end end
describe '#remove_item' do describe '#remove_item' do
before do before do
subject.add( upload_cache.add(
data: 'hello world', data: 'hello world',
filename: 'some.txt', filename: 'some.txt',
preferences: { preferences: {
@ -91,7 +91,7 @@ RSpec.describe UploadCache do
end end
it 'removes the Store item matching the given ID' do it 'removes the Store item matching the given ID' do
expect { subject.remove_item(Store.last.id) }.to change(Store, :count).by(-1) expect { upload_cache.remove_item(Store.last.id) }.to change(Store, :count).by(-1)
end end
it 'prevents removage of non UploadCache Store items' do it 'prevents removage of non UploadCache Store items' do
@ -106,11 +106,11 @@ RSpec.describe UploadCache do
}, },
) )
expect { subject.remove_item(item.id) }.to raise_error(Exceptions::UnprocessableEntity) expect { upload_cache.remove_item(item.id) }.to raise_error(Exceptions::UnprocessableEntity)
end end
it 'fails for non existing UploadCache Store items' do it 'fails for non existing UploadCache Store items' do
expect { subject.remove_item(1337) }.to raise_error(ActiveRecord::RecordNotFound) expect { upload_cache.remove_item(1337) }.to raise_error(ActiveRecord::RecordNotFound)
end end
end end
end end

View file

@ -9,7 +9,7 @@ RSpec.describe Channel::Filter::InternalArticleCheck do
let(:from) { "From: <#{vendor_email}>" } let(:from) { "From: <#{vendor_email}>" }
let(:message_id) { 'some_message_id_999@example.com' } let(:message_id) { 'some_message_id_999@example.com' }
let(:in_reply_to) { message_id } let(:in_reply_to) { message_id }
let(:subject) { "Subject: #{ticket.subject_build('some subject')}" } let(:article_subject) { "Subject: #{ticket.subject_build('some subject')}" }
let(:ticket_article) { build(:ticket_article, ticket: ticket, to: article_to, internal: false, message_id: message_id) } let(:ticket_article) { build(:ticket_article, ticket: ticket, to: article_to, internal: false, message_id: message_id) }
let(:inbound_email) { create(:ticket_article, :inbound_email, ticket: ticket) } let(:inbound_email) { create(:ticket_article, :inbound_email, ticket: ticket) }
let(:outbound_email) { create(:ticket_article, :outbound_email, ticket: ticket) } let(:outbound_email) { create(:ticket_article, :outbound_email, ticket: ticket) }
@ -23,7 +23,7 @@ RSpec.describe Channel::Filter::InternalArticleCheck do
let(:email_parse_mail_answer) do let(:email_parse_mail_answer) do
channel_as_model = Channel.new(options: {}) channel_as_model = Channel.new(options: {})
email_raw_string.sub!(%r{^Subject: .+?$}, subject) email_raw_string.sub!(%r{^Subject: .+?$}, article_subject)
email_raw_string.sub!('From: <John.Smith@example.com>', from) email_raw_string.sub!('From: <John.Smith@example.com>', from)
email_raw_string.sub!('Message-Id: <053EA3703574649ABDAF24D43A05604F327A130@MEMASFRK004.example.com>', "Message-Id: <053EA3703574649ABDAF24D43A05604F327A130@MEMASFRK004.example.com>\nIn-Reply-To: #{in_reply_to}") email_raw_string.sub!('Message-Id: <053EA3703574649ABDAF24D43A05604F327A130@MEMASFRK004.example.com>', "Message-Id: <053EA3703574649ABDAF24D43A05604F327A130@MEMASFRK004.example.com>\nIn-Reply-To: #{in_reply_to}")
Channel::EmailParser.new.process(channel_as_model, email_raw_string) Channel::EmailParser.new.process(channel_as_model, email_raw_string)

View file

@ -3,17 +3,17 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe HttpLog do RSpec.describe HttpLog do
let(:subject) { build(:http_log) } subject(:http_log) { build(:http_log) }
describe 'callbacks' do describe 'callbacks' do
# See https://github.com/zammad/zammad/issues/2100 # See https://github.com/zammad/zammad/issues/2100
it 'converts request/response message data to UTF-8 before saving' do it 'converts request/response message data to UTF-8 before saving' do
subject.request[:content] = 'foo'.force_encoding('ascii-8bit') http_log.request[:content] = 'foo'.force_encoding('ascii-8bit')
subject.response[:content] = 'bar'.force_encoding('ascii-8bit') http_log.response[:content] = 'bar'.force_encoding('ascii-8bit')
expect { subject.save } expect { http_log.save }
.to change { subject.request[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8') .to change { http_log.request[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
.and change { subject.response[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8') .and change { http_log.response[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
end end
end end
end end

View file

@ -6,44 +6,44 @@ RSpec.describe ObjectManager::Attribute, type: :model do
describe 'callbacks' do describe 'callbacks' do
context 'for setting default values on local data options' do context 'for setting default values on local data options' do
let(:subject) { described_class.new } subject(:attr) { described_class.new }
context ':null' do context ':null' do
it 'sets nil values to true' do it 'sets nil values to true' do
expect { subject.validate } expect { attr.validate }
.to change { subject.data_option[:null] }.to(true) .to change { attr.data_option[:null] }.to(true)
end end
it 'does not overwrite false values' do it 'does not overwrite false values' do
subject.data_option[:null] = false attr.data_option[:null] = false
expect { subject.validate } expect { attr.validate }
.not_to change { subject.data_option[:null] } .not_to change { attr.data_option[:null] }
end end
end end
context ':maxlength' do context ':maxlength' do
context 'for data_type: select / tree_select / checkbox' do context 'for data_type: select / tree_select / checkbox' do
let(:subject) { described_class.new(data_type: 'select') } subject(:attr) { described_class.new(data_type: 'select') }
it 'sets nil values to 255' do it 'sets nil values to 255' do
expect { subject.validate } expect { attr.validate }
.to change { subject.data_option[:maxlength] }.to(255) .to change { attr.data_option[:maxlength] }.to(255)
end end
end end
end end
context ':nulloption' do context ':nulloption' do
context 'for data_type: select / tree_select / checkbox' do context 'for data_type: select / tree_select / checkbox' do
let(:subject) { described_class.new(data_type: 'select') } subject(:attr) { described_class.new(data_type: 'select') }
it 'sets nil values to true' do it 'sets nil values to true' do
expect { subject.validate } expect { attr.validate }
.to change { subject.data_option[:nulloption] }.to(true) .to change { attr.data_option[:nulloption] }.to(true)
end end
it 'does not overwrite false values' do it 'does not overwrite false values' do
subject.data_option[:nulloption] = false attr.data_option[:nulloption] = false
expect { subject.validate } expect { subject.validate }
.not_to change { subject.data_option[:nulloption] } .not_to change { subject.data_option[:nulloption] }

View file

@ -754,7 +754,7 @@ RSpec.describe Ticket, type: :model do
end end
end end
context 'dispatching email with include attachment not present' do context 'dispatching email with include attachment not present' do
let(:notification_type) { :email } let(:notification_type) { :email }
let(:additional_options) do let(:additional_options) do
{ {

View file

@ -25,7 +25,7 @@ RSpec.describe Tag, type: :request do
let(:foobar_tag) { tags.first } let(:foobar_tag) { tags.first }
shared_examples 'foobar tag found using' do |search_term:| shared_examples 'foobar tag found using' do |search_term:|
it "found 1 tag using search term '#{search_term}'" do it "found 1 tag using search term '#{search_term}'" do
get '/api/v1/tag_search', params: { term: search_term } get '/api/v1/tag_search', params: { term: search_term }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response).to contain_exactly('id' => foobar_tag.id, 'value' => foobar_tag.name) expect(json_response).to contain_exactly('id' => foobar_tag.id, 'value' => foobar_tag.name)
@ -33,7 +33,7 @@ RSpec.describe Tag, type: :request do
end end
shared_examples 'no tag found using' do |search_term:| shared_examples 'no tag found using' do |search_term:|
it "found 0 tags using search term '#{search_term}'" do it "found 0 tags using search term '#{search_term}'" do
get '/api/v1/tag_search', params: { term: search_term } get '/api/v1/tag_search', params: { term: search_term }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response).to contain_exactly expect(json_response).to contain_exactly

View file

@ -2145,7 +2145,7 @@ RSpec.describe 'Ticket', type: :request do
expect(json_response['tickets']).to eq([ticket2.id, ticket1.id]) expect(json_response['tickets']).to eq([ticket2.id, ticket1.id])
end end
it 'does ticket history ' do it 'does ticket history' do
ticket1 = create( ticket1 = create(
:ticket, :ticket,
title: 'some title', title: 'some title',

View file

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Caller log', type: %i[system request] do # rubocop:disable RSpec/DescribeClass RSpec.describe 'Caller log', type: %i[system request] do
let(:admin) do let(:admin) do
create(:admin, groups: Group.all) create(:admin, groups: Group.all)
end end