Commit b046e2a3e49e2f4dd27abe009a9f820e64fec692
1 parent
5d1f706a
Exists in
master
and in
29 other branches
[Mezuro] Initial functional tests
Showing
3 changed files
with
34 additions
and
50 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -3,7 +3,8 @@ class MezuroPluginProfileController < ProfileController | @@ -3,7 +3,8 @@ class MezuroPluginProfileController < ProfileController | ||
3 | def metrics | 3 | def metrics |
4 | project_content = profile.articles.find(params[:id]) | 4 | project_content = profile.articles.find(params[:id]) |
5 | module_name = params[:module_name] | 5 | module_name = params[:module_name] |
6 | - render :partial => 'content_viewer/module_result', :locals => { :module_result => project_content.module_result(module_name) } | 6 | + render :partial => 'content_viewer/module_result', |
7 | + :locals => { :module_result => project_content.module_result(module_name)} | ||
7 | end | 8 | end |
8 | 9 | ||
9 | end | 10 | end |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
1 | require 'test_helper' | 1 | require 'test_helper' |
2 | 2 | ||
3 | -class MezuroPluginProfileControllerTest < ActiveSupport::TestCase | 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" |
4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | ||
5 | + | ||
6 | +class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
4 | 7 | ||
5 | def setup | 8 | def setup |
6 | @controller = MezuroPluginProfileController.new | 9 | @controller = MezuroPluginProfileController.new |
7 | @request = ActionController::TestRequest.new | 10 | @request = ActionController::TestRequest.new |
8 | - @response = ActionController::TestResponse.new | 11 | + @response = ActionController::TestResponse.new |
9 | @profile = fast_create(Community) | 12 | @profile = fast_create(Community) |
10 | @profile_id = @profile.identifier | 13 | @profile_id = @profile.identifier |
14 | + | ||
15 | + @module_result = ModuleResultFixtures.create | ||
16 | + @project_result = ProjectResultFixtures.project_result | ||
17 | + @project = @project_result.project | ||
11 | end | 18 | end |
12 | 19 | ||
13 | -# def test_metrics_for_unknown_module | ||
14 | -# get :metrics, :profile => @profile_id, :id => 0 | 20 | +# def test_metrics_for_unknown_project |
21 | +# get :metrics, :profile => @profile_id | ||
15 | # assert_response 404 | 22 | # assert_response 404 |
16 | # end | 23 | # end |
17 | - | 24 | +# |
18 | # def test_metric_unknown_module | 25 | # def test_metric_unknown_module |
19 | -# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => 'veryunlikelyname' | ||
20 | -# assert_response 404 | 26 | +# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => 'veryunlikelyname' |
27 | +# assert_response 404 | ||
21 | # end | 28 | # end |
22 | 29 | ||
23 | 30 | ||
24 | -# def test_metrics_for_known_module | ||
25 | -# @project_content = create_project_content(@profile) | ||
26 | -# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => @project_content.name | ||
27 | -# assert_response 200 | ||
28 | -# # assert_tag # TODO | ||
29 | -# end | 31 | + def test_metrics_for_known_module |
32 | + @project_content = create_project_content(@profile) | ||
33 | + Kalibro::Client::ProjectResultClient.expects(:last_result).with(@project.name).returns(@project_result) | ||
34 | + Kalibro::Client::ModuleResultClient.expects(:module_result). | ||
35 | + with(@project.name, @project.name, @project_result.date).returns(@module_result) | ||
36 | + get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => @project_content.title | ||
37 | + assert_response 200 | ||
38 | + # assert_tag # TODO | ||
39 | + end | ||
30 | 40 | ||
31 | protected | 41 | protected |
32 | 42 | ||
33 | # returns a new ProjectContent for the given profile | 43 | # returns a new ProjectContent for the given profile |
34 | def create_project_content(profile) | 44 | def create_project_content(profile) |
35 | - project_content = MezuroPlugin::ProjectContent.create!(:profile => profile, :name => 'foo') | 45 | + Kalibro::Client::ProjectClient.expects(:save).with(@project) |
46 | + Kalibro::Client::KalibroClient.expects(:process_project).with(@project.name) | ||
36 | 47 | ||
37 | - project = create_project(project_content.name) | ||
38 | - project_content.license = project.license | ||
39 | - project_content.description = project.description | ||
40 | - project_content.repository_type = project.repository.type | ||
41 | - project_content.repository_url = project.repository.address | ||
42 | - project_content.configuration_name = project.configuration_name | 48 | + project_content = MezuroPlugin::ProjectContent.new(:profile => profile, :name => @project.name) |
49 | + project_content.license = @project.license | ||
50 | + project_content.description = @project.description | ||
51 | + project_content.repository_type = @project.repository.type | ||
52 | + project_content.repository_url = @project.repository.address | ||
53 | + project_content.configuration_name = @project.configuration_name | ||
54 | + project_content.save | ||
43 | 55 | ||
44 | MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) | 56 | MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) |
45 | project_content | 57 | project_content |
46 | end | 58 | end |
47 | - | ||
48 | - def create_project(name) | ||
49 | - project = Kalibro::Entities::Project.new | ||
50 | - project.name = name | ||
51 | - project.license = 'GPL' | ||
52 | - project.description = 'testing' | ||
53 | - project.repository = crieate_repository | ||
54 | - project.configuration_name = 'Kalibro Default' | ||
55 | - project | ||
56 | - end | ||
57 | - | ||
58 | - def create_repository | ||
59 | - repository = Kalibro::Entities::Repository.new | ||
60 | - repository.type = 'git' | ||
61 | - repository.address = 'http://git.git' | ||
62 | - repository | ||
63 | - end | ||
64 | 59 | ||
65 | #TODO Adicionar module result manualmente | 60 | #TODO Adicionar module result manualmente |
66 | #TODO Ver testes do project content, refatorar o project content em cima dos testes | 61 | #TODO Ver testes do project content, refatorar o project content em cima dos testes |
plugins/mezuro/test/mezuro_test.rb
@@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
1 | -require "test_helper" | ||
2 | - | ||
3 | -require File.dirname(__FILE__) + '/../controllers/mezuro_plugin_myprofile_controller' | ||
4 | - | ||
5 | -class MezuroTest < ActiveSupport::TestCase | ||
6 | - | ||
7 | - should 'create a mezuro project' do | ||
8 | - controller = MezuroPluginMyprofileController.new | ||
9 | - controller.create | ||
10 | - end | ||
11 | - | ||
12 | -end |