chore: rubocop
chore: fix api test conventions chore: rubocop -A spec/ chore: more rubocop -A fix failing test rubocop fixes removes helper methods that are in my opinion dead code more rubocop fixes rubocop -a --auto-gen-config
This commit is contained in:
parent
f6fb804bbe
commit
fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions
|
|
@ -1,7 +1,7 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
describe BankTransaction do
|
||||
let(:bank_account) { create :bank_account }
|
||||
let(:bank_account) { create(:bank_account) }
|
||||
|
||||
it 'empty content' do
|
||||
content = ''
|
||||
|
|
@ -188,7 +188,7 @@ describe BankTransaction do
|
|||
expect(bt.date).to eq('2019-02-13'.to_date)
|
||||
expect(bt.text).to eq('Deutsche Bundesbahn')
|
||||
expect(bt.iban).to eq('DE72957284895783674747')
|
||||
expect(bt.reference).to eq("743574386368 Muenchen-Hamburg 27.03.2019")
|
||||
expect(bt.reference).to eq('743574386368 Muenchen-Hamburg 27.03.2019')
|
||||
expect(bt.receipt).to eq('Lastschrift')
|
||||
end
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ describe BankTransaction do
|
|||
expect(bt.date).to eq('2019-02-14'.to_date)
|
||||
expect(bt.text).to eq('superbank AG')
|
||||
expect(bt.iban).to be_nil
|
||||
expect(bt.reference).to eq("Überweisung US, Wechselspesen u Provision")
|
||||
expect(bt.reference).to eq('Überweisung US, Wechselspesen u Provision')
|
||||
expect(bt.receipt).to eq('Spesen/Gebühren')
|
||||
end
|
||||
|
||||
|
|
@ -384,7 +384,7 @@ describe BankTransaction do
|
|||
expect(bank_account.last_transaction_date).to eq('2020-01-01'.to_date)
|
||||
expect(bank_account.balance).to eq(22)
|
||||
|
||||
bt1 = bank_account.bank_transactions.find_by_external_id("T1")
|
||||
bt1 = bank_account.bank_transactions.find_by_external_id('T1')
|
||||
expect(bt1.amount).to eq(11)
|
||||
expect(bt1.date).to eq('2020-01-01'.to_date)
|
||||
expect(bt1.text).to eq('DN1')
|
||||
|
|
@ -392,7 +392,7 @@ describe BankTransaction do
|
|||
expect(bt1.reference).to eq('')
|
||||
expect(bt1.receipt).to eq('AI1')
|
||||
|
||||
bt2 = bank_account.bank_transactions.find_by_external_id("T2")
|
||||
bt2 = bank_account.bank_transactions.find_by_external_id('T2')
|
||||
expect(bt2.amount).to eq(-22)
|
||||
expect(bt2.date).to eq('2010-02-01'.to_date)
|
||||
expect(bt2.text).to eq('CN2')
|
||||
|
|
@ -400,7 +400,7 @@ describe BankTransaction do
|
|||
expect(bt2.reference).to eq('RI2')
|
||||
expect(bt2.receipt).to be_nil
|
||||
|
||||
bt3 = bank_account.bank_transactions.find_by_external_id("T3")
|
||||
bt3 = bank_account.bank_transactions.find_by_external_id('T3')
|
||||
expect(bt3.amount).to eq(33)
|
||||
expect(bt3.date).to eq('2000-03-01'.to_date)
|
||||
expect(bt3.text).to eq('DN3')
|
||||
|
|
|
|||
|
|
@ -34,62 +34,65 @@ describe BankTransactionReference do
|
|||
end
|
||||
|
||||
it 'returns correct value for FS1A1' do
|
||||
expect(BankTransactionReference.parse('FS1A1')).to match({ group: 1, parts: { "A" => 1 } })
|
||||
expect(BankTransactionReference.parse('FS1A1')).to match({ group: 1, parts: { 'A' => 1 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1.2A3' do
|
||||
expect(BankTransactionReference.parse('FS1.2A3')).to match({ group: 1, user: 2, parts: { "A" => 3 } })
|
||||
expect(BankTransactionReference.parse('FS1.2A3')).to match({ group: 1, user: 2, parts: { 'A' => 3 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1A2B3C4' do
|
||||
expect(BankTransactionReference.parse('FS1A2B3C4')).to match({ group: 1, parts: { "A" => 2, "B" => 3, "C" => 4 } })
|
||||
expect(BankTransactionReference.parse('FS1A2B3C4')).to match({ group: 1, parts: { 'A' => 2, 'B' => 3, 'C' => 4 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1A2B3A4' do
|
||||
expect(BankTransactionReference.parse('FS1A2B3A4')).to match({ group: 1, parts: { "A" => 6, "B" => 3 } })
|
||||
expect(BankTransactionReference.parse('FS1A2B3A4')).to match({ group: 1, parts: { 'A' => 6, 'B' => 3 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS1A2.34B5.67C8.90' do
|
||||
expect(BankTransactionReference.parse('FS1A2.34B5.67C8.90')).to match({ group: 1, parts: { "A" => 2.34, "B" => 5.67, "C" => 8.90 } })
|
||||
expect(BankTransactionReference.parse('FS1A2.34B5.67C8.90')).to match({ group: 1,
|
||||
parts: { 'A' => 2.34, 'B' => 5.67,
|
||||
'C' => 8.90 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with comma-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x,FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x,FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with minus-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x-FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x-FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with semicolon-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x;FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x;FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS123A456 with space-separated prefix' do
|
||||
expect(BankTransactionReference.parse('x FS123A456')).to match({ group: 123, parts: { "A" => 456 } })
|
||||
expect(BankTransactionReference.parse('x FS123A456')).to match({ group: 123, parts: { 'A' => 456 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with comma-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567,x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567,x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with minus-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with space-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567 x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567 x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with semicolon-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567;x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567;x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS234A567 with minus-separated suffix' do
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { "A" => 567 } })
|
||||
expect(BankTransactionReference.parse('FS234A567-x')).to match({ group: 234, parts: { 'A' => 567 } })
|
||||
end
|
||||
|
||||
it 'returns correct value for FS34.56A67.89 with prefix and suffix' do
|
||||
expect(BankTransactionReference.parse('prefix FS34.56A67.89, suffix')).to match({ group: 34, user: 56, parts: { "A" => 67.89 } })
|
||||
expect(BankTransactionReference.parse('prefix FS34.56A67.89, suffix')).to match({ group: 34, user: 56,
|
||||
parts: { 'A' => 67.89 } })
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,55 +6,6 @@ describe FoodsoftMailReceiver do
|
|||
@server.start
|
||||
end
|
||||
|
||||
it 'does not accept empty addresses' do
|
||||
begin
|
||||
FoodsoftMailReceiver.received('', 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'missing'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses' do
|
||||
begin
|
||||
FoodsoftMailReceiver.received('invalid', 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'has an invalid format'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept invalid scope in address' do
|
||||
begin
|
||||
FoodsoftMailReceiver.received('invalid.invalid', 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'could not be found'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept address without handler' do
|
||||
begin
|
||||
address = "#{FoodsoftConfig[:default_scope]}.invalid"
|
||||
FoodsoftMailReceiver.received(address, 'body')
|
||||
rescue => error
|
||||
expect(error.to_s).to include 'invalid format for recipient'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect {
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
}.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect {
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
}.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
|
||||
# TODO: Reanable this test.
|
||||
# It raised "Mysql2::Error: Lock wait timeout exceeded" at time of writing.
|
||||
# it 'accepts bounce mails via SMTP' do
|
||||
|
|
@ -74,4 +25,45 @@ describe FoodsoftMailReceiver do
|
|||
after :all do
|
||||
@server.shutdown
|
||||
end
|
||||
|
||||
it 'does not accept empty addresses' do
|
||||
FoodsoftMailReceiver.received('', 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'missing'
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses' do
|
||||
FoodsoftMailReceiver.received('invalid', 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'has an invalid format'
|
||||
end
|
||||
|
||||
it 'does not accept invalid scope in address' do
|
||||
FoodsoftMailReceiver.received('invalid.invalid', 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'could not be found'
|
||||
end
|
||||
|
||||
it 'does not accept address without handler' do
|
||||
address = "#{FoodsoftConfig[:default_scope]}.invalid"
|
||||
FoodsoftMailReceiver.received(address, 'body')
|
||||
rescue StandardError => e
|
||||
expect(e.to_s).to include 'invalid format for recipient'
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect do
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
end.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
|
||||
it 'does not accept invalid addresses via SMTP' do
|
||||
expect do
|
||||
Net::SMTP.start(@server.hosts.first, @server.ports.first) do |smtp|
|
||||
smtp.send_message 'body', 'from@example.com', 'invalid'
|
||||
end
|
||||
end.to raise_error(Net::SMTPFatalError)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ describe TokenVerifier do
|
|||
let(:msg) { v.generate }
|
||||
|
||||
it 'validates' do
|
||||
expect { v.verify(msg) }.to_not raise_error
|
||||
expect { v.verify(msg) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'validates when recreated' do
|
||||
v2 = TokenVerifier.new(prefix)
|
||||
expect { v2.verify(msg) }.to_not raise_error
|
||||
expect { v2.verify(msg) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'does not validate with a different prefix' do
|
||||
|
|
@ -32,7 +32,9 @@ describe TokenVerifier do
|
|||
end
|
||||
|
||||
it 'does not validate a random string' do
|
||||
expect { v.verify(Faker::Lorem.characters(number: 100)) }.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature)
|
||||
expect do
|
||||
v.verify(Faker::Lorem.characters(number: 100))
|
||||
end.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature)
|
||||
end
|
||||
|
||||
it 'returns the message' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue