Created
April 12, 2012 00:29
-
-
Save jadehopepunk/2363742 to your computer and use it in GitHub Desktop.
refactored test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe CommentsController do | |
let (:app_controller) { controller } | |
let (:motion) { mock_model(Motion) } | |
let (:comment) { mock_model(Comment, :default_motion => motion) } | |
context "deleting comment" do | |
before do | |
app_controller.stub(:authenticate_user!).and_return(true) | |
app_controller.stub(:authorize!).and_return(true) | |
app_controller.stub(:resource).and_return(comment) | |
end | |
it "requires an authorised resource" do | |
app_controller.should_receive(:authorize!).and_return(true) | |
delete :destroy, id: 23 | |
end | |
it "adds a message to the flash" do | |
delete :destroy, id: 23 | |
flash[:notice].should match(/Comment deleted/) | |
end | |
it "redirects to the comment's motion" do | |
delete :destroy, id: 23 | |
response.should redirect_to(motion_path(motion)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment