Skip to content

Instantly share code, notes, and snippets.

@patrick99e99
Created May 1, 2010 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrick99e99/386129 to your computer and use it in GitHub Desktop.
Save patrick99e99/386129 to your computer and use it in GitHub Desktop.
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
endr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment