diff --git a/lib/voicemail/call_controllers/mailbox_play_message_intro_controller.rb b/lib/voicemail/call_controllers/mailbox_play_message_intro_controller.rb index c810b61..5b85c2b 100644 --- a/lib/voicemail/call_controllers/mailbox_play_message_intro_controller.rb +++ b/lib/voicemail/call_controllers/mailbox_play_message_intro_controller.rb @@ -13,6 +13,8 @@ def intro_message def play_time_message case config.numeric_method + when :i18n_string + play I18n.t("voicemail.messages.message_received_on_x", received_on: I18n.localize(current_message[:received])) when :play_numeric play config.messages.message_received_on play_time current_message[:received], format: config.datetime_format @@ -24,6 +26,8 @@ def play_time_message def play_from_message case config.numeric_method + when :i18n_string + play I18n.t("voicemail.messages.message_received_from_x", from: from_digits) when :play_numeric play config.messages.from say_characters from_digits unless from_digits.empty? diff --git a/spec/voicemail/call_controllers/mailbox_play_message_intro_controller_spec.rb b/spec/voicemail/call_controllers/mailbox_play_message_intro_controller_spec.rb index 867dbc5..dcf2bac 100644 --- a/spec/voicemail/call_controllers/mailbox_play_message_intro_controller_spec.rb +++ b/spec/voicemail/call_controllers/mailbox_play_message_intro_controller_spec.rb @@ -13,9 +13,14 @@ } end + before { config.numeric_method = numeric_method } + + let(:numeric_method) { :play_numeric} + describe "#intro_message" do before { subject.should_receive(:current_message).and_return message } + after { subject.intro_message } context "with the default mode" do it "plays the message introduction" do @@ -24,14 +29,11 @@ should_play config.messages.from subject.should_receive(:say_characters).with "39335135335" - - controller.intro_message end end context "with ahnsay" do - before { config.numeric_method = :ahn_say } - after { config.numeric_method = :play_numeric } + let(:numeric_method) {:ahn_say } it "plays the message introduction" do should_play config.messages.message_received_on @@ -41,8 +43,19 @@ should_play config.messages.from subject.should_receive(:sounds_for_digits).with("39335135335").and_return ["digit1.wav", "digit2.wav"] should_play "digit1.wav", "digit2.wav" + end + end + + context "with i18n_string" do + let(:numeric_method) {:i18n_string } + + it "plays the message introduction" do + flexmock(I18n).should_receive(:localize).with(some_time).and_return "some time" + flexmock(I18n).should_receive(:t).with("voicemail.messages.message_received_on_x", received_on: "some time").and_return "Message received on some time. " + flexmock(I18n).should_receive(:t).with("voicemail.messages.message_received_from_x", from: "39335135335").and_return "Message received from 39335135335. " - controller.intro_message + should_play "Message received on some time. " + should_play "Message received from 39335135335. " end end end diff --git a/templates/en.yml b/templates/en.yml index 93ce9fd..47c0575 100644 --- a/templates/en.yml +++ b/templates/en.yml @@ -1,4 +1,10 @@ en: + time: + am: am + pm: pm + formats: + default: '%A, %B %d at %H:%M %p' + voicemail: default_greeting: "You have reached voicemail" mailbox_not_found: "Mailbox not found" @@ -43,3 +49,6 @@ en: no_saved_messages: "There are no saved messages" message_received_on: "Message received on " from: " from " + message_received_on_x: "Message received on %{received_on}. " + message_received_from_x: "Message received from %{from}. " +