* [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/, features/, spec/support/
@ 2011-03-19 15:44 Petteri Räty
0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-03-19 15:44 UTC (permalink / raw
To: gentoo-commits
commit: cfebc625aeb19099f07e199b1ea3c51f491d4bc2
Author: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 19 13:55:58 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Mar 19 13:55:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/recruiting-webapp.git;a=commit;h=cfebc625
Categories are selectable for new questions
The new question form was missing the inputs for categories. There are
now there and covered by our test suite.
---
app/models/question.rb | 2 +-
app/models/question_category.rb | 2 ++
features/answer_text_question.feature | 3 ++-
spec/models/question_category_spec.rb | 9 +++++++++
spec/support/test_permissions.rb | 1 +
5 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/app/models/question.rb b/app/models/question.rb
index fc9b176..2a7843d 100644
--- a/app/models/question.rb
+++ b/app/models/question.rb
@@ -40,7 +40,7 @@ class Question < ActiveRecord::Base
belongs_to :user, :creator => true
has_many :question_categories
- has_many :categories, :through => :question_categories
+ has_many :categories, :through => :question_categories, :accessible => true
belongs_to :question_group
has_many :answers
has_one :reference_answer, :class_name => "Answer", :conditions => ["answers.reference = ?", true]
diff --git a/app/models/question_category.rb b/app/models/question_category.rb
index c67ce9b..50a8ce8 100644
--- a/app/models/question_category.rb
+++ b/app/models/question_category.rb
@@ -24,4 +24,6 @@ class QuestionCategory < ActiveRecord::Base
belongs_to :question, :null => false, :index => false
belongs_to :category, :null => false, :index => false
index [:question_id, :category_id], :unique => true
+
+ include Permissions::AnyoneCanViewAdminCanChange
end
diff --git a/features/answer_text_question.feature b/features/answer_text_question.feature
index 7e17268..37f9a8b 100644
--- a/features/answer_text_question.feature
+++ b/features/answer_text_question.feature
@@ -18,7 +18,8 @@ Feature: Answering text question
Scenario: Create and edit text question
Given I am logged in as administrator
When I follow "New Question"
- And I fill in "some question" for "question[title]"
+ Then I should see "Categories" within ".field-list"
+ When I fill in "some question" for "question[title]"
And I press "Create Question"
Then I should see "The question was created successfully" within ".flash.notice"
diff --git a/spec/models/question_category_spec.rb b/spec/models/question_category_spec.rb
new file mode 100644
index 0000000..08a18db
--- /dev/null
+++ b/spec/models/question_category_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper.rb'
+
+describe QuestionCategory do
+ include Permissions::TestPermissions
+
+ it "should allow admin to do everything" do
+ allow_all Factory(:administrator), Factory(:question_category)
+ end
+end
diff --git a/spec/support/test_permissions.rb b/spec/support/test_permissions.rb
index 151d53f..f0d94b8 100644
--- a/spec/support/test_permissions.rb
+++ b/spec/support/test_permissions.rb
@@ -71,6 +71,7 @@ module Permissions
# if testee is nil it will yield block in for each user in users
# giving user as parameter to generate testee
def allow_all(users, testee = nil)
+ users = [users] unless users.is_a?(Array)
for user in users
testee = yield(user) if testee.nil?
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/, features/, spec/support/
@ 2011-03-19 15:44 Petteri Räty
0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-03-19 15:44 UTC (permalink / raw
To: gentoo-commits
commit: 23346baa4a2a88ba76f1e2926260652e7a54b5a3
Author: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 19 15:41:57 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Mar 19 15:41:57 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/recruiting-webapp.git;a=commit;h=23346baa
Improve ready recruits listing
Recruits who don't have any categories should not be considered ready.
There's plenty people signing and not answering anything so they should
not be listed. Fixes bug #355717.
---
app/models/user.rb | 3 ++-
.../recruits_who_answered_all_questions.feature | 2 --
spec/models/user_spec.rb | 16 +++++++++-------
spec/support/factory_orders.rb | 11 +++++++----
4 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/app/models/user.rb b/app/models/user.rb
index dff9295..87d9024 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -57,7 +57,8 @@ class User < ActiveRecord::Base
AND NOT EXISTS
(SELECT questions.id FROM questions INNER JOIN user_question_groups ON questions.id = user_question_groups.question_id
WHERE user_question_groups.user_id = users.id AND NOT EXISTS (
- SELECT answers.id FROM answers WHERE answers.question_id = questions.id AND answers.owner_id = users.id))"
+ SELECT answers.id FROM answers WHERE answers.question_id = questions.id AND answers.owner_id = users.id))
+ AND id IN (SELECT user_id FROM user_categories)"
# --- Signup lifecycle --- #
lifecycle do
diff --git a/features/recruits_who_answered_all_questions.feature b/features/recruits_who_answered_all_questions.feature
index d5861c0..33f5110 100644
--- a/features/recruits_who_answered_all_questions.feature
+++ b/features/recruits_who_answered_all_questions.feature
@@ -8,10 +8,8 @@ Feature: Viewing recruits who answered all questions
And recruit "recruit1" in following categories:
|some cat|
And user "recruit1" answered all questions in "some cat"
- And a user "recruit2" who is "recruit"
When I am on ready recruits page
Then I should see "recruit1" within ".user .collection"
- And I should see "recruit2" within ".user .collection"
Scenario: Go to ready recruits from homepage
Given a question "some question" in category "some cat"
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 4fdbbcf..76a1a45 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -123,10 +123,15 @@ describe User do
Factory(:recruit).answered_all_questions?.should be_true
end
+ it "should not consider recruits with no categories as answered all" do
+ r = Factory(:recruit)
+ r.categories.should be_empty
+ User.recruits_answered_all.count.should == 0
+ end
+
it "should return proper recruits with all questions` answered" do
- # recruits that should be returned
- correct_answered_all = [Factory(:recruit)]
- correct_answered_all.push recruit_with_answers_in_categories.recruit
+ # recruit that should be returned
+ correct_answered_all = [recruit_with_answers_in_categories.recruit]
# and some other users
recruit_with_answered_and_unanswered_questions
@@ -134,10 +139,7 @@ describe User do
Factory(:mentor)
Factory(:recruiter)
- answered_all = User.recruits_answered_all
-
- (answered_all - correct_answered_all).should be_empty
- (correct_answered_all - answered_all).should be_empty
+ User.recruits_answered_all.should == correct_answered_all
end
it "should allow recruiters to change nick of other users" do
diff --git a/spec/support/factory_orders.rb b/spec/support/factory_orders.rb
index 9548330..2847809 100644
--- a/spec/support/factory_orders.rb
+++ b/spec/support/factory_orders.rb
@@ -56,20 +56,23 @@ def recruit_with_answers_in_categories(mentor = nil, n_categories = 5, n_ans_in_
r.answers_in_cat = []
r.all_answers = []
for i in 1..n_categories
- r.categories.push Factory(:category)
+ c = Factory(:category)
+ r.categories.push c
+ r.recruit.categories.push c
+
r.answers_in_cat.push []
for i in 1..n_ans_in_cat
- question = Factory(:question_category, :category => r.categories.last).question
+ question = Factory(:question_category, :category => c).question
r.all_answers.push Factory(:answer, :owner => r.recruit, :question => question)
r.answers_in_cat.last.push r.all_answers.last
# group of two questions, answered
group = Factory(:question_group)
question = Factory(:question_category,
- :category => r.categories.last,
+ :category => c,
:question => Factory(:question, :question_group => group)).question
Factory(:question_category,
- :category => r.categories.last,
+ :category => c,
:question => Factory(:question, :question_group => group))
Factory(:user_question_group, :user => r.recruit, :question => question)
r.all_answers.push Factory(:answer, :owner => r.recruit, :question => question)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-19 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-19 15:44 [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/, features/, spec/support/ Petteri Räty
-- strict thread matches above, loose matches on Subject: below --
2011-03-19 15:44 Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox