aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/answer_spec.rb9
-rw-r--r--spec/models/question_group_spec.rb8
-rw-r--r--spec/models/question_spec.rb17
-rw-r--r--spec/models/user_category_spec.rb4
-rw-r--r--spec/models/user_mailer_spec.rb2
-rw-r--r--spec/models/user_spec.rb4
6 files changed, 23 insertions, 21 deletions
diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb
index e300537..61e23a8 100644
--- a/spec/models/answer_spec.rb
+++ b/spec/models/answer_spec.rb
@@ -250,7 +250,6 @@ describe Answer do
(!produced_ans.attributes[i[0]]).should be_true # it can be nil or false
end
end
-
end
it "should produce proper updated answer from params" do
@@ -270,10 +269,10 @@ describe Answer do
it "should properly return wrong answers of recruit" do
recruit = Factory(:recruit)
cat = Factory(:category)
- q1 = Factory(:question, :category => cat)
- q2 = Factory(:question, :category => cat)
- q3 = Factory(:question, :category => cat)
- q4 = Factory(:question, :category => cat)
+ q1 = Factory(:question_category, :category => cat).question
+ q2 = Factory(:question_category, :category => cat).question
+ q3 = Factory(:question_category, :category => cat).question
+ q4 = Factory(:question_category, :category => cat).question
Factory(:question_content_text, :question => q4)
diff --git a/spec/models/question_group_spec.rb b/spec/models/question_group_spec.rb
index b490f89..dc62f83 100644
--- a/spec/models/question_group_spec.rb
+++ b/spec/models/question_group_spec.rb
@@ -23,7 +23,9 @@ describe QuestionGroup do
for n in 1..5
groups_in_cat.push Factory(:question_group)
for i in 1..n
- Factory(:question, :category => category, :question_group => groups_in_cat.last)
+ Factory(:question_category,
+ :category => category,
+ :question => Factory(:question, :question_group => groups_in_cat.last))
end
end
@@ -44,7 +46,9 @@ describe QuestionGroup do
for n in 1..5
groups_in_cat.push Factory(:question_group)
for i in 1..n
- Factory(:question, :category => category, :question_group => groups_in_cat.last)
+ Factory(:question_category,
+ :category => category,
+ :question => Factory(:question, :question_group => groups_in_cat.last))
end
end
diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb
index 5dddd70..99a286f 100644
--- a/spec/models/question_spec.rb
+++ b/spec/models/question_spec.rb
@@ -68,8 +68,8 @@ describe Question do
it "should send email notifications to watching recruits when created by recruiter" do
category = Factory(:category)
recruit = Factory(:recruit, :categories => [category])
- question = Question.new(:title => "new question",
- :category => category)
+ question = Factory.build(:question)
+ question.categories << category
UserMailer.should_receive_delayed(:deliver_new_question, recruit, question)
@@ -79,19 +79,19 @@ describe Question do
it "should send email notifications to watching recruits when approved" do
category = Factory(:category)
recruit = Factory(:recruit, :categories => [category])
- question = Factory(:question, :title => "new question",
- :category => category, :user => Factory(:recruit))
+ question = Factory(:question, :user => Factory(:recruit))
+ question.categories << category
UserMailer.should_receive_delayed(:deliver_new_question, recruit, question)
question.approved = true
question.save!
end
- it "should not send email notifications to watching recruits when approved is changed" do
+ it "should not send email notifications to watching recruits when approved is not changed" do
category = Factory(:category)
recruit = Factory(:recruit, :categories => [category])
- question = Factory(:question, :title => "new question",
- :category => category, :user => Factory(:recruit), :approved => true)
+ question = Factory(:question, :user => Factory(:recruit), :approved => true)
+ question.categories << category
UserMailer.should_not_receive(:deliver_new_question).with(recruit, question)
@@ -146,7 +146,6 @@ 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, :category)
question.should_not be_editable_by(recruit, :user)
question.should_not be_editable_by(recruit, :approved)
@@ -159,7 +158,6 @@ 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, :category)
question.should_not be_editable_by(recruit, :user)
question.should_not be_editable_by(recruit, :approved)
@@ -172,7 +170,6 @@ 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, :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 99efdea..130a359 100644
--- a/spec/models/user_category_spec.rb
+++ b/spec/models/user_category_spec.rb
@@ -70,7 +70,9 @@ describe UserCategory do
for n in 1..5
groups_in_cat.push Factory(:question_group)
for i in 1..n
- Factory(:question, :category => category, :question_group => groups_in_cat.last)
+ Factory(:question_category,
+ :category => category,
+ :question => Factory(:question, :question_group => groups_in_cat.last))
end
end
diff --git a/spec/models/user_mailer_spec.rb b/spec/models/user_mailer_spec.rb
index 39a45e2..d681e9e 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.category.name}" you are assigned to./)
+ notification.should have_text(/one of the categories 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 ee256c4..b4a3dbf 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,
- :category => q1.category,
+ :category => q1.categories.first,
: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,
- :category => q1.category)
+ :category => q1.categories.first)
recruit.progress.should == "Answered 0 of 1 questions."
Factory(:answer, :owner => recruit, :question => q1)