Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify cancelled and canceled call states #873

Merged
merged 2 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/calls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def cancel
qc.destroy
end

call_log.state = "canceled"
call_log.state = "cancelled"
call_log.save!

render :json => {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/queued_calls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def destroy
@call.cancel_call!
@call.destroy

redirect_to(call_logs_path, :notice => "Call to #{@call.address} successfully canceled.")
redirect_to(call_logs_path, :notice => "Call to #{@call.address} successfully cancelled.")
end
end
2 changes: 1 addition & 1 deletion broker/src/africas_talking/africas_talking_pbx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ handle_call({resume, Params}, From, State = #state{session = Session, waiting =
"busy" -> busy;
"no-answer" -> no_answer;
"failed" -> failed;
"canceled" -> canceled;
"canceled" -> cancelled;
Other ->
lager:warning("Unknown DialCallStatus: ~p", [Other]),
failed
Expand Down
2 changes: 1 addition & 1 deletion broker/src/twilio/twilio_pbx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ handle_call({resume, Params}, From, State = #state{session = Session, waiting =
"busy" -> busy;
"no-answer" -> no_answer;
"failed" -> failed;
"canceled" -> canceled;
"canceled" -> cancelled;
Other ->
lager:warning("Unknown DialCallStatus: ~p", [Other]),
failed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class UnifyCancelledAndCancelledCallStates < ActiveRecord::Migration
def up
ActiveRecord::Base.connection.execute <<-SQL
UPDATE `call_logs`
SET `state` = "cancelled"
WHERE `state` = "canceled"
SQL
end

def down
# Nothing to do - can't revert the change
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class RemoveDeprecatedSuspendedCallLogState < ActiveRecord::Migration
def up
ActiveRecord::Base.connection.execute <<-SQL
UPDATE `call_logs`
SET `state` = "cancelled", `fail_reason` = "Call was kept in a deprecated 'suspended' state"
WHERE `state` = "suspended"
SQL
end

def down
# Nothing to do - can't revert the change
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20171211152836) do
ActiveRecord::Schema.define(:version => 20200420225523) do

create_table "accounts", :force => true do |t|
t.string "email", :default => "", :null => false
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/api/calls_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@

result = JSON.parse(@response.body)
expect(result['call_id']).to eq(call_log.id)
expect(result['state']).to eq('canceled')
expect(result['state']).to eq('cancelled')

call_log = CallLog.find_by_id(call_log.id)
expect(call_log.state).to eq(:canceled)
expect(call_log.state).to eq(:cancelled)

expect(QueuedCall.find_by_id(queued_call.id)).to be_nil
end
Expand Down