Included unit test for file structure change
This commit is contained in:
parent
358d3282b6
commit
5de3bd7720
@ -30,7 +30,7 @@ module RedmineDmsf
|
||||
unloadable
|
||||
alias_method_chain :copy, :dmsf
|
||||
|
||||
has_many :dmsf_files, :class_name => "DmsfFile", :foreign_key => "project_id", :conditions => { :deleted => false, :dmsf_folder_id => nil }
|
||||
has_many :dmsf_files, :class_name => "DmsfFile", :foreign_key => "project_id", :conditions => { :dmsf_folder_id => nil }
|
||||
#Fix: should only be root folders not, all folders
|
||||
has_many :dmsf_folders, :class_name => "DmsfFolder", :foreign_key => "project_id", :conditions => {:dmsf_folder_id => nil}, :dependent => :destroy
|
||||
|
||||
|
||||
@ -20,4 +20,4 @@ module RedmineDmsf
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
18
lib/redmine_dmsf/test/unit_test.rb
Normal file
18
lib/redmine_dmsf/test/unit_test.rb
Normal file
@ -0,0 +1,18 @@
|
||||
module RedmineDmsf
|
||||
module Test
|
||||
class UnitTest < ActiveSupport::TestCase
|
||||
|
||||
# Allow us to override the fixtures method to implement fixtures for our plugin.
|
||||
# Ultimately it allows for better integration without blowing redmine fixtures up,
|
||||
# and allowing us to suppliment redmine fixtures if we need to.
|
||||
def self.fixtures(*table_names)
|
||||
dir = File.expand_path( File.dirname(__FILE__) + "../../../../test/fixtures" )
|
||||
table_names.each{|x,i|
|
||||
ActiveRecord::Fixtures.create_fixtures(dir, x) if File.exist?(dir + "/" + x.to_s + ".yml")
|
||||
}
|
||||
super(table_names)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
20
test/fixtures/dmsf_file_revisions.yml
vendored
20
test/fixtures/dmsf_file_revisions.yml
vendored
@ -35,3 +35,23 @@ dmsf_file_revisions_002:
|
||||
deleted: 0
|
||||
deleted_by_user_id: NULL
|
||||
user_id: 1
|
||||
|
||||
#revision for deleted file on dmsf-enabled project
|
||||
dmsf_file_revisions_003:
|
||||
dmsf_file_id: 3
|
||||
source_dmsf_file_revision_id: NULL
|
||||
name: "deleted.txt"
|
||||
dmsf_folder_id: NULL
|
||||
disk_filename: "deleted.txt"
|
||||
size: 4
|
||||
mime_type: text/plain
|
||||
title: "Test File"
|
||||
description: NULL
|
||||
workflow: NULL
|
||||
minor_version: 0
|
||||
major_version: 1
|
||||
comment: NULL
|
||||
deleted: 1
|
||||
deleted_by_user_id: 1
|
||||
user_id: 1
|
||||
|
||||
|
||||
11
test/fixtures/dmsf_files.yml
vendored
11
test/fixtures/dmsf_files.yml
vendored
@ -17,3 +17,14 @@ dmsf_files_002:
|
||||
notification: 0
|
||||
deleted: 0
|
||||
deleted_by_user_id: NULL
|
||||
|
||||
#deleted file on dmsf-enabled project
|
||||
dmsf_files_003:
|
||||
id: 3
|
||||
project_id: 1
|
||||
dmsf_folder_id: NULL
|
||||
name: "deleted.txt"
|
||||
notification: 0
|
||||
deleted: 1
|
||||
deleted_by_user_id: 1
|
||||
|
||||
|
||||
32
test/unit/dmsf_file_test.rb
Normal file
32
test/unit/dmsf_file_test.rb
Normal file
@ -0,0 +1,32 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class DmsfFileTest < RedmineDmsf::Test::UnitTest
|
||||
fixtures :projects, :users, :dmsf_folders, :dmsf_files, :dmsf_file_revisions,
|
||||
:roles, :members, :member_roles, :enabled_modules, :enumerations
|
||||
|
||||
test "file data is created" do
|
||||
assert_not_nil(dmsf_files(:dmsf_files_001))
|
||||
end
|
||||
|
||||
test "project file count differs from project visibility count" do
|
||||
project = Project.find(1)
|
||||
assert_not_same(project.dmsf_files.count, project.dmsf_files.visible.count)
|
||||
end
|
||||
|
||||
test "project DMSF file listing contains deleted items" do
|
||||
project = Project.find(1)
|
||||
found_deleted = false
|
||||
project.dmsf_files.each {|file|
|
||||
found_deleted = true if file.deleted
|
||||
}
|
||||
assert found_deleted, "Expected at least one deleted item in <all items>"
|
||||
end
|
||||
|
||||
test "project DMSF file visible listing contains no deleted items" do
|
||||
project = Project.find(1)
|
||||
project.dmsf_files.visible.each {|file|
|
||||
assert !file.deleted, "File #{file.name} is deleted, this was unexpected"
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user