Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- describe ResultList do
- before(:all) do
- ResultList.all.map(&:destroy)
- Contact.all.map(&:destroy)
- @result_list = ResultList.create!
- 5.times do
- Contact.create!(:first_name => "James", :last_name => "Kirk")
- end
- @contact_ids = Contact.all.map(&:id)
- end
- it "should add the contacts to the list" do
- @result_list.add_or_remove_checked_to_list(@contact_ids.join(","), false)
- @result_list.job_action_count.should == @contact_ids.length
- @result_list.contacts.count.should == @contact_ids.length
- end
- it "should remove the contacts from the list" do
- @result_list.add_or_remove_checked_to_list(@contact_ids.join(","), true)
- @result_list.job_action_count.should == -@contact_ids.length
- @result_list.contacts.count.should == 0
- end
- it "should add the search result to the list" do
- @result_list.add_or_remove_search_result({:search => "Kirk",
- :search_scope => "name",
- :display => "all",
- :model => Contact.setup}, false)
- @result_list.job_action_count.should == @contact_ids.length
- @result_list.contacts.count.should == @contact_ids.length
- end
- it "should remove the search result from the list" do
- @result_list.add_or_remove_search_result({:search => "Kirk",
- :search_scope => "name",
- :display => "all",
- :model => Contact.setup}, true)
- @result_list.job_action_count.should == -@contact_ids.length
- @result_list.contacts.count.should == 0
- end
- it "should clear the contact results" do
- @result_list.add_or_remove_checked_to_list(@contact_ids.join(","), false)
- @result_list.contacts.count.should == @contact_ids.length
- @result_list.clear
- @result_list.contacts.count.should == 0
- end
- end
Add Comment
Please, Sign In to add comment