Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Martin Edenhofer 2016-01-15 20:09:25 +01:00
commit 815666a994
88 changed files with 769 additions and 800 deletions

View file

@ -2,13 +2,15 @@
# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
AllCops:
RunRailsCops: true
Exclude:
- 'bin/rails'
- 'bin/rake'
- 'bin/spring'
- 'db/schema.rb'
Rails:
Enabled: true
# Zammad StyleGuide
Metrics/LineLength:
@ -30,8 +32,13 @@ Style/IfUnlessModifier:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
Enabled: false
Style/TrailingComma:
Description: 'Checks for trailing comma in parameter lists and literals.'
Style/TrailingCommaInLiteral:
Description: 'Checks for trailing comma in array and hash literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false
Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false
@ -47,12 +54,6 @@ Style/SpaceAfterMethodName:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
Enabled: false
Style/SingleSpaceBeforeFirstArg:
Description: >-
Checks that exactly one space is used between a method name
and the first argument for method calls without parentheses.
Enabled: false
Style/LeadingCommentSpace:
Description: 'Comments should start with a space.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'

View file

@ -44,9 +44,7 @@ GEM
addressable (2.4.0)
arel (6.0.3)
ast (2.2.0)
astrolabe (1.3.1)
parser (~> 2.2)
autoprefixer-rails (6.2.3)
autoprefixer-rails (6.3.1)
execjs
json
biz (1.3.3)
@ -58,7 +56,7 @@ GEM
browser (1.1.0)
buftok (0.2.0)
builder (3.2.2)
childprocess (0.5.8)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
clavius (1.0.1)
memoizable (~> 0.4.0)
@ -95,7 +93,7 @@ GEM
http_parser.rb (~> 0.6.0)
equalizer (0.0.10)
erubis (2.7.0)
eventmachine (1.0.8)
eventmachine (1.0.9.1)
execjs (2.6.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
@ -159,7 +157,7 @@ GEM
mysql2 (0.3.20)
naught (1.1.0)
nenv (0.2.0)
net-ldap (0.12.1)
net-ldap (0.13.0)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
notiffany (0.0.8)
@ -177,28 +175,28 @@ GEM
rack (>= 1.0, < 3)
omniauth-facebook (3.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-google-oauth2 (0.2.10)
omniauth-google-oauth2 (0.3.0)
addressable (~> 2.3)
jwt (~> 1.0)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth2 (~> 1.3.1)
omniauth-oauth2 (>= 1.3.1)
omniauth-linkedin (0.2.0)
omniauth-oauth (~> 1.0)
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.3.1)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-twitter (1.2.1)
json (~> 1.3)
omniauth-oauth (~> 1.1)
parser (2.2.3.0)
ast (>= 1.1, < 3.0)
parser (2.3.0.1)
ast (~> 2.2)
pluginator (1.3.0)
polyglot (0.3.5)
power_assert (0.2.6)
power_assert (0.2.7)
powerpack (0.1.1)
pre-commit (0.26.0)
pluginator (~> 1.1)
@ -239,21 +237,19 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
rake (10.4.2)
rake (10.5.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
ref (2.0.0)
rubocop (0.35.1)
astrolabe (~> 1.3)
parser (>= 2.2.3.0, < 3.0)
rubocop (0.36.0)
parser (>= 2.3.0.0, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
tins (<= 1.6.0)
ruby-progressbar (1.7.5)
rubyzip (1.1.7)
sass (3.4.20)
sass (3.4.21)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
@ -261,7 +257,7 @@ GEM
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
scrub_rb (1.0.1)
selenium-webdriver (2.48.1)
selenium-webdriver (2.49.0)
childprocess (~> 0.5)
multi_json (~> 1.0)
rubyzip (~> 1.0)
@ -277,7 +273,7 @@ GEM
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
slop (3.6.0)
spring (1.6.1)
spring (1.6.2)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
@ -293,8 +289,7 @@ GEM
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
tins (1.6.0)
tilt (2.0.2)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)

View file

@ -20,10 +20,10 @@ class SearchController < ApplicationController
# convert objects string into array of class names
# e.g. user-ticket-another_object = %w( User Ticket AnotherObject )
if !params[:objects]
objects = Setting.get('models_searchable')
objects = if !params[:objects]
Setting.get('models_searchable')
else
objects = params[:objects].split('-').map(&:camelize)
params[:objects].split('-').map(&:camelize)
end
# get priorities of result

View file

@ -18,10 +18,8 @@ class SessionsController < ApplicationController
end
# remember me - set session cookie to expire later
if params[:remember_me]
request.env['rack.session.options'][:expire_after] = 1.year
else
request.env['rack.session.options'][:expire_after] = nil
request.env['rack.session.options'][:expire_after] = if params[:remember_me]
1.year
end
# both not needed to set :expire_after works fine
# request.env['rack.session.options'][:renew] = true

View file

@ -93,10 +93,10 @@ class TicketArticlesController < ApplicationController
file = params[:File]
content_type = file.content_type
if !content_type || content_type == 'application/octet-stream'
if MIME::Types.type_for(file.original_filename).first
content_type = MIME::Types.type_for(file.original_filename).first.content_type
content_type = if MIME::Types.type_for(file.original_filename).first
MIME::Types.type_for(file.original_filename).first.content_type
else
content_type = 'application/octet-stream'
'application/octet-stream'
end
end
headers_store = {

View file

@ -15,10 +15,10 @@ class UsersController < ApplicationController
def index
# only allow customer to fetch him self
if role?(Z_ROLENAME_CUSTOMER) && !role?(Z_ROLENAME_ADMIN) && !role?('Agent')
users = User.where( id: current_user.id )
users = if role?(Z_ROLENAME_CUSTOMER) && !role?(Z_ROLENAME_ADMIN) && !role?('Agent')
User.where( id: current_user.id )
else
users = User.all
User.all
end
users_all = []
users.each {|user|
@ -337,10 +337,10 @@ class UsersController < ApplicationController
end
# do query
if params[:role_ids] && !params[:role_ids].empty?
user_all = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where('users.id != 1').order('users.created_at DESC').limit( params[:limit] || 20 )
user_all = if params[:role_ids] && !params[:role_ids].empty?
User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where('users.id != 1').order('users.created_at DESC').limit( params[:limit] || 20 )
else
user_all = User.where('id != 1').order('created_at DESC').limit( params[:limit] || 20 )
User.where('id != 1').order('created_at DESC').limit( params[:limit] || 20 )
end
# build result list

View file

@ -97,12 +97,12 @@ return all activity entries of an user
customer_role = Role.lookup( name: 'Customer' )
return [] if role_ids.include?(customer_role.id)
if group_ids.empty?
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
stream = if group_ids.empty?
ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
.order( 'created_at DESC, id DESC' )
.limit( limit )
else
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
.order( 'created_at DESC, id DESC' )
.limit( limit )
end

View file

@ -142,7 +142,7 @@ returns
attributes = self.attributes
self.class.reflect_on_all_associations.map { |assoc|
real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
if self.respond_to?(real_key)
if respond_to?(real_key)
attributes[ real_key ] = send(real_key)
end
}
@ -230,7 +230,7 @@ returns
end
def cache_update(o)
cache_delete if self.respond_to?('cache_delete')
cache_delete if respond_to?('cache_delete')
o.cache_delete if o.respond_to?('cache_delete')
end
@ -241,7 +241,7 @@ returns
Cache.delete(key)
# delete old name / login caches
if self.changed?
if changed?
if changes.key?('name')
name = changes['name'][0]
key = "#{self.class}::#{name}"
@ -349,9 +349,9 @@ returns
end
}
return
else
fail 'Need name, id or login for lookup()'
end
fail 'Need name, id or login for lookup()'
end
=begin
@ -442,7 +442,7 @@ returns
# do lookup with == to handle case insensitive databases
records = where(login: data[:login])
records.each {|loop_record|
if loop_record.login.downcase == data[:login].downcase
if loop_record.login.casecmp data[:login] == 0
loop_record.update_attributes(data)
return loop_record
end
@ -455,7 +455,7 @@ returns
# do lookup with == to handle case insensitive databases
records = where(email: data[:email])
records.each {|loop_record|
if loop_record.email.downcase == data[:email].downcase
if loop_record.email.casecmp data[:email] == 0
loop_record.update_attributes(data)
return loop_record
end
@ -468,7 +468,7 @@ returns
# do lookup with == to handle case insensitive databases
records = where(locale: data[:locale])
records.each {|loop_record|
if loop_record.locale.downcase == data[:locale].downcase
if loop_record.locale.casecmp data[:locale] == 0
loop_record.update_attributes(data)
return loop_record
end
@ -783,7 +783,7 @@ log object update activity stream, if configured - will be executed automaticall
def activity_stream_update
return if !self.class.activity_stream_support_config
return if !self.changed?
return if !changed?
# default ignored attributes
ignore_attributes = {
@ -872,10 +872,10 @@ log object update history with all updated attributes, if configured - will be e
def history_update
return if !self.class.history_support_config
return if !self.changed?
return if !changed?
# return if it's no update
return if self.new_record?
return if new_record?
# new record also triggers update, so ignore new records
changes = self.changes
@ -921,7 +921,7 @@ log object update history with all updated attributes, if configured - will be e
value_id[0] = value[0]
value_id[1] = value[1]
if self.respond_to?( attribute_name ) && send(attribute_name)
if respond_to?( attribute_name ) && send(attribute_name)
relation_class = send(attribute_name).class
if relation_class && value_id[0]
relation_model = relation_class.lookup( id: value_id[0] )

View file

@ -344,10 +344,10 @@ returns
if public_holidays_was && public_holidays_was[day] && public_holidays_was[day]['feed']
meta['feed'] = public_holidays_was[day]['feed']
end
if meta['active']
meta['active'] = true
meta['active'] = if meta['active']
true
else
meta['active'] = false
false
end
}

View file

@ -40,10 +40,10 @@ module Channel::EmailBuild
next if key.to_s == 'attachments'
next if key.to_s == 'body'
next if key.to_s == 'content_type'
if value && value.class != Array
mail[key.to_s] = value.to_s
mail[key.to_s] = if value && value.class != Array
value.to_s
else
mail[key.to_s] = value
value
end
end

View file

@ -191,10 +191,9 @@ class Channel::EmailParser
end
# not multipart email
else
# text part only
if !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.downcase == 'text/plain'
elsif !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.casecmp('text/plain')
data[:body] = mail.body.decoded
data[:body] = Encode.conv(mail.charset, data[:body])
@ -205,7 +204,7 @@ class Channel::EmailParser
# html part only, convert ot text and add it as attachment
else
filename = '-no name-'
if mail.mime_type.to_s.downcase == 'text/html'
if mail.mime_type.to_s.casecmp('text/html')
filename = 'message.html'
data[:body] = mail.body.decoded
data[:body] = Encode.conv(mail.charset, data[:body])
@ -237,12 +236,11 @@ class Channel::EmailParser
}
data[:attachments].push attachment
end
end
# strip not wanted chars
data[:body].gsub!(/\n\r/, "\n")
data[:body].gsub!(/\r\n/, "\n")
data[:body].gsub!(/\r/, "\n")
data[:body].tr!("\r", "\n")
# remember original mail instance
data[:mail_instance] = mail

View file

@ -29,7 +29,7 @@ class ExternalCredential < ApplicationModel
def self.load_backend(provider)
adapter = "ExternalCredential::#{provider.camelcase}"
require "#{adapter.to_filename}"
require adapter.to_filename.to_s
load_adapter(adapter)
end

View file

@ -165,7 +165,7 @@ returns
history_object_related.id,
requested_object_id,
)
.order('created_at ASC, id ASC') # rubocop:disable Style/MultilineOperationIndentation
.order('created_at ASC, id ASC')
end
asset_list = {}
list = []

View file

@ -83,4 +83,5 @@ class Job < ApplicationModel
minutes.gsub!(/(\d)\d/, '\\1')
minutes.to_s + '0'
end
private_class_method :match_minutes
end

View file

@ -53,11 +53,8 @@ class Observer::Ticket::Notification::BackgroundJob
recipients.each do |user|
# ignore user who changed it by him self
if article
next if article.updated_by_id == user.id
else
next if ticket.updated_by_id == user.id
end
next if article && article.updated_by_id == user.id
next if !article && ticket.updated_by_id == user.id
# ignore inactive users
next if !user.active
@ -217,10 +214,10 @@ class Observer::Ticket::Notification::BackgroundJob
# set new key
display = object_manager_attribute[:display].to_s
end
if object_manager_attribute && object_manager_attribute[:translate]
changes[display] = ["i18n(#{value_str[0]})", "i18n(#{value_str[1]})"]
changes[display] = if object_manager_attribute && object_manager_attribute[:translate]
["i18n(#{value_str[0]})", "i18n(#{value_str[1]})"]
else
changes[display] = [value_str[0].to_s, value_str[1].to_s]
[value_str[0].to_s, value_str[1].to_s]
end
}
changes

View file

@ -117,8 +117,8 @@ return all online notifications of an object
object_lookup_id: object_id,
o_id: o_id,
)
.order( 'created_at DESC, id DESC' ) # rubocop:disable Style/MultilineOperationIndentation
.limit( 10_000 ) # rubocop:disable Style/MultilineOperationIndentation
.order( 'created_at DESC, id DESC' )
.limit( 10_000 )
notifications
end

View file

@ -96,7 +96,7 @@ class Package < ApplicationModel
def self.unlink(package_base_dir)
# check if zpm is a package source repo
package = self._package_base_dir?(package_base_dir)
package = _package_base_dir?(package_base_dir)
# migration down
Package::Migration.migrate( package, 'reverse' )
@ -126,7 +126,7 @@ class Package < ApplicationModel
def self.link(package_base_dir)
# check if zpm is a package source repo
package = self._package_base_dir?(package_base_dir)
package = _package_base_dir?(package_base_dir)
# link files
Dir.glob( package_base_dir + '/**/*' ) do |entry|
@ -337,12 +337,12 @@ class Package < ApplicationModel
end
def self._read_file(file, fullpath = false)
if fullpath == false
location = @@root + '/' + file
location = if fullpath == false
@@root + '/' + file
elsif fullpath == true
location = file
file
else
location = fullpath + '/' + file
fullpath + '/' + file
end
begin

View file

@ -36,12 +36,12 @@ class RecentView < ApplicationModel
end
def self.list( user, limit = 10, type = nil )
if !type
recent_views = RecentView.where( created_by_id: user.id )
recent_views = if !type
RecentView.where( created_by_id: user.id )
.order('created_at DESC, id DESC')
.limit(limit)
else
recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) )
RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) )
.order('created_at DESC, id DESC')
.limit(limit)
end

