diff --git a/.gitignore b/.gitignore index a76e9d47d..9f25704b1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,6 @@ # Ignore local database settings /config/database.yml -Gemfile.lock - # Ignore mac stuff .DS_Store diff --git a/.rubocop.yml b/.rubocop.yml index 2b6e174b9..35e39b606 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -196,3 +196,7 @@ Style/Documentation: Lint/UselessAssignment: Enabled: false + +Style/ExtraSpacing: + Description: 'Do not use unnecessary spacing.' + Enabled: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..3986f0b50 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,314 @@ +GEM + remote: http://rubygems.org/ + specs: + actionmailer (4.1.10) + actionpack (= 4.1.10) + actionview (= 4.1.10) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.10) + actionview (= 4.1.10) + activesupport (= 4.1.10) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.10) + activesupport (= 4.1.10) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.10) + activesupport (= 4.1.10) + builder (~> 3.1) + activerecord (4.1.10) + activemodel (= 4.1.10) + activesupport (= 4.1.10) + arel (~> 5.0.0) + activerecord-session_store (0.1.1) + actionpack (>= 4.0.0, < 5) + activerecord (>= 4.0.0, < 5) + railties (>= 4.0.0, < 5) + activesupport (4.1.10) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + addressable (2.3.8) + arel (5.0.1.20140414130214) + ast (2.1.0) + astrolabe (1.3.1) + parser (~> 2.2) + autoprefixer-rails (5.2.1.2) + execjs + json + browser (0.9.1) + buftok (0.2.0) + builder (3.2.2) + childprocess (0.5.6) + ffi (~> 1.0, >= 1.0.11) + coderay (1.1.0) + coffee-rails (4.1.0) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.9.1.1) + daemons (1.2.3) + delayed_job (4.0.6) + activesupport (>= 3.0, < 5.0) + delayed_job_active_record (4.0.3) + activerecord (>= 3.0, < 5.0) + delayed_job (>= 3.0, < 4.1) + docile (1.1.5) + eco (1.0.0) + coffee-script + eco-source + execjs + eco-source (1.1.0.rc.1) + em-websocket (0.5.1) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0.6.0) + equalizer (0.0.11) + erubis (2.7.0) + eventmachine (1.0.8) + execjs (2.6.0) + faraday (0.9.1) + multipart-post (>= 1.2, < 3) + ffi (1.9.10) + formatador (0.2.5) + guard (2.13.0) + formatador (>= 0.2.4) + listen (>= 2.7, <= 4.0) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-livereload (2.4.0) + em-websocket (~> 0.5) + guard (~> 2.8) + multi_json (~> 1.8) + hashie (3.4.2) + hike (1.2.3) + http (0.6.4) + http_parser.rb (~> 0.6.0) + http_parser.rb (0.6.0) + i18n (0.7.0) + icalendar (2.3.0) + json (1.8.3) + jwt (1.5.1) + koala (2.2.0) + addressable + faraday + multi_json + libv8 (3.16.14.11) + listen (3.0.3) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.9) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + memoizable (0.4.2) + thread_safe (~> 0.3, >= 0.3.1) + method_source (0.8.2) + mime-types (1.25.1) + minitest (5.8.0) + multi_json (1.11.2) + multi_xml (0.5.5) + multipart-post (2.0.0) + mysql2 (0.3.19) + naught (1.0.0) + nenv (0.2.0) + net-ldap (0.11) + notiffany (0.0.7) + nenv (~> 0.1) + shellany (~> 0.0) + oauth (0.4.7) + oauth2 (1.0.0) + faraday (>= 0.8, < 0.10) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (~> 1.2) + omniauth (1.2.2) + hashie (>= 1.2, < 4) + rack (~> 1.0) + omniauth-facebook (2.0.1) + omniauth-oauth2 (~> 1.2) + omniauth-google-oauth2 (0.2.6) + omniauth (> 1.0) + omniauth-oauth2 (~> 1.1) + omniauth-linkedin (0.2.0) + omniauth-oauth (~> 1.0) + omniauth-oauth (1.1.0) + oauth + omniauth (~> 1.0) + omniauth-oauth2 (1.3.1) + oauth2 (~> 1.0) + omniauth (~> 1.2) + omniauth-twitter (1.2.1) + json (~> 1.3) + omniauth-oauth (~> 1.1) + parser (2.2.2.6) + ast (>= 1.1, < 3.0) + polyglot (0.3.5) + power_assert (0.2.4) + powerpack (0.1.1) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + puma (2.13.4) + rack (1.5.5) + rack-livereload (0.3.16) + rack + rack-test (0.6.3) + rack (>= 1.0) + rails (4.1.10) + actionmailer (= 4.1.10) + actionpack (= 4.1.10) + actionview (= 4.1.10) + activemodel (= 4.1.10) + activerecord (= 4.1.10) + activesupport (= 4.1.10) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.10) + sprockets-rails (~> 2.0) + rails-observers (0.1.2) + activemodel (~> 4.0) + railties (4.1.10) + actionpack (= 4.1.10) + activesupport (= 4.1.10) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rainbow (2.0.0) + rake (10.4.2) + rb-fsevent (0.9.5) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + ref (2.0.0) + rubocop (0.33.0) + astrolabe (~> 1.3) + parser (>= 2.2.2.5, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.4) + ruby-progressbar (1.7.5) + rubyzip (1.1.7) + sass (3.4.16) + sass-rails (5.0.3) + railties (>= 4.0.0, < 5.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (~> 1.1) + selenium-webdriver (2.47.1) + childprocess (~> 0.5) + multi_json (~> 1.0) + rubyzip (~> 1.0) + websocket (~> 1.0) + shellany (0.0.1) + simple-rss (1.3.1) + simple_oauth (0.3.1) + simplecov (0.10.0) + docile (~> 1.1.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) + simplecov-rcov (0.2.3) + simplecov (>= 0.4.1) + slop (3.6.0) + spring (1.3.6) + sprockets (2.12.4) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.3.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + sqlite3 (1.3.10) + test-unit (3.1.3) + power_assert + therubyracer (0.12.2) + libv8 (~> 3.16.14.0) + ref + thor (0.19.1) + thread_safe (0.3.5) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + twitter (5.13.0) + addressable (~> 2.3) + buftok (~> 0.2.0) + equalizer (~> 0.0.9) + faraday (~> 0.9.0) + http (~> 0.6.0) + http_parser.rb (~> 0.6.0) + json (~> 1.8) + memoizable (~> 0.4.0) + naught (~> 1.0) + simple_oauth (~> 0.3.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.7.1) + execjs (>= 0.3.0) + json (>= 1.8.0) + websocket (1.2.2) + writeexcel (1.0.5) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord-session_store + autoprefixer-rails (>= 5.2) + browser + coffee-rails + coffee-script-source + daemons + delayed_job_active_record + eco + em-websocket + eventmachine + execjs + guard (>= 2.2.2) + guard-livereload + icalendar + json + koala + libv8 + mail (~> 2.5.0) + mime-types + mysql2 + net-ldap + omniauth + omniauth-facebook + omniauth-google-oauth2 + omniauth-linkedin + omniauth-twitter + puma + rack-livereload + rails (= 4.1.10) + rails-observers + rb-fsevent + rubocop + sass-rails + selenium-webdriver + simple-rss + simplecov + simplecov-rcov + spring + sprockets (~> 2.0) + sqlite3 + test-unit + therubyracer + twitter (~> 5.13.0) + uglifier + writeexcel + +BUNDLED WITH + 1.10.5 diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 0fa3af35c..25946bf47 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -34,7 +34,7 @@ class SearchController < ApplicationController next if !preferences objects_in_order_hash[preferences[:prio]] = object } - objects_in_order_hash.keys.sort.reverse.each {|prio| + objects_in_order_hash.keys.sort.reverse_each {|prio| objects_in_order.push objects_in_order_hash[prio] } diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index 1eb8448a1..ec008f731 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -68,7 +68,7 @@ returns # fallback do sql query # - stip out * we already search for *query* - - query.gsub! '*', '' + query.delete! '*', '' organizations = Organization.where( 'name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%" ).order('name').limit(limit) diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb index 4087738f3..955743154 100644 --- a/app/models/ticket/search.rb +++ b/app/models/ticket/search.rb @@ -146,7 +146,7 @@ returns # do query # - stip out * we already search for *query* - if query - query.gsub! '*', '' + query.delete! '*', '' tickets_all = Ticket.select('DISTINCT(tickets.id)') .where(access_condition) .where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ) diff --git a/app/models/user/search.rb b/app/models/user/search.rb index 54db73abe..59f2a6bc6 100644 --- a/app/models/user/search.rb +++ b/app/models/user/search.rb @@ -68,7 +68,7 @@ returns # fallback do sql query # - stip out * we already search for *query* - - query.gsub! '*', '' + query.delete! '*', '' if params[:role_ids] users = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where( '(users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%", diff --git a/app/models/user_device.rb b/app/models/user_device.rb index 858d7813e..094597c17 100644 --- a/app/models/user_device.rb +++ b/app/models/user_device.rb @@ -46,7 +46,7 @@ store device for user end # get browser details - browser = Browser.new(:ua => user_agent, :accept_language => 'en-us') + browser = Browser.new(ua: user_agent, accept_language: 'en-us') browser = { plattform: browser.platform.to_s.camelize, name: browser.name, @@ -73,7 +73,7 @@ store device for user end # check if exists - user_device = self.find_by( + user_device = find_by( user_id: user_id, os: browser[:plattform], browser: browser[:name], @@ -85,7 +85,7 @@ store device for user end # create new device - user_device = self.create( + user_device = create( user_id: user_id, name: name, os: browser[:plattform], @@ -120,7 +120,7 @@ log user device action =end - def self.action(user_device_id, user_agent, ip, user_id) + def self.action(user_device_id, _user_agent, ip, _user_id) user_device = UserDevice.find(user_device_id) # update location if needed diff --git a/config/database.yml.dist b/config/database.yml.dist index a86d68e41..70dc993dc 100644 --- a/config/database.yml.dist +++ b/config/database.yml.dist @@ -21,14 +21,13 @@ development: # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' test: - adapter: sqlite3 - database: db/test.sqlite3 - timeout: 5000 + adapter: mysql2 + database: zammad_test pool: 50 + timeout: 5000 + encoding: utf8 + username: some_user + password: some_pass + host: 127.0.0.1 diff --git a/lib/calendar_subscriptions/tickets.rb b/lib/calendar_subscriptions/tickets.rb index fe0d70fb6..ec74342d8 100644 --- a/lib/calendar_subscriptions/tickets.rb +++ b/lib/calendar_subscriptions/tickets.rb @@ -120,10 +120,8 @@ class CalendarSubscriptions::Tickets translated_state = Translation.translate(user_locale, ticket.state.name) - # rubocop:disable Rails/TimeZone event_data[:dtstart] = Icalendar::Values::DateTime.new( pending_time ) event_data[:dtend] = Icalendar::Values::DateTime.new( pending_time ) - # rubocop:enable Rails/TimeZone event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'" event_data[:description] = "T##{ticket.number}" @@ -162,10 +160,8 @@ class CalendarSubscriptions::Tickets escalation_time = Time.zone.today end - # rubocop:disable Rails/TimeZone event_data[:dtstart] = Icalendar::Values::DateTime.new( escalation_time ) event_data[:dtend] = Icalendar::Values::DateTime.new( escalation_time ) - # rubocop:enable Rails/TimeZone event_data[:summary] = "#{translated_ticket_escalation}: '#{ticket.title}'" event_data[:description] = "T##{ticket.number}" diff --git a/lib/models.rb b/lib/models.rb index c798a9aaa..ea73526a1 100644 --- a/lib/models.rb +++ b/lib/models.rb @@ -64,7 +64,7 @@ returns def self.searchable models = [] - all.each {|model_class, options| + all.each {|model_class, _options| next if !model_class next if !model_class.respond_to? :search_preferences models.push model_class diff --git a/lib/sessions.rb b/lib/sessions.rb index b0d38a3af..edc421a57 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -1,5 +1,3 @@ -# rubocop:disable Rails/TimeZone - require 'json' require 'session_helper' diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb index 187ff0269..41dd5d2dc 100644 --- a/lib/sessions/backend/collections/base.rb +++ b/lib/sessions/backend/collections/base.rb @@ -1,7 +1,7 @@ class Sessions::Backend::Collections::Base class << self; attr_accessor :model, :roles, :not_roles end - def initialize( user, client = nil, client_id = nil, ttl ) + def initialize( user, client, client_id, ttl ) @user = user @client = client @client_id = client_id diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index 5c99190a2..e563a05e2 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -23,10 +23,10 @@ put working hours matrix and timezone in function, returns UTC working hours mat if timezone begin time_diff = Time.zone.parse(start_time.to_s).in_time_zone(timezone).utc_offset - rescue => e - Rails.logger.error "Can't fine tomezone #{timezone}" - Rails.logger.error e.inspect - Rails.logger.error e.backtrace + rescue => e + Rails.logger.error "Can't fine tomezone #{timezone}" + Rails.logger.error e.inspect + Rails.logger.error e.backtrace end end beginning_of_workday = Time.zone.parse("1977-10-27 #{config['beginning_of_workday']}") diff --git a/lib/user_agent.rb b/lib/user_agent.rb index ba091cca8..40095986e 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -402,7 +402,8 @@ returns end def success? - @success + return true if @success + false end end end diff --git a/script/websocket-server.rb b/script/websocket-server.rb index c2b3184b8..46d69399a 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -1,6 +1,5 @@ #!/usr/bin/env ruby # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ -# rubocop:disable Rails/TimeZone $LOAD_PATH << './lib' require 'rubygems' diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb index 760241ae4..ebe6e18b8 100644 --- a/test/controllers/search_controller_test.rb +++ b/test/controllers/search_controller_test.rb @@ -452,5 +452,4 @@ class SearchControllerTest < ActionDispatch::IntegrationTest end - end diff --git a/test/unit/user_device_test.rb b/test/unit/user_device_test.rb index 7dcc758de..33975e783 100644 --- a/test/unit/user_device_test.rb +++ b/test/unit/user_device_test.rb @@ -21,7 +21,6 @@ class UserDeviceTest < ActiveSupport::TestCase ) end - test 'session test' do # signin with fingerprint A from country A via session -> new device #1 @@ -198,5 +197,4 @@ class UserDeviceTest < ActiveSupport::TestCase end - end