From 3acfa4a277c29a0eb3b7bff83fde1a60718a9746 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 27 Mar 2019 10:01:36 +0100 Subject: [PATCH] Fixed issue #2089 - timezone issue with report graphs not displaying or displaying $timezone hours out of step. --- Gemfile | 10 +- Gemfile.lock | 186 +++++++++--------- spec/factories/avatar.rb | 20 +- spec/factories/calendar.rb | 12 +- spec/factories/channel.rb | 18 +- spec/factories/external_credential.rb | 4 +- spec/factories/group.rb | 6 +- spec/factories/http_log.rb | 10 +- spec/factories/import_job.rb | 4 +- spec/factories/job.rb | 27 ++- spec/factories/locale.rb | 4 +- spec/factories/macro.rb | 4 +- .../notification_factory/renderer.rb | 8 +- spec/factories/object_manager_attribute.rb | 59 +++--- spec/factories/postmaster_filter.rb | 12 +- spec/factories/role.rb | 12 +- spec/factories/scheduler.rb | 33 ++-- spec/factories/signature.rb | 14 +- spec/factories/taskbar.rb | 14 +- spec/factories/ticket.rb | 9 +- spec/factories/ticket/article.rb | 2 +- spec/factories/ticket/priority.rb | 9 +- spec/factories/ticket/time_accounting.rb | 4 +- spec/factories/translation.rb | 10 +- spec/factories/user_device.rb | 20 +- spec/factories/vendor/net/ldap/entry.rb | 4 +- spec/models/ticket_spec.rb | 2 +- 27 files changed, 239 insertions(+), 278 deletions(-) diff --git a/Gemfile b/Gemfile index 15d0cfe16..695d8982f 100644 --- a/Gemfile +++ b/Gemfile @@ -17,8 +17,8 @@ gem 'unicorn', group: :unicorn # core - supported ORMs gem 'activerecord-nulldb-adapter', group: :nulldb -gem 'mysql2', group: :mysql -gem 'pg', group: :postgres +gem 'mysql2', '0.4.10', group: :mysql +gem 'pg', '0.21.0', group: :postgres # core - asynchrous task execution gem 'daemons' @@ -29,7 +29,7 @@ gem 'em-websocket' gem 'eventmachine' # core - password security -gem 'argon2' +gem 'argon2', '1.1.5' # performance - Memcached gem 'dalli' @@ -53,7 +53,7 @@ gem 'autoprefixer-rails' # asset handling - javascript execution for e.g. linux gem 'execjs' gem 'libv8' -gem 'therubyracer' +gem 'mini_racer' # authentication - provider gem 'doorkeeper' @@ -117,7 +117,7 @@ gem 'rubyntlm', git: 'https://github.com/wimm/rubyntlm' gem 'viewpoint' # image processing -gem 'rszr' +gem 'rszr', '0.4.0' # Gems used only for develop/test and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index 96f1bc17c..558357a3d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,16 +79,16 @@ GEM activemodel (= 5.1.6.2) activesupport (= 5.1.6.2) arel (~> 8.0) - activerecord-import (0.25.0) + activerecord-import (1.0.1) activerecord (>= 3.2) - activerecord-nulldb-adapter (0.3.7) + activerecord-nulldb-adapter (0.3.9) activerecord (>= 2.0.0) - activerecord-session_store (1.1.0) - actionpack (>= 4.0, < 5.2) - activerecord (>= 4.0, < 5.2) + activerecord-session_store (1.1.3) + actionpack (>= 4.0) + activerecord (>= 4.0) multi_json (~> 1.11, >= 1.11.2) rack (>= 1.5.2, < 3) - railties (>= 4.0, < 5.2) + railties (>= 4.0) activesupport (5.1.6.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) @@ -97,21 +97,21 @@ GEM addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) arel (8.0.0) - argon2 (1.1.4) + argon2 (1.1.5) ffi (~> 1.9) ffi-compiler (~> 0.1) ast (2.4.0) - autoprefixer-rails (7.1.6) + autoprefixer-rails (9.5.0) execjs binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) biz (1.8.2) clavius (~> 1.0) tzinfo - browser (2.5.2) + browser (2.5.3) buftok (0.2.0) builder (3.2.3) - byebug (10.0.2) + byebug (11.0.1) capybara (2.18.0) addressable mini_mime (>= 0.1.3) @@ -139,17 +139,17 @@ GEM composite_primary_keys (10.0.5) activerecord (~> 5.1.0, >= 5.1.6) concurrent-ruby (1.1.5) - coveralls (0.7.1) - multi_json (~> 1.3) - rest-client - simplecov (>= 0.7) - term-ansicolor - thor + coveralls (0.8.22) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) + term-ansicolor (~> 1.3) + thor (~> 0.19.4) + tins (~> 1.6) crack (0.4.3) safe_yaml (~> 1.0.0) crass (1.0.4) - daemons (1.2.5) - dalli (2.7.6) + daemons (1.3.1) + dalli (2.7.10) debug_inspector (0.0.3) delayed_job (4.1.5) activesupport (>= 3.0, < 5.3) @@ -157,11 +157,11 @@ GEM activerecord (>= 3.0, < 5.3) delayed_job (>= 3.0, < 5) diff-lcs (1.3) - diffy (3.2.0) - docile (1.1.5) + diffy (3.3.0) + docile (1.3.1) domain_name (0.5.20180417) unf (>= 0.0.5, < 1.0.0) - doorkeeper (4.4.0) + doorkeeper (5.0.2) railties (>= 4.2) eco (1.0.0) coffee-script @@ -173,20 +173,20 @@ GEM http_parser.rb (~> 0.6.0) equalizer (0.0.11) erubi (1.8.0) - eventmachine (1.2.5) + eventmachine (1.2.7) execjs (2.7.0) - factory_bot (4.8.2) - activesupport (>= 3.0.0) - factory_bot_rails (4.8.2) - factory_bot (~> 4.8.2) - railties (>= 3.0.0) - faker (1.9.1) + factory_bot (5.0.2) + activesupport (>= 4.2.0) + factory_bot_rails (5.0.1) + factory_bot (~> 5.0.0) + railties (>= 4.2.0) + faker (1.9.3) i18n (>= 0.7) faraday (0.15.4) multipart-post (>= 1.2, < 3) faraday-http-cache (2.0.0) faraday (~> 0.8) - ffi (1.9.25) + ffi (1.10.0) ffi-compiler (0.1.3) ffi (>= 1.0.0) rake @@ -201,10 +201,10 @@ GEM retriable (~> 2.1) globalid (0.4.2) activesupport (>= 4.2.0) - guard (2.14.1) + guard (2.15.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) - lumberjack (~> 1.0) + lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) @@ -219,7 +219,7 @@ GEM guard-symlink (0.1.1) guard guard-compat (~> 1.1) - hashdiff (0.3.7) + hashdiff (0.3.8) hashie (3.6.0) htmlentities (4.3.4) http (3.3.0) @@ -234,22 +234,23 @@ GEM httpclient (2.8.3) i18n (1.6.0) concurrent-ruby (~> 1.0) - icalendar (2.4.1) + icalendar (2.5.3) + ice_cube (~> 0.16) icalendar-recurrence (1.1.2) icalendar (~> 2.0) ice_cube (~> 0.13) - ice_cube (0.16.2) + ice_cube (0.16.3) inflection (1.0.0) interception (0.5) jaro_winkler (1.5.2) - json (2.1.0) + json (2.2.0) jwt (2.1.0) kgio (2.11.2) koala (3.0.0) addressable faraday json (>= 1.8) - libv8 (3.16.14.19) + libv8 (6.7.288.46.1) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -261,7 +262,7 @@ GEM loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.0.12) + lumberjack (1.0.13) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) method_source (0.9.2) @@ -270,6 +271,8 @@ GEM mime-types-data (3.2018.0812) mini_mime (1.0.1) mini_portile2 (2.4.0) + mini_racer (0.2.4) + libv8 (>= 6.3) minitest (5.11.3) multi_json (1.13.1) multi_xml (0.6.0) @@ -287,32 +290,31 @@ GEM notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - oauth (0.5.3) + oauth (0.5.4) oauth2 (1.4.1) faraday (>= 0.8, < 0.16.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - octokit (4.7.0) + octokit (4.13.0) sawyer (~> 0.8.0, >= 0.5.3) omniauth (1.9.0) hashie (>= 3.4.6, < 3.7.0) rack (>= 1.6.2, < 3) - omniauth-facebook (4.0.0) + omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) omniauth-github (1.3.0) omniauth (~> 1.5) omniauth-oauth2 (>= 1.4.0, < 2.0) - omniauth-gitlab (1.0.2) + omniauth-gitlab (2.0.0) omniauth (~> 1.0) omniauth-oauth2 (~> 1.0) - omniauth-google-oauth2 (0.6.0) + omniauth-google-oauth2 (0.6.1) jwt (>= 2.0) omniauth (>= 1.1.1) omniauth-oauth2 (>= 1.5) - omniauth-linkedin-oauth2 (0.2.5) - omniauth (~> 1.0) + omniauth-linkedin-oauth2 (1.0.0) omniauth-oauth2 omniauth-microsoft-office365 (0.0.7) omniauth @@ -326,36 +328,36 @@ GEM omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack - omniauth-weibo-oauth2 (0.4.5) + omniauth-weibo-oauth2 (0.5.2) omniauth (~> 1.5) omniauth-oauth2 (>= 1.4.0) - parallel (1.14.0) - parser (2.6.0.0) + parallel (1.15.0) + parser (2.6.2.0) ast (~> 2.4.0) pg (0.21.0) pluginator (1.5.0) - power_assert (1.1.1) - pre-commit (0.37.0) + power_assert (1.1.4) + pre-commit (0.39.0) pluginator (~> 1.5) - pry (0.11.3) + pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - pry-rails (0.3.6) + pry-rails (0.3.9) pry (>= 0.10.4) pry-remote (0.1.8) pry (~> 0.9) slop (~> 3.0) - pry-rescue (1.4.5) + pry-rescue (1.5.0) interception (>= 0.5) - pry - pry-stack_explorer (0.4.9.2) + pry (>= 0.12.0) + pry-stack_explorer (0.4.9.3) binding_of_caller (>= 0.7) pry (>= 0.9.11) psych (3.1.0) - public_suffix (3.0.1) - puma (3.12.0) + public_suffix (3.0.3) + puma (3.12.1) rack (2.0.6) - rack-livereload (0.3.16) + rack-livereload (0.3.17) rack rack-test (1.1.0) rack (>= 1.0, < 3) @@ -387,11 +389,10 @@ GEM rainbow (3.0.0) raindrops (0.19.0) rake (12.3.2) - rb-fsevent (0.10.2) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) rchardet (1.8.0) - ref (2.0.0) rest-client (2.0.2) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) @@ -399,13 +400,13 @@ GEM retriable (2.1.0) rspec-core (3.8.0) rspec-support (~> 3.8.0) - rspec-expectations (3.8.1) + rspec-expectations (3.8.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-mocks (3.8.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) - rspec-rails (3.8.0) + rspec-rails (3.8.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -414,7 +415,7 @@ GEM rspec-mocks (~> 3.8.0) rspec-support (~> 3.8.0) rspec-support (3.8.0) - rszr (0.3.2) + rszr (0.4.0) rubocop (0.66.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) @@ -426,11 +427,11 @@ GEM ruby-progressbar (1.10.0) ruby_dep (1.5.0) rubyzip (1.2.2) - safe_yaml (1.0.4) - sassc (2.0.0) - ffi (~> 1.9.6) + safe_yaml (1.0.5) + sassc (2.0.1) + ffi (~> 1.9) rake - sassc-rails (2.0.0) + sassc-rails (2.1.0) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) @@ -439,19 +440,19 @@ GEM sawyer (0.8.1) addressable (>= 2.3.5, < 2.6) faraday (~> 0.8, < 1.0) - selenium-webdriver (3.13.1) + selenium-webdriver (3.141.0) childprocess (~> 0.5) - rubyzip (~> 1.2) + rubyzip (~> 1.2, >= 1.2.2) shellany (0.0.1) simple_oauth (0.3.1) - simplecov (0.15.1) - docile (~> 1.1.0) + simplecov (0.16.1) + docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) simplecov-rcov (0.2.3) simplecov (>= 0.4.1) - slack-notifier (2.3.1) + slack-notifier (2.3.2) slop (3.6.0) spring (2.0.2) activesupport (>= 4.2) @@ -466,37 +467,34 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) + sqlite3 (1.4.0) telegramAPI (1.4.2) rest-client (~> 2.0, >= 2.0.2) - telephone_number (1.3.0) - term-ansicolor (1.6.0) + telephone_number (1.3.4) + term-ansicolor (1.7.1) tins (~> 1.0) - test-unit (3.2.6) + test-unit (3.3.0) power_assert - therubyracer (0.12.3) - libv8 (~> 3.16.14.15) - ref - thor (0.20.3) + thor (0.19.4) thread_safe (0.3.6) - tilt (2.0.8) - tins (1.15.1) - twilio-ruby (5.10.2) + tilt (2.0.9) + tins (1.20.2) + twilio-ruby (5.21.2) faraday (~> 0.9) jwt (>= 1.5, <= 2.5) nokogiri (>= 1.6, < 2.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (3.2.0) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.5) unicode-display_width (1.5.0) - unicorn (5.4.1) + unicorn (5.5.0) kgio (~> 2.6) raindrops (~> 0.7) - valid_email2 (2.1.0) + valid_email2 (3.0.1) activemodel (>= 3.2) mail (~> 2.5) vcr (4.0.0) @@ -505,7 +503,7 @@ GEM logging nokogiri rubyntlm - webmock (3.1.1) + webmock (3.5.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -515,7 +513,7 @@ GEM writeexcel (1.0.5) xpath (3.2.0) nokogiri (~> 1.8) - zendesk_api (1.16.0) + zendesk_api (1.17.0) faraday (~> 0.9) hashie (>= 3.5.2, < 4.0.0) inflection @@ -529,7 +527,7 @@ DEPENDENCIES activerecord-import activerecord-nulldb-adapter activerecord-session_store - argon2 + argon2 (= 1.1.5) autodiscover! autoprefixer-rails biz @@ -565,7 +563,8 @@ DEPENDENCIES libv8 mail! mime-types - mysql2 + mini_racer + mysql2 (= 0.4.10) net-ldap oauth2 omniauth @@ -578,7 +577,7 @@ DEPENDENCIES omniauth-oauth2 omniauth-twitter omniauth-weibo-oauth2 - pg + pg (= 0.21.0) pre-commit pry-rails pry-remote @@ -591,7 +590,7 @@ DEPENDENCIES rb-fsevent rchardet (>= 1.8.0) rspec-rails - rszr + rszr (= 0.4.0) rubocop rubyntlm! sassc-rails @@ -608,7 +607,6 @@ DEPENDENCIES telegramAPI telephone_number test-unit - therubyracer twilio-ruby twitter! uglifier diff --git a/spec/factories/avatar.rb b/spec/factories/avatar.rb index a3ab598e7..9e615b5c8 100644 --- a/spec/factories/avatar.rb +++ b/spec/factories/avatar.rb @@ -1,15 +1,15 @@ FactoryBot.define do factory :avatar do object_lookup_id { ObjectLookup.by_name('User') } - o_id 1 - default true - deletable true - initial false - source 'init' - source_url nil - created_by_id 1 - updated_by_id 1 - created_at Time.zone.now - updated_at Time.zone.now + o_id { 1 } + default { true } + deletable { true } + initial { false } + source { 'init' } + source_url { nil } + created_by_id { 1 } + updated_by_id { 1 } + created_at { Time.zone.now } + updated_at { Time.zone.now } end end diff --git a/spec/factories/calendar.rb b/spec/factories/calendar.rb index e9098ddab..4cc992b11 100644 --- a/spec/factories/calendar.rb +++ b/spec/factories/calendar.rb @@ -1,10 +1,10 @@ FactoryBot.define do factory :calendar do sequence(:name) { |n| "Escalation Test #{n}" } - timezone 'Europe/Berlin' - default true - ical_url nil - business_hours do + timezone { 'Europe/Berlin' } + default { true } + ical_url { nil } + business_hours do { mon: { active: true, @@ -36,7 +36,7 @@ FactoryBot.define do } } end - created_by_id 1 - updated_by_id 1 + created_by_id { 1 } + updated_by_id { 1 } end end diff --git a/spec/factories/channel.rb b/spec/factories/channel.rb index 2b727e977..dd6edcf51 100644 --- a/spec/factories/channel.rb +++ b/spec/factories/channel.rb @@ -1,15 +1,15 @@ FactoryBot.define do factory :channel do - area 'Email::Dummy' - group { ::Group.find(1) } - active true - options {} - preferences {} - updated_by_id 1 - created_by_id 1 + area { 'Email::Dummy' } + group { ::Group.find(1) } + active { true } + options {} + preferences {} + updated_by_id { 1 } + created_by_id { 1 } factory :email_channel do - area 'Email::Account' + area { 'Email::Account' } options do { inbound: { @@ -27,7 +27,7 @@ FactoryBot.define do custom_options { {} } end - area 'Twitter::Account' + area { 'Twitter::Account' } options do { adapter: 'twitter', diff --git a/spec/factories/external_credential.rb b/spec/factories/external_credential.rb index 05362d9d1..4a8dd3f0d 100644 --- a/spec/factories/external_credential.rb +++ b/spec/factories/external_credential.rb @@ -1,12 +1,12 @@ FactoryBot.define do factory :external_credential do factory :facebook_credential do - name 'facebook' + name { 'facebook' } credentials { { application_id: 123, application_secret: 123 } } end factory :twitter_credential do - name 'twitter' + name { 'twitter' } credentials do { consumer_key: 123, diff --git a/spec/factories/group.rb b/spec/factories/group.rb index d5a4ab1ed..ef5dd36ac 100644 --- a/spec/factories/group.rb +++ b/spec/factories/group.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :group do - sequence(:name) { |n| "Group #{n}" } email_address - created_by_id { 1 } - updated_by_id { 1 } + sequence(:name) { |n| "Group #{n}" } + created_by_id { 1 } + updated_by_id { 1 } end end diff --git a/spec/factories/http_log.rb b/spec/factories/http_log.rb index 24ddee7ad..94f62f4f1 100644 --- a/spec/factories/http_log.rb +++ b/spec/factories/http_log.rb @@ -1,12 +1,12 @@ FactoryBot.define do factory :http_log do - direction 'in' - facility 'cti' + direction { 'in' } + facility { 'cti' } add_attribute(:method) { 'post' } - url 'https://zammad.fqdn.com/api/v1/integration/cti/log' + url { 'https://zammad.fqdn.com/api/v1/integration/cti/log' } request { { content: 'foo' } } response { { content: 'bar' } } - created_by_id 1 - updated_by_id 1 + created_by_id { 1 } + updated_by_id { 1 } end end diff --git a/spec/factories/import_job.rb b/spec/factories/import_job.rb index 228093a1d..6cb1bee76 100644 --- a/spec/factories/import_job.rb +++ b/spec/factories/import_job.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :import_job do - name 'Import::Test' + name { 'Import::Test' } payload {} - dry_run false + dry_run { false } end end diff --git a/spec/factories/job.rb b/spec/factories/job.rb index caaa3ca1a..2ed12aa6e 100644 --- a/spec/factories/job.rb +++ b/spec/factories/job.rb @@ -1,13 +1,19 @@ FactoryBot.define do factory :job do sequence(:name) { |n| "Test job #{n}" } - condition { { 'ticket.state_id' => { 'operator' => 'is not', 'value' => 4 } } } - perform { { 'ticket.state_id' => { 'value' => 4 } } } - active true - created_by_id 1 - updated_by_id 1 - timeplan do - { 'days' => { 'Mon' => true, 'Tue' => false, 'Wed' => false, 'Thu' => false, 'Fri' => false, 'Sat' => false, 'Sun' => false }, + condition { { 'ticket.state_id' => { 'operator' => 'is not', 'value' => 4 } } } + perform { { 'ticket.state_id' => { 'value' => 4 } } } + active { true } + created_by_id { 1 } + updated_by_id { 1 } + timeplan do + { 'days' => { 'Mon' => true, + 'Tue' => false, + 'Wed' => false, + 'Thu' => false, + 'Fri' => false, + 'Sat' => false, + 'Sun' => false }, 'hours' => { '0' => true, '1' => false, @@ -33,7 +39,12 @@ FactoryBot.define do '21' => false, '22' => false, '23' => false }, - 'minutes' => { '0' => true, '10' => false, '20' => false, '30' => false, '40' => false, '50' => false } } + 'minutes' => { '0' => true, + '10' => false, + '20' => false, + '30' => false, + '40' => false, + '50' => false } } end end end diff --git a/spec/factories/locale.rb b/spec/factories/locale.rb index ee110b12c..2d30f9242 100644 --- a/spec/factories/locale.rb +++ b/spec/factories/locale.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :locale do - locale 'de-de' - name 'Deutsch' + locale { 'de-de' } + name { 'Deutsch' } end end diff --git a/spec/factories/macro.rb b/spec/factories/macro.rb index 24b913230..1af3f900b 100644 --- a/spec/factories/macro.rb +++ b/spec/factories/macro.rb @@ -1,9 +1,7 @@ FactoryBot.define do factory :macro do sequence(:name) { |n| "Macro #{n}" } - perform do - {} - end + perform { {} } ux_flow_next_up { 'next_task' } note { '' } active { true } diff --git a/spec/factories/notification_factory/renderer.rb b/spec/factories/notification_factory/renderer.rb index c957878c1..de4250681 100644 --- a/spec/factories/notification_factory/renderer.rb +++ b/spec/factories/notification_factory/renderer.rb @@ -1,9 +1,9 @@ FactoryBot.define do factory :notification_factory_renderer, class: NotificationFactory::Renderer do - objects {} - locale 'en-en' - template '' - escape true + objects {} + locale { 'en-en' } + template { '' } + escape { true } initialize_with { new(objects: objects, locale: locale, template: template, escape: escape) } end diff --git a/spec/factories/object_manager_attribute.rb b/spec/factories/object_manager_attribute.rb index 8168fb48f..e4ec58e21 100644 --- a/spec/factories/object_manager_attribute.rb +++ b/spec/factories/object_manager_attribute.rb @@ -1,25 +1,19 @@ -FactoryBot.define do - sequence :object_manager_attribute_name do |n| - "internal_name#{n}" - end - - sequence :object_manager_attribute_display do |n| - "Display Name #{n}" - end -end - FactoryBot.define do factory :object_manager_attribute, class: ObjectManager::Attribute do - - object_lookup_id { ObjectLookup.by_name('Ticket') } - name { generate(:object_manager_attribute_name) } - display { generate(:object_manager_attribute_display) } - data_option_new do - {} - end - editable true - active true - screens do + object_lookup_id { ObjectLookup.by_name('Ticket') } + sequence(:name) { |n| "internal_name#{n}" } + sequence(:display) { |n| "Display Name #{n}" } + data_option_new { {} } + editable { true } + active { true } + add_attribute(:to_create) { true } + to_migrate { true } + to_delete { false } + to_config { false } + position { 15 } + updated_by_id { 1 } + created_by_id { 1 } + screens do { 'create_top' => { '-all-' => { @@ -29,17 +23,10 @@ FactoryBot.define do 'edit' => {} } end - add_attribute(:to_create) { true } - to_migrate true - to_delete false - to_config false - position 15 - updated_by_id 1 - created_by_id 1 end factory :object_manager_attribute_text, parent: :object_manager_attribute do - data_type 'input' + data_type { 'input' } data_option do { 'type' => 'text', @@ -54,7 +41,7 @@ FactoryBot.define do end factory :object_manager_attribute_integer, parent: :object_manager_attribute do - data_type 'integer' + data_type { 'integer' } data_option do { 'default' => 0, @@ -65,8 +52,8 @@ FactoryBot.define do end factory :object_manager_attribute_date, parent: :object_manager_attribute do - name 'date_attribute' - data_type 'date' + name { 'date_attribute' } + data_type { 'date' } data_option do { 'diff' => 24, @@ -76,8 +63,8 @@ FactoryBot.define do end factory :object_manager_attribute_datetime, parent: :object_manager_attribute do - name 'datetime_attribute' - data_type 'datetime' + name { 'datetime_attribute' } + data_type { 'datetime' } data_option do { 'future' => true, @@ -89,7 +76,7 @@ FactoryBot.define do end factory :object_manager_attribute_select, parent: :object_manager_attribute do - data_type 'select' + data_type { 'select' } data_option do { 'default' => '', @@ -109,7 +96,7 @@ FactoryBot.define do end factory :object_manager_attribute_tree_select, parent: :object_manager_attribute do - data_type 'tree_select' + data_type { 'tree_select' } data_option do { 'options' => [ @@ -244,7 +231,7 @@ FactoryBot.define do } end - edit do + edit do { 'ticket.customer' => { shown: true, diff --git a/spec/factories/postmaster_filter.rb b/spec/factories/postmaster_filter.rb index 5b41a890c..6bb15f77f 100644 --- a/spec/factories/postmaster_filter.rb +++ b/spec/factories/postmaster_filter.rb @@ -1,11 +1,11 @@ FactoryBot.define do factory :postmaster_filter do sequence(:name) { |n| "Test PostmasterFilter #{n}" } - channel 'email' - match { { 'from' => { 'operator' => 'contains', 'value' => 'a' } } } - perform { { 'x-zammad-ticket-tags' => { 'operator' => 'remove', 'value' => 'test2, test7' } } } - active true - created_by_id 1 - updated_by_id 1 + channel { 'email' } + match { { 'from' => { 'operator' => 'contains', 'value' => 'a' } } } + perform { { 'x-zammad-ticket-tags' => { 'operator' => 'remove', 'value' => 'test2, test7' } } } + active { true } + created_by_id { 1 } + updated_by_id { 1 } end end diff --git a/spec/factories/role.rb b/spec/factories/role.rb index fe7d9b8e0..ca056a213 100644 --- a/spec/factories/role.rb +++ b/spec/factories/role.rb @@ -1,14 +1,8 @@ -FactoryBot.define do - sequence :test_role_name do |n| - "TestRole#{n}" - end -end - FactoryBot.define do factory :role do - name { generate(:test_role_name) } - created_by_id 1 - updated_by_id 1 + sequence(:name) { |n| "TestRole#{n}" } + created_by_id { 1 } + updated_by_id { 1 } factory :agent_role do permissions { Permission.where(name: 'ticket.agent') } diff --git a/spec/factories/scheduler.rb b/spec/factories/scheduler.rb index 5f2cc2e36..924540230 100644 --- a/spec/factories/scheduler.rb +++ b/spec/factories/scheduler.rb @@ -1,25 +1,18 @@ FactoryBot.define do - sequence :test_scheduler_name do |n| - "Testscheduler#{n}" - end -end - -FactoryBot.define do - factory :scheduler do - name { generate(:test_scheduler_name) } - last_run { Time.zone.now } - pid 1337 - prio 1 - status 'ok' - active true - period { 10.minutes } - running false - note 'test' - updated_by_id 1 - created_by_id 1 - created_at 1 - updated_at 1 + sequence(:name) { |n| "Testscheduler#{n}" } + last_run { Time.zone.now } + pid { 1337 } + prio { 1 } + status { 'ok' } + active { true } + period { 10.minutes } + running { false } + note { 'test' } + updated_by_id { 1 } + created_by_id { 1 } + created_at { 1 } + updated_at { 1 } add_attribute(:method) { 'test' } end end diff --git a/spec/factories/signature.rb b/spec/factories/signature.rb index 296992c1c..ca9bcb4f0 100644 --- a/spec/factories/signature.rb +++ b/spec/factories/signature.rb @@ -1,14 +1,8 @@ -FactoryBot.define do - sequence :test_signature_name do |n| - "Test signature #{n}" - end -end - FactoryBot.define do factory :signature do - name { generate(:test_signature_name) } - body '#{user.firstname} #{user.lastname}'.text2html # rubocop:disable Lint/InterpolationCheck - created_by_id 1 - updated_by_id 1 + sequence(:name) { |n| "Test signature #{n}" } + body { '#{user.firstname} #{user.lastname}'.text2html } # rubocop:disable Lint/InterpolationCheck + created_by_id { 1 } + updated_by_id { 1 } end end diff --git a/spec/factories/taskbar.rb b/spec/factories/taskbar.rb index a78034e0b..0ac816f30 100644 --- a/spec/factories/taskbar.rb +++ b/spec/factories/taskbar.rb @@ -1,13 +1,11 @@ FactoryBot.define do factory :taskbar do - client_id 123 - key 'Ticket-1234' + client_id { 123 } + key { 'Ticket-1234' } add_attribute(:callback) { 'TicketZoom' } - params do - {} - end - state {} - prio 1 - notify false + params { {} } + state {} + prio { 1 } + notify { false } end end diff --git a/spec/factories/ticket.rb b/spec/factories/ticket.rb index 7511eec3f..7a1dc754f 100644 --- a/spec/factories/ticket.rb +++ b/spec/factories/ticket.rb @@ -1,13 +1,14 @@ FactoryBot.define do factory :ticket do transient do - state_name 'new' - priority_name '2 normal' + state_name { 'new' } + priority_name { '2 normal' } end - title { 'Test Ticket' } - group + association :group, strategy: :create # or else build(:ticket).save fails + customer + title { 'Test Ticket' } state { Ticket::State.lookup(name: state_name) } priority { Ticket::Priority.lookup(name: priority_name) } updated_by_id { 1 } diff --git a/spec/factories/ticket/article.rb b/spec/factories/ticket/article.rb index 8d279614e..3f6ea34b9 100644 --- a/spec/factories/ticket/article.rb +++ b/spec/factories/ticket/article.rb @@ -5,7 +5,7 @@ FactoryBot.define do sender_name { 'Customer' } end - ticket + association :ticket, strategy: :create # or else build(:ticket_article).save fails from { 'factory-customer-1@example.com' } to { 'factory-customer-1@example.com' } subject { 'factory article' } diff --git a/spec/factories/ticket/priority.rb b/spec/factories/ticket/priority.rb index ea392e38c..bd7aef859 100644 --- a/spec/factories/ticket/priority.rb +++ b/spec/factories/ticket/priority.rb @@ -1,10 +1,7 @@ FactoryBot.define do factory :'ticket/priority', aliases: %i[ticket_priority] do - sequence :name do |n| - "#{n} urgent" - end - - updated_by_id { 1 } - created_by_id { 1 } + sequence(:name) { |n| "#{n} urgent" } + updated_by_id { 1 } + created_by_id { 1 } end end diff --git a/spec/factories/ticket/time_accounting.rb b/spec/factories/ticket/time_accounting.rb index faca6270f..25873d817 100644 --- a/spec/factories/ticket/time_accounting.rb +++ b/spec/factories/ticket/time_accounting.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :'ticket/time_accounting', aliases: %i[ticket_time_accounting] do ticket - time_unit { rand(100) } - created_by_id 1 + time_unit { rand(100) } + created_by_id { 1 } trait :for_article do ticket_article { create(:'ticket/article', ticket: ticket) } diff --git a/spec/factories/translation.rb b/spec/factories/translation.rb index c1d65b86f..fdafd3c83 100644 --- a/spec/factories/translation.rb +++ b/spec/factories/translation.rb @@ -1,9 +1,9 @@ FactoryBot.define do factory :translation do - locale 'de-de' - source 'date' - target 'dd/mm/yyyy' - created_by_id 1 - updated_by_id 1 + locale { 'de-de' } + source { 'date' } + target { 'dd/mm/yyyy' } + created_by_id { 1 } + updated_by_id { 1 } end end diff --git a/spec/factories/user_device.rb b/spec/factories/user_device.rb index 3ead8bc55..3f9889156 100644 --- a/spec/factories/user_device.rb +++ b/spec/factories/user_device.rb @@ -1,18 +1,10 @@ FactoryBot.define do - sequence :fingerprint do |n| - "fingerprint#{n}" - end -end - -FactoryBot.define do - factory :user_device do - user_id 1 - name 'test 1' - location 'some location' - user_agent 'some user agent' - ip '127.0.0.1' - fingerprint { generate(:fingerprint) } + user_id { 1 } + name { 'test 1' } + location { 'some location' } + user_agent { 'some user agent' } + ip { '127.0.0.1' } + sequence(:fingerprint) { |n| "fingerprint#{n}" } end - end diff --git a/spec/factories/vendor/net/ldap/entry.rb b/spec/factories/vendor/net/ldap/entry.rb index 5dc4fa729..e2972014d 100644 --- a/spec/factories/vendor/net/ldap/entry.rb +++ b/spec/factories/vendor/net/ldap/entry.rb @@ -4,8 +4,6 @@ FactoryBot.define do # mocked_entry = build(:ldap_entry) # mocked_entry['attr'] = [value, another_value] factory :ldap_entry, class: Net::LDAP::Entry do - initialize_with do - new('dc=com') - end + initialize_with { new('dc=com') } end end diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index f638ac45d..01f501045 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -40,7 +40,7 @@ RSpec.describe Ticket, type: :model do it 'returns a list of unique tickets (i.e., no duplicates)' do expect(Ticket.selectors(condition, limit: 100, access: 'full')) - .to match_array([2, tickets]) + .to match_array([2, tickets.to_a]) end end end