diff --git a/test/ci/redmine_install.sh b/test/ci/redmine_install.sh index da745b0f..a9ed4e00 100644 --- a/test/ci/redmine_install.sh +++ b/test/ci/redmine_install.sh @@ -43,11 +43,7 @@ run_tests() # exit if tests fail set -e - cd $PATH_TO_REDMINE - - - #mkdir -p coverage - #ln -sf `pwd`/coverage $WORKSPACE + cd $PATH_TO_REDMINE # Run tests within application - for some reason redmine:plugins:test wont work under 1.8 bundle exec rake redmine:plugins:test:units NAME=redmine_dmsf @@ -58,10 +54,11 @@ run_tests() uninstall() { set -e # exit if migrate fails + cd $PATH_TO_REDMINE + # clean up database - bundle exec rake $MIGRATE_PLUGINS NAME=redmine_dmsf VERSION=0 RAILS_ENV=test - #bundle exec rake $MIGRATE_PLUGINS NAME=redmine_dmsf VERSION=0 RAILS_ENV=development + bundle exec rake $MIGRATE_PLUGINS NAME=redmine_dmsf VERSION=0 RAILS_ENV=test } run_install() @@ -75,9 +72,7 @@ run_install() # create a link to the dmsf plugin ln -sf $PATH_TO_DMSF $PATH_TO_PLUGINS/redmine_dmsf - - #ignore redmine-master's test-unit dependency, we need 1.2.3 - #sed -i -e 's=.*gem ["'\'']test-unit["'\''].*==g' ${PATH_TO_REDMINE}/Gemfile + # install gems mkdir -p vendor/bundle @@ -89,11 +84,9 @@ run_install() bundle install --path vendor/bundle --without xapian # run redmine database migrations - bundle exec rake db:migrate RAILS_ENV=test --trace - #bundle exec rake db:migrate RAILS_ENV=development --trace + bundle exec rake db:migrate RAILS_ENV=test --trace - # Load redmine database default data - #bundle exec rake redmine:load_default_data REDMINE_LANG=en RAILS_ENV=development + # Load redmine database default data bundle exec rake redmine:load_default_data REDMINE_LANG=en RAILS_ENV=test # generate session store/secret token @@ -103,8 +96,7 @@ run_install() #touch dmsf.dev # run dmsf database migrations - bundle exec rake $MIGRATE_PLUGINS RAILS_ENV=test - #bundle exec rake $MIGRATE_PLUGINS RAILS_ENV=development + bundle exec rake $MIGRATE_PLUGINS RAILS_ENV=test } while getopts :irtu opt diff --git a/test/functional/dmsf_files_controller_test.rb b/test/functional/dmsf_files_controller_test.rb index 2dc14a31..671bd83d 100644 --- a/test/functional/dmsf_files_controller_test.rb +++ b/test/functional/dmsf_files_controller_test.rb @@ -21,35 +21,49 @@ require File.expand_path('../../test_helper', __FILE__) class DmsfFilesControllerTest < RedmineDmsf::Test::TestCase fixtures :users, :dmsf_files, :dmsf_file_revisions, :custom_fields, - :custom_values, :projects, :members, :member_roles, :enabled_modules, + :custom_values, :projects, :roles, :members, :member_roles, :enabled_modules, :dmsf_file_revisions def setup - @request.session[:user_id] = 2 - @file = DmsfFolder.find_by_id 1 + @project = Project.find_by_id 1 + assert_not_nil @project + @project.enable_module! :dmsf + @user = User.find_by_id 2 + assert_not_nil @user + @request.session[:user_id] = @user.id + @file = DmsfFile.find_by_id 1 @role = Role.find_by_id 1 @custom_field = CustomField.find_by_id 21 - @custom_value_2 = CustomValue.find_by_id 22 + @custom_value = CustomValue.find_by_id 22 end + + def test_truth + assert_kind_of Project, @project + assert_kind_of User, @user + assert_kind_of DmsfFile, @file + assert_kind_of Role, @role + assert_kind_of CustomField, @custom_field + assert_kind_of CustomValue, @custom_value + end def test_show_file # Missing permissions - get :show, :id => @file + get :show, :id => @file.id assert_response 403 # Permissions OK @role.add_permission! :view_dmsf_files @role.add_permission! :file_manipulation - get :show, :id => @file + get :show, :id => @file.id assert_response :success # The last revision - assert_select 'label', {:text => @custom_field.name} - assert_select '.customfield', {:text => "#{@custom_field.name}: #{@custom_value_2.value}"} + assert_select 'label', { :text => @custom_field.name } + assert_select '.customfield', { :text => "#{@custom_field.name}: #{@custom_value.value}" } # A new revision - assert_select 'label', {:text => @custom_field.name} - assert_select 'option', {:value => @custom_value_2.value} + assert_select 'label', { :text => @custom_field.name } + assert_select 'option', { :value => @custom_value.value } end end