OpenProject is the leading open source project management software.
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.
openproject/spec_legacy/functional/account_controller_spec.rb

81 lines
2.3 KiB

#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 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.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'legacy_spec_helper'
require 'account_controller'
describe AccountController, type: :controller do
render_views
fixtures :all
before do
User.current = nil
end
it 'should login with wrong password' do
post :login, username: 'admin', password: 'bad'
assert_response :success
assert_template 'login'
assert_select 'div.flash.error.icon.icon-error', /Invalid user or password/
end
it 'should login' do
get :login
assert_template 'login'
end
it 'should login should reset session' do
Convert specs to RSpec 3.2.0 syntax with Transpec This conversion is done by Transpec 3.1.0 with the following command: transpec -f -c "bundle exec rspec -Itest" test/functional/account_controller_test.rb test/functional/activities_controller_test.rb test/functional/admin_controller_test.rb test/functional/application_controller_test.rb test/functional/attachments_controller_test.rb test/functional/boards_controller_test.rb test/functional/custom_fields_controller_test.rb test/functional/enumerations_controller_test.rb test/functional/groups_controller_test.rb test/functional/help_controller_test.rb test/functional/journals_controller_test.rb test/functional/mail_handler_controller_test.rb test/functional/messages_controller_test.rb test/functional/my_controller_test.rb test/functional/project_enumerations_controller_test.rb test/functional/projects_controller_test.rb test/functional/repositories_controller_test.rb test/functional/repositories_filesystem_controller_test.rb test/functional/repositories_git_controller_test.rb test/functional/repositories_subversion_controller_test.rb test/functional/roles_controller_test.rb test/functional/search_controller_test.rb test/functional/settings_controller_test.rb test/functional/sys_controller_test.rb test/functional/time_entries/reports_controller_test.rb test/functional/timelog_controller_test.rb test/functional/types_controller_test.rb test/functional/user_mailer_test.rb test/functional/users_controller_test.rb test/functional/watchers_controller_test.rb test/functional/welcome_controller_test.rb test/functional/wiki_controller_test.rb test/functional/wikis_controller_test.rb test/functional/workflows_controller_test.rb test/integration/api_test/disabled_rest_api_test.rb test/integration/api_test/http_accept_auth_test.rb test/integration/api_test/http_basic_login_test.rb test/integration/api_test/http_basic_login_with_api_token_test.rb test/integration/api_test/token_authentication_test.rb test/integration/application_test.rb test/integration/layout_test.rb test/integration/lib/redmine/menu_manager_test.rb test/integration/lib/redmine/themes_test.rb test/integration/routing_test.rb test/unit/activity_test.rb test/unit/attachment_test.rb test/unit/board_test.rb test/unit/category_test.rb test/unit/changeset_test.rb test/unit/comment_test.rb test/unit/custom_field_test.rb test/unit/custom_field_user_format_test.rb test/unit/custom_value_test.rb test/unit/default_data_test.rb test/unit/enabled_module_test.rb test/unit/enumeration_test.rb test/unit/group_test.rb test/unit/helpers/application_helper_test.rb test/unit/helpers/custom_fields_helper_test.rb test/unit/helpers/sort_helper_test.rb test/unit/helpers/timelog_helper_test.rb test/unit/issue_nested_set_test.rb test/unit/issue_priority_test.rb test/unit/journal_observer_test.rb test/unit/journal_test.rb test/unit/ldap_auth_source_test.rb test/unit/lib/open_project/database_test.rb test/unit/lib/redmine/access_control_test.rb test/unit/lib/redmine/ciphering_test.rb test/unit/lib/redmine/codeset_util_test.rb test/unit/lib/redmine/helpers/calendar_test.rb test/unit/lib/redmine/hook_test.rb test/unit/lib/redmine/i18n_test.rb test/unit/lib/redmine/menu_manager/mapper_test.rb test/unit/lib/redmine/menu_manager/menu_helper_test.rb test/unit/lib/redmine/menu_manager/menu_item_test.rb test/unit/lib/redmine/menu_manager_test.rb test/unit/lib/redmine/mime_type_test.rb test/unit/lib/redmine/notifiable_test.rb test/unit/lib/redmine/plugin_test.rb test/unit/lib/redmine/safe_attributes_test.rb test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb test/unit/lib/redmine/scm/adapters/git_adapter_test.rb test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb test/unit/lib/redmine/unified_diff_test.rb test/unit/lib/redmine/wiki_formatting/macros_test.rb test/unit/lib/redmine/wiki_formatting/null_formatter_test.rb test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb test/unit/lib/redmine/wiki_formatting_test.rb test/unit/lib/redmine_test.rb test/unit/mail_handler_test.rb test/unit/member_test.rb test/unit/message_test.rb test/unit/principal_test.rb test/unit/project_nested_set_test.rb test/unit/project_test.rb test/unit/query_test.rb test/unit/relation_test.rb test/unit/repository_filesystem_test.rb test/unit/repository_git_test.rb test/unit/repository_subversion_test.rb test/unit/repository_test.rb test/unit/role_test.rb test/unit/search_test.rb test/unit/status_test.rb test/unit/time_entry_activity_test.rb test/unit/time_entry_test.rb test/unit/token_test.rb test/unit/type_test.rb test/unit/user_preference_test.rb test/unit/user_test.rb test/unit/version_test.rb test/unit/watcher_test.rb test/unit/wiki_content_test.rb test/unit/wiki_page_test.rb test/unit/wiki_redirect_test.rb test/unit/wiki_test.rb * 180 conversions from: it { should ... } to: it { is_expected.to ... } * 12 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 4 conversions from: Klass.any_instance.should_receive(:message) to: expect_any_instance_of(Klass).to receive(:message) * 4 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 2 conversions from: Klass.any_instance.stub(:message) to: allow_any_instance_of(Klass).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions
10 years ago
expect(@controller).to receive(:reset_session).once
post :login, username: 'jsmith', password: 'jsmith'
assert_response 302
end
it 'should login with logged account' do
session[:user_id] = 2
get :login
assert_redirected_to home_url
end
it 'should logout' do
session[:user_id] = 2
get :logout
assert_redirected_to '/'
assert_nil session[:user_id]
end
it 'should logout should reset session' do
Convert specs to RSpec 3.2.0 syntax with Transpec This conversion is done by Transpec 3.1.0 with the following command: transpec -f -c "bundle exec rspec -Itest" test/functional/account_controller_test.rb test/functional/activities_controller_test.rb test/functional/admin_controller_test.rb test/functional/application_controller_test.rb test/functional/attachments_controller_test.rb test/functional/boards_controller_test.rb test/functional/custom_fields_controller_test.rb test/functional/enumerations_controller_test.rb test/functional/groups_controller_test.rb test/functional/help_controller_test.rb test/functional/journals_controller_test.rb test/functional/mail_handler_controller_test.rb test/functional/messages_controller_test.rb test/functional/my_controller_test.rb test/functional/project_enumerations_controller_test.rb test/functional/projects_controller_test.rb test/functional/repositories_controller_test.rb test/functional/repositories_filesystem_controller_test.rb test/functional/repositories_git_controller_test.rb test/functional/repositories_subversion_controller_test.rb test/functional/roles_controller_test.rb test/functional/search_controller_test.rb test/functional/settings_controller_test.rb test/functional/sys_controller_test.rb test/functional/time_entries/reports_controller_test.rb test/functional/timelog_controller_test.rb test/functional/types_controller_test.rb test/functional/user_mailer_test.rb test/functional/users_controller_test.rb test/functional/watchers_controller_test.rb test/functional/welcome_controller_test.rb test/functional/wiki_controller_test.rb test/functional/wikis_controller_test.rb test/functional/workflows_controller_test.rb test/integration/api_test/disabled_rest_api_test.rb test/integration/api_test/http_accept_auth_test.rb test/integration/api_test/http_basic_login_test.rb test/integration/api_test/http_basic_login_with_api_token_test.rb test/integration/api_test/token_authentication_test.rb test/integration/application_test.rb test/integration/layout_test.rb test/integration/lib/redmine/menu_manager_test.rb test/integration/lib/redmine/themes_test.rb test/integration/routing_test.rb test/unit/activity_test.rb test/unit/attachment_test.rb test/unit/board_test.rb test/unit/category_test.rb test/unit/changeset_test.rb test/unit/comment_test.rb test/unit/custom_field_test.rb test/unit/custom_field_user_format_test.rb test/unit/custom_value_test.rb test/unit/default_data_test.rb test/unit/enabled_module_test.rb test/unit/enumeration_test.rb test/unit/group_test.rb test/unit/helpers/application_helper_test.rb test/unit/helpers/custom_fields_helper_test.rb test/unit/helpers/sort_helper_test.rb test/unit/helpers/timelog_helper_test.rb test/unit/issue_nested_set_test.rb test/unit/issue_priority_test.rb test/unit/journal_observer_test.rb test/unit/journal_test.rb test/unit/ldap_auth_source_test.rb test/unit/lib/open_project/database_test.rb test/unit/lib/redmine/access_control_test.rb test/unit/lib/redmine/ciphering_test.rb test/unit/lib/redmine/codeset_util_test.rb test/unit/lib/redmine/helpers/calendar_test.rb test/unit/lib/redmine/hook_test.rb test/unit/lib/redmine/i18n_test.rb test/unit/lib/redmine/menu_manager/mapper_test.rb test/unit/lib/redmine/menu_manager/menu_helper_test.rb test/unit/lib/redmine/menu_manager/menu_item_test.rb test/unit/lib/redmine/menu_manager_test.rb test/unit/lib/redmine/mime_type_test.rb test/unit/lib/redmine/notifiable_test.rb test/unit/lib/redmine/plugin_test.rb test/unit/lib/redmine/safe_attributes_test.rb test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb test/unit/lib/redmine/scm/adapters/git_adapter_test.rb test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb test/unit/lib/redmine/unified_diff_test.rb test/unit/lib/redmine/wiki_formatting/macros_test.rb test/unit/lib/redmine/wiki_formatting/null_formatter_test.rb test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb test/unit/lib/redmine/wiki_formatting_test.rb test/unit/lib/redmine_test.rb test/unit/mail_handler_test.rb test/unit/member_test.rb test/unit/message_test.rb test/unit/principal_test.rb test/unit/project_nested_set_test.rb test/unit/project_test.rb test/unit/query_test.rb test/unit/relation_test.rb test/unit/repository_filesystem_test.rb test/unit/repository_git_test.rb test/unit/repository_subversion_test.rb test/unit/repository_test.rb test/unit/role_test.rb test/unit/search_test.rb test/unit/status_test.rb test/unit/time_entry_activity_test.rb test/unit/time_entry_test.rb test/unit/token_test.rb test/unit/type_test.rb test/unit/user_preference_test.rb test/unit/user_test.rb test/unit/version_test.rb test/unit/watcher_test.rb test/unit/wiki_content_test.rb test/unit/wiki_page_test.rb test/unit/wiki_redirect_test.rb test/unit/wiki_test.rb * 180 conversions from: it { should ... } to: it { is_expected.to ... } * 12 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 4 conversions from: Klass.any_instance.should_receive(:message) to: expect_any_instance_of(Klass).to receive(:message) * 4 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 2 conversions from: Klass.any_instance.stub(:message) to: allow_any_instance_of(Klass).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions
10 years ago
expect(@controller).to receive(:reset_session).once
session[:user_id] = 2
get :logout
assert_response 302
end
end