Fixed bug: RSpec tests are broken because of not using RSpec hooks and structures.

This commit is contained in:
Thorsten Eckel 2018-10-18 14:16:29 +02:00
parent f3e20bca29
commit 7d9c087a84
3 changed files with 26 additions and 17 deletions

13
spec/factories/taskbar.rb Normal file
View file

@ -0,0 +1,13 @@
FactoryBot.define do
factory :taskbar do
client_id 123
key 'Ticket-1234'
add_attribute(:callback) { 'TicketZoom' }
params do
{}
end
state {}
prio 1
notify false
end
end

View file

@ -3,20 +3,16 @@ require 'rails_helper'
RSpec.describe Taskbar do RSpec.describe Taskbar do
context 'single creation' do context 'single creation' do
let(:taskbar) do
Taskbar.destroy_all Taskbar.destroy_all
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
taskbar = Taskbar.create( create(:taskbar, params: {
client_id: 123,
key: 'Ticket-1234',
callback: 'TicketZoom',
params: {
id: 1234, id: 1234,
}, })
state: {}, end
prio: 1,
notify: false,
)
it 'existing key' do it 'existing key' do
expect(taskbar.key).to eq('Ticket-1234') expect(taskbar.key).to eq('Ticket-1234')
@ -79,8 +75,6 @@ RSpec.describe Taskbar do
expect(taskbar.last_contact.to_s).not_to eq(last_contact1.to_s) expect(taskbar.last_contact.to_s).not_to eq(last_contact1.to_s)
expect(taskbar.last_contact.to_s).not_to eq(last_contact2.to_s) expect(taskbar.last_contact.to_s).not_to eq(last_contact2.to_s)
end end
UserInfo.current_user_id = nil
end end
context 'multible creation' do context 'multible creation' do

View file

@ -2,8 +2,10 @@ require 'rails_helper'
RSpec.describe Translation do RSpec.describe Translation do
before(:all) do
Translation.where(locale: 'de-de').destroy_all Translation.where(locale: 'de-de').destroy_all
Translation.sync('de-de') Translation.sync('de-de')
end
context 'default translations' do context 'default translations' do