diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/answer_spec.rb | 10 | ||||
-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.rb | 8 | ||||
-rw-r--r-- | spec/models/question_spec.rb | 24 | ||||
-rw-r--r-- | spec/models/user_category_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/user_mailer_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 4 |
7 files changed, 37 insertions, 37 deletions
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) |