Commit b7adb7d62174d1a1394f28548bd43c9e97de4b07
Committed by
Paulo Meireles
1 parent
4dc81614
Exists in
master
and in
28 other branches
[Mezuro] fixed mocks on refactored tests
Showing
2 changed files
with
21 additions
and
4 deletions
Show diff stats
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
| @@ -72,9 +72,13 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -72,9 +72,13 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 72 | 72 | ||
| 73 | should 'get module result without date' do | 73 | should 'get module result without date' do |
| 74 | date_with_milliseconds = Kalibro::ProjectResult.date_with_milliseconds(@project_result.date) | 74 | date_with_milliseconds = Kalibro::ProjectResult.date_with_milliseconds(@project_result.date) |
| 75 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | ||
| 76 | - Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_module_result, {:project_name => @project.name, :module_name => @project.name, :date => date_with_milliseconds}).returns({:module_result => @module_result.to_hash}) | ||
| 77 | - get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name, :date => nil | 75 | + Kalibro::ProjectResult.expects(:request). |
| 76 | + with("ProjectResult", :get_last_result_of, {:project_name => @project.name}). | ||
| 77 | + returns({:project_result => @project_result.to_hash}) | ||
| 78 | + Kalibro::ModuleResult.expects(:request). | ||
| 79 | + with("ModuleResult", :get_module_result, {:project_name => @project.name, :module_name => @project.name, :date => date_with_milliseconds}). | ||
| 80 | + returns({:module_result => @module_result.to_hash}) | ||
| 81 | + get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | ||
| 78 | assert_equal @content, assigns(:content) | 82 | assert_equal @content, assigns(:content) |
| 79 | assert_equal @module_result.grade, assigns(:module_result).grade | 83 | assert_equal @module_result.grade, assigns(:module_result).grade |
| 80 | assert_response 200 | 84 | assert_response 200 |
| @@ -96,6 +100,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -96,6 +100,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 96 | 100 | ||
| 97 | should 'test project tree without date' do | 101 | should 'test project tree without date' do |
| 98 | Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | 102 | Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) |
| 103 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | ||
| 99 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | 104 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil |
| 100 | assert_equal @content, assigns(:content) | 105 | assert_equal @content, assigns(:content) |
| 101 | assert_equal @project.name, assigns(:project_name) | 106 | assert_equal @project.name, assigns(:project_name) |
| @@ -106,6 +111,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -106,6 +111,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 106 | 111 | ||
| 107 | should 'test project tree with a specific date' do | 112 | should 'test project tree with a specific date' do |
| 108 | request_body = {:project_name => @project.name, :date => @project_result.date} | 113 | request_body = {:project_name => @project.name, :date => @project_result.date} |
| 114 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | ||
| 109 | Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | 115 | Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) |
| 110 | Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | 116 | Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) |
| 111 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date | 117 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date |
plugins/mezuro/test/unit/kalibro/project_test.rb
| @@ -57,7 +57,18 @@ class ProjectTest < ActiveSupport::TestCase | @@ -57,7 +57,18 @@ class ProjectTest < ActiveSupport::TestCase | ||
| 57 | end | 57 | end |
| 58 | 58 | ||
| 59 | should 'create project' do | 59 | should 'create project' do |
| 60 | - assert Kalibro::Project.create @project_content | 60 | + project_hash = Kalibro::Project.new({ |
| 61 | + :name => @project_content.name, | ||
| 62 | + :license => @project_content.license, | ||
| 63 | + :description => @project_content.description, | ||
| 64 | + :repository => { | ||
| 65 | + :type => @project_content.repository_type, | ||
| 66 | + :address => @project_content.repository_url | ||
| 67 | + }, | ||
| 68 | + :configuration_name => @project_content.configuration_name | ||
| 69 | + }).to_hash | ||
| 70 | + Kalibro::Project.expects(:request).with("Project", :save_project, {:project => project_hash}) | ||
| 71 | + Kalibro::Project.create @project_content | ||
| 61 | end | 72 | end |
| 62 | 73 | ||
| 63 | should 'convert project to hash' do | 74 | should 'convert project to hash' do |