Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
- index 9465ac4..67d802a 100644
- --- a/app/helpers/application_helper.rb
- +++ b/app/helpers/application_helper.rb
- @@ -35,6 +35,13 @@ module ApplicationHelper
- locale.split('-').last.mb_chars.upcase.to_s
- end
- + def us_only
- + return false unless locale_country(I18n.locale).eql?('US')
- + returning true do
- + yield if block_given?
- + end
- + end
- +
- def locale_languages(locale)
- COUNTRY_LOCALES[locale_country(locale)].collect do |lang, loc|
- [lang.t, loc]
- @@ -195,4 +202,6 @@ module ApplicationHelper
- def yes_or_no(answer)
- (answer =~ /^[y1t]$/i) ? 'content.question.answer_yes'.t : 'content.question.answer_no'.t
- end
- +
- +
- end
- \ No newline at end of file
- diff --git a/app/views/layouts/_checkin.html.erb b/app/views/layouts/_checkin.html.erb
- index 6847adc..6dd0831 100644
- --- a/app/views/layouts/_checkin.html.erb
- +++ b/app/views/layouts/_checkin.html.erb
- @@ -26,5 +26,7 @@
- </div>
- <div id="sidebar" class="column span-6 last">
- - <%= render :partial => site_specific('sidebar') %>
- + <% us_only do %>
- + <%= render :partial => site_specific('sidebar') %>
- + <% end %>
- </div>
- \ No newline at end of file
- diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
- index b6ba3ba..1ef0ec1 100644
- --- a/spec/helpers/application_helper_spec.rb
- +++ b/spec/helpers/application_helper_spec.rb
- @@ -269,4 +269,28 @@ describe ApplicationHelper do
- end
- end
- end
- +
- + describe "when passed a block that should work for the us only" do
- + describe "and the country is US" do
- + it "should evalutate the block" do
- + lambda {
- + I18n.should_receive(:locale).and_return('en-US')
- + helper.us_only do
- + raise RuntimeError.new(BlockEvaluated)
- + end
- + }.should raise_error(RuntimeError, BlockEvaluated)
- + end
- + end
- +
- + describe "and the country is not the US" do
- + it "should not evalutate the block" do
- + lambda {
- + I18n.should_receive(:locale).and_return('en-UK')
- + helper.us_only do
- + raise RuntimeError.new(BlockEvaluated)
- + end
- + }.should_not raise_error(RuntimeError, BlockEvaluated)
- + end
- + end
- + end
- end
- \ No newline at end of file
Add Comment
Please, Sign In to add comment