View file

@ -16,10 +16,10 @@ class Setting < ApplicationModel
@@current = {} # rubocop:disable Style/ClassVars
@@change_id = nil # rubocop:disable Style/ClassVars
@@lookup_at = nil # rubocop:disable Style/ClassVars
if ENV['ZAMMAD_SETTING_TTL']
@@lookup_timeout = ENV['ZAMMAD_SETTING_TTL'].to_i.seconds # rubocop:disable Style/ClassVars
@@lookup_timeout = if ENV['ZAMMAD_SETTING_TTL'] # rubocop:disable Style/ClassVars
ENV['ZAMMAD_SETTING_TTL'].to_i.seconds
else
@@lookup_timeout = 2.minutes # rubocop:disable Style/ClassVars
2.minutes
end
=begin
@ -118,6 +118,7 @@ reload config settings
cache(config)
true
end
private_class_method :load
# set initial value in state_initial
def set_initial
@ -131,6 +132,7 @@ reload config settings
logger.debug "Setting.cache: set cache, #{@@change_id}"
@@lookup_at = Time.zone.now # rubocop:disable Style/ClassVars
end
private_class_method :cache
# reset cache
def reset_cache
@ -156,6 +158,7 @@ reload config settings
logger.debug "Setting.cache_valid?: cache has changed, #{@@change_id}/#{change_id}"
false
end
private_class_method :cache_valid?
# convert state into hash to be able to store it as store
def state_check

