Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 206
- Log:
Initial import of Gullery, an open source photo gallery:
http://nubyonrails.com/pages/gullery
- Author:
- rool
- Date:
- Sun May 20 19:05:59 +0100 2007
- Size:
- 2620 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | require 'projects_controller' |
3 | |
4 | # Re-raise errors caught by the controller. |
5 | class ProjectsController; def rescue_action(e) raise e end; end |
6 | |
7 | class ProjectsControllerTest < Test::Unit::TestCase |
8 | |
9 | def setup |
10 | @controller = ProjectsController.new |
11 | @request = ActionController::TestRequest.new |
12 | @response = ActionController::TestResponse.new |
13 | end |
14 | |
15 | # TODO |
16 | # test_sort |
17 | # require login for sort |
18 | |
19 | def test_index |
20 | get :index |
21 | assert_response :success |
22 | assert_not_nil assigns(:projects) |
23 | end |
24 | |
25 | def test_create_restricted |
26 | assert_requires_login() { post :create } |
27 | |
28 | login_as :quentin |
29 | project_count = Project.count |
30 | post :create, :project => { :name => 'Fox Tall Action Figure' } |
31 | assert_response :redirect |
32 | assert_redirected_to projects_url |
33 | assert_equal project_count + 1, Project.count |
34 | end |
35 | |
36 | def test_update_restricted |
37 | assert_requires_login() { post :update_description } |
38 | assert_accepts_login(:quentin) { post :update_description, :id => 1, :value => 'Cloneberry Lollipop' } |
39 | end |
40 | |
41 | def test_destroy_restricted |
42 | assert_requires_login() { get :destroy } |
43 | assert_accepts_login(:quentin) { get :destroy, :id => 1 } |
44 | end |
45 | |
46 | def test_show |
47 | get :show, :id => 1 |
48 | assert_response :success |
49 | assert_not_nil assigns(:project) |
50 | assert_equal 3, assigns(:project).visible_assets.length |
51 | end |
52 | |
53 | def test_create |
54 | old_count = Project.count |
55 | login_as :quentin |
56 | post :create, :project => { :name => 'Fox Tall Action Figure' } |
57 | assert_response :redirect |
58 | assert_redirected_to projects_url |
59 | assert_not_nil assigns(:project) |
60 | |
61 | assert_equal old_count + 1, Project.count |
62 | end |
63 | |
64 | def test_update_description |
65 | login_as :quentin |
66 | post :update_description, :id => 1, :value => 'Cloneberry Pie' |
67 | assert_response :success |
68 | assert_not_nil assigns(:project) |
69 | assert_equal 'Cloneberry Pie', Project.find(1).description |
70 | end |
71 | |
72 | def test_destroy |
73 | old_count = Project.count |
74 | login_as :quentin |
75 | post :destroy, :id => 1 |
76 | assert_response :success |
77 | assert_not_nil assigns(:project) |
78 | |
79 | assert_equal old_count - 1, Project.count |
80 | end |
81 | |
82 | def test_bad_create |
83 | old_count = Project.count |
84 | login_as :quentin |
85 | post :create, :project => { } |
86 | assert_response :success |
87 | assert_not_nil assigns(:project).errors.on(:name) |
88 | |
89 | assert_equal old_count, Project.count |
90 | end |
91 | |
92 | def test_bad_update |
93 | old_count = Project.count |
94 | login_as :quentin |
95 | post :update |
96 | assert_nil assigns(:project) |
97 | assert_equal old_count, Project.count |
98 | end |
99 | |
100 | end |