messages-partner_portal


/ Published in: Ruby
Save to your folder(s)

Added partial, shared by both cobrand and dashboard views.busy/stale messages are dynamic ad can be customized for each of them independently.


Copy this code and paste it in your HTML
  1. --partial--
  2.  
  3. #_messaging_options.html.haml
  4.  
  5. .ugc-middle.partner-portal-middle
  6. .ugc-middle-content-block.ugc-middle-content-pp-block
  7. %p{:class => "cb-#{@backfilling}"}
  8. = @backfilling_message
  9.  
  10.  
  11. --views rendering partial--
  12.  
  13. #1. cobrand/index.html.haml
  14. - if (@backfilling == "stale" || @backfilling == "busy")
  15. = render :partial => 'partners/messaging_options'
  16.  
  17. #2. dashboard/index.html.haml
  18. - if (@backfilling == "stale" || @backfilling == "busy")
  19. = render :partial => 'partners/messaging_options'
  20. - else
  21. .ugc-middle.partner-portal-middle
  22. ...
  23. ..
  24.  
  25. --- controllers populates state and messages ---
  26.  
  27. # dashboard_controller and cobrand_controller has the same code.
  28.  
  29. @backfilling = AppConfig.value_of("fansnap.broker.backfill", "ok")
  30.  
  31. # Change in message @ view can be achieved by editing here.
  32. @backfilling_message = if(@backfilling == 'busy')
  33. <<-eos
  34. The Partner Portal is not currently available while data is being updated. We will make the Partner Portal available again as soon as possible and we apologize for any inconvenience this may cause. Please contact us at
  35. <a href="mailto:[email protected]"> sales@fansnap.com </a>
  36. if you have an urgent data request. Thank you for your patience.
  37. eos
  38. elsif(@backfilling == 'stale')
  39. <<-eos
  40. FanSnap is currently updating data in the portal from previous months. As a result, the information displayed may change when the update is complete. We apologize for any inconvenience this may cause. Please contact us at
  41. <a href="mailto:[email protected]"> sales@fansnap.com </a>
  42. if you have an urgent data request. Thank you for your patience.
  43. eos
  44.  
  45.  
  46. ---
  47. #The same code at both controller can be moved to a helper and call it from a helper. This #approach would reduce our chances of customizing these messages specific to cobrand and #dashboard.
  48.  
  49. #--- specs --
  50.  
  51. #I have created a shared example group which can be reused by both DashBoard(Broker) and #CoBrand.
  52.  
  53. # This group should support both DashBoard and CoBrand
  54.  
  55. shared_examples_for "Supporting back filling messages" do
  56. it "should have message as 'unavailable' when state is 'busy'" do
  57. @controller.stub!(:init_props)# No more pre-populating values
  58. AppConfig.merge({"fansnap.broker.backfill" => "busy"})# Setting the value to be busy
  59. AppConfig.merge({"fansnap.cobrand.backfill" => "busy"})
  60. # Expecting that 'over riding properties through hierarchy' works fine.
  61. get :index, :channel_name => "fs"
  62. #Check if the view has proper message
  63. assigns[:backfilling_message].should =~ /The Partner Portal is not currently available/
  64. end
  65.  
  66. it "should have no message when state is 'ok'" do
  67. @controller.stub!(:init_props)# No more pre-populating values
  68. AppConfig.merge({"fansnap.broker.backfill" => "ok"})# Setting the value to be 'ok'
  69. AppConfig.merge({"fansnap.cobrand.backfill" => "ok"})
  70. get :index, :channel_name => "fs"
  71. #Check if the view has no error message
  72. assigns[:backfilling_message].should be_nil
  73. end
  74. end
  75.  
  76. and then dashboard and cobrand controllers uses it as;
  77. it_should_behave_like "Supporting back filling messages"
  78.  
  79. #Both specs are green now.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.