Skip to content

Commit 76c8db7

Browse files
committed
Fixing tests, updating dependancies.
In my hurry, I've neglected testing. Stuff had broken, now it's fixed. Yay!
1 parent e78d4c2 commit 76c8db7

11 files changed

Lines changed: 29 additions & 21 deletions

File tree

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ source "http://rubygems.org"
1010
gem "sinatra", "=1.0"
1111
gem "haml", "3.0.13"
1212
gem "rspec", "=1.3.0"
13-
gem "cucumber", "=0.8.3"
14-
gem "webrat", "=0.7.1"
13+
gem "cucumber"
14+
gem "webrat"
1515
gem "mongo_mapper", "=0.8.2"
16-
gem "cucumber-sinatra", "=0.2.2"
17-
gem "capybara", "=0.3.9"
16+
gem "cucumber-sinatra"
17+
gem "capybara"
1818
gem "factory_girl", "=1.3.1"
1919
gem "database_cleaner", "=0.5.2"
2020
gem "rack-flash", "=0.1.1"

controllers/posts.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@
8989
#if we fail, return to /posts
9090
require_login! :return => "/posts"
9191

92-
#set the email of the comment to our email
92+
#set the username/email of the comment to our email
9393
params[:comment]['author'] = current_user.username
94+
params[:comment]['author_email'] = current_user.email
9495

9596
#find the post we want to comment on
9697
@post = Post.first(:slug => params[:post_slug])

factories/discussion.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Factory.define :discussion do |d|
22
d.author "jane_hacker"
3+
d.author_email "jane_hacker@example.com"
34
end
45
Factory.define :discussion_with_reply, :parent => :discussion do |t|
56
t.replies {|r| [Factory(:reply)] }
@@ -8,4 +9,5 @@
89
Factory.define :reply do |r|
910
r.body "I'm here to help!"
1011
r.author "john_hacker"
12+
r.author_email "john_hacker@example.com"
1113
end

factories/post.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
Factory.define :post do |p|
66
p.title "default title"
77
p.body "This is a body"
8+
p.slug "default_title"
9+
p.comments []
810
end

features/blog.feature

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Feature: The Hackety Blog
88
And I go to the new post page
99
When I fill in "Title" with "new title"
1010
And I fill in "Body" with "new body"
11+
And I fill in "Slug" with "new_title"
1112
And I press "Create Post"
1213
Then I should see "Post Created"
1314
And I should see "new title"
@@ -31,6 +32,7 @@ Feature: The Hackety Blog
3132
And there is a blog post with the title "First Post"
3233
And I go to the edit post page for the post with the title "First Post"
3334
And I fill in "Title" with "new title"
35+
And I fill in "Slug" with "new_title"
3436
And I fill in "Body" with "new body"
3537
When I press "Modify Post"
3638
Then I should see "Post Modified"
@@ -48,25 +50,26 @@ Feature: The Hackety Blog
4850
And I go to the edit post page for the post with the title "First Post"
4951
Then I should see "Sorry, buddy"
5052
Scenario: Logged in Users can comment on the blog
51-
Given I'm logged in as a user with the email "awesome@example.com"
53+
Given I'm logged in as "steve"
5254
And there is a blog post
5355
When I go to a blog post page
54-
And I fill in "Speak your mind:" with "This post is amazing!"
55-
And I press "Submit comment"
56+
And I fill in "Submit your opinion:" with "This post is amazing!"
57+
And I press "Submit"
5658
Then I should be on a blog post page
5759
And I should see "Thanks for your comment!"
58-
And I should see "awesome@example.com says:"
60+
And I should see "steve says:"
5961
And I should see "This post is amazing!"
6062
Scenario: Logged out users can't comment on the blog
6163
Given I'm not logged in
6264
And there is a blog post
6365
When I go to a blog post page
64-
Then should not see "Speak your mind:"
65-
And I should not see "Submit comment"
66+
Then should not see "Submit your opinion:"
67+
And I should not see "Submit"
6668
Scenario: Blog should use Markdown
6769
Given I'm logged in as admin
6870
And I go to the new post page
6971
When I fill in "Title" with "new title"
72+
And I fill in "Slug" with "new_title"
7073
And I fill in "Body" with "new body with a link: [google](http://google.com/)"
7174
And I press "Create Post"
7275
Then I should see "Post Created"

features/forum.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Feature: The Hackety Forum
3737
When I follow "New Discussion"
3838
And I fill in "Title" with "HALP!"
3939
And I fill in "Body" with "I'm really unsure as to how to do something."
40-
And I press "Create Discussion"
40+
And I press "Submit"
4141
Then I should be on the discussion "halp" in "learning_ruby"
4242
And I should see "Discussion created!"
4343
And I should see "HALP!"
44-
And I should see "some_hacker says:"
44+
And I should see "By some_hacker"
4545
Scenario: Can't make discussions when logged out
4646
Given I'm not logged in
4747
And I go to the forums

features/homepage.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: Homepage looks correct
22
Scenario: We should see a download link
33
Given I go to the homepage
4-
Then I should see "Download Hackety"
4+
Then I should see "Click the Shoes logo"
55
Scenario: We should be able to get help
66
Given I go to the homepage
77
When I follow "Help"

features/step_definitions/common_steps.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ def login hacker
22
visit "/login"
33
fill_in "username", :with => hacker.username
44
fill_in "password", :with => hacker.password
5-
click_button "login"
5+
click_button "Log in"
66
end
77

88
Given /^I'm logged in as admin$/ do

features/support/paths.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def path_to(page_name)
2424

2525
when /the edit post page for the post with the title "(.*)"/
2626
post = Post.first(:title => $1)
27-
"/posts/#{post.id}/edit"
27+
"/posts/#{post.slug}/edit"
2828

2929
when /the post page for the post with the title "(.*)"/
3030
post = Post.first(:title => $1)
31-
"/posts/#{post.id}"
31+
"/posts/#{post.slug}"
3232
when /a blog post page/
3333
post = Post.first
34-
"/posts/#{post.id}"
34+
"/posts/#{post.slug}"
3535
when /the new hacker page/
3636
"/signup"
3737
when /the main page/

views/posts/edit.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
%form{:method => "POST", :action => "/posts/#{@post.id}" }
1+
%form{:method => "POST", :action => "/posts/#{@post.slug}" }
22
%input{ :type => 'hidden', :name => "_method", :value => "PUT" }
33
%label{:for => 'post_title'} Title
44
%br
55
%input{ :type => 'text', :name => 'title', :id => 'post_title', :value => @post.title}
6-
%label{:for => 'post_slug'} Title
6+
%label{:for => 'post_slug'} Slug
77
%br
88
%input{ :type => 'text', :name => 'slug', :id => 'post_slug', :value => @post.slug}
99
%br

0 commit comments

Comments
 (0)