mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-24 09:43:24 -04:00
added comment button to posts
This commit is contained in:
@@ -20,12 +20,16 @@ class Ability
|
||||
can :update, ScientificName
|
||||
can :destroy, ScientificName
|
||||
|
||||
# anyone can create a post, but only the author can edit/destroy
|
||||
# it.
|
||||
# anyone can create a post, or comment on a post,
|
||||
# but only the author can edit/destroy it.
|
||||
can :create, Post
|
||||
can :update, Post, :author_id => member.id
|
||||
can :destroy, Post, :author_id => member.id
|
||||
|
||||
can :create, Comment
|
||||
can :update, Comment, :author_id => member.id
|
||||
can :destroy, Comment, :author_id => member.id
|
||||
|
||||
# same deal for gardens and plantings
|
||||
can :create, Garden
|
||||
can :update, Garden, :owner_id => member.id
|
||||
|
||||
@@ -24,3 +24,7 @@
|
||||
- if can? :destroy, post
|
||||
= link_to 'Delete', post, method: :delete, |
|
||||
data: { confirm: 'Are you sure?' }, :class => 'btn'
|
||||
|
||||
- if can? :create, Comment
|
||||
.post-actions
|
||||
=link_to 'Comment', new_comment_path(), :class => 'btn'
|
||||
|
||||
@@ -34,4 +34,19 @@ describe "posts/show" do
|
||||
rendered.should_not match(/a href="http:\/\/evil.com"/)
|
||||
end
|
||||
|
||||
context "signed in" do
|
||||
before(:each) do
|
||||
sign_in @author
|
||||
controller.stub(:current_user) { @author }
|
||||
@post = assign(:post,
|
||||
FactoryGirl.create(:post, :author => @author))
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows a comment button' do
|
||||
assert_select "a[href=#{new_comment_path}]", "Comment"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user