Skip to content

Instantly share code, notes, and snippets.

@justinko
Forked from alindeman/let_with_contexts.rb
Created June 23, 2011 23:45
Show Gist options
  • Save justinko/1043913 to your computer and use it in GitHub Desktop.
Save justinko/1043913 to your computer and use it in GitHub Desktop.
describe PostsController do
describe "PUT #update" do
let(:post) { Factory(:post) }
context "when logged in as post's author" do
before { sign_in post.author }
it "allows the post to be updated" do
do_action
response.should be_success
end
end
context "when logged in as another user" do
before { sign_in Factory(:user) }
it "does not allow the post to be updated" do
do_action
response.should be_forbidden
end
end
def do_action
put :update, :id => post.id, :body => "new content"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment