From 91018b2fa2e58b42c72014294c148fe7af5a5a71 Mon Sep 17 00:00:00 2001 From: Stefan Frank Date: Wed, 14 Aug 2013 11:29:30 +0200 Subject: [PATCH] converted the document_category_test to rspec. --- spec/models/document_category_spec.rb | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/models/document_category_spec.rb diff --git a/spec/models/document_category_spec.rb b/spec/models/document_category_spec.rb new file mode 100644 index 0000000000..ed833710d9 --- /dev/null +++ b/spec/models/document_category_spec.rb @@ -0,0 +1,40 @@ +#-- copyright +# OpenProject is a project management system. +# +# Copyright (C) 2012-2013 the OpenProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# See doc/COPYRIGHT.rdoc for more details. +#++ +require File.dirname(__FILE__) + '/../spec_helper' + + +describe DocumentCategory do + + let(:project) {FactoryGirl.create(:project)} + + it "should be an enumeration" do + expect(DocumentCategory.ancestors).to include Enumeration + end + + it "should order documents by the category they are created with" do + uncategorized = FactoryGirl.create :document_category, :name => "Uncategorized", :project => project + user_documentation = FactoryGirl.create :document_category, :name => "User documentation" + + FactoryGirl.create_list :document, 2, :category => uncategorized, :project => project + + expect(DocumentCategory.find_by_name(uncategorized.name).objects_count).to eql 2 + expect(DocumentCategory.find_by_name(user_documentation.name).objects_count).to eql 0 + + end + + it "should file the categorizations under the option name :enumeration_doc_categories" do + expect(DocumentCategory.new.option_name).to eql :enumeration_doc_categories + end + +end + + +