View file

@ -46,11 +46,11 @@ read content of a file
def content
adapter = self.class.load_adapter("Store::Provider::#{provider}")
if sha
c = adapter.get( sha )
c = if sha
adapter.get( sha )
else
# fallback until migration is done
c = Store::Provider::DB.find_by( md5: md5 ).data
Store::Provider::DB.find_by( md5: md5 ).data
end
c
end

View file

@ -108,10 +108,10 @@ returns
.map( &:id )
access_condition = [ 'group_id IN (?)', group_ids ]
else
if !user.organization || ( !user.organization.shared || user.organization.shared == false )
access_condition = [ 'tickets.customer_id = ?', user.id ]
access_condition = if !user.organization || ( !user.organization.shared || user.organization.shared == false )
[ 'tickets.customer_id = ?', user.id ]
else
access_condition = [ '( tickets.customer_id = ? OR tickets.organization_id = ? )', user.id, user.organization.id ]
[ '( tickets.customer_id = ? OR tickets.organization_id = ? )', user.id, user.organization.id ]
end
end
access_condition
@ -134,7 +134,7 @@ returns
ticket_states = Ticket::State.where(
state_type_id: Ticket::StateType.find_by( name: 'pending action' ),
)
.where.not(next_state_id: nil) # rubocop:disable Style/MultilineOperationIndentation
.where.not(next_state_id: nil)
return [] if !ticket_states
@ -146,7 +146,7 @@ returns
tickets = where(
state_id: next_state_map.keys,
)
.where( 'pending_time <= ?', Time.zone.now ) # rubocop:disable Style/MultilineOperationIndentation
.where( 'pending_time <= ?', Time.zone.now )
return [] if !tickets

