Guest User

Untitled

a guest
Feb 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
  2. index 9465ac4..67d802a 100644
  3. --- a/app/helpers/application_helper.rb
  4. +++ b/app/helpers/application_helper.rb
  5. @@ -35,6 +35,13 @@ module ApplicationHelper
  6. locale.split('-').last.mb_chars.upcase.to_s
  7. end
  8.  
  9. + def us_only
  10. + return false unless locale_country(I18n.locale).eql?('US')
  11. + returning true do
  12. + yield if block_given?
  13. + end
  14. + end
  15. +
  16. def locale_languages(locale)
  17. COUNTRY_LOCALES[locale_country(locale)].collect do |lang, loc|
  18. [lang.t, loc]
  19. @@ -195,4 +202,6 @@ module ApplicationHelper
  20. def yes_or_no(answer)
  21. (answer =~ /^[y1t]$/i) ? 'content.question.answer_yes'.t : 'content.question.answer_no'.t
  22. end
  23. +
  24. +
  25. end
  26. \ No newline at end of file
  27. diff --git a/app/views/layouts/_checkin.html.erb b/app/views/layouts/_checkin.html.erb
  28. index 6847adc..6dd0831 100644
  29. --- a/app/views/layouts/_checkin.html.erb
  30. +++ b/app/views/layouts/_checkin.html.erb
  31. @@ -26,5 +26,7 @@
  32. </div>
  33.  
  34. <div id="sidebar" class="column span-6 last">
  35. - <%= render :partial => site_specific('sidebar') %>
  36. + <% us_only do %>
  37. + <%= render :partial => site_specific('sidebar') %>
  38. + <% end %>
  39. </div>
  40. \ No newline at end of file
  41. diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
  42. index b6ba3ba..1ef0ec1 100644
  43. --- a/spec/helpers/application_helper_spec.rb
  44. +++ b/spec/helpers/application_helper_spec.rb
  45. @@ -269,4 +269,28 @@ describe ApplicationHelper do
  46. end
  47. end
  48. end
  49. +
  50. + describe "when passed a block that should work for the us only" do
  51. + describe "and the country is US" do
  52. + it "should evalutate the block" do
  53. + lambda {
  54. + I18n.should_receive(:locale).and_return('en-US')
  55. + helper.us_only do
  56. + raise RuntimeError.new(BlockEvaluated)
  57. + end
  58. + }.should raise_error(RuntimeError, BlockEvaluated)
  59. + end
  60. + end
  61. +
  62. + describe "and the country is not the US" do
  63. + it "should not evalutate the block" do
  64. + lambda {
  65. + I18n.should_receive(:locale).and_return('en-UK')
  66. + helper.us_only do
  67. + raise RuntimeError.new(BlockEvaluated)
  68. + end
  69. + }.should_not raise_error(RuntimeError, BlockEvaluated)
  70. + end
  71. + end
  72. + end
  73. end
  74. \ No newline at end of file
Add Comment
Please, Sign In to add comment