Guest User

Untitled

a guest
Apr 23rd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. >>>> THIS IS NEW <% if current_account.entries.empty? %>
  2. <p class="empty_summary">
  3. Ready to begin taking advantage of change:healthcare's bill management capabilities? How about adding a <%= link_to 'Bill', :controller => 'bills', :action => 'new' %>, <%= link_to 'EOB', :controller => 'eobs', :action => 'new' %>, <%= link_to 'Payment', :controller => 'payments', :action => 'new' %>, or <%= link_to 'Prescription', :controller => 'prescriptions', :action => 'new' %> to get started? Don't worry, it's not hard, and you'll be taking control of your medical paperwork in no time!</p>
  4. <p class="empty_summary">Confused? Have a look at our <%=link_to('help section', {:controller => 'help', :action => 'index'}) %> for more information.</p>
  5. >>>> EVERYTHING BELOW PREVIOUSLY TESTED <% else %>
  6. <ul>
  7. <% current_account.providers.each do |provider| %>
  8. <% balance = provider.records.total(:balance) %>
  9. <% if balance > 0 %>
  10. <li>
  11. <div class="left"><span class="red"><%= number_to_currency(balance) %></span> to <span class="blue"><%= provider.name %></span></div>
  12. <div class="right">&rsaquo; <%= link_to 'View Details', :controller => 'providers', :action => 'show', :id => provider.id %></div>
  13. <div class="clear"></div>
  14. </li>
  15. <% end %>
  16. <% end %>
  17. </ul>
  18. <% end %>
  19.  
  20.  
  21.  
  22. >>>>>THIS IS THE CODE IN THE TEST
  23.  
  24. it 'has an area for providers with balances' do
  25. do_render
  26. response.should have_tag('div[id=?]', 'you_owe_list')
  27. end
  28.  
  29. describe 'within the providers with balances area' do
  30. before :each do
  31. @provider = Provider.generate!(:name => 'Mr. Provider')
  32. @account.stubs(:providers).returns([@provider])
  33. @pro_record = Record.generate!
  34. @pro_record.stubs(:balance).returns(1)
  35. @provider.stubs(:records).returns([@pro_record])
  36. end
  37.  
  38. it 'has a transaction list header' do
  39. do_render
  40. response.should have_tag('div[id=?]', 'you_owe_list') do
  41. with_tag('h3', 'List of Transactions')
  42. end
  43. end
  44.  
  45. it 'has a list' do
  46. do_render
  47. response.should have_tag('div[id=?]', 'you_owe_list') do
  48. with_tag('ul')
  49. end
  50. end
  51.  
  52. it 'contains the provider name' do
  53. do_render
  54. response.should have_tag('div[id=?]', 'you_owe_list') do
  55. with_tag('ul') do
  56. with_tag('li', /#{@provider.name}/)
  57. end
  58. end
  59. end
  60.  
  61. it 'contains the balance of the provider record in currency format' do
  62. @pro_record.stubs(:balance).returns(5.67)
  63. do_render
  64. response.should have_tag('div[id=?]', 'you_owe_list') do
  65. with_tag('ul') do
  66. with_tag('li', /\$5\.67/)
  67. end
  68. end
  69. end
  70.  
  71. it 'sums the total balance of the provider records' do
  72. other_record = Record.generate!
  73. @pro_record.stubs(:balance).returns(5.67)
  74. other_record.stubs(:balance).returns(8.35)
  75. records = [@pro_record, other_record]
  76. @provider.stubs(:records).returns(records)
  77.  
  78. do_render
  79. response.should have_tag('div[id=?]', 'you_owe_list') do
  80. with_tag('ul') do
  81. with_tag('li', /\$14\.02/)
  82. end
  83. end
  84. end
  85.  
  86. it 'contains a link to the provider' do
  87. do_render
  88. response.should have_tag('div[id=?]', 'you_owe_list') do
  89. with_tag('ul') do
  90. with_tag('li') do
  91. with_tag('a[href=?]', url_for(:controller => 'providers', :action => 'show', :id => @provider.id))
  92. end
  93. end
  94. end
  95. end
  96.  
  97. it 'has an item for every provider' do
  98. other_provider = Provider.generate!(:name => 'Ms. Provider')
  99. other_provider.stubs(:records).returns([@pro_record])
  100. providers = [@provider, other_provider]
  101. @account.stubs(:providers).returns(providers)
  102.  
  103. do_render
  104. response.should have_tag('div[id=?]', 'you_owe_list') do
  105. with_tag('ul') do
  106. providers.each do |provider|
  107. with_tag('li', /#{provider.name}/)
  108. end
  109. end
  110. end
  111. end
  112.  
  113. it 'has no items if there are no providers' do
  114. @account.stubs(:providers).returns([])
  115. do_render
  116. response.should have_tag('div[id=?]', 'you_owe_list') do
  117. with_tag('ul') do
  118. without_tag('li')
  119. end
  120. end
  121. end
  122.  
  123. it 'has no item for a provider with a 0 balance' do
  124. @pro_record.stubs(:balance).returns(0)
  125. do_render
  126. response.should have_tag('div[id=?]', 'you_owe_list') do
  127. with_tag('ul') do
  128. without_tag('li', /#{@provider.name}/)
  129. end
  130. end
  131. end
  132.  
  133. it 'has no item for a provider with a negative balance' do
  134. @pro_record.stubs(:balance).returns(-789)
  135. do_render
  136. response.should have_tag('div[id=?]', 'you_owe_list') do
  137. with_tag('ul') do
  138. without_tag('li', /#{@provider.name}/)
  139. end
  140. end
  141. end
  142. end
  143. end
Add Comment
Please, Sign In to add comment