Guest User

Untitled

a guest
May 24th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe ResultList do
  4.  
  5. before(:all) do
  6. ResultList.all.map(&:destroy)
  7. Contact.all.map(&:destroy)
  8. @result_list = ResultList.create!
  9.  
  10. 5.times do
  11. Contact.create!(:first_name => "James", :last_name => "Kirk")
  12. end
  13.  
  14. @contact_ids = Contact.all.map(&:id)
  15. end
  16.  
  17. it "should add the contacts to the list" do
  18. @result_list.add_or_remove_checked_to_list(@contact_ids.join(","), false)
  19. @result_list.job_action_count.should == @contact_ids.length
  20. @result_list.contacts.count.should == @contact_ids.length
  21. end
  22.  
  23. it "should remove the contacts from the list" do
  24. @result_list.add_or_remove_checked_to_list(@contact_ids.join(","), true)
  25. @result_list.job_action_count.should == -@contact_ids.length
  26. @result_list.contacts.count.should == 0
  27. end
  28.  
  29. it "should add the search result to the list" do
  30. @result_list.add_or_remove_search_result({:search => "Kirk",
  31. :search_scope => "name",
  32. :display => "all",
  33. :model => Contact.setup}, false)
  34. @result_list.job_action_count.should == @contact_ids.length
  35. @result_list.contacts.count.should == @contact_ids.length
  36. end
  37.  
  38. it "should remove the search result from the list" do
  39. @result_list.add_or_remove_search_result({:search => "Kirk",
  40. :search_scope => "name",
  41. :display => "all",
  42. :model => Contact.setup}, true)
  43. @result_list.job_action_count.should == -@contact_ids.length
  44. @result_list.contacts.count.should == 0
  45. end
  46.  
  47. it "should clear the contact results" do
  48. @result_list.add_or_remove_checked_to_list(@contact_ids.join(","), false)
  49. @result_list.contacts.count.should == @contact_ids.length
  50. @result_list.clear
  51. @result_list.contacts.count.should == 0
  52. end
  53. end
Add Comment
Please, Sign In to add comment