Commit cde2390306f8752b1a32634afe7d04a2e39dea7a
Committed by
Paulo Meireles
1 parent
92ed6364
Exists in
master
and in
29 other branches
[Mezuro] Created test for project result with date
Showing
3 changed files
with
11 additions
and
4 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -16,7 +16,6 @@ class MezuroPluginProfileController < ProfileController |
16 | 16 | end |
17 | 17 | |
18 | 18 | def project_result |
19 | - | |
20 | 19 | content = profile.articles.find(params[:id]) |
21 | 20 | date = params[:date] |
22 | 21 | project_result = date.nil? ? content.project_result : content.get_date_result(date) | ... | ... |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
... | ... | @@ -30,8 +30,8 @@ class MezuroPlugin::ProjectContent < Article |
30 | 30 | end |
31 | 31 | |
32 | 32 | def get_date_result(date) |
33 | -#client = Kalibro::Client::ProjectResultClient.new | |
34 | - @project_result ||= Kalibro::Client::ProjectResultClient.has_results_before(name, date) ? Kalibro::Client::ProjectResultClient.last_result_before(name, date) : Kalibro::Client::ProjectResultClient.first_result_after(name, date) | |
33 | + client = Kalibro::Client::ProjectResultClient.new | |
34 | + @project_result ||= client.has_results_before(name, date) ? client.last_result_before(name, date) : client.first_result_after(name, date) | |
35 | 35 | end |
36 | 36 | |
37 | 37 | def module_result(module_name) | ... | ... |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
... | ... | @@ -68,7 +68,15 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
68 | 68 | assert_select('h4', 'Last Result') |
69 | 69 | end |
70 | 70 | |
71 | - should 'get project results from a specific date' | |
71 | + should 'get project results from a specific date' do | |
72 | + create_project_content | |
73 | + client = mock | |
74 | + Kalibro::Client::ProjectResultClient.expects(:new).returns(client) | |
75 | + client.expects(:has_results_before).returns(true) | |
76 | + client.expects(:last_result_before).returns(@project_result) | |
77 | + get :project_result, :profile => @profile.identifier, :id => @content.id, :date => "2012-04-13T20:39:41+04:00" | |
78 | + assert_response 200 | |
79 | + end | |
72 | 80 | |
73 | 81 | should 'get module result' do |
74 | 82 | create_project_content | ... | ... |