diff options
author | 2011-03-19 15:55:58 +0200 | |
---|---|---|
committer | 2011-03-19 15:55:58 +0200 | |
commit | cfebc625aeb19099f07e199b1ea3c51f491d4bc2 (patch) | |
tree | 96909d290e6ea5f5cac18ce546daa5bb6b876380 | |
parent | Typo fix paramter to parameter (diff) | |
download | recruiting-webapp-cfebc625aeb19099f07e199b1ea3c51f491d4bc2.tar.gz recruiting-webapp-cfebc625aeb19099f07e199b1ea3c51f491d4bc2.tar.bz2 recruiting-webapp-cfebc625aeb19099f07e199b1ea3c51f491d4bc2.zip |
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.
-rw-r--r-- | app/models/question.rb | 2 | ||||
-rw-r--r-- | app/models/question_category.rb | 2 | ||||
-rw-r--r-- | features/answer_text_question.feature | 3 | ||||
-rw-r--r-- | spec/models/question_category_spec.rb | 9 | ||||
-rw-r--r-- | 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? |