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/step_definitions
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/step_definitions')
-rw-r--r--features/step_definitions/email_answer_steps.rb75
1 files changed, 75 insertions, 0 deletions
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