Skip to content

Commit 0ed22d0

Browse files
committed
comments on programs only work when logged in
1 parent 281c670 commit 0ed22d0

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

spec/acceptance/content_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
2+
3+
feature "Content" do
4+
scenario "adds a subscription when commented upon"
5+
scenario "notifies a subscription when comments are made"
6+
scenario "can be unsubscribed from"
7+
end

spec/acceptance/programs_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,25 @@
3535
page.should have_content program.title
3636
end
3737
end
38+
39+
describe "has comments" do
40+
scenario "can't be commented on when not logged in" do
41+
@hacker = Factory(:hacker)
42+
43+
program = Factory(:program, :creator_username => @hacker.username)
44+
45+
visit "/programs/#{@hacker.slug}/#{@hacker.programs.first.slug}"
46+
page.should_not have_content "Add a comment"
47+
end
48+
49+
scenario "can be commented on when you are logged in" do
50+
@hacker = Factory(:hacker)
51+
log_in @hacker
52+
53+
program = Factory(:program, :creator_username => @hacker.username)
54+
55+
visit "/programs/#{@hacker.slug}/#{@hacker.programs.first.slug}"
56+
page.should have_content "Add a comment"
57+
end
58+
end
3859
end

views/programs/show.haml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
#{reply.body}
2222
%br/
2323
%br/
24-
%h2 Add a comment
25-
%form{:action => "/programs/#{@program.creator_username}/#{@program.slug}/comment", :method => "POST"}
26-
%label{:for => "comment_body"} Body
27-
%br
28-
%textarea{:id => "comment_body", :name => "comment[body]", :rows => 20, :cols => 50}
29-
%br
30-
%input{:type => "submit", :value => "Submit", :class => "button"}
24+
- if logged_in?
25+
%h2 Add a comment
26+
%form{:action => "/programs/#{@program.creator_username}/#{@program.slug}/comment", :method => "POST"}
27+
%label{:for => "comment_body"} Body
28+
%br
29+
%textarea{:id => "comment_body", :name => "comment[body]", :rows => 20, :cols => 50}
30+
%br
31+
%input{:type => "submit", :value => "Submit", :class => "button"}
3132
%br/
3233
%br/

0 commit comments

Comments
 (0)