diff --git a/spec/factories/taskbar.rb b/spec/factories/taskbar.rb new file mode 100644 index 000000000..a78034e0b --- /dev/null +++ b/spec/factories/taskbar.rb @@ -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 diff --git a/spec/models/taskbar_spec.rb b/spec/models/taskbar_spec.rb index 40badc798..6ef634700 100644 --- a/spec/models/taskbar_spec.rb +++ b/spec/models/taskbar_spec.rb @@ -3,20 +3,16 @@ require 'rails_helper' RSpec.describe Taskbar do context 'single creation' do - Taskbar.destroy_all - UserInfo.current_user_id = 1 - taskbar = Taskbar.create( - client_id: 123, - key: 'Ticket-1234', - callback: 'TicketZoom', - params: { - id: 1234, - }, - state: {}, - prio: 1, - notify: false, - ) + let(:taskbar) do + + Taskbar.destroy_all + UserInfo.current_user_id = 1 + + create(:taskbar, params: { + id: 1234, + }) + end it 'existing key' do 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_contact2.to_s) end - - UserInfo.current_user_id = nil end context 'multible creation' do diff --git a/spec/models/translation_spec.rb b/spec/models/translation_spec.rb index f8ba12e2d..c40aee37c 100644 --- a/spec/models/translation_spec.rb +++ b/spec/models/translation_spec.rb @@ -2,8 +2,10 @@ require 'rails_helper' RSpec.describe Translation do - Translation.where(locale: 'de-de').destroy_all - Translation.sync('de-de') + before(:all) do + Translation.where(locale: 'de-de').destroy_all + Translation.sync('de-de') + end context 'default translations' do