profile_controller_test.rb
2.51 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
68
69
70
71
72
require File.dirname(__FILE__) + '/../../../../test/test_helper'
require File.dirname(__FILE__) + '/../helpers/institution_test_helper'
require File.dirname(__FILE__) + '/../helpers/software_test_helper'
require(
File.dirname(__FILE__) +
'/../../../../app/controllers/public/profile_controller'
)
class ProfileController; def rescue_action(e) raise e end; end
class ProfileControllerTest < ActionController::TestCase
include InstitutionTestHelper
include SoftwareTestHelper
def setup
@environment = Environment.default
@environment.enabled_plugins = ['SoftwareCommunitiesPlugin']
@environment.save!
@controller = ProfileController.new
@request = ActionController::TestRequest.new
@request.stubs(:ssl?).returns(:false)
@response = ActionController::TestResponse.new
@user = create_user('testuser').person
LicenseInfo.create(
:version=>"CC-GPL-V2",
:link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt"
)
@community = fast_create(Community, :name=> "Test community")
@institution = InstitutionTestHelper.create_private_institution "Test institution", "ti", "BR", "DF", "Brasilia", "11.111.111/1111-11"
basic_fields = software_fields
@software = create_software basic_fields
@community.add_member(@user)
@institution.community.add_member(@user)
@software.community.add_member(@user)
login_as(@user.identifier)
end
should "Show only communities on community block view all" do
get :communities, :profile => @user.identifier
assert_match Regexp.new("#{@community.name}"), @response.body
assert_not_match Regexp.new("#{@institution.community.name}"), @response.body
assert_not_match Regexp.new("#{@software.community.name}"), @response.body
end
should "Show only institutions on community block view all with type=software" do
get :communities,:type => "Software", :profile => @user.identifier
assert_not_match Regexp.new("#{@community.name}"), @response.body
assert_not_match Regexp.new("#{@institution.community.name}"), @response.body
assert_match Regexp.new("#{@software.community.name}"), @response.body
end
should "Show only communities on community block view all with type=institution" do
get :communities,:type => "Institution", :profile => @user.identifier
assert_not_match Regexp.new("#{@community.name}"), @response.body
assert_match Regexp.new("#{@institution.community.name}"), @response.body
assert_not_match Regexp.new("#{@software.community.name}"), @response.body
end
end