aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPetteri Räty <betelgeuse@gentoo.org>2011-03-12 19:50:20 +0200
committerPetteri Räty <betelgeuse@gentoo.org>2011-03-12 19:50:20 +0200
commit151c361a71c0b663c44c6bf5f7d310f1f12a87af (patch)
tree0cfd1511c28da5eb670f867f95b2508a2e361d20 /spec
parentFix deprecation warnings from delayed_job (diff)
downloadrecruiting-webapp-151c361a71c0b663c44c6bf5f7d310f1f12a87af.tar.gz
recruiting-webapp-151c361a71c0b663c44c6bf5f7d310f1f12a87af.tar.bz2
recruiting-webapp-151c361a71c0b663c44c6bf5f7d310f1f12a87af.zip
Rename QuestionCategory to Category
We have a need for a many to many between questions and categories so start the work by renaming QuestionCategory to just Category. This allows us to add a pivot model with the name QuestionCategory.
Diffstat (limited to 'spec')
-rw-r--r--spec/factories.rb12
-rw-r--r--spec/models/answer_spec.rb10
-rw-r--r--spec/models/category_spec.rb (renamed from spec/models/question_category_spec.rb)18
-rw-r--r--spec/models/question_group_spec.rb8
-rw-r--r--spec/models/question_spec.rb24
-rw-r--r--spec/models/user_category_spec.rb8
-rw-r--r--spec/models/user_mailer_spec.rb2
-rw-r--r--spec/models/user_spec.rb4
-rw-r--r--spec/support/factory_orders.rb22
9 files changed, 54 insertions, 54 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index 0b26477..2c663af 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -43,12 +43,12 @@
u.nick { |u| u.name }
end
- Factory.sequence :question_category do |n|
- "question category-#{n}"
+ Factory.sequence :category do |n|
+ "category-#{n}"
end
- Factory.define :question_category do |q|
- q.name { Factory.next(:question_category) }
+ Factory.define :category do |q|
+ q.name { Factory.next(:category) }
end
Factory.sequence :question do |n|
@@ -58,7 +58,7 @@
# it'll belong to new category by default
Factory.define :question do |q|
q.title { Factory.next(:question) }
- q.question_category { Factory(:question_category)}
+ q.category { Factory(:category)}
end
Factory.sequence :answer do |n|
@@ -81,7 +81,7 @@
Factory.define :user_category do |q|
q.user { Factory(:recruit) }
- q.question_category { Factory(:question_category) }
+ q.category { Factory(:category) }
end
Factory.sequence :comment do |n|
diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb
index de72393..e300537 100644
--- a/spec/models/answer_spec.rb
+++ b/spec/models/answer_spec.rb
@@ -269,11 +269,11 @@ describe Answer do
it "should properly return wrong answers of recruit" do
recruit = Factory(:recruit)
- cat = Factory(:question_category)
- q1 = Factory(:question, :question_category => cat)
- q2 = Factory(:question, :question_category => cat)
- q3 = Factory(:question, :question_category => cat)
- q4 = Factory(:question, :question_category => cat)
+ cat = Factory(:category)
+ q1 = Factory(:question, :category => cat)
+ q2 = Factory(:question, :category => cat)
+ q3 = Factory(:question, :category => cat)
+ q4 = Factory(:question, :category => cat)
Factory(:question_content_text, :question => q4)
diff --git a/spec/models/question_category_spec.rb b/spec/models/category_spec.rb
index 32511a8..8e482c5 100644
--- a/spec/models/question_category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -1,31 +1,31 @@
require 'spec_helper.rb'
-describe QuestionCategory do
+describe Category do
include Permissions::TestPermissions
it "should allow admin to create, edit, update and remove" do
- cud_allowed([Factory(:administrator)], Factory(:question_category))
+ cud_allowed([Factory(:administrator)], Factory(:category))
end
it "should prohibit nonadmins to creating, editing, updating and removing" do
cud_denied([Factory(:recruit), Factory(:mentor), Guest.new,
- Factory(:recruiter)], Factory(:question_category))
+ Factory(:recruiter)], Factory(:category))
end
it "should be allowed for everybody to view" do
view_allowed([Factory(:recruit), Factory(:mentor), Factory(:recruiter),
- Factory(:administrator), Guest.new], Factory(:question_category))
+ Factory(:administrator), Guest.new], Factory(:category))
end
it { should validate_presence_of :name }
it "should return proper as_select_opts" do
- c1 = Factory(:question_category)
- c2 = Factory(:question_category)
+ c1 = Factory(:category)
+ c2 = Factory(:category)
options = [['All Categories', nil], [c1.name, c1.id], [c2.name, c2.id]]
- (options - QuestionCategory.as_select_opts).should be_empty
- (QuestionCategory.as_select_opts - options).should be_empty
- QuestionCategory.as_select_opts.count.should == QuestionCategory.as_select_opts.uniq.count
+ (options - Category.as_select_opts).should be_empty
+ (Category.as_select_opts - options).should be_empty
+ Category.as_select_opts.count.should == Category.as_select_opts.uniq.count
end
end
diff --git a/spec/models/question_group_spec.rb b/spec/models/question_group_spec.rb
index ac8cb06..b490f89 100644
--- a/spec/models/question_group_spec.rb
+++ b/spec/models/question_group_spec.rb
@@ -18,12 +18,12 @@ describe QuestionGroup do
end
it "should return proper in_category results" do
- category = Factory(:question_category)
+ category = Factory(:category)
groups_in_cat = []
for n in 1..5
groups_in_cat.push Factory(:question_group)
for i in 1..n
- Factory(:question, :question_category => category, :question_group => groups_in_cat.last)
+ Factory(:question, :category => category, :question_group => groups_in_cat.last)
end
end
@@ -39,12 +39,12 @@ describe QuestionGroup do
it "should return proper unassociated_in_category results" do
recruit = Factory(:recruit)
- category = Factory(:question_category)
+ category = Factory(:category)
groups_in_cat = []
for n in 1..5
groups_in_cat.push Factory(:question_group)
for i in 1..n
- Factory(:question, :question_category => category, :question_group => groups_in_cat.last)
+ Factory(:question, :category => category, :question_group => groups_in_cat.last)
end
end
diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb
index 0489be4..5dddd70 100644
--- a/spec/models/question_spec.rb
+++ b/spec/models/question_spec.rb
@@ -66,10 +66,10 @@ describe Question do
end
it "should send email notifications to watching recruits when created by recruiter" do
- category = Factory(:question_category)
- recruit = Factory(:recruit, :question_categories => [category])
+ category = Factory(:category)
+ recruit = Factory(:recruit, :categories => [category])
question = Question.new(:title => "new question",
- :question_category => category)
+ :category => category)
UserMailer.should_receive_delayed(:deliver_new_question, recruit, question)
@@ -77,10 +77,10 @@ describe Question do
end
it "should send email notifications to watching recruits when approved" do
- category = Factory(:question_category)
- recruit = Factory(:recruit, :question_categories => [category])
+ category = Factory(:category)
+ recruit = Factory(:recruit, :categories => [category])
question = Factory(:question, :title => "new question",
- :question_category => category, :user => Factory(:recruit))
+ :category => category, :user => Factory(:recruit))
UserMailer.should_receive_delayed(:deliver_new_question, recruit, question)
question.approved = true
@@ -88,10 +88,10 @@ describe Question do
end
it "should not send email notifications to watching recruits when approved is changed" do
- category = Factory(:question_category)
- recruit = Factory(:recruit, :question_categories => [category])
+ category = Factory(:category)
+ recruit = Factory(:recruit, :categories => [category])
question = Factory(:question, :title => "new question",
- :question_category => category, :user => Factory(:recruit), :approved => true)
+ :category => category, :user => Factory(:recruit), :approved => true)
UserMailer.should_not_receive(:deliver_new_question).with(recruit, question)
@@ -146,7 +146,7 @@ describe Question do
question.should be_editable_by(recruit)
question.should be_editable_by(recruit, :title)
question.should be_editable_by(recruit, :documentation)
- question.should be_editable_by(recruit, :question_category)
+ question.should be_editable_by(recruit, :category)
question.should_not be_editable_by(recruit, :user)
question.should_not be_editable_by(recruit, :approved)
@@ -159,7 +159,7 @@ describe Question do
question.should be_editable_by(recruit)
question.should be_editable_by(recruit, :title)
question.should be_editable_by(recruit, :documentation)
- question.should be_editable_by(recruit, :question_category)
+ question.should be_editable_by(recruit, :category)
question.should_not be_editable_by(recruit, :user)
question.should_not be_editable_by(recruit, :approved)
@@ -172,7 +172,7 @@ describe Question do
question.should be_editable_by(admin)
question.should be_editable_by(admin, :title)
question.should be_editable_by(admin, :documentation)
- question.should be_editable_by(admin, :question_category)
+ question.should be_editable_by(admin, :category)
question.should be_editable_by(admin, :approved)
question.should_not be_editable_by(admin, :user)
diff --git a/spec/models/user_category_spec.rb b/spec/models/user_category_spec.rb
index 3b833d3..99efdea 100644
--- a/spec/models/user_category_spec.rb
+++ b/spec/models/user_category_spec.rb
@@ -64,13 +64,13 @@ describe UserCategory do
end
end
- it "should associate user with one question from each group from question category on creation" do
- category = Factory(:question_category)
+ it "should associate user with one question from each group from category on creation" do
+ category = Factory(:category)
groups_in_cat = []
for n in 1..5
groups_in_cat.push Factory(:question_group)
for i in 1..n
- Factory(:question, :question_category => category, :question_group => groups_in_cat.last)
+ Factory(:question, :category => category, :question_group => groups_in_cat.last)
end
end
@@ -79,7 +79,7 @@ describe UserCategory do
end
recruit = Factory(:recruit)
- Factory(:user_category, :user => recruit, :question_category => category)
+ Factory(:user_category, :user => recruit, :category => category)
for group in groups_in_cat
has_question_from_group = group.questions.inject(false) do |result, question|
diff --git a/spec/models/user_mailer_spec.rb b/spec/models/user_mailer_spec.rb
index 4e7c613..39a45e2 100644
--- a/spec/models/user_mailer_spec.rb
+++ b/spec/models/user_mailer_spec.rb
@@ -10,7 +10,7 @@ describe UserMailer do
notification.should deliver_to(recruit.email_address)
notification.should deliver_from("no-reply@localhost")
notification.should have_text(/There is a new question "#{question.title}"/)
- notification.should have_text(/in category "#{question.question_category.name}" you are assigned to./)
+ notification.should have_text(/in category "#{question.category.name}" you are assigned to./)
notification.should have_text(/http:\/\/localhost:3000\/questions\/#{question.id}/)
notification.should have_subject('New question')
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 529c3b9..ee256c4 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -310,7 +310,7 @@ describe User do
q1 = Factory(:question)
Factory(:question_content_multiple_choice, :question => q1)
Factory(:user_category,
- :question_category => q1.question_category,
+ :category => q1.category,
:user => recruit)
recruit.answered_all_multi_choice_questions?.should be_false
@@ -337,7 +337,7 @@ describe User do
q1 = Factory(:question)
Factory(:user_category, :user => recruit,
- :question_category => q1.question_category)
+ :category => q1.category)
recruit.progress.should == "Answered 0 of 1 questions."
Factory(:answer, :owner => recruit, :question => q1)
diff --git a/spec/support/factory_orders.rb b/spec/support/factory_orders.rb
index 76c0d63..d02249a 100644
--- a/spec/support/factory_orders.rb
+++ b/spec/support/factory_orders.rb
@@ -11,25 +11,25 @@ def recruit_with_answered_and_unanswered_questions(n=5)
r.unanswered = []
for i in 1..n
# answered and unanswered ungrouped questions
- category = Factory(:question_category)
- r.answered.push Factory(:question, :question_category => category)
- r.unanswered.push Factory(:question, :question_category => category)
+ category = Factory(:category)
+ r.answered.push Factory(:question, :category => category)
+ r.unanswered.push Factory(:question, :category => category)
Factory(:answer, :owner => r.recruit, :question => r.answered.last)
# and answered and unanswered question in one group
group = Factory(:question_group)
- r.answered.push Factory(:question, :question_category => category, :question_group => group)
+ r.answered.push Factory(:question, :category => category, :question_group => group)
Factory(:user_question_group, :user => r.recruit, :question => r.answered.last)
# This question isn't unanswered! This is question user can't answer
- Factory(:question, :question_category => category, :question_group => group)
+ Factory(:question, :category => category, :question_group => group)
# add a unanswered grouped question
- r.unanswered.push Factory(:question, :question_category => category, :question_group => Factory(:question_group))
+ r.unanswered.push Factory(:question, :category => category, :question_group => Factory(:question_group))
Factory(:user_question_group, :user => r.recruit, :question => r.unanswered.last)
Factory(:answer, :owner => r.recruit, :question => r.answered.last)
- r.recruit.question_categories.push category
+ r.recruit.categories.push category
end
r
end
@@ -48,17 +48,17 @@ 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(:question_category)
+ r.categories.push Factory(:category)
r.answers_in_cat.push []
for i in 1..n_ans_in_cat
- question = Factory(:question, :question_category => r.categories.last)
+ question = Factory(:question, :category => r.categories.last)
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, :question_category => r.categories.last, :question_group => group)
- Factory(:question, :question_category => r.categories.last, :question_group => group)
+ question = Factory(:question, :category => r.categories.last, :question_group => group)
+ Factory(:question, :category => r.categories.last, :question_group => group)
Factory(:user_question_group, :user => r.recruit, :question => question)
r.all_answers.push Factory(:answer, :owner => r.recruit, :question => question)
r.answers_in_cat.last.push r.all_answers.last