v1.5.9 tests
This commit is contained in:
parent
c1ed977985
commit
f9765c5af1
@ -26,7 +26,7 @@ class DmsfPublicUrlsController < ApplicationController
|
||||
skip_before_filter :check_if_login_required, :only => [:show]
|
||||
|
||||
def show
|
||||
dmsf_public_url = DmsfPublicUrl.where("token = ? AND expire_at >= ?", params[:token], DateTime.now).first
|
||||
dmsf_public_url = DmsfPublicUrl.where('token = ? AND expire_at >= ?', params[:token], DateTime.now).first
|
||||
if dmsf_public_url
|
||||
revision = dmsf_public_url.dmsf_file.last_revision
|
||||
begin
|
||||
|
||||
@ -34,59 +34,60 @@ class DmsfFilesControllerTest < RedmineDmsf::Test::TestCase
|
||||
@role = Role.find_by_id 1
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 2
|
||||
DmsfFile.storage_path = File.expand_path '../../fixtures/files', __FILE__
|
||||
end
|
||||
|
||||
def test_truth
|
||||
def test_truth
|
||||
assert_kind_of DmsfFile, @file
|
||||
assert_kind_of Role, @role
|
||||
assert_kind_of Role, @role
|
||||
end
|
||||
|
||||
|
||||
def test_show_file_ok
|
||||
# Permissions OK
|
||||
@role.add_permission! :view_dmsf_files
|
||||
@role.add_permission! :view_dmsf_files
|
||||
get :show, :id => @file.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
def test_show_file_forbidden
|
||||
# Missing permissions
|
||||
# Missing permissions
|
||||
get :show, :id => @file.id
|
||||
assert_response :forbidden
|
||||
end
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
def test_view_file_ok
|
||||
# Permissions OK
|
||||
@role.add_permission! :view_dmsf_files
|
||||
get :view, :id => @file.id
|
||||
assert_response :missing # The file is physicaly not present
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_view_file_forbidden
|
||||
# Missing permissions
|
||||
# Missing permissions
|
||||
get :view, :id => @file.id
|
||||
assert_response :forbidden
|
||||
end
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
def delete_forbidden
|
||||
# Missing permissions
|
||||
delete @file, :commit => false
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
def delete_locked
|
||||
# Permissions OK but the file is locked
|
||||
|
||||
def delete_locked
|
||||
# Permissions OK but the file is locked
|
||||
@role.add_permission! :file_delete
|
||||
delete @file, :commit => false
|
||||
assert_response :redirect
|
||||
assert_response :redirect
|
||||
assert_include l(:error_file_is_locked), flash[:error]
|
||||
end
|
||||
|
||||
|
||||
def delete_ok
|
||||
# Permissions OK and not locked
|
||||
flash[:error].clear
|
||||
flash[:error].clear
|
||||
@file.unlock!
|
||||
delete @file, :commit => false
|
||||
assert_response :redirect
|
||||
assert_response :redirect
|
||||
assert_equal 0, flash[:error].size
|
||||
end
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ class DmsfPublicUrlsControllerTest < RedmineDmsf::Test::TestCase
|
||||
|
||||
def test_show_valid_url
|
||||
get :show, :token => 'd8d33e21914a433b280fdc94450ee212'
|
||||
assert_response :success
|
||||
assert_response :success, "#{DmsfFile.find_by_id(1).last_revision.disk_file} probably not found"
|
||||
end
|
||||
|
||||
def test_show_url_width_invalid_token
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user