To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / functional / journals_controller_test.rb @ 441:cbce1fd3b1b7
History | View | Annotate | Download (3.11 KB)
| 1 | 245:051f544170fe | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang
|
||
| 3 | 0:513646585e45 | Chris | #
|
| 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 | 441:cbce1fd3b1b7 | Chris | #
|
| 9 | 0:513646585e45 | Chris | # 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 | 441:cbce1fd3b1b7 | Chris | #
|
| 14 | 0:513646585e45 | Chris | # 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 | 119:8661b858af72 | Chris | require File.expand_path('../../test_helper', __FILE__) |
| 19 | 0:513646585e45 | Chris | require 'journals_controller'
|
| 20 | |||
| 21 | # Re-raise errors caught by the controller.
|
||
| 22 | class JournalsController; def rescue_action(e) raise e end; end |
||
| 23 | |||
| 24 | class JournalsControllerTest < ActionController::TestCase |
||
| 25 | 441:cbce1fd3b1b7 | Chris | fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules, |
| 26 | :trackers, :issue_statuses, :enumerations, :custom_fields, :custom_values, :custom_fields_projects |
||
| 27 | |||
| 28 | 0:513646585e45 | Chris | def setup |
| 29 | @controller = JournalsController.new |
||
| 30 | @request = ActionController::TestRequest.new |
||
| 31 | @response = ActionController::TestResponse.new |
||
| 32 | User.current = nil |
||
| 33 | end
|
||
| 34 | 441:cbce1fd3b1b7 | Chris | |
| 35 | 14:1d32c0a0efbf | Chris | def test_index |
| 36 | get :index, :project_id => 1 |
||
| 37 | assert_response :success
|
||
| 38 | assert_not_nil assigns(:journals)
|
||
| 39 | assert_equal 'application/atom+xml', @response.content_type |
||
| 40 | end
|
||
| 41 | 441:cbce1fd3b1b7 | Chris | |
| 42 | 245:051f544170fe | Chris | def test_diff |
| 43 | get :diff, :id => 3, :detail_id => 4 |
||
| 44 | assert_response :success
|
||
| 45 | assert_template 'diff'
|
||
| 46 | 441:cbce1fd3b1b7 | Chris | |
| 47 | 245:051f544170fe | Chris | assert_tag 'span',
|
| 48 | :attributes => {:class => 'diff_out'}, |
||
| 49 | :content => /removed/ |
||
| 50 | assert_tag 'span',
|
||
| 51 | :attributes => {:class => 'diff_in'}, |
||
| 52 | :content => /added/ |
||
| 53 | end
|
||
| 54 | 441:cbce1fd3b1b7 | Chris | |
| 55 | 14:1d32c0a0efbf | Chris | def test_reply_to_issue |
| 56 | @request.session[:user_id] = 2 |
||
| 57 | 119:8661b858af72 | Chris | get :new, :id => 6 |
| 58 | 14:1d32c0a0efbf | Chris | assert_response :success
|
| 59 | assert_select_rjs :show, "update" |
||
| 60 | end
|
||
| 61 | 441:cbce1fd3b1b7 | Chris | |
| 62 | 119:8661b858af72 | Chris | def test_reply_to_issue_without_permission |
| 63 | @request.session[:user_id] = 7 |
||
| 64 | get :new, :id => 6 |
||
| 65 | assert_response 403
|
||
| 66 | end
|
||
| 67 | 14:1d32c0a0efbf | Chris | |
| 68 | def test_reply_to_note |
||
| 69 | @request.session[:user_id] = 2 |
||
| 70 | 119:8661b858af72 | Chris | get :new, :id => 6, :journal_id => 4 |
| 71 | 14:1d32c0a0efbf | Chris | assert_response :success
|
| 72 | assert_select_rjs :show, "update" |
||
| 73 | end
|
||
| 74 | |||
| 75 | 0:513646585e45 | Chris | def test_get_edit |
| 76 | @request.session[:user_id] = 1 |
||
| 77 | xhr :get, :edit, :id => 2 |
||
| 78 | assert_response :success
|
||
| 79 | assert_select_rjs :insert, :after, 'journal-2-notes' do |
||
| 80 | assert_select 'form[id=journal-2-form]'
|
||
| 81 | assert_select 'textarea'
|
||
| 82 | end
|
||
| 83 | end
|
||
| 84 | 441:cbce1fd3b1b7 | Chris | |
| 85 | 0:513646585e45 | Chris | def test_post_edit |
| 86 | @request.session[:user_id] = 1 |
||
| 87 | xhr :post, :edit, :id => 2, :notes => 'Updated notes' |
||
| 88 | assert_response :success
|
||
| 89 | assert_select_rjs :replace, 'journal-2-notes' |
||
| 90 | assert_equal 'Updated notes', Journal.find(2).notes |
||
| 91 | end
|
||
| 92 | 441:cbce1fd3b1b7 | Chris | |
| 93 | 0:513646585e45 | Chris | def test_post_edit_with_empty_notes |
| 94 | @request.session[:user_id] = 1 |
||
| 95 | xhr :post, :edit, :id => 2, :notes => '' |
||
| 96 | assert_response :success
|
||
| 97 | assert_select_rjs :remove, 'change-2' |
||
| 98 | assert_nil Journal.find_by_id(2) |
||
| 99 | end
|
||
| 100 | end |