aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-12 18:47:01 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-29 19:49:13 +0200
commit84c29dd7f3fc64ea491f0342476f7bc31a20171f (patch)
tree6bd86e4dac5bc216de46c5e18569de8deeaf012d /features
parentAllow project leads to add Project Acceptances easily (diff)
downloadrecruiting-webapp-84c29dd7f3fc64ea491f0342476f7bc31a20171f.tar.gz
recruiting-webapp-84c29dd7f3fc64ea491f0342476f7bc31a20171f.tar.bz2
recruiting-webapp-84c29dd7f3fc64ea491f0342476f7bc31a20171f.zip
Email questions
Also make sure users can answer questions with multiple and text content and can't answer email questions within application. Added "Gentoo-dev-announce posting" question to seed
Diffstat (limited to 'features')
-rw-r--r--features/email_answers.feature40
-rw-r--r--features/step_definitions/email_answer_steps.rb75
2 files changed, 115 insertions, 0 deletions
diff --git a/features/email_answers.feature b/features/email_answers.feature
new file mode 100644
index 0000000..19ef7fe
--- /dev/null
+++ b/features/email_answers.feature
@@ -0,0 +1,40 @@
+Feature: gentoo-dev-announce
+ As a recruiting lead
+ I want recruits to send actual emails instead of writing
+ So that they learn in practice
+
+ Scenario: Testing gentoo-dev-announce-posting
+ Given recruit that should answer gentoo-dev-announce posting question
+ And I am logged in as "recruit"
+ When I send wrong email announcement
+ And I am on show "gentoo-dev-announce posting" question page
+ Then I should see "Your answer should have subject (without quotes)"
+ Then I should see subject for email "recruit" should send to answer "gentoo-dev-announce posting"
+
+ When I follow "View you answer"
+ Then I should see "Email you sent didn't match requirements"
+
+ When I send proper email announcement
+ And I am on show "gentoo-dev-announce posting" question page
+ Then I should see "Remember to replace @gentoo.org with localhost"
+
+ When I follow "View you answer"
+ Then I should see "You sent proper email"
+
+ Scenario: Don't see answer it link on email question page
+ Given recruit that should answer gentoo-dev-announce posting question
+ And I am logged in as "recruit"
+ And I am on show "gentoo-dev-announce posting" question page
+ Then I should not see "Answer it"
+
+ Scenario: Protect from forged responses
+ Given recruit that should answer gentoo-dev-announce posting question
+ And someone sends forged answer
+ And I am logged in as "recruit"
+ And I am on show "gentoo-dev-announce posting" question page
+ Then I should not see "View you answer"
+
+ Scenario: Don't show answering subject to guest
+ Given recruit that should answer gentoo-dev-announce posting question
+ When I am on show "gentoo-dev-announce posting" question page
+ Then I should not see "Your answer should have subject (without quotes)"
diff --git a/features/step_definitions/email_answer_steps.rb b/features/step_definitions/email_answer_steps.rb
new file mode 100644
index 0000000..24a2555
--- /dev/null
+++ b/features/step_definitions/email_answer_steps.rb
@@ -0,0 +1,75 @@
+Given /^email question content for "([^\"]*)"$/ do |question|
+ Given "a question \"#{question}\""
+ @content = @question.content
+ unless @content.is_a? QuestionContentEmail
+ @content.try.destroy
+ @content = QuestionContentEmail.create!(:question => @question, :description => "Remember to replace @gentoo.org with localhost")
+ @question.reload
+ end
+end
+
+Given /^email question content for "([^\"]*)" with following requirements:$/ do |question, table|
+ Given "email question content for \"#{question}\""
+ res = table.raw.inject(String.new) do |res, cur|
+ cur[0].sub!(':', '\:')
+ cur[1].sub!(':', '\:')
+ res += "#{cur[0]} : #{cur[1]}\n"
+ res
+ end
+ @content.req_text = res
+ @content.save!
+end
+
+Given /^recruit that should answer gentoo-dev-announce posting question$/ do
+ Given 'user "recruit" has category "questions"'
+ Given 'a question "gentoo-dev-announce posting" in category "questions"'
+ Given 'email question content for "gentoo-dev-announce posting" with following requirements:', table(%{
+ |To|gentoo-dev-announce@localhost|
+ |To|gentoo-dev@localhost|
+ |Reply-To|gentoo-dev@localhost|
+ })
+end
+
+When /^I send wrong email announcement$/ do
+ Given 'user "recruit"'
+ Given 'a question "gentoo-dev-announce posting"'
+
+ mail = TMail::Mail.new
+ mail.subject = "#{@question.id}-#{@user.token}"
+ mail.from = @user.email_address
+ mail.to = ['gentoo-dev-announce@localhost']
+
+ UserMailer.receive(mail.to_s)
+end
+
+When /^I send proper email announcement$/ do
+ Given 'user "recruit"'
+
+ mail = TMail::Mail.new
+ mail.from = @user.email_address
+ mail.subject = "#{@question.id}-#{@user.token}"
+ mail.to = ['gentoo-dev-announce@localhost', 'gentoo-dev@localhost']
+ mail.reply_to = 'gentoo-dev@localhost'
+
+ UserMailer.receive(mail.to_s)
+end
+
+When /^someone sends forged answer$/ do
+ Given 'user "recruit"'
+
+ mail = TMail::Mail.new
+ mail.from = @user.email_address
+ mail.to = ['gentoo-dev-announce@localhost', 'gentoo-dev@localhost']
+ mail.reply_to = 'gentoo-dev@localhost'
+
+ Given 'user "forger"'
+ mail.subject = "#{@question.id}-#{@user.token}"
+
+ UserMailer.receive(mail.to_s)
+end
+
+Then /^I should see subject for email "([^"]+)" should send to answer "([^"]+)"$/ do |user, question|
+ Given "user \"#{user}\""
+ Given "a question \"#{question}\""
+ Then "I should see \"#{@question.id}-#{@user.token}\""
+end