View file

@ -171,11 +171,9 @@ returns
# get close time in min
if close_time
self.close_time_in_min = pending_minutes(created_at, close_time, biz, 'business_minutes')
else
if close_time_escal_date && ((!escalation_time && close_time_escal_date) || close_time_escal_date < escalation_time)
elsif close_time_escal_date && ((!escalation_time && close_time_escal_date) || close_time_escal_date < escalation_time)
self.escalation_time = close_time_escal_date
end
end
# set time to show if sla is raised or not
if sla.solution_time && close_time_in_min
@ -186,7 +184,7 @@ returns
self.escalation_time = nil
end
return if !self.changed?
return if !changed?
self.callback_loop = true
save
@ -279,10 +277,10 @@ returns
end
total_time_in_min = total_time_in_min + diff
if history_item['value_to'] == 'pending reminder'
last_state_is_pending = true
last_state_is_pending = if history_item['value_to'] == 'pending reminder'
true
else
last_state_is_pending = false
false
end
# remember for next loop last state

View file

@ -20,10 +20,10 @@ module Ticket::Number::Date
# increase counter
counter_increment, date_file = counter.content.to_s.split(';')
if date_file == date
counter_increment = counter_increment.to_i + 1
counter_increment = if date_file == date
counter_increment.to_i + 1
else
counter_increment = 1
1
end
# store new counter value

View file

@ -20,10 +20,10 @@ returns
# get customer overviews
if data[:current_user].role?('Customer')
role = Role.find_by( name: 'Customer' )
if data[:current_user].organization_id && data[:current_user].organization.shared
overviews = Overview.where( role_id: role.id, active: true )
overviews = if data[:current_user].organization_id && data[:current_user].organization.shared
Overview.where( role_id: role.id, active: true )
else
overviews = Overview.where( role_id: role.id, organization_shared: false, active: true )
Overview.where( role_id: role.id, organization_shared: false, active: true )
end
return overviews
end

View file

