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.
175 lines
5.0 KiB
175 lines
5.0 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
|
#
|
||
18 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'
|
||
18 years ago
|
require 'my_controller'
|
||
|
|
||
11 years ago
|
describe MyController, type: :controller do
|
||
12 years ago
|
fixtures :all
|
||
14 years ago
|
|
||
11 years ago
|
before do
|
||
10 years ago
|
session[:user_id] = 2
|
||
18 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should index' do
|
||
18 years ago
|
get :index
|
||
|
assert_response :success
|
||
|
assert_template 'page'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should page' do
|
||
18 years ago
|
get :page
|
||
|
assert_response :success
|
||
|
assert_template 'page'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should my account should not show non editable custom fields' do
|
||
16 years ago
|
UserCustomField.find(4).update_attribute :editable, false
|
||
14 years ago
|
|
||
16 years ago
|
get :account
|
||
|
assert_response :success
|
||
|
assert_template 'account'
|
||
|
assert_equal User.find(2), assigns(:user)
|
||
14 years ago
|
|
||
10 years ago
|
assert_no_tag :input, attributes: { name: 'user[custom_field_values][4]' }
|
||
18 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should update account' do
|
||
12 years ago
|
put :account,
|
||
10 years ago
|
user: {
|
||
|
firstname: 'Joe',
|
||
|
login: 'root', # should not be allowed
|
||
|
admin: 1,
|
||
|
group_ids: ['10'],
|
||
|
custom_field_values: { '4' => '0100562500' }
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
assert_redirected_to '/my/account'
|
||
18 years ago
|
user = User.find(2)
|
||
|
assert_equal user, assigns(:user)
|
||
10 years ago
|
assert_equal 'Joe', user.firstname
|
||
|
assert_equal 'jsmith', user.login
|
||
|
assert_equal '0100562500', user.custom_value_for(4).value
|
||
14 years ago
|
# ignored
|
||
18 years ago
|
assert !user.admin?
|
||
14 years ago
|
assert user.groups.empty?
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should page layout' do
|
||
15 years ago
|
get :page_layout
|
||
|
assert_response :success
|
||
|
assert_template 'page_layout'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should add block' do
|
||
10 years ago
|
xhr :post, :add_block, block: 'issuesreportedbyme'
|
||
15 years ago
|
assert_response :success
|
||
|
assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme')
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should remove block' do
|
||
10 years ago
|
xhr :post, :remove_block, block: 'issuesassignedtome'
|
||
15 years ago
|
assert_response :success
|
||
|
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should order blocks' do
|
||
10 years ago
|
xhr :post, :order_blocks, group: 'left', 'list-left' => ['documents', 'calendar', 'latestnews']
|
||
15 years ago
|
assert_response :success
|
||
|
assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left']
|
||
|
end
|
||
15 years ago
|
|
||
10 years ago
|
context 'POST to reset_rss_key' do
|
||
|
context 'with an existing rss_token' do
|
||
11 years ago
|
before do
|
||
15 years ago
|
@previous_token_value = User.find(2).rss_key # Will generate one if it's missing
|
||
|
post :reset_rss_key
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should destroy the existing token' do
|
||
15 years ago
|
assert_not_equal @previous_token_value, User.find(2).rss_key
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should create a new token' do
|
||
15 years ago
|
assert User.find(2).rss_token
|
||
|
end
|
||
|
|
||
10 years ago
|
it { is_expected.to set_flash.to /reset/ }
|
||
|
it { is_expected.to redirect_to '/my/account' }
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
context 'with no rss_token' do
|
||
11 years ago
|
before do
|
||
15 years ago
|
assert_nil User.find(2).rss_token
|
||
|
post :reset_rss_key
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should create a new token' do
|
||
15 years ago
|
assert User.find(2).rss_token
|
||
|
end
|
||
|
|
||
10 years ago
|
it { is_expected.to set_flash.to /reset/ }
|
||
|
it { is_expected.to redirect_to '/my/account' }
|
||
15 years ago
|
end
|
||
|
end
|
||
15 years ago
|
|
||
10 years ago
|
context 'POST to reset_api_key' do
|
||
|
context 'with an existing api_token' do
|
||
11 years ago
|
before do
|
||
15 years ago
|
@previous_token_value = User.find(2).api_key # Will generate one if it's missing
|
||
|
post :reset_api_key
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should destroy the existing token' do
|
||
15 years ago
|
assert_not_equal @previous_token_value, User.find(2).api_key
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should create a new token' do
|
||
15 years ago
|
assert User.find(2).api_token
|
||
|
end
|
||
|
|
||
10 years ago
|
it { is_expected.to set_flash.to /reset/ }
|
||
|
it { is_expected.to redirect_to '/my/account' }
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
context 'with no api_token' do
|
||
11 years ago
|
before do
|
||
15 years ago
|
assert_nil User.find(2).api_token
|
||
|
post :reset_api_key
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should create a new token' do
|
||
15 years ago
|
assert User.find(2).api_token
|
||
|
end
|
||
|
|
||
10 years ago
|
it { is_expected.to set_flash.to /reset/ }
|
||
|
it { is_expected.to redirect_to '/my/account' }
|
||
15 years ago
|
end
|
||
|
end
|
||
18 years ago
|
end
|