software_communities_plugin_profile_controller_test.rb
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require File.dirname(__FILE__) + '/../../../../test/test_helper'
require File.dirname(__FILE__) + '/../helpers/software_test_helper'
require File.dirname(__FILE__) + '/../../controllers/software_communities_plugin_profile_controller'
class SoftwareCommunitiesPluginProfileController; def rescue_action(e) raise e end; end
class SoftwareCommunitiesPluginProfileControllerTest < ActionController::TestCase
include SoftwareTestHelper
def setup
@controller = SoftwareCommunitiesPluginProfileController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@environment = Environment.default
@environment.enable_plugin('SoftwareCommunitiesPlugin')
@environment.save!
LicenseInfo.create(
:version=>"CC-GPL-V2",
:link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt"
)
@download_data = {
:name=>"Google",
:link=>"http://google.com",
:software_description=>"all",
:minimum_requirements=>"none",
:size=>"?",
:total_downloads=>0
}
@software = create_software(software_fields)
@software.save!
download_block = DownloadBlock.new
download_block.downloads = Download.validate_download_list([@download_data])
download_block.save!
@software.community.blocks << download_block
@software.community.save!
end
should 'redirect to download link with correct params' do
download_block = DownloadBlock.last
get :download_file, :profile=>@software.community.identifier,
:block => download_block.id, :download_index => 0
assert_equal nil, session[:notice]
assert_redirected_to download_block.downloads[0][:link]
end
should "notice when the download was not found" do
download_block = DownloadBlock.last
get :download_file, :profile=>@software.community.identifier,
:block => 123, :download_index => 0
assert_equal "Could not find the download file", session[:notice]
end
should "notice when given invalid download params" do
download_block = DownloadBlock.last
get :download_file, :profile=>@software.community.identifier,
:block => download_block.id, :download_index => -5
assert_equal "Invalid download params", session[:notice]
end
end