kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.3 KiB
122 lines
3.3 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
15 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
15 years ago
|
require 'groups_controller'
|
||
|
|
||
11 years ago
|
describe GroupsController, type: :controller do
|
||
12 years ago
|
fixtures :all
|
||
14 years ago
|
|
||
11 years ago
|
before do
|
||
15 years ago
|
User.current = nil
|
||
10 years ago
|
session[:user_id] = 1
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should index' do
|
||
15 years ago
|
get :index
|
||
|
assert_response :success
|
||
|
assert_template 'index'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show' do
|
||
10 years ago
|
get :show, id: 10
|
||
15 years ago
|
assert_response :success
|
||
|
assert_template 'show'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should new' do
|
||
15 years ago
|
get :new
|
||
|
assert_response :success
|
||
|
assert_template 'new'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create' do
|
||
15 years ago
|
assert_difference 'Group.count' do
|
||
10 years ago
|
post :create, group: { lastname: 'New group' }
|
||
15 years ago
|
end
|
||
12 years ago
|
assert_redirected_to groups_path
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should edit' do
|
||
10 years ago
|
get :edit, id: 10
|
||
15 years ago
|
assert_response :success
|
||
|
assert_template 'edit'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should update' do
|
||
10 years ago
|
put :update, id: 10, group: { lastname: 'new name' }
|
||
12 years ago
|
assert_redirected_to groups_path
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy' do
|
||
15 years ago
|
assert_difference 'Group.count', -1 do
|
||
10 years ago
|
delete :destroy, id: 10
|
||
15 years ago
|
end
|
||
12 years ago
|
assert_redirected_to groups_path
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should add users' do
|
||
15 years ago
|
assert_difference 'Group.find(10).users.count', 2 do
|
||
10 years ago
|
post :add_users, id: 10, user_ids: ['2', '3']
|
||
15 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should remove user' do
|
||
15 years ago
|
assert_difference 'Group.find(10).users.count', -1 do
|
||
10 years ago
|
delete :remove_user, id: 10, user_id: '8'
|
||
15 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create membership' do
|
||
15 years ago
|
assert_difference 'Group.find(10).members.count' do
|
||
10 years ago
|
post :create_memberships, id: 10, membership: { project_id: 2, role_ids: ['1', '2'] }
|
||
15 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should edit membership' do
|
||
15 years ago
|
assert_no_difference 'Group.find(10).members.count' do
|
||
10 years ago
|
put :edit_membership, id: 10, membership_id: 6, membership: { role_ids: ['1', '3'] }
|
||
15 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy membership' do
|
||
15 years ago
|
assert_difference 'Group.find(10).members.count', -1 do
|
||
10 years ago
|
delete :destroy_membership, id: 10, membership_id: 6
|
||
15 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should autocomplete for user' do
|
||
10 years ago
|
get :autocomplete_for_user, id: 10, q: 'mis'
|
||
14 years ago
|
assert_response :success
|
||
|
users = assigns(:users)
|
||
9 years ago
|
refute_nil users
|
||
14 years ago
|
assert users.any?
|
||
|
assert !users.include?(Group.find(10).users.first)
|
||
|
end
|
||
15 years ago
|
end
|