Fixed test and applied rubocop.

This commit is contained in:
Martin Edenhofer 2016-11-30 08:04:35 +01:00
parent c8e7ce9d63
commit a4341626b9

View file

@ -259,7 +259,7 @@ returns
comment = params['cause'] comment = params['cause']
event = params['event'] event = params['event']
user = params['user'] user = params['user']
if Array === user if user.class == Array
user = user.join(', ') user = user.join(', ')
end end
@ -268,15 +268,15 @@ returns
preferences = nil preferences = nil
if params['direction'] == 'in' if params['direction'] == 'in'
to_comment = user to_comment = user
from_comment, preferences = CallerId.get_comment_preferences(params['from'], params['direction']) from_comment, preferences = CallerId.get_comment_preferences(params['from'], 'from')
else else
from_comment = user from_comment = user
to_comment, preferences = CallerId.get_comment_preferences(params['to'], params['direction']) to_comment, preferences = CallerId.get_comment_preferences(params['to'], 'to')
end end
case event case event
when 'newCall' when 'newCall'
self.create( create(
direction: params['direction'], direction: params['direction'],
from: params['from'], from: params['from'],
from_comment: from_comment, from_comment: from_comment,
@ -288,7 +288,7 @@ returns
preferences: preferences, preferences: preferences,
) )
when 'answer' when 'answer'
log = self.find_by(call_id: params['callId']) log = find_by(call_id: params['callId'])
raise "No such call_id #{params['callId']}" if !log raise "No such call_id #{params['callId']}" if !log
log.state = 'answer' log.state = 'answer'
log.start = Time.zone.now log.start = Time.zone.now
@ -298,7 +298,7 @@ returns
log.comment = comment log.comment = comment
log.save log.save
when 'hangup' when 'hangup'
log = self.find_by(call_id: params['callId']) log = find_by(call_id: params['callId'])
raise "No such call_id #{params['callId']}" if !log raise "No such call_id #{params['callId']}" if !log
if params['direction'] == 'in' && log.state == 'newCall' if params['direction'] == 'in' && log.state == 'newCall'
log.done = false log.done = false