From 8922487a577a3258819d9329550efde326b136bc Mon Sep 17 00:00:00 2001 From: Joachim Filip Ignacy Bartosik Date: Wed, 23 Jun 2010 11:32:26 +0200 Subject: Support for mentor comments Generated Comment model and CommentsController. Added relation (answer has many comments, comment belongs to answer). Added email notification when new comment is created. This commit includes also schema change and tests. --- features/commenting.feature | 28 ++++++++++++++++++++++++++++ features/step_definitions/comments_steps.rb | 5 +++++ features/support/paths.rb | 9 +++++++++ 3 files changed, 42 insertions(+) create mode 100644 features/commenting.feature create mode 100644 features/step_definitions/comments_steps.rb (limited to 'features') diff --git a/features/commenting.feature b/features/commenting.feature new file mode 100644 index 0000000..578ed63 --- /dev/null +++ b/features/commenting.feature @@ -0,0 +1,28 @@ +Feature: Mentor comments for recruit answers + As a mentor + I want to be able to comment answers of my recruits + so they can improve their answers + + Scenario: Go to add comment page from answer page + Given user "mentor" is mentor of "recruit" + And answer of "recruit" for question "example question" + And I am logged in as "mentor" + And I am on answer of "recruit" for question "example question" page + When I follow "Comment this answer" + Then I should be on new comment for answer of "recruit" for question "example question" + + Scenario: Add comment + Given user "mentor" is mentor of "recruit" + And answer of "recruit" for question "example question" + And I am logged in as "mentor" + And I am on new comment for answer of "recruit" for question "example question" + When I fill in "comment_content" with "some comment" + And press "Create Comment" + Then I should be on newest comment page + And I should see "some comment" + + Scenario: View comment on answer page + Given a comment "example comment" of "mentor" for answer of "recruit" for question "example question" + And I am logged in as "recruit" + And I am on answer of "recruit" for question "example question" page + Then I should see "example comment" diff --git a/features/step_definitions/comments_steps.rb b/features/step_definitions/comments_steps.rb new file mode 100644 index 0000000..1f6d158 --- /dev/null +++ b/features/step_definitions/comments_steps.rb @@ -0,0 +1,5 @@ +Given /^(?:|a )comment "([^\"]*)" of "([^\"]*)" for answer of "([^\"]*)" for question "([^\"]*)"$/ do |comment, mentor, user, question| + Given "user \"#{mentor}\" is mentor of \"#{user}\"" + Given "answer of \"#{user}\" for question \"#{question}\"" + Comment.create! :owner => @mentor, :answer => @answer, :content => comment +end diff --git a/features/support/paths.rb b/features/support/paths.rb index e8d8a09..3d34dd6 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -22,6 +22,15 @@ module NavigationHelpers when /unanswered questions page/ unanswered_questions_questions_path + + when /answer of "([^\"]*)" for question "([^\"]*)" page/ + answer_path(Question.find_by_title($2).answer_of(User.find_by_name($1))) + + when /new comment for answer of "([^\"]*)" for question "([^\"]*)"/ + new_comment_for_answer_path(Question.find_by_title($2).answer_of(User.find_by_name($1))) + + when /newest comment page/ + comment_path(Comment.last) # Add more mappings here. # Here is an example that pulls values out of the Regexp: # -- cgit v1.2.3-65-gdbad