From d2a651ad638cae4bcac5b892ca45501a50e69b5e Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Wed, 6 Nov 2013 14:32:23 +0100 Subject: [PATCH] Tests for new blocks in My page adeded --- app/views/my/blocks/_open_approvals.html.erb | 6 ++- test/fixtures/dmsf_locks.yml | 7 +++ test/functional/my_controller_test.rb | 49 ++++++++++++++++++++ travis_patch.diff | 27 ++++++----- 4 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 test/functional/my_controller_test.rb diff --git a/app/views/my/blocks/_open_approvals.html.erb b/app/views/my/blocks/_open_approvals.html.erb index 69737e83..8b675d62 100644 --- a/app/views/my/blocks/_open_approvals.html.erb +++ b/app/views/my/blocks/_open_approvals.html.erb @@ -43,7 +43,9 @@ <% assignments.each do |assignment| %> - <%= link_to_project(assignment.dmsf_file_revision.project) %> + <% if assignment.dmsf_file_revision.project %> + <%= link_to_project(assignment.dmsf_file_revision.project) %> + <% end %> <% if assignment.dmsf_workflow_step && assignment.dmsf_workflow_step.dmsf_workflow %> @@ -62,7 +64,7 @@ <% if assignment.dmsf_file_revision.folder %> <%= link_to(h(assignment.dmsf_file_revision.folder.title), {:controller => 'dmsf', :action => 'show', :id=> assignment.dmsf_file_revision.project, :folder_id => assignment.dmsf_file_revision.folder}) %> - <% else %> + <% elsif assignment.dmsf_file_revision.project %> <%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.project }) %> <% end %> <% end %> diff --git a/test/fixtures/dmsf_locks.yml b/test/fixtures/dmsf_locks.yml index e3bb4fbe..4dd50953 100644 --- a/test/fixtures/dmsf_locks.yml +++ b/test/fixtures/dmsf_locks.yml @@ -13,3 +13,10 @@ dmsf_locks_002: entity_type: 1 lock_type_cd: 0 lock_scope_cd: 0 +dmsf_locks_003: + id: 3 + entity_id: 2 + user_id: 2 + entity_type: 0 + lock_type_cd: 0 + lock_scope_cd: 0 diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb new file mode 100644 index 00000000..803da864 --- /dev/null +++ b/test/functional/my_controller_test.rb @@ -0,0 +1,49 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2013 Karel Picman +# +# 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. + +require File.expand_path('../../test_helper', __FILE__) + +class MyControllerTest < RedmineDmsf::Test::TestCase + include Redmine::I18n + + fixtures :users, :user_preferences, :dmsf_locks + + def setup + @request.session[:user_id] = 2 + end + + def test_page_with_open_approvals_block + preferences = User.find(2).pref + preferences[:my_page_layout] = {'top' => ['open_approvals']} + preferences.save! + + get :page + assert_response :success + assert_select 'h3', {:text => "#{l(:label_my_open_approvals)} (2)"} + end + + def test_page_with_open_locked_documents + preferences = User.find(2).pref + preferences[:my_page_layout] = {'top' => ['locked_documents']} + preferences.save! + + get :page + assert_response :success + assert_select 'h3', {:text => "#{l(:label_my_locked_documents)} (0/1)"} + end +end diff --git a/travis_patch.diff b/travis_patch.diff index 96a743b2..c1e8930a 100644 --- a/travis_patch.diff +++ b/travis_patch.diff @@ -2,17 +2,20 @@ Index: db/migrate/062_insert_builtin_roles.rb =================================================================== --- db/migrate/062_insert_builtin_roles.rb (revision 12244) +++ db/migrate/062_insert_builtin_roles.rb (working copy) -@@ -2,11 +2,11 @@ - def self.up - Role.reset_column_information - nonmember = Role.new(:name => 'Non member', :position => 0) +@@ -1,16 +0,0 @@ +-class InsertBuiltinRoles < ActiveRecord::Migration +- def self.up +- Role.reset_column_information +- nonmember = Role.new(:name => 'Non member', :position => 0) - nonmember.builtin = Role::BUILTIN_NON_MEMBER -+ #nonmember.builtin = Role::BUILTIN_NON_MEMBER - nonmember.save - - anonymous = Role.new(:name => 'Anonymous', :position => 0) +- nonmember.save +- +- anonymous = Role.new(:name => 'Anonymous', :position => 0) - anonymous.builtin = Role::BUILTIN_ANONYMOUS -+ #anonymous.builtin = Role::BUILTIN_ANONYMOUS - anonymous.save - end - +- anonymous.save +- end +- +- def self.down +- Role.destroy_all 'builtin <> 0' +- end +-end