voicemail 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebbfc0fc6aa71ce48bbf95b132fd0592471772c5
4
- data.tar.gz: 93ffac6ced909671f4eb252ccf17d4c7149e61a0
3
+ metadata.gz: 04851c91ceb009b391e4d88cd43136f058bfc729
4
+ data.tar.gz: 5c27720d3277680199ad4a5e73984669c0803e14
5
5
  SHA512:
6
- metadata.gz: 91b768677cebd27b9cc10ec9cf69943e18d6d66f511f957984f25eb7efe870fa74e41c4568e8ae632135e99795c21e93b2572a4a8b027d9a7bb6b56fbf9d154c
7
- data.tar.gz: 1c93c3d54fc3ff26d7e31a0dfbe3973da49bc7885f11885eed20862cdaabad92cde5f133c5dcbede1b491baedbd63393ccc70050420a51e743361810bbd51f04
6
+ metadata.gz: a00a3e02a77c97182063156e5d507d9208899246fadb180af9123da2e71eceb923f78239ba34387b457a7a240098591e1c90c2ae54f5d5c5ccea4a3b27880716
7
+ data.tar.gz: 76be7111e297639752090580c56061f465345339e6bd8657c28828021443121f12e1f06b7c770ed26cefdd69010e7891dc3e5b42c60ae9d02759c88a081ca1e4
@@ -0,0 +1,2 @@
1
+ LineLength:
2
+ Enabled: false
@@ -1,3 +1,12 @@
1
+ #develop
2
+ * CHANGE - Menu intros are one message, making them skippable.
3
+ * FEATURE - Personalized voicemail greetings can be deleted
4
+ * FEATURE - Add message to play after recording a voicemail is complete
5
+ * FEATURE - Add an option to erase all messages from a mailbox
6
+ * FEATURE - Put a timeout on waiting for a PIN
7
+ * FEATURE - Allow messages to be skipped
8
+ * BUG - Resolve issue where caller presses the pound key twice in succession
9
+
1
10
  #v1.0.0 - 2014-01-02
2
11
  * FEATURE - Optional per-mailbox override of default recording hash
3
12
  * FEATURE - Optional rerecording of voicemail messages
data/README.md CHANGED
@@ -45,9 +45,19 @@ Alternatively, you can pass in a storage layer dynamically when invoking the con
45
45
  # etc.
46
46
  ```
47
47
 
48
- ## Method Overrides
48
+ ## Customizing Voicemail
49
49
 
50
- If you prefer to use your own main menu instead of the [one provided](https://github.com/adhearsion/voicemail/blob/develop/lib/voicemail/call_controllers/mailbox_main_menu_controller.rb#L10-L13), you can set the class to use like so:
50
+ The easiest way to customize the main menu is by subclassing (MailboxMainMenuController](https://github.com/adhearsion/voicemail/blob/develop/lib/voicemail/call_controllers/mailbox_main_menu_controller.rb) and replacing the `#main_menu` method with one of your own.
51
+
52
+ Within `#main_menu` you have several options that can be invoked, each by simply calling the method:
53
+
54
+ * listen_to_new_messages - self-explanatory
55
+ * listen_to_saved_messages - self-explanatory
56
+ * set_greeting - prompt to set the mailbox greeting
57
+ * set_pin - prompt to set the mailbox PIN
58
+ * empty_mailbox(:new or :saved or :all) - removes all (new or saved) messages from a given mailbox. Includes confirmation for safety
59
+
60
+ Then tell Adhearsion to use your new voicemail menu class:
51
61
  ```ruby
52
62
  config.voicemail.main_menu_class = MyMenuController
53
63
  ```
@@ -95,8 +105,14 @@ Using I18n for the numeric method will nicely handle pluralizing message counts
95
105
 
96
106
  ## Authors
97
107
 
