Skip to content

Commit

Permalink
Add I18n string option for the message intro
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinAiken committed Oct 9, 2013
1 parent 29ae6e7 commit 6c175a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions templates/en.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}. "

0 comments on commit 6c175a4

Please sign in to comment.