@@ -1741,6 +1741,12 class IssuesControllerTest < ActionController::TestCase | |||
|
1741 | 1741 | assert_select_error /No tracker/ |
|
1742 | 1742 | end |
|
1743 | 1743 | |
|
1744 | def test_new_with_invalid_project_id | |
|
1745 | @request.session[:user_id] = 1 | |
|
1746 | get :new, :project_id => 'invalid' | |
|
1747 | assert_response 404 | |
|
1748 | end | |
|
1749 | ||
|
1744 | 1750 | def test_update_form_for_new_issue |
|
1745 | 1751 | @request.session[:user_id] = 2 |
|
1746 | 1752 | xhr :post, :update_form, :project_id => 1, |
@@ -4032,6 +4038,19 class IssuesControllerTest < ActionController::TestCase | |||
|
4032 | 4038 | assert_equal 2, TimeEntry.find(2).issue_id |
|
4033 | 4039 | end |
|
4034 | 4040 | |
|
4041 | def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail | |
|
4042 | @request.session[:user_id] = 2 | |
|
4043 | ||
|
4044 | assert_no_difference 'Issue.count' do | |
|
4045 | assert_no_difference 'TimeEntry.count' do | |
|
4046 | # try to reassign time to an issue of another project | |
|
4047 | delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 4 | |
|
4048 | end | |
|
4049 | end | |
|
4050 | assert_response :success | |
|
4051 | assert_template 'destroy' | |
|
4052 | end | |
|
4053 | ||
|
4035 | 4054 | def test_destroy_issues_from_different_projects |
|
4036 | 4055 | @request.session[:user_id] = 2 |
|
4037 | 4056 |
@@ -75,6 +75,14 class ProjectsControllerTest < ActionController::TestCase | |||
|
75 | 75 | assert_select 'a[href=?]', '/time_entries', 0 |
|
76 | 76 | end |
|
77 | 77 | |
|
78 | test "#index by non-admin user with permission should show add project link" do | |
|
79 | Role.find(1).add_permission! :add_project | |
|
80 | @request.session[:user_id] = 2 | |
|
81 | get :index | |
|
82 | assert_template 'index' | |
|
83 | assert_select 'a[href=?]', '/projects/new' | |
|
84 | end | |
|
85 | ||
|
78 | 86 | test "#new by admin user should accept get" do |
|
79 | 87 | @request.session[:user_id] = 1 |
|
80 | 88 |
@@ -239,6 +239,17 class UsersControllerTest < ActionController::TestCase | |||
|
239 | 239 | assert user.check_password?(password) |
|
240 | 240 | end |
|
241 | 241 | |
|
242 | def test_create_and_continue | |
|
243 | post :create, :user => { | |
|
244 | :login => 'randompass', | |
|
245 | :firstname => 'Random', | |
|
246 | :lastname => 'Pass', | |
|
247 | :mail => 'randompass@example.net', | |
|
248 | :generate_password => '1' | |
|
249 | }, :continue => '1' | |
|
250 | assert_redirected_to '/users/new?user%5Bgenerate_password%5D=1' | |
|
251 | end | |
|
252 | ||
|
242 | 253 | def test_create_with_failure |
|
243 | 254 | assert_no_difference 'User.count' do |
|
244 | 255 | post :create, :user => {} |
@@ -320,8 +320,10 class WikiControllerTest < ActionController::TestCase | |||
|
320 | 320 | :id => 'Another_page', |
|
321 | 321 | :content => { |
|
322 | 322 | :comments => 'a' * 300, # failure here, comment is too long |
|
323 |
:text => 'edited' |
|
|
324 | :version => 1 | |
|
323 | :text => 'edited' | |
|
324 | }, | |
|
325 | :wiki_page => { | |
|
326 | :parent_id => "" | |
|
325 | 327 | } |
|
326 | 328 |
|
|
327 | 329 |
|
@@ -61,6 +61,13 class WorkflowsControllerTest < ActionController::TestCase | |||
|
61 | 61 | assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0 |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | def test_get_edit_with_all_roles_and_all_trackers | |
|
65 | get :edit, :role_id => 'all', :tracker_id => 'all' | |
|
66 | assert_response :success | |
|
67 | assert_equal Role.sorted.to_a, assigns(:roles) | |
|
68 | assert_equal Tracker.sorted.to_a, assigns(:trackers) | |
|
69 | end | |
|
70 | ||
|
64 | 71 | def test_get_edit_with_role_and_tracker_and_all_statuses |
|
65 | 72 | WorkflowTransition.delete_all |
|
66 | 73 |
@@ -20,6 +20,26 require File.expand_path('../../../test_helper', __FILE__) | |||
|
20 | 20 | class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :users, :members, :member_roles, :roles, :projects |
|
22 | 22 | |
|
23 | test "GET /users.xml should return users" do | |
|
24 | get '/users.xml', {}, credentials('admin') | |
|
25 | ||
|
26 | assert_response :success | |
|
27 | assert_equal 'application/xml', response.content_type | |
|
28 | assert_select 'users' do | |
|
29 | assert_select 'user', assigns(:users).size | |
|
30 | end | |
|
31 | end | |
|
32 | ||
|
33 | test "GET /users.json should return users" do | |
|
34 | get '/users.json', {}, credentials('admin') | |
|
35 | ||
|
36 | assert_response :success | |
|
37 | assert_equal 'application/json', response.content_type | |
|
38 | json = ActiveSupport::JSON.decode(response.body) | |
|
39 | assert json.key?('users') | |
|
40 | assert_equal assigns(:users).size, json['users'].size | |
|
41 | end | |
|
42 | ||
|
23 | 43 | test "GET /users/:id.xml should return the user" do |
|
24 | 44 | get '/users/2.xml' |
|
25 | 45 |
@@ -132,4 +132,30 class GroupTest < ActiveSupport::TestCase | |||
|
132 | 132 | |
|
133 | 133 | assert_equal nil, Issue.find(1).assigned_to_id |
|
134 | 134 | end |
|
135 | ||
|
136 | def test_builtin_groups_should_be_created_if_missing | |
|
137 | Group.delete_all | |
|
138 | ||
|
139 | assert_difference 'Group.count', 2 do | |
|
140 | group = Group.anonymous | |
|
141 | assert_equal GroupAnonymous, group.class | |
|
142 | ||
|
143 | group = Group.non_member | |
|
144 | assert_equal GroupNonMember, group.class | |
|
145 | end | |
|
146 | end | |
|
147 | ||
|
148 | def test_builtin_in_group_should_be_uniq | |
|
149 | group = GroupAnonymous.new | |
|
150 | group.name = 'Foo' | |
|
151 | assert !group.save | |
|
152 | end | |
|
153 | ||
|
154 | def test_builtin_in_group_should_not_accept_users | |
|
155 | group = Group.anonymous | |
|
156 | assert_raise RuntimeError do | |
|
157 | group.users << User.find(1) | |
|
158 | end | |
|
159 | assert_equal 0, group.reload.users.count | |
|
160 | end | |
|
135 | 161 | end |
@@ -647,6 +647,12 class ProjectTest < ActiveSupport::TestCase | |||
|
647 | 647 | end |
|
648 | 648 | end |
|
649 | 649 | |
|
650 | def test_enabled_modules_names_with_nil_should_clear_modules | |
|
651 | p = Project.find(1) | |
|
652 | p.enabled_module_names = nil | |
|
653 | assert_equal [], p.enabled_modules | |
|
654 | end | |
|
655 | ||
|
650 | 656 | test "enabled_modules should define module by names and preserve ids" do |
|
651 | 657 | @project = Project.find(1) |
|
652 | 658 | # Remove one module |
@@ -947,4 +953,23 class ProjectTest < ActiveSupport::TestCase | |||
|
947 | 953 | assert_equal [Role.anonymous], project.override_roles(Role.anonymous) |
|
948 | 954 | assert_equal [Role.non_member], project.override_roles(Role.non_member) |
|
949 | 955 | end |
|
956 | ||
|
957 | def test_css_classes | |
|
958 | p = Project.new | |
|
959 | assert_kind_of String, p.css_classes | |
|
960 | assert_not_include 'archived', p.css_classes.split | |
|
961 | assert_not_include 'closed', p.css_classes.split | |
|
962 | end | |
|
963 | ||
|
964 | def test_css_classes_for_archived_project | |
|
965 | p = Project.new | |
|
966 | p.status = Project::STATUS_ARCHIVED | |
|
967 | assert_include 'archived', p.css_classes.split | |
|
968 | end | |
|
969 | ||
|
970 | def test_css_classes_for_closed_project | |
|
971 | p = Project.new | |
|
972 | p.status = Project::STATUS_CLOSED | |
|
973 | assert_include 'closed', p.css_classes.split | |
|
974 | end | |
|
950 | 975 | end |
@@ -127,6 +127,12 class VersionTest < ActiveSupport::TestCase | |||
|
127 | 127 | assert_equal [v5, v3, v1, v2, v4], Version.sorted.to_a |
|
128 | 128 | end |
|
129 | 129 | |
|
130 | def test_should_sort_versions_with_same_date_by_name | |
|
131 | v1 = Version.new(:effective_date => '2014-12-03', :name => 'v2') | |
|
132 | v2 = Version.new(:effective_date => '2014-12-03', :name => 'v1') | |
|
133 | assert_equal [v2, v1], [v1, v2].sort | |
|
134 | end | |
|
135 | ||
|
130 | 136 | def test_completed_should_be_false_when_due_today |
|
131 | 137 | version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today') |
|
132 | 138 | assert_equal false, version.completed? |
General Comments 0
You need to be logged in to leave comments.
Login now