98
- * Original author: [Luca Pradovera](https://github.com/polysics)
99
- * Also contributed: [Justin Aiken](https://github.com/JustinAiken)
108
+ Original author: [Luca Pradovera](https://github.com/polysics)
109
+
110
+ Contributors:
111
+ * [Luca Pradovera](https://github.com/polysics)
112
+ * [Justin Aiken](https://github.com/JustinAiken)
113
+ * [Ben Klang](https://github.com/bklang)
114
+ * [Evan McGee](https://github.com/emcgee)
115
+ * [Will Drexler](https://github.com/wdrexler)
100
116
 
101
117
  ## Links
102
118
 
@@ -114,4 +130,4 @@ Using I18n for the numeric method will nicely handle pluralizing message counts
114
130
 
115
131
  ## Copyright
116
132
 
117
- Copyright (c) 2012 Adhearsion Foundation Inc. MIT license (see LICENSE for details).
133
+ Copyright (c) 2012-2014 Adhearsion Foundation Inc. MIT license (see LICENSE for details).
@@ -6,6 +6,7 @@ require "voicemail/storage_pstore"
6
6
  require "voicemail/storage"
7
7
  require "voicemail/matcher"
8
8
  require "voicemail/localization_loader"
9
+ require "voicemail/intro_message_creator"
9
10
  require "voicemail/call_controllers/application_controller"
10
11
  require "voicemail/call_controllers/voicemail_controller"
11
12
  require "voicemail/call_controllers/mailbox_controller"
@@ -16,6 +17,7 @@ require "voicemail/call_controllers/mailbox_play_message_intro_controller"
16
17
  require "voicemail/call_controllers/mailbox_play_message_controller"
17
18
  require "voicemail/call_controllers/mailbox_set_greeting_controller"
18
19
  require "voicemail/call_controllers/mailbox_set_pin_controller"
20
+ require "voicemail/call_controllers/mailbox_cleaner_controller"
19
21
 
20
22
 
21
23
  require "voicemail/plugin"
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ module Voicemail
4
+ class MailboxCleanerController < ApplicationController
5
+ def run
6
+ menu_prompt = metadata[:new_or_saved].to_s == "new" ? config.mailbox.clear_new_messages : config.mailbox.clear_saved_messages
7
+ menu menu_prompt, timeout: config.menu_timeout, tries: config.menu_tries do
8
+ match(1) { erase_all metadata[:new_or_saved] }
9
+
10
+ invalid { confirm_no_action_taken }
11
+ timeout { confirm_no_action_taken }
12
+ failure { confirm_no_action_taken }
13
+ end
14
+ end
15
+
16
+ def confirm_no_action_taken
17
+ play config.mailbox.no_messages_deleted
18
+ main_menu
19
+ end
20
+
21
+ def erase_all(type)
22
+ method = "next_#{type}_message"
23
+
24
+ messages_count = storage.send "count_#{type}_messages", mailbox[:id]
25
+
26
+ deleting_all_messages = metadata[:new_or_saved].to_s == "new" ? config.mailbox.deleting_all_new_messages : config.mailbox.deleting_all_saved_messages
27
+ play deleting_all_messages
28
+
29
+ messages_count.times do
30
+ message = storage.send(method, mailbox[:id])
31
+ storage.delete_message mailbox[:id], message[:id]
32
+ end
33
+
34
+ all_messages_deleted = metadata[:new_or_saved].to_s == "new" ? config.mailbox.all_new_messages_deleted : config.mailbox.all_saved_messages_deleted
35
+ play all_messages_deleted
36
+
37
+ main_menu
38
+ end
39
+ end
40
+ end
@@ -11,6 +11,8 @@ module Voicemail
11
11
  match(2) { listen_to_saved_messages }
12
12
  match(3) { set_greeting }
13
13
  match(4) { set_pin }
14
+ match(7) { clear_new_messages }
15
+ match(9) { clear_saved_messages }
14
16
 
15
17
  timeout do
16
18
  play config.mailbox.menu_timeout_message
@@ -42,5 +44,13 @@ module Voicemail
42
44
  def listen_to_saved_messages
43
45
  invoke MailboxMessagesController, mailbox: mailbox[:id], new_or_saved: :saved
44
46
  end
47
+
48
+ def clear_new_messages
49
+ invoke MailboxCleanerController, mailbox: mailbox[:id], new_or_saved: :new
50
+ end
51
+
52
+ def clear_saved_messages
53
+ invoke MailboxCleanerController, mailbox: mailbox[:id], new_or_saved: :saved
54
+ end
45
55
  end
46
56
  end
@@ -5,18 +5,16 @@ module Voicemail
5
5
 
6
6
  def initialize(call, metadata={})
7
7
  @new_or_saved = metadata[:new_or_saved] || :new
8
-
9
8
  super call, metadata
10
9
  end
11
10
 
12
11
  def run
13
12
  load_message
14
- intro_message
15
13
  play_message
16
14
  end
17
15
 
18
16
  def play_message
19
- menu message_uri, play_message_menu, timeout: config.menu_timeout, tries: config.menu_tries do
17
+ menu intro_message, message_uri, play_message_menu, timeout: config.menu_timeout, tries: config.menu_tries do
20
18
  match 1 do
21
19
  archive_or_unarchive_message
22
20
  end
@@ -26,6 +24,7 @@ module Voicemail
26
24
  end
27
25
 
28
26
  match(7) { rewind_message }
27
+ match(8) { skip_message }
29
28
  match(9) { main_menu }
30
29
 
31
30
  timeout do
@@ -38,13 +37,13 @@ module Voicemail
38
37
 
39
38
  failure do
40
39
  play config.mailbox.menu_failure_message
41
- hangup
40
+ main_menu
42
41
  end
43
42
  end
44
43
  end
45
44
 
46
45
  def intro_message
47
- invoke MailboxPlayMessageIntroController, message: current_message, mailbox: mailbox[:id], storage: storage
46
+ IntroMessageCreator.new(current_message).intro_message
48
47
  end
49
48
 
50
49
  def play_message_menu
@@ -59,6 +58,10 @@ module Voicemail
59
58
  play_message
60
59
  end
61
60
 
61
+ def skip_message
62
+ # This method intentionally left blank
63
+ end
64
+
62
65
  def archive_or_unarchive_message
63
66
  if new_or_saved == :new
64
67
  storage.archive_message mailbox[:id], current_message[:id]
@@ -69,6 +72,7 @@ module Voicemail
69
72
 
70
73
  def delete_message
71
74
  storage.delete_message mailbox[:id], current_message[:id]
75
+ play config.messages.message_deleted
72
76
  end
73
77
 
74
78
  def current_message
@@ -11,6 +11,7 @@ module Voicemail
11
11
  timeout: config.menu_timeout, tries: config.menu_tries do
12
12
  match(1) { listen_to_current_greeting }
13
13
  match(2) { record_greeting }
14
+ match(3) { delete_greeting_menu }
14
15
  match(9) { main_menu }
15
16
 
16
17
  timeout do
@@ -23,7 +24,7 @@ module Voicemail
23
24
 
24
25
  failure do
25
26
  play config.mailbox.menu_failure_message
26
- hangup
27
+ main_menu
27
28
  end
28
29
  end
29
30
  end
@@ -62,11 +63,37 @@ module Voicemail
62
63
 
63
64
  failure do
64
65
  play config.mailbox.menu_failure_message
65
- hangup
66
+ section_menu
67
+ end
68
+ end
69
+ end
70
+
71
+ def delete_greeting_menu
72
+ menu config.set_greeting.delete_confirmation,
73
+ timeout: config.menu_timeout, tries: config.menu_tries do
74
+ match(1) { delete_greeting }
75
+ match(9) { section_menu }
76
+ timeout do
77
+ play config.mailbox.menu_timeout_message
78
+ end
79
+
80
+ invalid do
81
+ play config.mailbox.menu_invalid_message
82
+ end
83
+
84
+ failure do
85
+ play config.mailbox.menu_failure_message
86
+ section_menu
66
87
  end
67
88
  end
68
89
  end
69
90
 
91
+ def delete_greeting
92
+ storage.delete_greeting_from_mailbox mailbox[:id]
93
+ play config.set_greeting.greeting_deleted
94
+ main_menu
95
+ end
96
+
70
97
  def save_greeting
71
98
  storage.save_greeting_for_mailbox mailbox[:id], temp_recording
72
99
  main_menu
@@ -20,16 +20,16 @@ module Voicemail
20
20
 
21
21
  failure do
22
22
  play config.mailbox.menu_failure_message
23
- hangup
23
+ main_menu
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
28
  def set_pin
29
- pin = ask config.set_pin.prompt, terminator: "#"
30
- repeat_pin = ask config.set_pin.repeat_prompt, terminator: "#"
29
+ pin = ask config.set_pin.prompt, terminator: "#", timeout: 5
30
+ repeat_pin = ask config.set_pin.repeat_prompt, terminator: "#", timeout: 5
31
31
 
32
- if pin.to_s.size < config.set_pin.pin_minimum_digits
32
+ if pin.to_s.nil? || pin.to_s.size < config.set_pin.pin_minimum_digits
33
33
  play config.set_pin.pin_error
34
34
  set_pin
35
35
  elsif pin.to_s != repeat_pin.to_s
@@ -9,6 +9,7 @@ module Voicemail
9
9
  play_greeting
10
10
  answer if config.when_to_answer == :after_greeting
11
11
  record_message
12
+ play_recording_confirmation
12
13
  hangup
13
14
  else
14
15
  mailbox_not_found
@@ -19,6 +20,10 @@ module Voicemail
19
20
  play mailbox[:greeting_message] || config.default_greeting
20
21
  end
21
22
 
23
+ def play_recording_confirmation
24
+ play config.recording_confirmation
25
+ end
26
+
22
27
  def record_message
23
28
  @recording = record record_options
24
29
 
@@ -0,0 +1,84 @@
1
+ module Voicemail
2
+ class IntroMessageCreator
3
+
4
+ begin
5
+ require 'ahnsay'
6
+ rescue LoadError
7
+ end
8
+
9
+ attr_accessor :current_message
10
+
11
+ def initialize(message)
12
+ raise ArgumentError, "MailboxPlayMessageIntroController needs a valid message passed to it" unless message
13
+ @current_message = message
14
+ end
15
+
16
+ def intro_message
17
+ Array(time_message) + Array(from_message)
18
+ end
19
+
20
+ def time_message
21
+ case config.numeric_method
22
+ when :i18n_string
23
+ I18n.t "voicemail.messages.message_received_on_x", received_on: I18n.localize(current_message[:received])
24
+ when :play_numeric
25
+ [config.messages.message_received_on, time_ssml]
26
+ when :ahn_say
27
+ [
28
+ config.messages.message_received_on,
29
+ Ahnsay.sounds_for_time(current_message[:received], format: config.datetime_format)
30
+ ]
31
+ end
32
+ end
33
+
34
+ def from_message
35
+ case config.numeric_method
36
+ when :i18n_string
37
+ I18n.t "voicemail.messages.message_received_from_x", from: from_string
38
+ when :play_numeric
39
+ [config.messages.from, from_ssml]
40
+ when :ahn_say
41
+ [config.messages.from, Ahnsay.sounds_for_digits(from_digits)]
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def from_digits
48
+ current_message[:from].scan(/\d/).join
49
+ end
50
+
51
+ def from_string
52
+ "".tap do |string|
53
+ from_digits.each_char do |char|
54
+ digit_word = I18n.t "numbers.#{char}"
55
+ if digit_word =~ /missing/
56
+ string << char
57
+ else
58
+ string << digit_word
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def time_ssml
65
+ output_formatter.ssml_for_time current_message[:received], format: config.datetime_format
66
+ end
67
+
68
+ def from_ssml
69
+ if from_digits != ""
70
+ output_formatter.ssml_for_characters from_digits
71
+ else
72
+ "unknown caller"
73
+ end
74
+ end
75
+
76
+ def output_formatter
77
+ @output_formatter ||= Adhearsion::CallController::Output::Formatter.new
78
+ end
79
+
80
+ def config
81
+ Voicemail::Plugin.config
82
+ end
83
+ end
84
+ end
@@ -1,3 +1,6 @@
1
+ # encoding: utf-8
2
+ # This template exists for the purpose of being overridden. See the README for more information.
3
+
1
4
  module Voicemail
2
5
  class Matcher
3
6
  def initialize(entered, actual)
@@ -6,8 +9,6 @@ module Voicemail
6
9
  end
7
10
 
8
11
  def matches?
9
- logger.info "input : #{@entered}"
10
- logger.info "actual: #{@actual}"
11
12
  @entered == @actual
12
13
  end
13
14
  end
@@ -28,6 +28,7 @@ module Voicemail
28
28
 
29
29
  allow_rerecording true, desc: "Allow caller to rerecord their voicemail"
30
30
  after_record "Press 1 to save your voicemail. Press 2 to rerecord.", desc: "Message to play if allow_rerecording is set"
31
+ recording_confirmation "Your message has been saved. Thank you.", desc: "Message to play after the voicemail has been saved"
31
32
 
32
33
  desc "Default recording options"
33
34
  recording {
@@ -50,18 +51,27 @@ module Voicemail
50
51
  number_before "You have ", desc: "What to play before the number of new messages"
51
52
  number_after_new " new messages", desc: "What to play after the number of new messages"
52
53
  number_after_saved " saved messages", desc: "What to play after the number of saved messages"
53
- menu_greeting "Press 1 to listen to new messages, 2 to listen to saved messages, 3 to change your greeting, 4 to change your PIN", desc: "What to say before the main menu"
54
+ menu_greeting "Press 1 to listen to new messages, 2 to listen to saved messages, 3 to change your greeting, 4 to change your PIN, 7 to delete all new messages, 9 to delete all saved messages", desc: "What to say before the main menu"
54
55
  menu_timeout_message "Please enter a digit for the menu", desc: "Message to play on main menu timeout"
55
56
  menu_invalid_message "Please enter valid input", desc: "Message to play on main menu invalid"
56
57
  menu_failure_message "Sorry, unable to understand your input.", desc: "Message to play on main menu failure"
58
+ clear_new_messages "Are you sure you want to permanently erase all new messages? Press 1 to delete, or any other key to cancel", desc: "New message clearing confirmation"
59
+ clear_saved_messages "Are you sure you want to permanently erase all saved messages? Press 1 to delete, or any other key to cancel", desc: "Saved message clearing confirmation"
60
+ no_messages_deleted "Your messages will not be deleted. Returning to main menu."
61
+ deleting_all_new_messages "All of your new messages are being deleted. Please wait."
62
+ deleting_all_saved_messages "All of your saved messages are being deleted. Please wait."
63
+ all_new_messages_deleted "All new messages have been successfully deleted."
64
+ all_saved_messages_deleted "All saved messages have been successfully deleted."
57
65
  }
58
66
 
59
67
  desc "Set greeting configuration"
60
68
  set_greeting {
61
- prompt "Press 1 to listen to your current greeting, 2 to record a new greeting, 9 to return to the main menu", desc: "Main prompt for setting greeting"
69
+ prompt "Press 1 to listen to your current greeting, 2 to record a new greeting, 3 to delete your personalized greeting, 9 to return to the main menu", desc: "Main prompt for setting greeting"
62
70
  before_record "Please speak after the beep. The prompt will be played back after.", desc: "Recording instructions"
63
71
  after_record "Press 1 to save your new greeting, 2 to discard it, 9 to go back to the menu", desc: "Menu to use after recording"
64
72
  no_personal_greeting "You do not currently have a personalized greeting.", desc: "What to play if there is no specific greeting"
73
+ delete_confirmation "Your personlized greeting will be deleted. Press 1 to confirm, 9 to return to the main menu.", desc: "Ask the user to confirm removal of personalized greeting"
74
+ greeting_deleted "Your personalized greeting was deleted.", desc: "What to play after a greeting has been deleted"
65
75
  }
66
76
 
67
77
  desc "Set PIN configuration"
@@ -77,12 +87,13 @@ module Voicemail
77
87
 
78
88
  desc "Listen to messages menu configuration"
79
89
  messages {
80
- menu_new "Press 1 to archive the message and go to the next, press 5 to delete the message and go to the next, press 7 to hear the message again, press 9 for the main menu", desc: "Menu to use inside new messages"
81
- menu_saved "Press 1 to unarchive the message and go to the next, press 5 to delete the message and go to the next, press 7 to hear the message again, press 9 for the main menu", desc: "Menu to use inside saved messages"
90
+ menu_new "Press 1 to archive the message and go to the next, press 5 to delete the message and go to the next, press 7 to hear the message again, press 8 to skip the message, press 9 for the main menu", desc: "Menu to use inside new messages"
91
+ menu_saved "Press 1 to unarchive the message and go to the next, press 5 to delete the message and go to the next, press 7 to hear the message again, press 8 to skip the message, press 9 for the main menu", desc: "Menu to use inside saved messages"
82
92
  no_new_messages "There are no new messages", desc: "Message to inform the user he has no new messages"
83
93
  no_saved_messages "There are no saved messages", desc: "Message to inform the user he has no saved messages"
84
94
  message_received_on "Message received on ", desc: "Prefix to menu intro"
85
95
  from " from ", desc: "Used in message intro"
96
+ message_deleted "Message deleted.", desc: "Confirmation that a message has been deleted"
86
97
  }
87
98
 
88
99
  desc "Storage configuration"
@@ -72,6 +72,14 @@ module Voicemail
72
72
  end
73
73
  end
74
74
 
75
+ def delete_greeting_from_mailbox(mailbox_id)
76
+ store.transaction do
77
+ rec = store[:mailboxes][mailbox_id][:greeting_message]
78
+ File.unlink rec if File.exists? rec
79
+ store[:mailboxes][mailbox_id][:greeting_message] = nil
80
+ end
81
+ end
82
+
75
83
  def change_pin_for_mailbox(mailbox_id, new_pin)
76
84
  store.transaction do
77
85
  store[:mailboxes][mailbox_id][:pin] = new_pin
@@ -1,3 +1,3 @@
1
1
  module Voicemail
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Voicemail::MailboxCleanerController do
4
+ include VoicemailControllerSpecHelper
5
+ describe "#run" do
6
+ context "new messages" do
7
+ subject { flexmock(Voicemail::MailboxCleanerController.new call, {new_or_saved: :new}) }
8
+ it 'should call #menu with the proper arguments' do
9
+ subject.should_receive(:menu).with(config.mailbox.clear_new_messages,
10
+ { timeout: config.menu_timeout, tries: config.menu_tries }, Proc)
11
+ subject.run
12
+ end
13
+ end
14
+
15
+ context "saved messages" do
16
+ subject { flexmock(Voicemail::MailboxCleanerController.new call, {new_or_saved: :saved}) }
17
+ it 'should call #menu with the proper arguments' do
18
+ subject.should_receive(:menu).with(config.mailbox.clear_saved_messages,
19
+ { timeout: config.menu_timeout, tries: config.menu_tries }, Proc)
20
+ subject.run
21
+ end
22
+ end
23
+ end
24
+ end
@@ -39,27 +39,21 @@ describe Voicemail::MailboxPlayMessageController do
39
39
  it "deletes the message" do
40
40
  subject.should_receive(:current_message).once.and_return(message)
41
41
  storage_instance.should_receive(:delete_message).once.with(mailbox[:id], message[:id])
42
+ subject.should_receive(:play).once.with(config.messages.message_deleted)
42
43
  controller.delete_message
43
44
  end
44
45
  end
45
46
 
46
- describe "#intro_message" do
47
- it "plays the message introduction" do
48
- subject.should_receive(:current_message).once.and_return message
49
- should_invoke Voicemail::MailboxPlayMessageIntroController, message: message, mailbox: 100, storage: storage_instance
50
- controller.intro_message
51
- end
52
- end
53
-
54
47
  describe "#play_message" do
48
+ include FlexMock::ArgumentTypes
55
49
  after { subject.play_message }
56
50
 
57
51
  context "with a new message" do
58
52
  before { subject.new_or_saved = :new }
59
53
 
60
54
  it "plays the message, followed by the new message menu" do
61
- subject.should_receive(:current_message).once.and_return message
62
- subject.should_receive(:menu).once.with message[:uri], config.messages.menu_new,
55
+ subject.should_receive(:current_message).and_return message
56
+ subject.should_receive(:menu).once.with any, message[:uri], config.messages.menu_new,
63
57
  { timeout: config.menu_timeout, tries: config.menu_tries }, Proc
64
58
  end
65
59
  end
@@ -68,8 +62,8 @@ describe Voicemail::MailboxPlayMessageController do
68
62
  before { subject.new_or_saved = :saved }
69
63
 
70
64
  it "plays the message, followed by the saved message menu" do
71
- subject.should_receive(:current_message).once.and_return message
72
- subject.should_receive(:menu).once.with message[:uri], config.messages.menu_saved,
65
+ subject.should_receive(:current_message).and_return message
66
+ subject.should_receive(:menu).once.with any, message[:uri], config.messages.menu_saved,
73
67
  { timeout: config.menu_timeout, tries: config.menu_tries }, Proc
74
68
  end
75
69
  end
@@ -66,6 +66,24 @@ describe Voicemail::MailboxSetGreetingController do
66
66
  end
67
67
  end
68
68
 
69
+ describe "#delete_greeting_menu" do
70
+ it "calls #menu with proper parameters" do
71
+ subject.should_receive(:menu).once.with(config.set_greeting.delete_confirmation,
72
+ {timeout: config.menu_timeout,
73
+ tries: config.menu_tries}, Proc)
74
+ subject.delete_greeting_menu
75
+ end
76
+ end
77
+
78
+ describe "#delete_greeting" do
79
+ it "deletes the greeting and plays a confirmation" do
80
+ storage_instance.should_receive(:delete_greeting_from_mailbox).with(mailbox[:id])
81
+ subject.should_receive(:play).with(config.set_greeting.greeting_deleted)
82
+ subject.should_receive(:main_menu)
83
+ subject.delete_greeting
84
+ end
85
+ end
86
+
69
87
  describe "#save_greeting" do
70
88
  let(:file_path) { "/path/to/file" }
71
89
 
@@ -18,8 +18,8 @@ describe Voicemail::MailboxSetPinController do
18
18
  let(:short_pin) { "9" }
19
19
 
20
20
  it "makes the user enter a PIN and repeat it" do
21
- should_ask(config.set_pin.prompt, terminator: "#").and_return(pin).ordered
22
- should_ask(config.set_pin.repeat_prompt, terminator: "#").and_return(pin).ordered
21
+ should_ask(config.set_pin.prompt, terminator: "#", timeout: 5).and_return(pin).ordered
22
+ should_ask(config.set_pin.repeat_prompt, terminator: "#", timeout: 5).and_return(pin).ordered
23
23
  should_play(config.set_pin.change_ok).ordered
24
24
  storage_instance.should_receive(:change_pin_for_mailbox).with(mailbox[:id], pin).once.ordered
25
25
  subject.should_receive(:main_menu).once
@@ -27,11 +27,11 @@ describe Voicemail::MailboxSetPinController do
27
27
  end
28
28
 
29
29
  it "makes the user start over if the PIN is too short" do
30
- should_ask(config.set_pin.prompt, terminator: "#").and_return(short_pin).ordered
31
- should_ask(config.set_pin.repeat_prompt, terminator: "#").and_return(short_pin).ordered
30
+ should_ask(config.set_pin.prompt, terminator: "#", timeout: 5).and_return(short_pin).ordered
31
+ should_ask(config.set_pin.repeat_prompt, terminator: "#", timeout: 5).and_return(short_pin).ordered
32
32
  should_play(config.set_pin.pin_error).ordered
33
- should_ask(config.set_pin.prompt, terminator: "#").and_return(pin).ordered
34
- should_ask(config.set_pin.repeat_prompt, terminator: "#").and_return(pin).ordered
33
+ should_ask(config.set_pin.prompt, terminator: "#", timeout: 5).and_return(pin).ordered
34
+ should_ask(config.set_pin.repeat_prompt, terminator: "#", timeout: 5).and_return(pin).ordered
35
35
  should_play(config.set_pin.change_ok).ordered
36
36
  storage_instance.should_receive(:change_pin_for_mailbox).with(mailbox[:id], pin).once.ordered
37
37
  subject.should_receive(:main_menu).once
@@ -39,11 +39,11 @@ describe Voicemail::MailboxSetPinController do
39
39
  end
40
40
 
41
41
  it "makes the user start over if the PIN does not match confirmation" do
42
- should_ask(config.set_pin.prompt, terminator: "#").and_return(pin).ordered
43
- should_ask(config.set_pin.repeat_prompt, terminator: "#").and_return(not_matching_pin).ordered
42
+ should_ask(config.set_pin.prompt, terminator: "#", timeout: 5).and_return(pin).ordered
43
+ should_ask(config.set_pin.repeat_prompt, terminator: "#", timeout: 5).and_return(not_matching_pin).ordered
44
44
  should_play(config.set_pin.match_error).ordered
45
- should_ask(config.set_pin.prompt, terminator: "#").and_return(pin).ordered
46
- should_ask(config.set_pin.repeat_prompt, terminator: "#").and_return(pin).ordered
45
+ should_ask(config.set_pin.prompt, terminator: "#", timeout: 5).and_return(pin).ordered
46
+ should_ask(config.set_pin.repeat_prompt, terminator: "#", timeout: 5).and_return(pin).ordered
47
47
  should_play(config.set_pin.change_ok).ordered
48
48
  storage_instance.should_receive(:change_pin_for_mailbox).with(mailbox[:id], pin).once.ordered
49
49
  subject.should_receive(:main_menu).once
@@ -46,6 +46,7 @@ describe Voicemail::VoicemailController do
46
46
  it "plays the default greeting if one is not specified" do
47
47
  should_play config.default_greeting
48
48
  subject.should_receive :record_message
49
+ should_play config.recording_confirmation
49
50
  controller.run
50
51
  end
51
52
  end
@@ -56,6 +57,7 @@ describe Voicemail::VoicemailController do
56
57
  it "plays the specific greeting message" do
57
58
  should_play greeting_message
58
59
  subject.should_receive :record_message
60
+ should_play config.recording_confirmation
59
61
  controller.run
60
62
  end
61
63
  end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe Voicemail::IntroMessageCreator do
4
+ include FlexMock::ArgumentTypes
5
+
6
+ let(:config) { Voicemail::Plugin.config }
7
+ let(:message) do
8
+ {
9
+ from: "1234",
10
+ received: Time.local(2012, 5, 1, 9, 0, 0)
11
+ }
12
+ end
13
+
14
+ subject { flexmock described_class.new(message) }
15
+
16
+ describe "#intro_message" do
17
+ context "in :i18n_string mode" do
18
+ before { config.numeric_method = :i18n_string }
19
+
20
+ it "returns the translation" do
21
+ flexmock(I18n).should_receive('localize').with(Time.local(2012, 5, 1, 9, 0, 0)).and_return "9pm"
22
+ I18n.backend.store_translations :en, voicemail: {
23
+ messages: {
24
+ message_received_on_x: "Message received on %{received_on}",
25
+ message_received_from_x: "Message received from %{from}"
26
+ }
27
+ }, numbers: {'1' => "one ", '2' => "two ", '3' => 'three ', '4' => 'four '}
28
+
29
+ subject.intro_message.should == ["Message received on 9pm", "Message received from one two three four "]
30
+ end
31
+ end
32
+
33
+ context "in :ahn_say mode" do
34
+ let!(:ahn_config) { flexmock(Adhearsion.config, punchblock: OpenStruct.new, ahnsay: OpenStruct.new(sounds_dir: "/")) }
35
+
36
+ before do
37
+ config.numeric_method = :ahn_say
38
+ config.datetime_format = "hmp"
39
+ end
40
+
41
+ it "returns a nice array full of ahn_say sound files" do
42
+ subject.intro_message.should == [
43
+ "Message received on ",
44
+ ["/9.ul", "/oclock.ul", "/a-m.ul"],
45
+ " from ",
46
+ ["/1.ul", "/2.ul", "/3.ul", "/4.ul"]
47
+ ]
48
+ end
49
+ end
50
+
51
+ context "in :play_numeric mode" do
52
+ let(:formatter) { flexmock Adhearsion::CallController::Output::Formatter }
53
+ before do
54
+ flexmock Adhearsion::CallController::Output::Formatter, new: formatter
55
+ config.numeric_method = :play_numeric
56
+ end
57
+
58
+ it "returns speech and ssml in an array" do
59
+ formatter.should_receive(:ssml_for_time).with(Time.local(2012, 5, 1, 9, 0, 0), any).and_return :time
60
+ formatter.should_receive(:ssml_for_characters).with('1234').and_return :number
61
+ subject.intro_message.should == ["Message received on ", :time, " from ", :number]
62
+ end
63
+ end
64
+ end
65
+ end
@@ -103,5 +103,20 @@ module Voicemail
103
103
  end
104
104
  end
105
105
  end
106
+
107
+ describe "#delete_greeting_from_mailbox" do
108
+ before do
109
+ storage.store.transaction do |store|
110
+ store[:mailboxes][100][:greeting_message] = "/some/path"
111
+ end
112
+ end
113
+
114
+ it "deletes the greeting message" do
115
+ storage.delete_greeting_from_mailbox 100
116
+ storage.store.transaction do |store|
117
+ store[:mailboxes][100][:greeting_message].should be_nil
118
+ end
119
+ end
120
+ end
106
121
  end
107
122
  end
@@ -17,14 +17,14 @@ en:
17
17
  '0': "zero "
18
18
 
19
19
  voicemail:
20
- default_greeting: "You have reached voicemail"
20
+ default_greeting: "You have reached Voicemail"
21
21
  mailbox_not_found: "Mailbox not found"
22
22
 
23
23
  mailbox:
24
24
  greeting_message: "Welcome to the mailbox system."
25
25
  please_enter_pin: "Please enter your PIN."
26
26
  pin_wrong: "The PIN you entered does not match. Please try again."
27
- could_not_auth: "We are sorry, the system could not authenticate you"
27
+ could_not_auth: "We are sorry, the system could not authenticate you."
28
28
  number_before: "You have "
29
29
  number_after: " new messages"
30
30
  number_after_saved: " saved messages"
@@ -34,34 +34,38 @@ en:
34
34
  x_saved_messages:
35
35
  one: "You have one saved message. "
36
36
  other: "You have %{count} saved messages. "
37
- menu_greeting: "Press 1 to listen to new messages, 2 to change your greeting, 3 to change your PIN"
38
- menu_timeout_message: "Please enter a digit for the menu"
39
- menu_invalid_message: "Please enter valid input"
37
+ menu_greeting: "Press 1 to listen to new messages, 2 to change your greeting, 3 to change your PIN."
38
+ menu_timeout_message: "Please enter a digit for the menu."
39
+ menu_invalid_message: "Please enter valid input."
40
40
  menu_failure_message: "Sorry, unable to understand your input."
41
41
 
42
42
  after_record: "Press 1 to save your voicemail. Press 2 to rerecord."
43
+ recording_confirmation: "Your message has been saved. Thank you."
43
44
 
44
45
  set_greeting:
45
- prompt: "Press 1 to listen to your current greeting, 2 to record a new greeting, 9 to return to the main menu"
46
+ prompt: "Press 1 to listen to your current greeting, 2 to record a new greeting, 9 to return to the main menu."
46
47
  before_record: "Please speak after the beep. The prompt will be played back after."
47
- after_record: "Press 1 to save your new greeting, 2 to discard it, 9 to go back to the menu"
48
+ after_record: "Press 1 to save your new greeting, 2 to discard it, 9 to go back to the menu."
48
49
  no_personal_greeting: "You do not currently have a personalized greeting."
49
50
 
50
51
  set_pin:
51
- menu: "Press 1 to change your current PIN, or 9 to go back to the main menu"
52
- prompt: "Enter your new PIN of at least four digits followed by the pound sign"
53
- repeat_prompt: "Please enter your new PIN again, followed by the pound sign"
52
+ menu: "Press 1 to change your current PIN, or 9 to go back to the main menu."
53
+ prompt: "Enter your new PIN of at least four digits followed by the pound sign."
54
+ repeat_prompt: "Please enter your new PIN again, followed by the pound sign."
54
55
  pin_error: "Please enter at least four digits followed by the pound sign."
55
56
  match_error: "The two entered PINs don't match, please try again."
56
- change_ok: "Your PIN has been successfully changed"
57
+ change_ok: "Your PIN has been successfully changed."
57
58
 
58
59
  messages:
59
60
  menu_new: "Press 1 to archive the message and go to the next, press 5 to delete the message and go to the next, press 7 to hear the message again, press 9 for the main menu"
60
61
  menu_saved: "Press 1 to unarchive the message and go to the next, press 5 to delete the message and go to the next, press 7 to hear the message again, press 9 for the main menu"
61
- no_new_messages: "There are no new messages"
62
- no_saved_messages: "There are no saved messages"
62
+ no_new_messages: "There are no new messages."
63
+ no_saved_messages: "There are no saved messages."
63
64
  message_received_on: "Message received on "
64
65
  from: " from "
65
66
  message_received_on_x: "Message received on %{received_on}. "
66
67
  message_received_from_x: "Message received from %{from}. "
67
-
68
+ deleting_all_new_messages: "All of your new messages are being deleted. Please wait."
69
+ deleting_all_saved_messages: "All of your saved messages are being deleted. Please wait."
70
+ all_new_messages_deleted: "All new messages have been deleted."
71
+ all_saved_messages_deleted: "All saved messages have been deleted."
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency %q<rake>, [">= 0"]
27
27
  s.add_development_dependency %q<guard-rspec>
28
28
  s.add_development_dependency %q<flexmock>
29
+ s.add_development_dependency %q<ahnsay>
29
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voicemail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Pradovera
@@ -9,104 +9,118 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-02 00:00:00.000000000 Z
12
+ date: 2014-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: adhearsion
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '2.4'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.4'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 2.14.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 2.14.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: yard
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: 0.6.0
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: 0.6.0
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rake
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: guard-rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: flexmock
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: ahnsay
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
110
124
  - !ruby/object:Gem::Version
111
125
  version: '0'
112
126
  description: A simple, extensible voicemail implementation
@@ -117,8 +131,9 @@ executables: []
117
131
  extensions: []
118
132
  extra_rdoc_files: []
119
133
  files:
120
- - .gitignore
121
- - .rspec
134
+ - ".gitignore"
135
+ - ".hound.yml"
136
+ - ".rspec"
122
137
  - CHANGELOG.md
123
138
  - Gemfile
124
139
  - Guardfile
@@ -128,6 +143,7 @@ files:
128
143
  - lib/voicemail.rb
129
144
  - lib/voicemail/call_controllers/application_controller.rb
130
145
  - lib/voicemail/call_controllers/authentication_controller.rb
146
+ - lib/voicemail/call_controllers/mailbox_cleaner_controller.rb
131
147
  - lib/voicemail/call_controllers/mailbox_controller.rb
132
148
  - lib/voicemail/call_controllers/mailbox_main_menu_controller.rb
133
149
  - lib/voicemail/call_controllers/mailbox_messages_controller.rb
@@ -136,6 +152,7 @@ files:
136
152
  - lib/voicemail/call_controllers/mailbox_set_greeting_controller.rb
137
153
  - lib/voicemail/call_controllers/mailbox_set_pin_controller.rb
138
154
  - lib/voicemail/call_controllers/voicemail_controller.rb
155
+ - lib/voicemail/intro_message_creator.rb
139
156
  - lib/voicemail/localization_loader.rb
140
157
  - lib/voicemail/matcher.rb
141
158
  - lib/voicemail/plugin.rb
@@ -146,6 +163,7 @@ files:
146
163
  - spec/support/voicemail_controller_spec_helper.rb
147
164
  - spec/voicemail/call_controllers/application_controller_spec.rb
148
165
  - spec/voicemail/call_controllers/authentication_controller_spec.rb
166
+ - spec/voicemail/call_controllers/mailbox_cleaner_controller_spec.rb
149
167
  - spec/voicemail/call_controllers/mailbox_controller_spec.rb
150
168
  - spec/voicemail/call_controllers/mailbox_main_menu_controller_spec.rb
151
169
  - spec/voicemail/call_controllers/mailbox_messages_controller_spec.rb
@@ -154,6 +172,7 @@ files:
154
172
  - spec/voicemail/call_controllers/mailbox_set_greeting_controller_spec.rb
155
173
  - spec/voicemail/call_controllers/mailbox_set_pin_controller_spec.rb
156
174
  - spec/voicemail/call_controllers/voicemail_controller_spec.rb
175
+ - spec/voicemail/intro_message_creator_spec.rb
157
176
  - spec/voicemail/localization_loader_spec.rb
158
177
  - spec/voicemail/storage_pstore_spec.rb
159
178
  - spec/voicemail/storage_spec.rb
@@ -170,17 +189,17 @@ require_paths:
170
189
  - lib
171
190
  required_ruby_version: !ruby/object:Gem::Requirement
172
191
  requirements:
173
- - - '>='
192
+ - - ">="
174
193
  - !ruby/object:Gem::Version
175
194
  version: '0'
176
195
  required_rubygems_version: !ruby/object:Gem::Requirement
177
196
  requirements:
178
- - - '>='
197
+ - - ">="
179
198
  - !ruby/object:Gem::Version
180
199
  version: '0'
181
200
  requirements: []
182
201
  rubyforge_project: voicemail
183
- rubygems_version: 2.0.3
202
+ rubygems_version: 2.2.2
184
203
  signing_key:
185
204
  specification_version: 4
186
205
  summary: Voicemail for Adhearsion
@@ -189,6 +208,7 @@ test_files:
189
208
  - spec/support/voicemail_controller_spec_helper.rb
190
209
  - spec/voicemail/call_controllers/application_controller_spec.rb
191
210
  - spec/voicemail/call_controllers/authentication_controller_spec.rb
211
+ - spec/voicemail/call_controllers/mailbox_cleaner_controller_spec.rb
192
212
  - spec/voicemail/call_controllers/mailbox_controller_spec.rb
193
213
  - spec/voicemail/call_controllers/mailbox_main_menu_controller_spec.rb
194
214
  - spec/voicemail/call_controllers/mailbox_messages_controller_spec.rb
@@ -197,6 +217,7 @@ test_files:
197
217
  - spec/voicemail/call_controllers/mailbox_set_greeting_controller_spec.rb
198
218
  - spec/voicemail/call_controllers/mailbox_set_pin_controller_spec.rb
199
219
  - spec/voicemail/call_controllers/voicemail_controller_spec.rb
220
+ - spec/voicemail/intro_message_creator_spec.rb
200
221
  - spec/voicemail/localization_loader_spec.rb
201
222
  - spec/voicemail/storage_pstore_spec.rb
202
223
  - spec/voicemail/storage_spec.rb