Permalink
Browse files

Merge branch 'master' of git://github.com/hacketyhack/hackety-hack.com

  • Loading branch information...
2 parents 0708da2 + 6068ecc commit 3716cf543377a8de29b2a87e1f1877bacb9a68c1 Marylou Lenhart committed Mar 16, 2012
@@ -13,5 +13,13 @@ def create
create!(:notice => "Answer Posted!"){ question_url(params[:question_id]) }
end
+ def update
+ # inherited resorces (gem) magic
+ super do |format|
+ format.html { redirect_to question_url(resource.question) }
+ end
+ end
+
end
+
@@ -23,17 +23,18 @@ def unfollow
end
def following
- @user = User.first(:id => params[:user_id])
+ @user = User.first(:username => params[:user_id])
end
def followers
- @user = User.first(:id => params[:user_id])
+ @user = User.first(:username => params[:user_id])
end
#################
def resource
@user ||= end_of_association_chain.find_by_username(params[:id])
end
-
+
end
+
@@ -1,9 +1,3 @@
-= simple_form_for(@answer, :url => question_answers_path(@question)) do |f|
- = f.error_notification
+= simple_form_for(resource, :url => @form_url) do |f|
+ = render 'form_content', :f => f
- .inputs
- = f.input :description, :as => :text, :label => "Answer",
- :hint => "You can format your input with <a href=\"http://daringfireball.net/projects/markdown/\">Markdown</a>".html_safe
-
- .actions
- = f.button :submit, :value => "Post Answer", :class => "primary btn"
@@ -0,0 +1,9 @@
+= f.error_notification
+
+.inputs
+ = f.input :description, :as => :text, :label => "Answer",
+ :hint => "You can format your input with <a href=\"http://daringfireball.net/projects/markdown/\">Markdown</a>".html_safe
+
+.actions
+ = f.button :submit, :value => "Post Answer", :class => "primary btn"
+
@@ -0,0 +1,3 @@
+= simple_form_for(@answer, :url => question_answers_path(@question)) do |f|
+ = render 'answers/form_content', :f => f
+
@@ -1,4 +1,5 @@
- content_for :title do
- = "Editing #{resource}"
+ = "Editing your answer"
= render 'form'
+
@@ -34,4 +34,5 @@
= render :partial => "answers/list", :collection => resource.answers
- if can? :create, Answer
- = render :partial => "answers/form"
+ = render :partial => "answers/short_answer"
+
@@ -20,10 +20,10 @@
= link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource), :class => "user-programs"
%p
Following:
- =link_to resource.following.count, resource_path(resource) + "/following"
+ =link_to resource.following.count, resource_path(resource) + "/following", :class => 'user-following'
%p
Followers:
- = link_to resource.followers.count, resource_path(resource) + "/followers"
+ = link_to resource.followers.count, resource_path(resource) + "/followers", :class => 'user-followers'
%hr
- if can? :update, resource
= link_to "Change My Settings", edit_registration_path(resource), :class => "btn success"
@@ -52,3 +52,4 @@
= answer.description.truncate(100)
.meta
= link_to("View Answer", answer.question)
+
View
@@ -9,5 +9,10 @@ Feature: CRUD actions for answers
And an email should be sent to the author
And I should be able to see my answer
And my answer should show on my profile page
-
- Scenario: Accept an answer
+
+ Scenario: Edit an answer
+ Given a question exists
+ And I answer that question
+ When I edit that answer
+ Then I should see the updated answer
+
@@ -28,3 +28,15 @@
ActionMailer::Base.deliveries.should_not be_empty
end
+When /^I edit that answer$/ do
+ visit question_path(@question)
+ page.find('.answer > .links').click_link('Edit')
+ fill_in 'Answer', with: 'Edit: Did you try magic?'
+ click_button 'Post Answer'
+end
+
+Then /^I should see the updated answer$/ do
+ page.should have_content("#{@user.username} says")
+ page.should have_content('Edit: Did you try magic?')
+end
+
@@ -1,14 +1,21 @@
def login_user
@user = User.create!(username: "test_user",
- email: "test_user@example.com",
- password: "foobar",
- password_confirmation: "foobar")
+ email: "test_user@example.com",
+ password: "foobar",
+ password_confirmation: "foobar")
visit login_path
fill_in("Username", :with => @user.username)
fill_in("Password", :with => @user.password)
click_button("Sign in")
end
+def create_other_user
+ @other_user = User.create!(username: "other_user",
+ email: "other_user@example.com",
+ password: "123456",
+ password_confirmation: "123456")
+end
+
Given /^a logged in user$/ do
login_user unless @user
end
@@ -29,6 +36,34 @@ def login_user
click_button "Update"
end
+When /^I have a follower$/ do
+ create_other_user
+ @other_user.follow! @user
+end
+
+When /^I am following someone$/ do
+ create_other_user
+ @user.follow! @other_user
+end
+
+When /^I click on the number of followers on my profile$/ do
+ step 'I go to look at my profile page'
+ first('.user-followers').click
+end
+
+When /^I click on the number of people I am following on my profile$/ do
+ step 'I go to look at my profile page'
+ first('.user-following').click
+end
+
+Then /^I should see someone I'm following$/ do
+ page.should have_link @other_user.username
+end
+
+Then /^I should see my follower$/ do
+ page.should have_link @other_user.username
+end
+
Then /^I should be notified that my profile was updated$/ do
page.should have_content("updated your account")
end
@@ -37,3 +72,4 @@ def login_user
visit("/users/#{@user.username}")
page.should have_content("Test user likes to edit his profile")
end
+
View
@@ -1,6 +1,6 @@
Feature: Manage account
- As a user of this site, I can view and update my profile
+ As a user of this site, I can view and update my profile, see my followers
Background: The user is logged in
Given a logged in user
@@ -12,4 +12,15 @@ Feature: Manage account
Scenario: Edit my profile
When I edit my profile
Then I should be notified that my profile was updated
- And I should see my changes reflected on my profile page
+ And I should see my changes reflected on my profile page
+
+ Scenario: See my followers
+ When I have a follower
+ And I click on the number of followers on my profile
+ Then I should see my follower
+
+ Scenario: See who I am following
+ When I am following someone
+ And I click on the number of people I am following on my profile
+ Then I should see someone I'm following
+

0 comments on commit 3716cf5

Please sign in to comment.