Skip to content

Instantly share code, notes, and snippets.

@alindeman
Created June 21, 2011 16:16
Show Gist options
  • Save alindeman/1038219 to your computer and use it in GitHub Desktop.
Save alindeman/1038219 to your computer and use it in GitHub Desktop.
describe PostsController do
describe "PUT #update" do
let(:post) { Factory(:post) }
before(:each) do
sign_in user # user is defined as a memoized helper method using let { } below
put :update, :id => post.id, :body => "new content"
end
context "when logged in as post's author" do
let(:user) { post.author }
it "allows the post to be updated" do
response.should be_success
end
end
context "when logged in as another user" do
let(:user) { Factory(:user) }
it "does not allow the post to be updated" do
response.should be_forbidden
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment