Commit f4aecdffad6d0850164e1dcf71a56e9abb802c36
1 parent
a947b109
Exists in
master
and in
29 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,11 +24,7 @@ class MezuroPluginProfileController < ProfileController | ||
24 | 24 | ||
25 | def module_result | 25 | def module_result |
26 | content = profile.articles.find(params[:id]) | 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 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} | 28 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} |
33 | end | 29 | end |
34 | 30 |
plugins/mezuro/lib/kalibro/entities/entity.rb
@@ -7,7 +7,7 @@ class Kalibro::Entities::Entity | @@ -7,7 +7,7 @@ class Kalibro::Entities::Entity | ||
7 | end | 7 | end |
8 | 8 | ||
9 | def set(field, value) | 9 | def set(field, value) |
10 | - send("#{field}=", value) | 10 | + send("#{field}=", value) if not field.to_s.start_with? '@' |
11 | end | 11 | end |
12 | 12 | ||
13 | def to_entity_array(value, entity_class = nil) | 13 | def to_entity_array(value, entity_class = nil) |
@@ -50,4 +50,4 @@ class Kalibro::Entities::Entity | @@ -50,4 +50,4 @@ class Kalibro::Entities::Entity | ||
50 | send("#{field}") | 50 | send("#{field}") |
51 | end | 51 | end |
52 | 52 | ||
53 | -end | ||
54 | \ No newline at end of file | 53 | \ No newline at end of file |
54 | +end |
plugins/mezuro/lib/kalibro/entities/native_metric.rb
@@ -2,4 +2,4 @@ class Kalibro::Entities::NativeMetric < Kalibro::Entities::Metric | @@ -2,4 +2,4 @@ class Kalibro::Entities::NativeMetric < Kalibro::Entities::Metric | ||
2 | 2 | ||
3 | attr_accessor :origin, :language | 3 | attr_accessor :origin, :language |
4 | 4 | ||
5 | -end | ||
6 | \ No newline at end of file | 5 | \ No newline at end of file |
6 | +end |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
@@ -26,6 +26,7 @@ class MezuroPlugin::ProjectContent < Article | @@ -26,6 +26,7 @@ class MezuroPlugin::ProjectContent < Article | ||
26 | end | 26 | end |
27 | 27 | ||
28 | def module_result(module_name) | 28 | def module_result(module_name) |
29 | + module_name = project.name if module_name.nil? | ||
29 | @module_client ||= Kalibro::Client::ModuleResultClient.module_result(self, module_name) | 30 | @module_client ||= Kalibro::Client::ModuleResultClient.module_result(self, module_name) |
30 | end | 31 | end |
31 | 32 |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
@@ -50,6 +50,20 @@ class ProjectContentTest < ActiveSupport::TestCase | @@ -50,6 +50,20 @@ class ProjectContentTest < ActiveSupport::TestCase | ||
50 | assert_equal module_result, @content.module_result(module_name) | 50 | assert_equal module_result, @content.module_result(module_name) |
51 | end | 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 | should 'send project to service after saving' do | 67 | should 'send project to service after saving' do |
54 | @content.expects :send_project_to_service | 68 | @content.expects :send_project_to_service |
55 | @content.run_callbacks :after_save | 69 | @content.run_callbacks :after_save |