Skip to content

Commit

Permalink
Merge pull request hotsh#502 from nashby/fix-issue-501
Browse files Browse the repository at this point in the history
add tests for deleting updates, closes hotsh#501
  • Loading branch information
steveklabnik committed Feb 15, 2012
2 parents 7e611d0 + 7782dbe commit 6ae126d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/updates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def destroy
flash[:notice] = "Update Deleted!"
redirect_to root_path
else
flash[:notice] = "I'm afraid I can't let you do that, #{current_user.name}."
flash[:notice] = "I'm afraid I can't let you do that, #{current_user.username}."
redirect_to :back
end
end
Expand Down
30 changes: 30 additions & 0 deletions test/acceptance/update_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,36 @@
end
end

describe "destroy" do
before do
log_in_as_some_user

@u.feed.updates << Fabricate(:update, :author => @u.author)
end

it "destroys own update" do
visit "/users/#{@u.username}"
click_button "I Regret This"

within 'div.flash' do
assert has_content? "Update Deleted!"
end
end

it "doesn't destroy not own update" do
author = Fabricate(:author)
visit "/users/#{@u.username}"

Update.any_instance.stubs(:author).returns(author)

click_button "I Regret This"

within 'div.flash' do
assert has_content? "I'm afraid I can't let you do that, #{@u.username}."
end
end
end

describe "reply and share links for each update" do
before do
log_in_as_some_user
Expand Down

0 comments on commit 6ae126d

Please sign in to comment.