Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created May 19, 2011 02:17
Show Gist options
  • Select an option

  • Save dangalipo/980045 to your computer and use it in GitHub Desktop.

Select an option

Save dangalipo/980045 to your computer and use it in GitHub Desktop.
describe '#destroy' do
before :each do
stub(HealthProfessional).find(8) { @health_professional }
end
context 'as a user without permissions' do
before :each do
login_as_user!
delete :destroy, :id => 8
end
it_should_behave_like 'user gets redirected to profile'
end
context 'as a user with permissions' do
before :each do
login_as_admin!
end
it 'redirect to index' do
mock(@health_professional).destroy { true }
stub(@health_professional).persisted? { false }
delete :destroy, :id => 8
response.should redirect_to manage_health_professionals_url
end
it 'should destroy the health professional object' do
mock(@health_professional).destroy { true }
stub(@health_professional).persisted? { false }
delete :destroy, :id => 8
end
it 'should display a flash notice' do
mock(@health_professional).destroy { true}
stub(@health_professional).persisted? { false }
delete :destroy, :id => 8
flash.now[:notice].should == "successfully deleted health professional"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment