Commit f4aecdffad6d0850164e1dcf71a56e9abb802c36
1 parent
a947b109
Exists in
staging
and in
42 other branches
[Mezuro] Refactored module_result from project_content
Showing
5 changed files
with
19 additions
and
8 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
| ... | ... | @@ -24,11 +24,7 @@ class MezuroPluginProfileController < ProfileController |
| 24 | 24 | |
| 25 | 25 | def module_result |
| 26 | 26 | content = profile.articles.find(params[:id]) |
| 27 | - if params[:module_name].nil? or params[:module_name] == content.project.name | |
| 28 | - module_result = content.module_result(content.project.name) | |
| 29 | - else | |
| 30 | - module_result = content.module_result(params[:module_name]) | |
| 31 | - end | |
| 27 | + module_result = content.module_result(params[:module_name]) | |
| 32 | 28 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} |
| 33 | 29 | end |
| 34 | 30 | ... | ... |
plugins/mezuro/lib/kalibro/entities/entity.rb
| ... | ... | @@ -7,7 +7,7 @@ class Kalibro::Entities::Entity |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | def set(field, value) |
| 10 | - send("#{field}=", value) | |
| 10 | + send("#{field}=", value) if not field.to_s.start_with? '@' | |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | def to_entity_array(value, entity_class = nil) |
| ... | ... | @@ -50,4 +50,4 @@ class Kalibro::Entities::Entity |
| 50 | 50 | send("#{field}") |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | -end | |
| 54 | 53 | \ No newline at end of file |
| 54 | +end | ... | ... |
plugins/mezuro/lib/kalibro/entities/native_metric.rb
plugins/mezuro/lib/mezuro_plugin/project_content.rb
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
| ... | ... | @@ -50,6 +50,20 @@ class ProjectContentTest < ActiveSupport::TestCase |
| 50 | 50 | assert_equal module_result, @content.module_result(module_name) |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | + should 'get module result root when nil is given' do | |
| 54 | + module_result = mock | |
| 55 | + Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @project.name). | |
| 56 | + returns(module_result) | |
| 57 | + assert_equal module_result, @content.module_result(nil) | |
| 58 | + end | |
| 59 | + | |
| 60 | + should 'get module result root when project name is give' do | |
| 61 | + module_result = mock | |
| 62 | + Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @project.name). | |
| 63 | + returns(module_result) | |
| 64 | + assert_equal module_result, @content.module_result(@project.name) | |
| 65 | + end | |
| 66 | + | |
| 53 | 67 | should 'send project to service after saving' do |
| 54 | 68 | @content.expects :send_project_to_service |
| 55 | 69 | @content.run_callbacks :after_save | ... | ... |