Commit 4c598d73dccd5502be54e16f8b68b973fa4ddb4e
Committed by
Carlos Morais
1 parent
2e43c86a
Exists in
master
and in
22 other branches
[Mezuro] Review mock expectations for controller test
Showing
1 changed file
with
11 additions
and
15 deletions
Show diff stats
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
| ... | ... | @@ -13,7 +13,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 13 | 13 | @profile_id = @profile.identifier |
| 14 | 14 | |
| 15 | 15 | @module_result = ModuleResultFixtures.create |
| 16 | - @project_result = ProjectResultFixtures.project_result | |
| 16 | + @project_result = ProjectResultFixtures.qt_calculator | |
| 17 | 17 | @project = @project_result.project |
| 18 | 18 | end |
| 19 | 19 | |
| ... | ... | @@ -29,11 +29,13 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 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 | |
| 32 | + project_content = create_project_content(@profile) | |
| 33 | + project_name = project_content.name | |
| 34 | + module_name = project_name | |
| 35 | + Kalibro::Client::ProjectResultClient.expects(:last_result).with(project_name).returns(@project_result) | |
| 36 | + Kalibro::Client::ModuleResultClient.expects(:module_result).with(project_content, module_name). | |
| 37 | + returns(@module_result) | |
| 38 | + get :metrics, :profile => @profile_id, :id => project_content.id, :module_name => module_name | |
| 37 | 39 | assert_response 200 |
| 38 | 40 | # assert_tag # TODO |
| 39 | 41 | end |
| ... | ... | @@ -42,18 +44,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 42 | 44 | |
| 43 | 45 | # returns a new ProjectContent for the given profile |
| 44 | 46 | def create_project_content(profile) |
| 45 | - Kalibro::Client::ProjectClient.expects(:save).with(@project) | |
| 46 | - Kalibro::Client::KalibroClient.expects(:process_project).with(@project.name) | |
| 47 | - | |
| 48 | 47 | 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 | |
| 48 | + Kalibro::Client::ProjectClient.expects(:save).with(project_content) | |
| 49 | + Kalibro::Client::KalibroClient.expects(:process_project).with(project_content.name) | |
| 54 | 50 | project_content.save |
| 55 | 51 | |
| 56 | - MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) | |
| 52 | +# MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) | |
| 57 | 53 | project_content |
| 58 | 54 | end |
| 59 | 55 | ... | ... |