Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>>> THIS IS NEW <% if current_account.entries.empty? %>
- <p class="empty_summary">
- 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>
- <p class="empty_summary">Confused? Have a look at our <%=link_to('help section', {:controller => 'help', :action => 'index'}) %> for more information.</p>
- >>>> EVERYTHING BELOW PREVIOUSLY TESTED <% else %>
- <ul>
- <% current_account.providers.each do |provider| %>
- <% balance = provider.records.total(:balance) %>
- <% if balance > 0 %>
- <li>
- <div class="left"><span class="red"><%= number_to_currency(balance) %></span> to <span class="blue"><%= provider.name %></span></div>
- <div class="right">› <%= link_to 'View Details', :controller => 'providers', :action => 'show', :id => provider.id %></div>
- <div class="clear"></div>
- </li>
- <% end %>
- <% end %>
- </ul>
- <% end %>
- >>>>>THIS IS THE CODE IN THE TEST
- it 'has an area for providers with balances' do
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list')
- end
- describe 'within the providers with balances area' do
- before :each do
- @provider = Provider.generate!(:name => 'Mr. Provider')
- @account.stubs(:providers).returns([@provider])
- @pro_record = Record.generate!
- @pro_record.stubs(:balance).returns(1)
- @provider.stubs(:records).returns([@pro_record])
- end
- it 'has a transaction list header' do
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('h3', 'List of Transactions')
- end
- end
- it 'has a list' do
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul')
- end
- end
- it 'contains the provider name' do
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- with_tag('li', /#{@provider.name}/)
- end
- end
- end
- it 'contains the balance of the provider record in currency format' do
- @pro_record.stubs(:balance).returns(5.67)
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- with_tag('li', /\$5\.67/)
- end
- end
- end
- it 'sums the total balance of the provider records' do
- other_record = Record.generate!
- @pro_record.stubs(:balance).returns(5.67)
- other_record.stubs(:balance).returns(8.35)
- records = [@pro_record, other_record]
- @provider.stubs(:records).returns(records)
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- with_tag('li', /\$14\.02/)
- end
- end
- end
- it 'contains a link to the provider' do
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- with_tag('li') do
- with_tag('a[href=?]', url_for(:controller => 'providers', :action => 'show', :id => @provider.id))
- end
- end
- end
- end
- it 'has an item for every provider' do
- other_provider = Provider.generate!(:name => 'Ms. Provider')
- other_provider.stubs(:records).returns([@pro_record])
- providers = [@provider, other_provider]
- @account.stubs(:providers).returns(providers)
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- providers.each do |provider|
- with_tag('li', /#{provider.name}/)
- end
- end
- end
- end
- it 'has no items if there are no providers' do
- @account.stubs(:providers).returns([])
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- without_tag('li')
- end
- end
- end
- it 'has no item for a provider with a 0 balance' do
- @pro_record.stubs(:balance).returns(0)
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- without_tag('li', /#{@provider.name}/)
- end
- end
- end
- it 'has no item for a provider with a negative balance' do
- @pro_record.stubs(:balance).returns(-789)
- do_render
- response.should have_tag('div[id=?]', 'you_owe_list') do
- with_tag('ul') do
- without_tag('li', /#{@provider.name}/)
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment