Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 2279 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | |
3 | class ResourceTest < Test::Unit::TestCase |
4 | fixtures :resources |
5 | |
6 | def setup |
7 | # put the files on disk as if it were uploaded |
8 | FileUtils.mkpath("#{RAILS_ROOT}/public/files") |
9 | [ resources(:resource1), resources(:resource2) ].each { |f| FileUtils.touch(f.fullpath) } |
10 | end |
11 | |
12 | def teardown |
13 | # remove the files on disk |
14 | [ resources(:resource1), resources(:resource2) ].each { |f| |
15 | File.unlink(f.fullpath) if File.exist?(f.fullpath) |
16 | } |
17 | end |
18 | |
19 | def test_fullpath |
20 | assert_equal resources(:resource1).fullpath, "#{RAILS_ROOT}/public/files/#{resources(:resource1).filename}" |
21 | end |
22 | |
23 | def test_create |
24 | assert_not_nil resources(:resource1) |
25 | assert_not_nil resources(:resource2) |
26 | |
27 | f1 = Resource.create(:filename => resources(:resource1).filename, |
28 | :mime => resources(:resource1).mime, |
29 | :created_at => Time.now) |
30 | assert_not_nil f1 |
31 | f2 = Resource.create(:filename => resources(:resource2).filename, |
32 | :mime => resources(:resource2).mime, |
33 | :created_at => Time.now) |
34 | assert_not_nil f2 |
35 | |
36 | assert resources(:resource1).filename != f1.filename |
37 | assert resources(:resource2).filename != f2.filename |
38 | f1.destroy |
39 | f2.destroy |
40 | end |
41 | |
42 | def test_read |
43 | assert_not_nil resources(:resource1) |
44 | f = Resource.find_by_filename(resources(:resource1).filename) |
45 | assert_not_nil f |
46 | assert_equal f, resources(:resource1) |
47 | end |
48 | |
49 | def test_update |
50 | assert_not_nil resources(:resource1) |
51 | assert_not_nil resources(:resource2) |
52 | |
53 | f = resources(:resource2) |
54 | assert resources(:resource2).save |
55 | assert_equal f.filename, resources(:resource2).filename |
56 | |
57 | resources(:resource1).filename = f.filename |
58 | assert !resources(:resource1).save |
59 | |
60 | resources(:resource1).filename = Resource.find(1).filename |
61 | assert resources(:resource1).save |
62 | end |
63 | |
64 | def test_destroy |
65 | assert_not_nil resources(:resource1) |
66 | # blow it away, ensure that the file is removed from the public/files dir |
67 | assert resources(:resource1).destroy |
68 | assert !File.exist?(resources(:resource1).fullpath) |
69 | assert_raise(ActiveRecord::RecordNotFound) { Resource.find(resources(:resource1).id) } |
70 | end |
71 | end |