From 1834f77ee69ad1a8abda5fcf83a54aa7b7d67bce Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 30 Nov 2015 14:29:23 +0100 Subject: [PATCH] Applied new rubocop. --- app/controllers/channels_controller.rb | 6 +++--- app/controllers/sessions_controller.rb | 2 +- app/models/calendar.rb | 2 +- app/models/job.rb | 2 +- app/models/online_notification.rb | 2 +- lib/service/geo_calendar/zammad.rb | 2 +- lib/sessions/backend/rss.rb | 2 +- test/unit/organization_ref_object_touch_test.rb | 8 ++++---- test/unit/ticket_ref_object_touch_test.rb | 16 ++++++++-------- test/unit/token_test.rb | 4 ++-- test/unit/user_ref_object_touch_test.rb | 8 ++++---- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index 259ab597e..08d805fde 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -119,7 +119,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten return if deny_if_not_role(Z_ROLENAME_ADMIN) # verify access - return if !check_access(params[:channel_id]) if params[:channel_id] + return if params[:channel_id] && !check_access(params[:channel_id]) # connection test render json: EmailHelper::Probe.outbound(params, params[:email]) @@ -131,7 +131,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten return if deny_if_not_role(Z_ROLENAME_ADMIN) # verify access - return if !check_access(params[:channel_id]) if params[:channel_id] + return if params[:channel_id] && !check_access(params[:channel_id]) # connection test result = EmailHelper::Probe.inbound(params) @@ -152,7 +152,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten channel_id = params[:channel_id] # verify access - return if !check_access(channel_id) if channel_id + return if channel_id && !check_access(channel_id) # check account duplicate return if email_account_duplicate?({ setting: { inbound: params[:inbound] } }, channel_id) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 82708c8b9..9ffee73f9 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -119,7 +119,7 @@ class SessionsController < ApplicationController @_current_user = session[:user_id] = nil # reset session cookie (reset :expire_after in case remember_me is active) - request.env['rack.session.options'][:expire_after] = -1.year + request.env['rack.session.options'][:expire_after] = -1.years request.env['rack.session.options'][:renew] = true render json: {} diff --git a/app/models/calendar.rb b/app/models/calendar.rb index ffe2aa068..5bbd3ee7b 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -275,7 +275,7 @@ returns events = {} cal.events.each {|event| next if event.dtstart < Time.zone.now - 1.year - next if event.dtstart > Time.zone.now + 3.year + next if event.dtstart > Time.zone.now + 3.years day = "#{event.dtstart.year}-#{format('%02d', event.dtstart.month)}-#{format('%02d', event.dtstart.day)}" comment = event.summary || event.description comment = Encode.conv( 'utf8', comment.to_s.force_encoding('utf-8') ) diff --git a/app/models/job.rb b/app/models/job.rb index f742675bc..2e0b50321 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -26,7 +26,7 @@ class Job < ApplicationModel jobs.each do |job| # only execute jobs, older then 1 min, to give admin posibility to change - next if job.updated_at > Time.zone.now - 1.minutes + next if job.updated_at > Time.zone.now - 1.minute # check if jobs need to be executed # ignore if job was running within last 10 min. diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index bca01059b..1cdd7e52b 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -190,7 +190,7 @@ cleanup old online notifications def self.cleanup OnlineNotification.where('created_at < ?', Time.zone.now - 6.months).delete_all OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 4.hours).delete_all - OnlineNotification.where('seen = ? AND updated_at < ?', true, Time.zone.now - 1.hours).delete_all + OnlineNotification.where('seen = ? AND updated_at < ?', true, Time.zone.now - 1.hour).delete_all # notify all agents User.of_role('Agent').each {|user| diff --git a/lib/service/geo_calendar/zammad.rb b/lib/service/geo_calendar/zammad.rb index 602203e9b..3df78e7f1 100644 --- a/lib/service/geo_calendar/zammad.rb +++ b/lib/service/geo_calendar/zammad.rb @@ -37,7 +37,7 @@ class Service::GeoCalendar::Zammad Cache.write( cache_key, data, { expires_in: 30.minutes } ) rescue => e Rails.logger.error "#{host}#{url}: #{e.inspect}" - Cache.write( cache_key, data, { expires_in: 1.minutes } ) + Cache.write( cache_key, data, { expires_in: 1.minute } ) end data end diff --git a/lib/sessions/backend/rss.rb b/lib/sessions/backend/rss.rb index f6f3e9835..d43485c49 100644 --- a/lib/sessions/backend/rss.rb +++ b/lib/sessions/backend/rss.rb @@ -23,7 +23,7 @@ class Sessions::Backend::Rss rss_items = Rss.fetch( url, 8 ) # set new timeout - Sessions::CacheIn.set( collection_key, rss_items, { expires_in: 1.hours } ) + Sessions::CacheIn.set( collection_key, rss_items, { expires_in: 1.hour } ) rss_items end diff --git a/test/unit/organization_ref_object_touch_test.rb b/test/unit/organization_ref_object_touch_test.rb index 4b7727348..02acd2718 100644 --- a/test/unit/organization_ref_object_touch_test.rb +++ b/test/unit/organization_ref_object_touch_test.rb @@ -82,14 +82,14 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase # check if ticket and customer has been touched ticket = Ticket.find(ticket.id) - if ticket.updated_at > 4.second.ago + if ticket.updated_at > 4.seconds.ago assert( true, 'ticket.updated_at has been updated' ) else assert( false, 'ticket.updated_at has not been updated' ) end customer1 = User.find(customer1.id) - if customer1.updated_at > 4.second.ago + if customer1.updated_at > 4.seconds.ago assert( true, 'customer1.updated_at has been updated' ) else assert( false, 'customer1.updated_at has not been updated' ) @@ -102,14 +102,14 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase # check if customer1 and organization has been touched customer1 = User.find(customer1.id) - if customer1.updated_at > 4.second.ago + if customer1.updated_at > 4.seconds.ago assert( true, 'customer1.updated_at has been updated' ) else assert( false, 'customer1.updated_at has not been updated' ) end organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( true, 'organization1.updated_at has been updated' ) else assert( false, 'organization1.updated_at has not been updated' ) diff --git a/test/unit/ticket_ref_object_touch_test.rb b/test/unit/ticket_ref_object_touch_test.rb index 23af3da11..170f0448b 100644 --- a/test/unit/ticket_ref_object_touch_test.rb +++ b/test/unit/ticket_ref_object_touch_test.rb @@ -71,14 +71,14 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase # check if customer and organization has been touched customer1 = User.find(customer1.id) - if customer1.updated_at > 4.second.ago + if customer1.updated_at > 4.seconds.ago assert( true, 'customer1.updated_at has been updated' ) else assert( false, 'customer1.updated_at has not been updated' ) end organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( true, 'organization1.updated_at has been updated' ) else assert( false, 'organization1.updated_at has not been updated' ) @@ -91,14 +91,14 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase # check if customer and organization has been touched customer1 = User.find(customer1.id) - if customer1.updated_at > 4.second.ago + if customer1.updated_at > 4.seconds.ago assert( true, 'customer1.updated_at has been updated' ) else assert( false, 'customer1.updated_at has not been updated' ) end organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( true, 'organization1.updated_at has been updated' ) else assert( false, 'organization1.updated_at has not been updated' ) @@ -124,14 +124,14 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase # check if customer and organization has been touched customer2 = User.find(customer2.id) - if customer2.updated_at > 4.second.ago + if customer2.updated_at > 4.seconds.ago assert( true, 'customer2.updated_at has been updated' ) else assert( false, 'customer2.updated_at has not been updated' ) end organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( false, 'organization1.updated_at has been updated' ) else assert( true, 'organization1.updated_at has not been updated' ) @@ -144,14 +144,14 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase # check if customer and organization has been touched customer2 = User.find(customer2.id) - if customer2.updated_at > 4.second.ago + if customer2.updated_at > 4.seconds.ago assert( true, 'customer2.updated_at has been updated' ) else assert( false, 'customer2.updated_at has not been updated' ) end organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( false, 'organization1.updated_at has been updated' ) else assert( true, 'organization1.updated_at has not been updated' ) diff --git a/test/unit/token_test.rb b/test/unit/token_test.rb index 3e83355e1..9b483c019 100644 --- a/test/unit/token_test.rb +++ b/test/unit/token_test.rb @@ -37,7 +37,7 @@ class TokenTest < ActiveSupport::TestCase create: { user_id: 2, action: 'PasswordReset', - created_at: 2.day.ago, + created_at: 2.days.ago, }, action: 'PasswordReset', result: nil, @@ -48,7 +48,7 @@ class TokenTest < ActiveSupport::TestCase create: { user_id: 2, action: 'iCal', - created_at: 2.day.ago, + created_at: 2.days.ago, persistent: true, }, action: 'iCal', diff --git a/test/unit/user_ref_object_touch_test.rb b/test/unit/user_ref_object_touch_test.rb index c97eb380e..d13354220 100644 --- a/test/unit/user_ref_object_touch_test.rb +++ b/test/unit/user_ref_object_touch_test.rb @@ -76,7 +76,7 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase # check if organization has been touched organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( true, 'organization1.updated_at has been updated' ) else assert( false, 'organization1.updated_at has not been updated' ) @@ -89,21 +89,21 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase # check if customer1, customer2 and organization has been touched customer1 = User.find(customer1.id) - if customer1.updated_at > 4.second.ago + if customer1.updated_at > 4.seconds.ago assert( true, 'customer1.updated_at has been updated' ) else assert( false, 'customer1.updated_at has not been updated' ) end customer2 = User.find(customer2.id) - if customer2.updated_at > 4.second.ago + if customer2.updated_at > 4.seconds.ago assert( true, 'customer2.updated_at has been updated' ) else assert( false, 'customer2.updated_at has not been updated' ) end organization1 = Organization.find(organization1.id) - if organization1.updated_at > 4.second.ago + if organization1.updated_at > 4.seconds.ago assert( true, 'organization1.updated_at has been updated' ) else assert( false, 'organization1.updated_at has not been updated' )