voicemail 0.2.0 → 1.0.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/README.md +57 -2
- data/lib/voicemail.rb +15 -8
- data/lib/voicemail/{application_controller.rb → call_controllers/application_controller.rb} +14 -1
- data/lib/voicemail/call_controllers/authentication_controller.rb +60 -0
- data/lib/voicemail/call_controllers/mailbox_controller.rb +46 -0
- data/lib/voicemail/{mailbox_main_menu_controller.rb → call_controllers/mailbox_main_menu_controller.rb} +9 -4
- data/lib/voicemail/call_controllers/mailbox_messages_controller.rb +48 -0
- data/lib/voicemail/{mailbox_play_message_controller.rb → call_controllers/mailbox_play_message_controller.rb} +26 -10
- data/lib/voicemail/call_controllers/mailbox_play_message_intro_controller.rb +72 -0
- data/lib/voicemail/{mailbox_set_greeting_controller.rb → call_controllers/mailbox_set_greeting_controller.rb} +2 -2
- data/lib/voicemail/{mailbox_set_pin_controller.rb → call_controllers/mailbox_set_pin_controller.rb} +0 -0
- data/lib/voicemail/call_controllers/voicemail_controller.rb +57 -0
- data/lib/voicemail/localization_loader.rb +28 -0
- data/lib/voicemail/matcher.rb +14 -0
- data/lib/voicemail/plugin.rb +40 -15
- data/lib/voicemail/storage_pstore.rb +49 -2
- data/lib/voicemail/version.rb +1 -1
- data/spec/voicemail/call_controllers/application_controller_spec.rb +31 -0
- data/spec/voicemail/call_controllers/authentication_controller_spec.rb +59 -0
- data/spec/voicemail/call_controllers/mailbox_controller_spec.rb +107 -0
- data/spec/voicemail/{mailbox_main_menu_controller_spec.rb → call_controllers/mailbox_main_menu_controller_spec.rb} +9 -2
- data/spec/voicemail/call_controllers/mailbox_messages_controller_spec.rb +110 -0
- data/spec/voicemail/call_controllers/mailbox_play_message_controller_spec.rb +97 -0
- data/spec/voicemail/call_controllers/mailbox_play_message_intro_controller_spec.rb +81 -0
- data/spec/voicemail/{mailbox_set_greeting_controller_spec.rb → call_controllers/mailbox_set_greeting_controller_spec.rb} +24 -6
- data/spec/voicemail/{mailbox_set_pin_controller_spec.rb → call_controllers/mailbox_set_pin_controller_spec.rb} +0 -0
- data/spec/voicemail/call_controllers/voicemail_controller_spec.rb +97 -0
- data/spec/voicemail/localization_loader_spec.rb +21 -0
- data/spec/voicemail/storage_pstore_spec.rb +64 -2
- data/templates/en.yml +67 -0
- data/voicemail.gemspec +2 -2
- metadata +42 -26
- data/lib/voicemail/mailbox_controller.rb +0 -56
- data/lib/voicemail/mailbox_messages_controller.rb +0 -55
- data/lib/voicemail/voicemail_controller.rb +0 -33
- data/spec/voicemail/mailbox_controller_spec.rb +0 -79
- data/spec/voicemail/mailbox_messages_controller_spec.rb +0 -71
- data/spec/voicemail/mailbox_play_message_controller_spec.rb +0 -70
- data/spec/voicemail/voicemail_controller_spec.rb +0 -76
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Voicemail::MailboxController do
|
4
|
-
include VoicemailControllerSpecHelper
|
5
|
-
|
6
|
-
describe "#run" do
|
7
|
-
context "with a missing mailbox parameter in metadata" do
|
8
|
-
let(:metadata) { Hash.new }
|
9
|
-
|
10
|
-
it "should raise an error if there is no mailbox in the metadata" do
|
11
|
-
expect { controller.run }.to raise_error ArgumentError
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with a present mailbox parameter in metadata" do
|
16
|
-
context "with an invalid mailbox" do
|
17
|
-
let(:mailbox) { nil }
|
18
|
-
|
19
|
-
it "plays the mailbox not found message and hangs up" do
|
20
|
-
should_play config.mailbox_not_found
|
21
|
-
subject.should_receive(:hangup).once
|
22
|
-
controller.run
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "with an existing mailbox" do
|
27
|
-
it "plays the mailbox greeting message" do
|
28
|
-
should_play config.mailbox.greeting_message
|
29
|
-
subject.should_receive(:authenticate).and_return(true)
|
30
|
-
subject.should_receive(:play_number_of_messages).and_return(true)
|
31
|
-
subject.should_receive(:main_menu).and_return(true)
|
32
|
-
controller.run
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#authenticate" do
|
38
|
-
it "authenticates an user that enters the correct pin" do
|
39
|
-
should_ask(config.mailbox.please_enter_pin, terminator: "#", timeout: config.prompt_timeout).once.and_return(1234)
|
40
|
-
controller.authenticate.should == true
|
41
|
-
end
|
42
|
-
|
43
|
-
it "tell a user his pin is wrong and retries" do
|
44
|
-
subject.should_receive(:ask).times(2).and_return(1111, 1234)
|
45
|
-
should_play config.mailbox.pin_wrong
|
46
|
-
controller.authenticate.should == true
|
47
|
-
end
|
48
|
-
|
49
|
-
it "fails with a message if the user enters a wrong PIN the set number of times" do
|
50
|
-
subject.should_receive(:ask).times(3).and_return(1111, 2222, 3333)
|
51
|
-
subject.should_receive(:play).with(config.mailbox.pin_wrong).times(3)
|
52
|
-
controller.authenticate.should == false
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#play_number_of_messages" do
|
57
|
-
it "plays the number of new messages if there is at least one" do
|
58
|
-
storage_instance.should_receive(:count_new_messages).once.with(mailbox[:id]).and_return(3)
|
59
|
-
should_play(config.mailbox.number_before).ordered
|
60
|
-
subject.should_receive(:play_numeric).ordered.with(3)
|
61
|
-
should_play(config.mailbox.number_after).ordered
|
62
|
-
controller.play_number_of_messages
|
63
|
-
end
|
64
|
-
|
65
|
-
it "does play the no messages audio if there are none" do
|
66
|
-
storage_instance.should_receive(:count_new_messages).once.with(mailbox[:id]).and_return(0)
|
67
|
-
should_play(config.messages.no_new_messages).ordered
|
68
|
-
controller.play_number_of_messages
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#main_menu" do
|
73
|
-
it "passes to MainMenuController" do
|
74
|
-
subject.should_receive(:pass).once.with(Voicemail::MailboxMainMenuController, mailbox: mailbox[:id])
|
75
|
-
controller.main_menu
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Voicemail
|
4
|
-
describe MailboxMessagesController do
|
5
|
-
include VoicemailControllerSpecHelper
|
6
|
-
|
7
|
-
let(:call) { flexmock('Call') }
|
8
|
-
let(:config) { Voicemail::Plugin.config }
|
9
|
-
let(:metadata) do
|
10
|
-
{ :mailbox => '100' }
|
11
|
-
end
|
12
|
-
let(:mailbox) do
|
13
|
-
{
|
14
|
-
:id => 100,
|
15
|
-
:pin => 1234,
|
16
|
-
:greeting_message => nil,
|
17
|
-
:send_email => true,
|
18
|
-
:email_address => "lpradovera@mojolingo.com"
|
19
|
-
}
|
20
|
-
end
|
21
|
-
let(:message) do
|
22
|
-
{
|
23
|
-
:id => 123,
|
24
|
-
:from => "+39-335135335",
|
25
|
-
:received => Time.local(2012, 5, 1, 9, 0, 0),
|
26
|
-
:uri => "/path/to/file"
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
let(:storage_instance) { flexmock('StorageInstance') }
|
31
|
-
|
32
|
-
let(:controller){ Voicemail::MailboxMessagesController.new call, metadata }
|
33
|
-
subject { flexmock controller }
|
34
|
-
|
35
|
-
before(:each) do
|
36
|
-
storage_instance.should_receive(:get_mailbox).with(metadata[:mailbox]).and_return(mailbox)
|
37
|
-
flexmock(Storage).should_receive(:instance).and_return(storage_instance)
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#message_loop" do
|
41
|
-
it "calls #next_message if there are new messages" do
|
42
|
-
storage_instance.should_receive(:count_new_messages).once.with(mailbox[:id]).and_return(3)
|
43
|
-
subject.should_receive(:next_message).once
|
44
|
-
controller.message_loop
|
45
|
-
end
|
46
|
-
|
47
|
-
it "plays a message and goes to the main menu if there are no new messages" do
|
48
|
-
storage_instance.should_receive(:count_new_messages).once.with(mailbox[:id]).and_return(0)
|
49
|
-
subject.should_receive(:play).with(config.messages.no_new_messages).once
|
50
|
-
subject.should_receive(:main_menu).once
|
51
|
-
controller.message_loop
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#next_message" do
|
56
|
-
it "gets the next message and calls #handle_message" do
|
57
|
-
storage_instance.should_receive(:next_new_message).once.with(mailbox[:id]).and_return(message)
|
58
|
-
subject.should_receive(:handle_message).once.with(message)
|
59
|
-
subject.should_receive(:message_loop).once
|
60
|
-
controller.next_message
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#handle_message" do
|
65
|
-
it "invokes MailboxPlayMessageController" do
|
66
|
-
should_invoke Voicemail::MailboxPlayMessageController, message: message, mailbox: mailbox[:id]
|
67
|
-
controller.handle_message message
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Voicemail::MailboxPlayMessageController do
|
4
|
-
include VoicemailControllerSpecHelper
|
5
|
-
|
6
|
-
let(:message) do
|
7
|
-
{
|
8
|
-
id: 123,
|
9
|
-
from: "+39-335135335",
|
10
|
-
received: Time.local(2012, 5, 1, 9, 0, 0),
|
11
|
-
uri: "/path/to/file"
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#archive_message" do
|
16
|
-
it "archives the message" do
|
17
|
-
subject.should_receive(:current_message).once.and_return(message)
|
18
|
-
storage_instance.should_receive(:archive_message).once.with(mailbox[:id], message[:id])
|
19
|
-
controller.archive_message
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#delete_message" do
|
24
|
-
it "deletes the message" do
|
25
|
-
subject.should_receive(:current_message).once.and_return(message)
|
26
|
-
storage_instance.should_receive(:delete_message).once.with(mailbox[:id], message[:id])
|
27
|
-
controller.delete_message
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#intro_message" do
|
32
|
-
it "plays the message introduction" do
|
33
|
-
subject.should_receive(:current_message).and_return(message)
|
34
|
-
should_play config.messages.message_received_on
|
35
|
-
subject.should_receive(:play_time).once.with(message[:received], format: config.datetime_format)
|
36
|
-
should_play config.messages.from
|
37
|
-
subject.should_receive(:say_characters).once.with "39335135335"
|
38
|
-
controller.intro_message
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#play_message" do
|
43
|
-
it "plays the message, followed by the menu" do
|
44
|
-
subject.should_receive(:current_message).once.and_return(message)
|
45
|
-
subject.should_receive(:menu).once.with(message[:uri], config.messages.menu,
|
46
|
-
{ timeout: config.menu_timeout, tries: config.menu_tries }, Proc)
|
47
|
-
subject.play_message
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#load_message" do
|
52
|
-
|
53
|
-
context "with a message" do
|
54
|
-
let(:metadata) { {message: "foo"} }
|
55
|
-
|
56
|
-
it "loads the messge" do
|
57
|
-
subject.load_message
|
58
|
-
subject.current_message.should == "foo"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "with no message passed" do
|
63
|
-
let(:metadata) { {message: nil} }
|
64
|
-
|
65
|
-
it "raises an error" do
|
66
|
-
expect { subject.load_message }.to raise_error ArgumentError
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Voicemail::VoicemailController do
|
4
|
-
include VoicemailControllerSpecHelper
|
5
|
-
|
6
|
-
describe "#run" do
|
7
|
-
context "with a missing mailbox parameter in metadata" do
|
8
|
-
let(:metadata) { Hash.new }
|
9
|
-
|
10
|
-
it "should raise an error if there is no mailbox in the metadata" do
|
11
|
-
subject.should_receive(:answer).once
|
12
|
-
expect { controller.run }.to raise_error ArgumentError
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "When force_183 is set and there's no mailbox" do
|
17
|
-
let(:mailbox) { nil }
|
18
|
-
|
19
|
-
before { config.force_183 = true }
|
20
|
-
after { config.force_183 = false }
|
21
|
-
|
22
|
-
it "should not answer" do
|
23
|
-
should_play config.mailbox_not_found
|
24
|
-
subject.should_receive(:hangup).once
|
25
|
-
controller.run
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "with a present mailbox parameter in metadata" do
|
30
|
-
before { subject.should_receive(:answer).once }
|
31
|
-
|
32
|
-
context "with an invalid mailbox" do
|
33
|
-
let(:mailbox) { nil }
|
34
|
-
|
35
|
-
it "plays the mailbox not found message and hangs up" do
|
36
|
-
should_play config.mailbox_not_found
|
37
|
-
subject.should_receive(:hangup).once
|
38
|
-
controller.run
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with an existing mailbox" do
|
43
|
-
context "without a greeting message" do
|
44
|
-
it "plays the default greeting if one is not specified" do
|
45
|
-
should_play config.default_greeting
|
46
|
-
subject.should_receive(:handle_recording).and_return(true)
|
47
|
-
controller.run
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "with a specified greeting message" do
|
52
|
-
let(:greeting_message) { "Howdy!" }
|
53
|
-
|
54
|
-
it "plays the specific greeting message" do
|
55
|
-
should_play greeting_message
|
56
|
-
subject.should_receive(:handle_recording).and_return(true)
|
57
|
-
controller.run
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "handling a recording" do
|
62
|
-
let(:recording_component) { flexmock 'Record' }
|
63
|
-
let(:file_path) { "/path/to/file" }
|
64
|
-
|
65
|
-
it "saves the recording" do
|
66
|
-
recording_component.should_receive("complete_event.recording.uri").and_return(file_path)
|
67
|
-
subject.should_receive(:record).with(config.recording.to_hash.merge(interruptible: true, direction: :recv)).and_return(recording_component)
|
68
|
-
storage_instance.should_receive(:save_recording).with(mailbox[:id], call.from, file_path)
|
69
|
-
should_play
|
70
|
-
controller.run
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|