@ -113,24 +113,24 @@ returns
access_condition = {
'query_string' => { 'default_field' => 'Ticket.group.name', 'query' => "\"#{group_condition.join('" OR "')}\"" }
}
query_extention['bool']['must'].push access_condition
else
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
access_condition = {
access_condition = if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
{
'query_string' => { 'default_field' => 'Ticket.customer_id', 'query' => current_user.id }
}
# customer_id: XXX
# conditions = [ 'customer_id = ?', current_user.id ]
else
access_condition = {
{
'query_string' => { 'query' => "Ticket.customer_id:#{current_user.id} OR Ticket.organization_id:#{current_user.organization.id}" }
}
# customer_id: XXX OR organization_id: XXX
# conditions = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ]
end
query_extention['bool']['must'].push access_condition
end
query_extention['bool']['must'].push access_condition
items = SearchIndexBackend.search( query, limit, 'Ticket', query_extention )
if !full
ids = []

View file

@ -175,30 +175,30 @@ get list of translations
'total' => Translation.where(locale: 'de-de').count,
}
list = []
if admin
translations = Translation.where(locale: locale.downcase).order(:source)
translations = if admin
Translation.where(locale: locale.downcase).order(:source)
else
translations = Translation.where(locale: locale.downcase).where.not(target: '').order(:source)
Translation.where(locale: locale.downcase).where.not(target: '').order(:source)
end
translations.each { |item|
if admin
translation_item = [
translation_item = []
translation_item = if admin
[
item.id,
item.source,
item.target,
item.target_initial,
item.format,
]
list.push translation_item
else
translation_item = [
[
item.id,
item.source,
item.target,
item.format,
]
list.push translation_item
end
list.push translation_item
}
data['list'] = list
@ -250,8 +250,10 @@ translate strings in ruby context, e. g. for notifications
def self.cache_set(locale, data)
Cache.write('TranslationMapOnlyContent::' + locale.downcase, data)
end
private_class_method :cache_set
def self.cache_get(locale)
Cache.get('TranslationMapOnlyContent::' + locale.downcase)
end
private_class_method :cache_get
end

View file

@ -124,8 +124,8 @@ returns
roles.each { |role|
if role_name.class == Array
next if !role_name.include?(role.name)
else
next if role.name != role_name
elsif role.name != role_name
next
end
result = true
break

View file

@ -69,12 +69,12 @@ returns
# fallback do sql query
# - stip out * we already search for *query* -
query.delete! '*'
if params[:role_ids]
users = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where(
users = if params[:role_ids]
User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where(
'(users.firstname LIKE ? OR users.lastname LIKE ? OR users.email LIKE ? OR users.login LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%"
).order('firstname').limit(limit)
else
users = User.where(
User.where(
'(firstname LIKE ? OR lastname LIKE ? OR email LIKE ? OR login LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%"
).order('firstname').limit(limit)
end

View file

@ -3,6 +3,6 @@
# Prefix all zammad constants w/ Z_
# Prefix all rolenames with Z_ROLENAME
Z_ROLENAME_ADMIN = 'Admin'
Z_ROLENAME_AGENT = 'Agent'
Z_ROLENAME_CUSTOMER = 'Customer'
Z_ROLENAME_ADMIN = 'Admin'.freeze
Z_ROLENAME_AGENT = 'Agent'.freeze
Z_ROLENAME_CUSTOMER = 'Customer'.freeze

View file

@ -18,10 +18,10 @@ class CreateMacro < ActiveRecord::Migration
Macro.create_or_update(
name: 'Close & Tag as Spam',
perform: {
'ticket.state_id': {
'ticket.state_id' => {
value: Ticket::State.find_by(name: 'closed').id,
},
'ticket.tags': {
'ticket.tags' => {
operator: 'add',
value: 'spam',
},

View file

@ -1644,10 +1644,10 @@ Ticket::Article::Sender.create_if_not_exists( id: 3, name: 'System' )
Macro.create_if_not_exists(
name: 'Close & Tag as Spam',
perform: {
'ticket.state_id': {
'ticket.state_id' => {
value: Ticket::State.find_by(name: 'closed').id,
},
'ticket.tags': {
'ticket.tags' => {
operator: 'add',
value: 'spam',
},

View file

@ -147,11 +147,10 @@ returns
admin_user
end
private
def self.file_location
auto_wizard_file_name = 'auto_wizard.json'
auto_wizard_file_location = "#{Rails.root}/#{auto_wizard_file_name}"
auto_wizard_file_location
end
private_class_method :file_location
end

View file

@ -31,7 +31,7 @@ class String
=end
def to_filename
camel_cased_word = "#{self}"
camel_cased_word = to_s
camel_cased_word.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
@ -48,7 +48,7 @@ class String
=end
def to_classname
camel_cased_word = "#{self}"
camel_cased_word = to_s
camel_cased_word.gsub!(/\.rb$/, '')
camel_cased_word.split('/').map(&:camelize).join('::')
end
@ -65,7 +65,7 @@ class String
end
c
}
.join('') # rubocop:disable Style/MultilineOperationIndentation
.join('')
end
=begin
@ -79,7 +79,7 @@ class String
=end
def html2text(string_only = false)
string = "#{self}"
string = to_s
# in case of invalid encodeing, strip invalid chars
# see also test/fixtures/mail21.box

View file

@ -280,15 +280,15 @@ returns on fail
end
# prepare test email
if subject
mail = {
mail = if subject
{
from: email,
to: email,
subject: "Zammad Getting started Test Email #{subject}",
body: "This is a Test Email of Zammad to check if sending and receiving is working correctly.\n\nYou can ignore or delete this email.",
}
else
mail = {
{
from: email,
to: 'emailtrytest@znuny.com',
subject: 'This is a Test Email',

View file

@ -56,10 +56,10 @@ or
def self.email(params)
# send verify email
if !params[:subject] || params[:subject].empty?
subject = '#' + rand(99_999_999_999).to_s
subject = if !params[:subject] || params[:subject].empty?
'#' + rand(99_999_999_999).to_s
else
subject = params[:subject]
params[:subject]
end
result = EmailHelper::Probe.outbound(params[:outbound], params[:sender], subject)
if result[:result] != 'ok'

View file

@ -11,7 +11,7 @@ module Encode
end
# validate already existing utf8 strings
if charset.downcase == 'utf8' || charset.downcase == 'utf-8'
if charset.casecmp('utf8') || charset.casecmp('utf-8')
begin
# return if encoding is valid

View file

@ -1,6 +1,6 @@
# Monkey-patch HTTP::URI
class HTTP::URI
def port
443 if self.https?
443 if https?
end
end

View file

@ -609,10 +609,10 @@ module Import::OTRS
# find owner
if ticket_new[:owner]
user = User.lookup( login: ticket_new[:owner].downcase )
if user
ticket_new[:owner_id] = user.id
ticket_new[:owner_id] = if user
user.id
else
ticket_new[:owner_id] = 1
1
end
ticket_new.delete(:owner)
end
@ -620,10 +620,10 @@ module Import::OTRS
# find customer
if ticket_new[:customer]
user = User.lookup( login: ticket_new[:customer].downcase )
if user
ticket_new[:customer_id] = user.id
ticket_new[:customer_id] = if user
user.id
else
ticket_new[:customer_id] = 1
1
end
ticket_new.delete(:customer)
else
@ -1345,18 +1345,18 @@ module Import::OTRS
def self._set_valid(record)
# map
if record['ValidID'].to_s == '3'
record['ValidID'] = false
record['ValidID'] = if record['ValidID'].to_s == '3'
false
elsif record['ValidID'].to_s == '2'
record['ValidID'] = false
false
elsif record['ValidID'].to_s == '1'
record['ValidID'] = true
true
elsif record['ValidID'].to_s == '0'
record['ValidID'] = false
false
# fallback
else
record['ValidID'] = true
true
end
end

View file

@ -192,10 +192,10 @@ module Import::Zendesk
def import_field(local_object, zendesk_field)
name = ''
if local_object == 'Ticket'
name = zendesk_field.title
name = if local_object == 'Ticket'
zendesk_field.title
else
name = zendesk_field['key'] # TODO: y?!
zendesk_field['key'] # TODO: y?!
end
@zendesk_ticket_field_mapping ||= {}
@ -512,12 +512,12 @@ module Import::Zendesk
ticket_author = User.find( @zendesk_user_mapping[ zendesk_ticket.requester_id ] )
if ticket_author.role?('Customer')
local_ticket_fields[:create_article_sender_id] = article_sender_customer.id
local_ticket_fields[:create_article_sender_id] = if ticket_author.role?('Customer')
article_sender_customer.id
elsif ticket_author.role?('Agent')
local_ticket_fields[:create_article_sender_id] = article_sender_agent.id
article_sender_agent.id
else
local_ticket_fields[:create_article_sender_id] = article_sender_system.id
article_sender_system.id
end
# TODO: zendesk_ticket.external_id ?
@ -530,19 +530,19 @@ module Import::Zendesk
elsif zendesk_ticket.via.channel == 'twitter'
# TODO
if zendesk_ticket.via.source.rel == 'mention'
local_ticket_fields[:create_article_type_id] = article_type_twitter_status.id
local_ticket_fields[:create_article_type_id] = if zendesk_ticket.via.source.rel == 'mention'
article_type_twitter_status.id
else
local_ticket_fields[:create_article_type_id] = article_type_twitter_dm.id
article_type_twitter_dm.id
end
elsif zendesk_ticket.via.channel == 'facebook'
# TODO
if zendesk_ticket.via.source.rel == 'post'
local_ticket_fields[:create_article_type_id] = article_type_facebook_feed_post.id
local_ticket_fields[:create_article_type_id] = if zendesk_ticket.via.source.rel == 'post'
article_type_facebook_feed_post.id
else
local_ticket_fields[:create_article_type_id] = article_type_facebook_feed_comment.id
article_type_facebook_feed_comment.id
end
end
@ -587,12 +587,12 @@ module Import::Zendesk
article_author = User.find( @zendesk_user_mapping[ zendesk_article.author_id ] )
if article_author.role?('Customer')
local_article_fields[:sender_id] = article_sender_customer.id
local_article_fields[:sender_id] = if article_author.role?('Customer')
article_sender_customer.id
elsif article_author.role?('Agent')
local_article_fields[:sender_id] = article_sender_agent.id
article_sender_agent.id
else
local_article_fields[:sender_id] = article_sender_system.id
article_sender_system.id
end
if zendesk_article.via.channel == 'web'
@ -610,10 +610,10 @@ module Import::Zendesk
local_article_fields[:message_id] = zendesk_article.id
# TODO
if zendesk_article.via.source.rel == 'mention'
local_article_fields[:type_id] = article_type_twitter_status.id
local_article_fields[:type_id] = if zendesk_article.via.source.rel == 'mention'
article_type_twitter_status.id
else
local_article_fields[:type_id] = article_type_twitter_dm.id
article_type_twitter_dm.id
end
elsif zendesk_article.via.channel == 'facebook'
@ -623,10 +623,10 @@ module Import::Zendesk
local_article_fields[:message_id] = zendesk_article.id
# TODO
if zendesk_article.via.source.rel == 'post'
local_article_fields[:type_id] = article_type_facebook_feed_post.id
local_article_fields[:type_id] = if zendesk_article.via.source.rel == 'post'
article_type_facebook_feed_post.id
else
local_article_fields[:type_id] = article_type_facebook_feed_comment.id
article_type_facebook_feed_comment.id
end
end

View file

@ -70,10 +70,10 @@ module NotificationFactory
object_refs = object_refs.html2text.chomp
}
if !value
placeholder = object_refs
placeholder = if !value
object_refs
else
placeholder = value
value
end
end
end

View file

@ -33,8 +33,7 @@ class Report::Base
history_attribute = History::Attribute.lookup( name: params[:attribute] )
if !history_attribute || !history_type
count = 0
else
if params[:id_not_from] && params[:id_to]
elsif params[:id_not_from] && params[:id_to]
return History.select('histories.o_id').joins('INNER JOIN tickets ON tickets.id = histories.o_id')
.where(query, *bind_params).joins(tables)
.where(
@ -97,11 +96,10 @@ class Report::Base
history_attribute.id,
params[:id_to],
).count
else
end
fail "UNKOWN params (#{params.inspect})!"
end
end
end
fail "UNKOWN :type (#{params[:type]})!"
end
@ -281,10 +279,10 @@ class Report::Base
time_min = diff
end
}
if time_min == 0
tickets = -0.001
tickets = if time_min == 0
-0.001
else
tickets = (time_min / 60).to_i
(time_min / 60).to_i
end
{
count: tickets,
@ -319,10 +317,10 @@ class Report::Base
time_max = diff
end
}
if time_max == 0
tickets = -0.001
tickets = if time_max == 0
-0.001
else
tickets = (time_max / 60).to_i
(time_max / 60).to_i
end
{
count: tickets,

View file

@ -155,14 +155,14 @@ return search result
url = build_url()
return if !url
if index
url += if index
if index.class == Array
url += "/#{index.join(',')}/_search"
"/#{index.join(',')}/_search"
else
url += "/#{index}/_search"
"/#{index}/_search"
end
else
url += '/_search'
'/_search'
end
data = {}
data['from'] = 0
@ -274,14 +274,14 @@ get count of tickets and tickets which match on selector
url = build_url()
return if !url
if index
url += if index
if index.class == Array
url += "/#{index.join(',')}/_search"
"/#{index.join(',')}/_search"
else
url += "/#{index}/_search"
"/#{index}/_search"
end
else
url += '/_search'
'/_search'
end
data = selector2query(selectors, current_user, aggs_interval, limit)
@ -444,14 +444,14 @@ return true if backend is configured
return if !SearchIndexBackend.enabled?
index = Setting.get('es_index').to_s + "_#{Rails.env}"
url = Setting.get('es_url')
if type
url = if type
if o_id
url = "#{url}/#{index}/#{type}/#{o_id}"
"#{url}/#{index}/#{type}/#{o_id}"
else
url = "#{url}/#{index}/#{type}"
"#{url}/#{index}/#{type}"
end
else
url = "#{url}/#{index}"
"#{url}/#{index}"
end
url
end

View file

@ -12,10 +12,10 @@ class Service::GeoCalendar::Zammad
# do lookup
host = 'https://geo.zammad.com'
if address
url = "/calendar?ip=#{CGI.escape address}"
url = if address
"/calendar?ip=#{CGI.escape address}"
else
url = '/calendar'
'/calendar'
end
data = {}
begin

View file

@ -401,7 +401,7 @@ returns
}
files.sort.each {|entry|
filename = "#{path}/#{entry}"
if /^send/.match(entry)
if /^send/ =~ entry
data.push Sessions.queue_file_read(path, entry)
end
}

View file

@ -7,11 +7,9 @@ class Sessions::Backend::Collections::Organization < Sessions::Backend::Collecti
all = []
if !@user.role?('Customer')
all = Organization.all
else
if @user.organization_id
elsif @user.organization_id
all = Organization.where( id: @user.organization_id )
end
end
all
end

View file

@ -11,10 +11,10 @@ class Sessions::Event::Base
end
def websocket_send(recipient_client_id, data)
if data.class != Array
msg = "[#{data.to_json}]"
msg = if data.class != Array
"[#{data.to_json}]"
else
msg = data.to_json
data.to_json
end
if @clients[recipient_client_id]
log 'debug', "ws send #{msg}", recipient_client_id

View file

@ -14,11 +14,9 @@ class Sessions::Event::Broadcast < Sessions::Event::Base
if @payload['recipient']
if @payload['recipient'].class != Hash
log 'error', "recipient attribute isn't a hash '#{@payload['recipient'].inspect}'"
else
if !@payload['recipient'].key?('user_id')
elsif !@payload['recipient'].key?('user_id')
log 'error', "need recipient.user_id attribute '#{@payload['recipient'].inspect}'"
else
if @payload['recipient']['user_id'].class != Array
elsif @payload['recipient']['user_id'].class != Array
log 'error', "recipient.user_id attribute isn't an array '#{@payload['recipient']['user_id'].inspect}'"
else
@payload['recipient']['user_id'].each { |user_id|
@ -29,8 +27,6 @@ class Sessions::Event::Broadcast < Sessions::Event::Base
websocket_send(local_client_id, @payload['data'])
}
end
end
end
# broadcast every client
else

View file

@ -13,10 +13,10 @@ class Sessions::Event::Login < Sessions::Event::Base
end
end
if session && session.data && session.data['user_id']
new_session_data = { 'id' => session.data['user_id'] }
new_session_data = if session && session.data && session.data['user_id']
{ 'id' => session.data['user_id'] }
else
new_session_data = {}
{}
end
if @clients[@client_id]

View file

@ -21,11 +21,10 @@ class Sessions::Event::Spool < Sessions::Event::Base
# create new msg to push to client
if item[:type] == 'direct'
log 'notice', "send spool to (user_id=#{@session['id']})"
websocket_send(@client_id, item[:message])
else
log 'notice', 'send spool'
websocket_send(@client_id, item[:message])
end
websocket_send(@client_id, item[:message])
}
# send spool:sent event to client

View file

@ -67,18 +67,18 @@ class Stats::TicketChannelDistribution
channels.each {|channel|
count = result[channel[:sender].to_sym][:inbound]
#puts "#{channel.inspect}:in/#{result.inspect}:#{count}"
if count == 0
in_process_precent = 0
in_process_precent = if count == 0
0
else
in_process_precent = (count * 1000) / ((total_in * 1000) / 100)
(count * 1000) / ((total_in * 1000) / 100)
end
result[channel[:sender].to_sym][:inbound_in_percent] = in_process_precent
count = result[channel[:sender].to_sym][:outbound]
if count == 0
out_process_precent = 0
out_process_precent = if count == 0
0
else
out_process_precent = (count * 1000) / ((total_out * 1000) / 100)
(count * 1000) / ((total_out * 1000) / 100)
end
result[channel[:sender].to_sym][:outbound_in_percent] = out_process_precent
}

View file

@ -21,14 +21,14 @@ class Stats::TicketEscalation
average = '-'
state = 'supergood'
if own_escalated == 0
state = 'supergood'
state = if own_escalated == 0
'supergood'
elsif own_escalated <= 1
state = 'good'
'good'
elsif own_escalated <= 4
state = 'ok'
'ok'
else
state = 'bad'
'bad'
end
{

View file

@ -63,16 +63,16 @@ class Stats::TicketInProcess
end
in_percent = ( result[:used_for_average].to_f / (result[:average_per_agent].to_f / 100) ).round(1)
if in_percent >= 90
result[:state] = 'supergood'
result[:state] = if in_percent >= 90
'supergood'
elsif in_percent >= 65
result[:state] = 'good'
'good'
elsif in_percent >= 40
result[:state] = 'ok'
'ok'
elsif in_percent >= 20
result[:state] = 'bad'
'bad'
else
result[:state] = 'superbad'
'superbad'
end
result

View file

@ -44,16 +44,16 @@ class Stats::TicketLoadMeasure
in_percent = ( result[:used_for_average].to_f / (result[:average_per_agent].to_f / 100) ).round(1)
result[:average_per_agent_in_percent] = in_percent
if in_percent >= 90
result[:state] = 'supergood'
result[:state] = if in_percent >= 90
'supergood'
elsif in_percent >= 65
result[:state] = 'good'
'good'
elsif in_percent >= 40
result[:state] = 'ok'
'ok'
elsif in_percent >= 20
result[:state] = 'bad'
'bad'
else
result[:state] = 'superbad'
'superbad'
end
# convert result[:used_for_average] in percent to related total

View file

@ -49,16 +49,16 @@ class Stats::TicketReopen
#in_percent = ( result[:used_for_average].to_f / (result[:average_per_agent].to_f / 100) ).round(1)
#result[:average_per_agent_in_percent] = in_percent
in_percent = ( result[:count].to_f / (result[:total].to_f / 100) ).round(1)
if in_percent >= 90
result[:state] = 'superbad'
result[:state] = if in_percent >= 90
'superbad'
elsif in_percent >= 65
result[:state] = 'bad'
'bad'
elsif in_percent >= 40
result[:state] = 'ok'
'ok'
elsif in_percent >= 20
result[:state] = 'good'
'good'
else
result[:state] = 'supergood'
'supergood'
end
result
end

View file

@ -56,16 +56,16 @@ class Stats::TicketResponseTime
end
in_percent = ( result[:used_for_average].to_f / (result[:total].to_f / 100) ).round(1)
if in_percent >= 90
result[:state] = 'supergood'
result[:state] = if in_percent >= 90
'supergood'
elsif in_percent >= 65
result[:state] = 'good'
'good'
elsif in_percent >= 40
result[:state] = 'ok'
'ok'
elsif in_percent >= 20
result[:state] = 'bad'
'bad'
else
result[:state] = 'superbad'
'superbad'
end
result

View file

@ -274,11 +274,9 @@ returns
if !params.empty?
request.body = params.to_json
end
else
if !params.empty?
elsif !params.empty?
request.set_form_data(params)
end
end
request
end

View file

@ -238,10 +238,10 @@ EventMachine.run {
end
def websocket_send(client_id, data)
if data.class != Array
msg = "[#{data.to_json}]"
msg = if data.class != Array
"[#{data.to_json}]"
else
msg = data.to_json
data.to_json
end
log 'debug', "send #{msg}", client_id
if !@clients[client_id]

View file

@ -512,12 +512,10 @@ class TestCase < Test::Unit::TestCase
if params[:type] == 'on'
instance.find_elements({ css: "#{params[:css]} label" })[0].click
end
else
if params[:type] == 'off'
elsif params[:type] == 'off'
instance.find_elements({ css: "#{params[:css]} label" })[0].click
end
end
end
=begin
@ -622,32 +620,30 @@ class TestCase < Test::Unit::TestCase
if success
fail "should not match '#{params[:value]}' in select list, but is matching"
end
return true
else
if !success
elsif !success
fail "not matching '#{params[:value]}' in select list"
end
return true
end
end
# match on attribute
begin
if params[:attribute]
text = element.attribute(params[:attribute])
text = if params[:attribute]
element.attribute(params[:attribute])
elsif params[:css] =~ /(input|textarea)/i
text = element.attribute('value')
element.attribute('value')
else
text = element.text
element.text
end
rescue => e
# just try again
if !fallback
return match(params, true)
else
raise e.inspect
end
raise e.inspect
end
# do cleanups (needed for richtext tests)
@ -662,20 +658,17 @@ class TestCase < Test::Unit::TestCase
if text =~ /#{params[:value]}/i
match = $1 || true
end
else
if text =~ /#{Regexp.quote(params[:value])}/i
elsif text =~ /#{Regexp.quote(params[:value])}/i
match = true
end
end
if match
if params[:should_not_match]
fail "matching '#{params[:value]}' in content '#{text}' but should not!"
end
else
if !params[:should_not_match]
elsif !params[:should_not_match]
fail "not matching '#{params[:value]}' in content '#{text}' but should!"
end
end
sleep 0.8
match
end
@ -855,8 +848,7 @@ class TestCase < Test::Unit::TestCase
else
fail "task '#{data[:title]}' is not modifed"
end
else
if !is_modified
elsif !is_modified
assert(true, "task '#{data[:title]}' is modifed")
elsif !exists
fail "task '#{data[:title]}' not exists, should be not modified"
@ -864,15 +856,13 @@ class TestCase < Test::Unit::TestCase
fail "task '#{data[:title]}' is modifed, but should not"
end
end
end
rescue => e
# just try again
if !fallback
verify_task(params, true)
else
raise 'ERROR: ' + e.inspect
end
raise 'ERROR: ' + e.inspect
end
true
end
@ -948,7 +938,7 @@ class TestCase < Test::Unit::TestCase
if params[:timeout]
timeout = params[:timeout]
end
loops = (timeout).to_i * 2
loops = timeout.to_i * 2
text = ''
(1..loops).each {
element = instance.find_elements({ css: params[:css] })[0]
@ -956,12 +946,12 @@ class TestCase < Test::Unit::TestCase
begin
# match pn attribute
if params[:attribute]
text = element.attribute(params[:attribute])
text = if params[:attribute]
element.attribute(params[:attribute])
elsif params[:css] =~ /(input|textarea)/i
text = element.attribute('value')
element.attribute('value')
else
text = element.text
element.text
end
if text =~ /#{params[:value]}/i
assert(true, "'#{params[:value]}' found in '#{text}'")
@ -1009,7 +999,7 @@ wait untill text in selector disabppears
if params[:timeout]
timeout = params[:timeout]
end
loops = (timeout).to_i
loops = timeout.to_i
text = ''
(1..loops).each {
element = instance.find_elements({ css: params[:css] })[0]

View file

@ -215,12 +215,12 @@ class TwitterBrowserTest < TestCase
watch_for(
css: '.content.active',
value: "#{hash}",
value: hash.to_s,
timeout: 20,
)
ticket_open_by_title(
title: "#{hash}",
title: hash.to_s,
)
# reply via app

View file

@ -383,11 +383,9 @@ class ActivityStreamTest < ActiveSupport::TestCase
assert_equal( check_item[:object], item['object'] )
assert_equal( check_item[:type], item['type'] )
assert_equal( check_item[:o_id], item['o_id'] )
else
if check_item[:object] == item['object'] && check_item[:type] == item['type'] && check_item[:o_id] == item['o_id']
elsif check_item[:object] == item['object'] && check_item[:type] == item['type'] && check_item[:o_id] == item['o_id']
assert( false, "entry should not exist #{item['object']}/#{item['type']}/#{item['o_id']}" )
end
end
}
}
end

View file

@ -98,7 +98,7 @@ class ObjectCacheTest < ActiveSupport::TestCase
assert_equal( name, group_new[:name], 'verify by where' )
# lookup by name
cache_key = "#{group_new.name}"
cache_key = group_new.name.to_s
assert_nil( Group.cache_get(cache_key) )
group_lookup_name = Group.lookup( name: group_new.name )
@ -106,7 +106,7 @@ class ObjectCacheTest < ActiveSupport::TestCase
assert( Group.cache_get(cache_key) )
# lookup by id
cache_key = "#{group_new.id}"
cache_key = group_new.id.to_s
assert_nil( Group.cache_get(cache_key) )
group_lookup_id = Group.lookup( id: group.id )
@ -119,7 +119,7 @@ class ObjectCacheTest < ActiveSupport::TestCase
group.save
# lookup by name
cache_key = "#{group.name}"
cache_key = group.name.to_s
assert_nil( Group.cache_get(cache_key) )
group_lookup = Group.where( name: group_new.name ).first
@ -139,7 +139,7 @@ class ObjectCacheTest < ActiveSupport::TestCase
assert( Group.cache_get(cache_key) )
# lookup by id
cache_key = "#{group_new.id}"
cache_key = group_new.id.to_s
assert_nil( Group.cache_get(cache_key) )
group_lookup_id = Group.lookup( id: group.id )

View file

@ -116,10 +116,10 @@ class TagTest < ActiveSupport::TestCase
# delete tags
tests.each { |test|
tags = nil
if test[:tag_add]
tags = test[:tag_add]
tags = if test[:tag_add]
test[:tag_add]
else
tags = test[:tag_remove]
test[:tag_remove]
end
success = Tag.tag_remove( tags )
assert( success, 'Tag.tag_remove successful')