aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-07 11:11:20 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-12 19:17:11 +0200
commiteeb8448766d00776516a71367bf8fb3a09cc8ece (patch)
treefb0933b9ddde57662b8b7962f6039962df7239b5 /features
parentAllow users to suggest questions (diff)
downloadrecruiting-webapp-eeb8448766d00776516a71367bf8fb3a09cc8ece.tar.gz
recruiting-webapp-eeb8448766d00776516a71367bf8fb3a09cc8ece.tar.bz2
recruiting-webapp-eeb8448766d00776516a71367bf8fb3a09cc8ece.zip
User may view and answer only one randomly chosen question from group
When adding user to category associate user with one question from each group in this category. Feature to make sure question listings are correct.
Diffstat (limited to 'features')
-rw-r--r--features/question_listing.feature26
-rw-r--r--features/recruits_who_answered_all_questions.feature27
-rw-r--r--features/step_definitions/answers_steps.rb2
-rw-r--r--features/step_definitions/question_group_steps.rb6
-rw-r--r--features/step_definitions/question_listing_steps.rb20
-rw-r--r--features/step_definitions/questions_steps.rb16
-rw-r--r--features/step_definitions/users_steps.rb10
7 files changed, 105 insertions, 2 deletions
diff --git a/features/question_listing.feature b/features/question_listing.feature
new file mode 100644
index 0000000..8d3fd62
--- /dev/null
+++ b/features/question_listing.feature
@@ -0,0 +1,26 @@
+Feature: Viewing question listings
+ As recruit
+ I want to see listings of questions
+ To answer them
+
+ Scenario: View listing of all questions I should answer
+ Given I am logged in as recruit with some answered and unanswered questions
+ When I am on all my questions page
+ Then I should see following:
+ |q1|q3|q4|
+ And I should not see "q2"
+
+ Scenario: View listing of all questions I answered
+ Given I am logged in as recruit with some answered and unanswered questions
+ When I am on my answered questions page
+ Then I should see "q3"
+ And I should not see following:
+ |q1|q2|q4|
+
+ Scenario: View listing of all questions I didn't answer yet
+ Given I am logged in as recruit with some answered and unanswered questions
+ When I am on my unanswered questions page
+ Then I should see following:
+ |q1|q4|
+ And I should not see following:
+ |q2|q3|
diff --git a/features/recruits_who_answered_all_questions.feature b/features/recruits_who_answered_all_questions.feature
index 7d7ccc0..d5861c0 100644
--- a/features/recruits_who_answered_all_questions.feature
+++ b/features/recruits_who_answered_all_questions.feature
@@ -23,3 +23,30 @@ Feature: Viewing recruits who answered all questions
When I am on the home page
And I follow "Recruits that answered all questions"
Then I should be on ready recruits page
+
+ Scenario: Recruit that answered assigned and ungrouped questions is ready
+ Given following questions:
+ |q1|cat1|grp1|
+ |q2|cat1|grp1|
+ And following questions:
+ |q3|cat1|
+ |q4|cat1|
+ And user "recruit" is associated with question "q1"
+ And answer of "recruit" for question "q1"
+ And user "recruit" has category "cat1"
+ And user "recruit" answered all questions in "cat1"
+ When I am on ready recruits page
+ Then I should see "recruit" within ".user .collection"
+
+ Scenario: Recruit that answered didn't answer assigned grouped question isn't ready
+ Given following questions:
+ |q1|cat1|grp1|
+ |q2|cat1|grp1|
+ And following questions:
+ |q3|cat1|
+ |q4|cat1|
+ And user "recruit" is associated with question "q1"
+ And user "recruit" has category "cat1"
+ And user "recruit" answered all questions in "cat1"
+ When I am on ready recruits page
+ Then I should see "No users to display" within ".empty-collection-message"
diff --git a/features/step_definitions/answers_steps.rb b/features/step_definitions/answers_steps.rb
index f2217b3..b720473 100644
--- a/features/step_definitions/answers_steps.rb
+++ b/features/step_definitions/answers_steps.rb
@@ -3,6 +3,6 @@ Given /^(?:|a )answer of "([^\"]*)" for question "([^\"]*)"$/ do |user, question
Given "user \"#{user}\""
@answer = @question.answer_of @user
if @answer.nil?
- @answer = Answer.create!( :owner => @user, :question => @question, :content => "fake")
+ @answer = Answer.create!(:owner => @user, :question => @question, :content => "fake")
end
end
diff --git a/features/step_definitions/question_group_steps.rb b/features/step_definitions/question_group_steps.rb
new file mode 100644
index 0000000..0834b44
--- /dev/null
+++ b/features/step_definitions/question_group_steps.rb
@@ -0,0 +1,6 @@
+Given /^question group "([^"]*)"$/ do |name|
+ @question_group = QuestionGroup.find_by_name(name)
+ if @question_group.nil?
+ @question_group = QuestionGroup.create! :name => name
+ end
+end
diff --git a/features/step_definitions/question_listing_steps.rb b/features/step_definitions/question_listing_steps.rb
new file mode 100644
index 0000000..0019483
--- /dev/null
+++ b/features/step_definitions/question_listing_steps.rb
@@ -0,0 +1,20 @@
+Given /^a recruit with some answered and unanswered questions$/ do
+ Given "following questions:", table(%{
+ |q1|cat1|grp1|
+ |q2|cat1|grp1|
+ })
+ Given "following questions:", table(%{
+ |q3|cat1|
+ |q4|cat1|
+ })
+
+ Given "user \"recruit\" is associated with question \"q1\""
+ Given "answer of \"recruit\" for question \"q3\""
+ And "user \"recruit\" has category \"cat1\""
+ And "user \"recruit\" has category \"cat2\""
+end
+
+Given /^I am logged in as recruit with some answered and unanswered questions$/ do
+ Given "I am logged in as \"recruit\""
+ Given "a recruit with some answered and unanswered questions"
+end
diff --git a/features/step_definitions/questions_steps.rb b/features/step_definitions/questions_steps.rb
index c4d1957..da57160 100644
--- a/features/step_definitions/questions_steps.rb
+++ b/features/step_definitions/questions_steps.rb
@@ -12,12 +12,22 @@ Given /^a question "([^\"]*)" in category "([^\"]*)"$/ do |title, category|
@question.save!
end
+Given /^a question "([^\"]*)" in group "([^\"]*)"$/ do |title, group|
+ Given "a question \"#{title}\""
+ Given "question group \"#{group}\""
+ @question.question_group = @question_group
+ @question.save!
+end
+
Given /^following questions:$/ do |table|
for question in table.raw
if question.size == 1
Given "a question \"#{question[0]}\""
elsif question.size == 2
Given "a question \"#{question[0]}\" in category \"#{question[1]}\""
+ elsif question.size == 3
+ Given "a question \"#{question[0]}\" in category \"#{question[1]}\""
+ Given "a question \"#{question[0]}\" in group \"#{question[2]}\""
else
fail "Each row of table should have one or two columns"
end
@@ -29,3 +39,9 @@ Then /^I should see following:$/ do |table|
Then "I should see \"#{txt}\""
end
end
+
+Then /^I should not see following:$/ do |table|
+ for txt in table.raw.flatten
+ Then "I should not see \"#{txt}\""
+ end
+end
diff --git a/features/step_definitions/users_steps.rb b/features/step_definitions/users_steps.rb
index 5d0f4f5..4493402 100644
--- a/features/step_definitions/users_steps.rb
+++ b/features/step_definitions/users_steps.rb
@@ -32,7 +32,9 @@ end
Given /^user "([^\"]*)" answered all questions in "([^\"]*)"$/ do |user_name, category_name|
Given "a question category \"#{category_name}\""
for q in @question_category.questions
- And "\"#{user_name}\" answered question \"#{q.title}\""
+ if q.question_group.nil?
+ Given "\"#{user_name}\" answered question \"#{q.title}\""
+ end
end
end
@@ -79,3 +81,9 @@ Given /^"([^"]*)" suggested question "([^"]*)"$/ do |user, question|
@question.approved = false
@question.save!
end
+
+Given /^user "([^"]*)" is associated with question "([^"]*)"$/ do |user, question|
+ Given "user \"#{user}\""
+ Given "a question \"#{question}\""
+ UserQuestionGroup.create! :user => @user, :question => question
+end