Skip to content

Instantly share code, notes, and snippets.

@bnferguson
Created December 29, 2010 20:04
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 bnferguson/5f1f968b93e028aaf210 to your computer and use it in GitHub Desktop.
Save bnferguson/5f1f968b93e028aaf210 to your computer and use it in GitHub Desktop.
describe "as a superuser" do
before(:each) do
@superuser = mock_model(Person, :business => @business).as_null_object
@superuser.stub!(:any_role?).and_return(true)
@superuser.stub!(:is_superuser?).and_return(true)
@superuser.stub!(:must_agree_to_policy?).and_return(false)
controller.stub!(:current_person).and_return(@superuser)
end
describe "in non-production environments" do
before(:each) do
controller.stub!(:production?).and_return(false)
end
it "assigns business" do
do_action
assigns(:business).should be_a_kind_of(Business)
end
%W(lines people groups bill_imports carrier_accounts business_plans custom_carrier_plans imports surveys activities notes notifications business_ref_devices faqs).each do |removable|
before(:each) do
# ActiveRecord doesn't need to be tested here.
@business.send(removable).stub!(:destroy_all).and_return(true)
end
it "removes #{removable} if found in params" do
@params[removable.to_sym] = true
@business.send(removable).should_receive(:destroy_all)
do_action
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment