To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 42 / 42862198b703389f6caeb94209420fc08fb8d9e9.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (2.22 KB)
| 1 | 1296:038ba2d95de8 | Chris | # Redmine - project management software |
|---|---|---|---|
| 2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
||
| 3 | # |
||
| 4 | # This program is free software; you can redistribute it and/or |
||
| 5 | # modify it under the terms of the GNU General Public License |
||
| 6 | # as published by the Free Software Foundation; either version 2 |
||
| 7 | # of the License, or (at your option) any later version. |
||
| 8 | # |
||
| 9 | # This program is distributed in the hope that it will be useful, |
||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | # GNU General Public License for more details. |
||
| 13 | # |
||
| 14 | # You should have received a copy of the GNU General Public License |
||
| 15 | # along with this program; if not, write to the Free Software |
||
| 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||
| 17 | |||
| 18 | require File.expand_path('../../test_helper', __FILE__)
|
||
| 19 | |||
| 20 | class DocumentTest < ActiveSupport::TestCase |
||
| 21 | fixtures :projects, :enumerations, :documents, :attachments, |
||
| 22 | :enabled_modules, |
||
| 23 | :users, :members, :member_roles, :roles, |
||
| 24 | :groups_users |
||
| 25 | |||
| 26 | def test_create |
||
| 27 | doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation'))
|
||
| 28 | assert doc.save |
||
| 29 | end |
||
| 30 | |||
| 31 | def test_create_should_send_email_notification |
||
| 32 | ActionMailer::Base.deliveries.clear |
||
| 33 | |||
| 34 | with_settings :notified_events => %w(document_added) do |
||
| 35 | doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation'))
|
||
| 36 | assert doc.save |
||
| 37 | end |
||
| 38 | assert_equal 1, ActionMailer::Base.deliveries.size |
||
| 39 | end |
||
| 40 | |||
| 41 | def test_create_with_default_category |
||
| 42 | # Sets a default category |
||
| 43 | e = Enumeration.find_by_name('Technical documentation')
|
||
| 44 | e.update_attributes(:is_default => true) |
||
| 45 | |||
| 46 | doc = Document.new(:project => Project.find(1), :title => 'New document') |
||
| 47 | assert_equal e, doc.category |
||
| 48 | assert doc.save |
||
| 49 | end |
||
| 50 | |||
| 51 | def test_updated_on_with_attachments |
||
| 52 | d = Document.find(1) |
||
| 53 | assert d.attachments.any? |
||
| 54 | assert_equal d.attachments.map(&:created_on).max, d.updated_on |
||
| 55 | end |
||
| 56 | |||
| 57 | def test_updated_on_without_attachments |
||
| 58 | d = Document.find(2) |
||
| 59 | assert d.attachments.empty? |
||
| 60 | assert_equal d.created_on, d.updated_on |
||
| 61 | end |
||
| 62 | end |