Test-suite functionality
This commit is contained in:
parent
6f7a4f2e4a
commit
bad46400c7
14
lib/redmine_dmsf/test/integration_test.rb
Normal file
14
lib/redmine_dmsf/test/integration_test.rb
Normal file
@ -0,0 +1,14 @@
|
||||
module RedmineDmsf
|
||||
module Test
|
||||
class IntegrationTest < ActionController::IntegrationTest
|
||||
def self.fixtures(*table_names)
|
||||
dir = File.join(File.dirname(__FILE__), "../../../test/fixtures" )
|
||||
modified_tables = table_names.reject{|x| !File.exist?(dir + "/" + x.to_s + ".yml") }
|
||||
ActiveRecord::Fixtures.create_fixtures(dir, modified_tables) unless modified_tables.empty?
|
||||
table_names -= modified_tables
|
||||
super(table_names-modified_tables)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
23
lib/redmine_dmsf/test/test_case.rb
Normal file
23
lib/redmine_dmsf/test/test_case.rb
Normal file
@ -0,0 +1,23 @@
|
||||
module RedmineDmsf
|
||||
module Test
|
||||
class TestCase < ActionController::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.join( File.dirname(__FILE__), "../../../test/fixtures" )
|
||||
table_names.each{|x|
|
||||
ActiveRecord::Fixtures.create_fixtures(dir, x) if File.exist?(dir + "/" + x.to_s + ".yml")
|
||||
}
|
||||
super(table_names)
|
||||
end
|
||||
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
18
test/fixtures/dmsf_file_revisions.yml
vendored
Normal file
18
test/fixtures/dmsf_file_revisions.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
dmsf_file_revisions_001:
|
||||
dmsf_file_id: 1
|
||||
source_dmsf_file_revision_id: NULL
|
||||
name: "test.txt"
|
||||
dmsf_folder_id: 1
|
||||
disk_filename: "test.txt"
|
||||
size: 4
|
||||
mime_type: text/plain
|
||||
title: "Test File"
|
||||
description: NULL
|
||||
workflow: NULL
|
||||
minor_version: 0
|
||||
major_version: 1
|
||||
comment: NULL
|
||||
deleted: 0
|
||||
deleted_by_user_id: NULL
|
||||
user_id: 1
|
||||
9
test/fixtures/dmsf_files.yml
vendored
Normal file
9
test/fixtures/dmsf_files.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
dmsf_files_001:
|
||||
id: 1
|
||||
project_id: 1
|
||||
dmsf_folder_id: NULL
|
||||
name: "test.txt"
|
||||
notification: 0
|
||||
deleted: 0
|
||||
deleted_by_user_id: NULL
|
||||
5
test/fixtures/enabled_modules.yml
vendored
Normal file
5
test/fixtures/enabled_modules.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
enabled_modules_001:
|
||||
name: dmsf
|
||||
project_id: 1
|
||||
id: 1
|
||||
64
test/integration/dmsf_webdav_get_test.rb
Normal file
64
test/integration/dmsf_webdav_get_test.rb
Normal file
@ -0,0 +1,64 @@
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DmsfWebdavIntegrationTest < RedmineDmsf::Test::IntegrationTest
|
||||
|
||||
fixtures :projects, :users, :members, :enabled_modules, :dmsf_folders, :dmsf_files, :dmsf_file_revisions
|
||||
|
||||
def setup
|
||||
@headers = credentials('admin')
|
||||
super
|
||||
end
|
||||
|
||||
def teardown
|
||||
@headers = nil
|
||||
end
|
||||
|
||||
test "should deny anonymous" do
|
||||
get 'dmsf/webdav'
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
test "should deny failed authentication" do
|
||||
get 'dmsf/webdav', nil, credentials('admin', 'badpassword')
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
test "should permit authenticated user" do
|
||||
get 'dmsf/webdav', nil, @headers
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should list DMSF enabled project" do
|
||||
|
||||
get 'dmsf/webdav', nil, @headers
|
||||
assert_response :success
|
||||
|
||||
assert !response.body.match(Project.find(1).name).nil?, "Expected to find project #{Project.find(1).name} in return data"
|
||||
end
|
||||
|
||||
test "should not list non-DMSF enabled project" do
|
||||
|
||||
get 'dmsf/webdav', nil, @headers
|
||||
assert_response :success
|
||||
|
||||
assert response.body.match(Project.find(3).name).nil?, "Unexpected find of project #{Project.find(3).name} in return data"
|
||||
end
|
||||
|
||||
test "should return status 404 when accessing non-existant or non dmsf-enabled project" do
|
||||
get 'dmsf/webdav/project_does_not_exist/test1', nil, @headers
|
||||
assert_response 404
|
||||
|
||||
get "dmsf/webdav/#{Project.find(3).identifier}", nil, @headers
|
||||
STDOUT.puts response.body
|
||||
assert_response 404
|
||||
|
||||
end
|
||||
|
||||
test "should list dmsf contents within \"#{Project.find(1).identifier}\"" do
|
||||
get "dmsf/webdav/#{Project.find(1).identifier}", nil, @headers
|
||||
assert_response :success
|
||||
assert !response.body.match(DmsfFolder.find(1).title).nil?, "Expected to find #{DmsfFolder.find(1).title} in return data"
|
||||
assert !response.body.match(DmsfFile.find(1).name).nil?, "Expected to find #{DmsfFile.find(1).name} in return data"
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user