@@ -5,12 +5,12 | |||||
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -24,20 +24,20 class WatchersController; def rescue_action(e) raise e end; end | |||||
24 | class WatchersControllerTest < ActionController::TestCase |
|
24 | class WatchersControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, |
|
25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, | |
26 | :issues, :trackers, :projects_trackers, :issue_statuses, :enumerations, :watchers |
|
26 | :issues, :trackers, :projects_trackers, :issue_statuses, :enumerations, :watchers | |
27 |
|
27 | |||
28 | def setup |
|
28 | def setup | |
29 | @controller = WatchersController.new |
|
29 | @controller = WatchersController.new | |
30 | @request = ActionController::TestRequest.new |
|
30 | @request = ActionController::TestRequest.new | |
31 | @response = ActionController::TestResponse.new |
|
31 | @response = ActionController::TestResponse.new | |
32 | User.current = nil |
|
32 | User.current = nil | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_get_watch_should_be_invalid |
|
35 | def test_get_watch_should_be_invalid | |
36 | @request.session[:user_id] = 3 |
|
36 | @request.session[:user_id] = 3 | |
37 | get :watch, :object_type => 'issue', :object_id => '1' |
|
37 | get :watch, :object_type => 'issue', :object_id => '1' | |
38 | assert_response 405 |
|
38 | assert_response 405 | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_watch |
|
41 | def test_watch | |
42 | @request.session[:user_id] = 3 |
|
42 | @request.session[:user_id] = 3 | |
43 | assert_difference('Watcher.count') do |
|
43 | assert_difference('Watcher.count') do | |
@@ -47,7 +47,7 class WatchersControllerTest < ActionController::TestCase | |||||
47 | end |
|
47 | end | |
48 | assert Issue.find(1).watched_by?(User.find(3)) |
|
48 | assert Issue.find(1).watched_by?(User.find(3)) | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def test_watch_should_be_denied_without_permission |
|
51 | def test_watch_should_be_denied_without_permission | |
52 | Role.find(2).remove_permission! :view_issues |
|
52 | Role.find(2).remove_permission! :view_issues | |
53 | @request.session[:user_id] = 3 |
|
53 | @request.session[:user_id] = 3 | |
@@ -56,7 +56,7 class WatchersControllerTest < ActionController::TestCase | |||||
56 | assert_response 403 |
|
56 | assert_response 403 | |
57 | end |
|
57 | end | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def test_unwatch |
|
60 | def test_unwatch | |
61 | @request.session[:user_id] = 3 |
|
61 | @request.session[:user_id] = 3 | |
62 | assert_difference('Watcher.count', -1) do |
|
62 | assert_difference('Watcher.count', -1) do | |
@@ -76,7 +76,7 class WatchersControllerTest < ActionController::TestCase | |||||
76 | end |
|
76 | end | |
77 | assert Issue.find(2).watched_by?(User.find(4)) |
|
77 | assert Issue.find(2).watched_by?(User.find(4)) | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_remove_watcher |
|
80 | def test_remove_watcher | |
81 | @request.session[:user_id] = 2 |
|
81 | @request.session[:user_id] = 2 | |
82 | assert_difference('Watcher.count', -1) do |
|
82 | assert_difference('Watcher.count', -1) do |
General Comments 0
You need to be logged in to leave comments.
Login now