mezuro_plugin_profile_controller_test.rb
2.21 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
require 'test_helper'
class MezuroPluginProfileControllerTest < ActionController::TestCase
def setup
@controller = MezuroPluginProfileController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@profile = fast_create(Community)
@profile_id = @profile.identifier
end
# def test_metrics_for_unknown_module
# get :metrics, :profile => @profile_id, :id => 0
# assert_response 404
# end
# def test_metric_unknown_module
# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => 'veryunlikelyname'
# assert_response 404
# end
# def test_metrics_for_known_module
# @project_content = create_project_content(@profile)
# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => @project_content.name
# assert_response 200
# # assert_tag # TODO
# end
protected
# returns a new ProjectContent for the given profile
def create_project_content(profile)
project_content = MezuroPlugin::ProjectContent.create!(:profile => profile, :name => 'foo')
project = create_project(project_content.name)
project_content.license = project.license
project_content.description = project.description
project_content.repository_type = project.repository.type
project_content.repository_url = project.repository.address
project_content.configuration_name = project.configuration_name
MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content)
project_content
end
def create_project(name)
project = Kalibro::Entities::Project.new
project.name = name
project.license = 'GPL'
project.description = 'testing'
project.repository = crieate_repository
project.configuration_name = 'Kalibro Default'
project
end
def create_repository
repository = Kalibro::Entities::Repository.new
repository.type = 'git'
repository.address = 'http://git.git'
repository
end
#TODO Adicionar module result manualmente
#TODO Ver testes do project content, refatorar o project content em cima dos testes
#TODO Repensar design OO: nao amarrar o project_content ao webservice. Criar um modelo abstrato do webservice
end