assert_select_error /No tracker/
end
+ def test_new_with_invalid_project_id
+ @request.session[:user_id] = 1
+ get :new, :project_id => 'invalid'
+ assert_response 404
+ end
+
def test_update_form_for_new_issue
@request.session[:user_id] = 2
xhr :post, :update_form, :project_id => 1,
assert_equal 2, TimeEntry.find(2).issue_id
end
+ def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
+ @request.session[:user_id] = 2
+
+ assert_no_difference 'Issue.count' do
+ assert_no_difference 'TimeEntry.count' do
+ # try to reassign time to an issue of another project
+ delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 4
+ end
+ end
+ assert_response :success
+ assert_template 'destroy'
+ end
+
def test_destroy_issues_from_different_projects
@request.session[:user_id] = 2
assert_select 'a[href=?]', '/time_entries', 0
end
+ test "#index by non-admin user with permission should show add project link" do
+ Role.find(1).add_permission! :add_project
+ @request.session[:user_id] = 2
+ get :index
+ assert_template 'index'
+ assert_select 'a[href=?]', '/projects/new'
+ end
+
test "#new by admin user should accept get" do
@request.session[:user_id] = 1
assert user.check_password?(password)
end
+ def test_create_and_continue
+ post :create, :user => {
+ :login => 'randompass',
+ :firstname => 'Random',
+ :lastname => 'Pass',
+ :mail => 'randompass@example.net',
+ :generate_password => '1'
+ }, :continue => '1'
+ assert_redirected_to '/users/new?user%5Bgenerate_password%5D=1'
+ end
+
def test_create_with_failure
assert_no_difference 'User.count' do
post :create, :user => {}
:id => 'Another_page',
:content => {
:comments => 'a' * 300, # failure here, comment is too long
- :text => 'edited',
- :version => 1
+ :text => 'edited'
+ },
+ :wiki_page => {
+ :parent_id => ""
}
- end
end
end
+ end
assert_response :success
assert_template 'edit'
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
end
+ def test_get_edit_with_all_roles_and_all_trackers
+ get :edit, :role_id => 'all', :tracker_id => 'all'
+ assert_response :success
+ assert_equal Role.sorted.to_a, assigns(:roles)
+ assert_equal Tracker.sorted.to_a, assigns(:trackers)
+ end
+
def test_get_edit_with_role_and_tracker_and_all_statuses
WorkflowTransition.delete_all
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
fixtures :users, :members, :member_roles, :roles, :projects
+ test "GET /users.xml should return users" do
+ get '/users.xml', {}, credentials('admin')
+
+ assert_response :success
+ assert_equal 'application/xml', response.content_type
+ assert_select 'users' do
+ assert_select 'user', assigns(:users).size
+ end
+ end
+
+ test "GET /users.json should return users" do
+ get '/users.json', {}, credentials('admin')
+
+ assert_response :success
+ assert_equal 'application/json', response.content_type
+ json = ActiveSupport::JSON.decode(response.body)
+ assert json.key?('users')
+ assert_equal assigns(:users).size, json['users'].size
+ end
+
test "GET /users/:id.xml should return the user" do
get '/users/2.xml'
assert_equal nil, Issue.find(1).assigned_to_id
end
+
+ def test_builtin_groups_should_be_created_if_missing
+ Group.delete_all
+
+ assert_difference 'Group.count', 2 do
+ group = Group.anonymous
+ assert_equal GroupAnonymous, group.class
+
+ group = Group.non_member
+ assert_equal GroupNonMember, group.class
+ end
+ end
+
+ def test_builtin_in_group_should_be_uniq
+ group = GroupAnonymous.new
+ group.name = 'Foo'
+ assert !group.save
+ end
+
+ def test_builtin_in_group_should_not_accept_users
+ group = Group.anonymous
+ assert_raise RuntimeError do
+ group.users << User.find(1)
+ end
+ assert_equal 0, group.reload.users.count
+ end
end
end
end
+ def test_enabled_modules_names_with_nil_should_clear_modules
+ p = Project.find(1)
+ p.enabled_module_names = nil
+ assert_equal [], p.enabled_modules
+ end
+
test "enabled_modules should define module by names and preserve ids" do
@project = Project.find(1)
# Remove one module
assert_equal [Role.anonymous], project.override_roles(Role.anonymous)
assert_equal [Role.non_member], project.override_roles(Role.non_member)
end
+
+ def test_css_classes
+ p = Project.new
+ assert_kind_of String, p.css_classes
+ assert_not_include 'archived', p.css_classes.split
+ assert_not_include 'closed', p.css_classes.split
+ end
+
+ def test_css_classes_for_archived_project
+ p = Project.new
+ p.status = Project::STATUS_ARCHIVED
+ assert_include 'archived', p.css_classes.split
+ end
+
+ def test_css_classes_for_closed_project
+ p = Project.new
+ p.status = Project::STATUS_CLOSED
+ assert_include 'closed', p.css_classes.split
+ end
end
assert_equal [v5, v3, v1, v2, v4], Version.sorted.to_a
end
+ def test_should_sort_versions_with_same_date_by_name
+ v1 = Version.new(:effective_date => '2014-12-03', :name => 'v2')
+ v2 = Version.new(:effective_date => '2014-12-03', :name => 'v1')
+ assert_equal [v2, v1], [v1, v2].sort
+ end
+
def test_completed_should_be_false_when_due_today
version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today')
assert_equal false, version.completed?