From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Q0yL7-0006vL-C1 for garchives@archives.gentoo.org; Sat, 19 Mar 2011 15:45:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BF1BAE05E8; Sat, 19 Mar 2011 15:44:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 75360E05D9 for ; Sat, 19 Mar 2011 15:44:30 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 061981B40EF for ; Sat, 19 Mar 2011 15:44:30 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6EA1D8005E for ; Sat, 19 Mar 2011 15:44:29 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: Subject: [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/, features/, spec/support/ X-VCS-Repository: proj/recruiting-webapp X-VCS-Files: app/models/question.rb app/models/question_category.rb features/answer_text_question.feature spec/models/question_category_spec.rb spec/support/test_permissions.rb X-VCS-Directories: app/models/ spec/models/ features/ spec/support/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: cfebc625aeb19099f07e199b1ea3c51f491d4bc2 Date: Sat, 19 Mar 2011 15:44:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: e5200bd71fc5f6b19bda3e3ac693965d commit: cfebc625aeb19099f07e199b1ea3c51f491d4bc2 Author: Petteri R=C3=A4ty gentoo org> AuthorDate: Sat Mar 19 13:55:58 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Sat Mar 19 13:55:58 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/recruiting-we= bapp.git;a=3Dcommit;h=3Dcfebc625 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 =20 belongs_to :user, :creator =3D> true has_many :question_categories - has_many :categories, :through =3D> :question_categories + has_many :categories, :through =3D> :question_categories, :accessib= le =3D> true belongs_to :question_group has_many :answers has_one :reference_answer, :class_name =3D> "Answer", :conditions = =3D> ["answers.reference =3D ?", true] diff --git a/app/models/question_category.rb b/app/models/question_catego= ry.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 =3D> false, :index =3D> false belongs_to :category, :null =3D> false, :index =3D> false index [:question_id, :category_id], :unique =3D> 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 ".f= lash.notice" =20 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_permiss= ions.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 =3D nil) + users =3D [users] unless users.is_a?(Array) for user in users testee =3D yield(user) if testee.nil? =20