Commit cb5511ae524a0190a604400741946d82a0861222

Authored by João M. M. da Silva
2 parents e498c21b afcd974d

Merge branch 'refactoring_js' into refactoring

Showing 56 changed files with 435 additions and 258 deletions   Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb
... ... @@ -7,7 +7,7 @@ class MezuroPluginModuleResultController < MezuroPluginProfileController
7 7 @metric_results = Kalibro::MetricResult.metric_results_of(@module_result.id)
8 8 render :partial => 'module_result'
9 9 end
10   -
  10 +
11 11 def metric_result_history
12 12 @history = Kalibro::MetricResult.history_of(params[:metric_name], params[:module_result_id].to_i)
13 13 render :partial => 'score_history'
... ...
plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb
... ... @@ -2,20 +2,32 @@ class MezuroPluginProcessingController < MezuroPluginProfileController
2 2  
3 3 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4  
5   - def render_last_state
6   - last_state = Kalibro::Processing.last_processing_state_of(params[:repository_id].to_i)
7   - render :text => last_state
  5 + def state
  6 + processing = processing_for_date(params[:repository_id].to_i, params[:date])
  7 + if processing.error.nil?
  8 + render :text => processing.state
  9 + else
  10 + render :text => 'ERROR'
  11 + end
8 12 end
9 13  
10 14 def processing
11   - date = params[:date]
12   - repository_id = params[:repository_id].to_i
13   - processing_class = Kalibro::Processing
14   - @processing = date.nil? ? processing_class.processing_of(repository_id) : processing_class.processing_with_date_of(repository_id, date)
15   - if @processing.state == 'ERROR'
  15 + @processing = processing_for_date(params[:repository_id].to_i, params[:date])
  16 + if @processing.error.nil?
  17 + render :partial => 'processing'
  18 + else
16 19 render :partial => 'processing_error'
  20 + end
  21 + end
  22 +
  23 + private
  24 +
  25 + def processing_for_date(repository_id, date = nil)
  26 + processing_class = Kalibro::Processing
  27 + if date.nil?
  28 + processing_class.processing_of(repository_id)
17 29 else
18   - render :partial => 'processing'
  30 + processing_class.processing_with_date_of(repository_id, date)
19 31 end
20 32 end
21 33  
... ...
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
... ... @@ -3,8 +3,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
3 3 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4  
5 5 def new
6   - @project_content = profile.articles.find(params[:id])
7   -
  6 + project_content = profile.articles.find(params[:id])
  7 + @project_name = project_content.name
  8 + @data_profile = project_content.profile.identifier
  9 + @project_content_id = project_content.id
  10 +
8 11 @repository_types = Kalibro::Repository.repository_types
9 12  
10 13 configurations = Kalibro::Configuration.all
... ... @@ -16,20 +19,24 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
16 19  
17 20 def create
18 21 project_content = profile.articles.find(params[:id])
19   -
  22 +
20 23 repository = Kalibro::Repository.new( params[:repository] )
21 24 repository.save(project_content.project_id)
22 25  
23 26 if( repository.errors.empty? )
24   - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
  27 + repository.process
  28 + redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}"
25 29 else
26 30 redirect_to_error_page repository.errors[0].message
27 31 end
28 32 end
29 33  
30 34 def edit
31   - @project_content = profile.articles.find(params[:id])
32   -
  35 + project_content = profile.articles.find(params[:id])
  36 + @project_name = project_content.name
  37 + @data_profile = project_content.profile.identifier
  38 + @project_content_id = project_content.id
  39 +
33 40 @repository_types = Kalibro::Repository.repository_types
34 41  
35 42 configurations = Kalibro::Configuration.all
... ... @@ -38,7 +45,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
38 45 [configuration.name,configuration.id]
39 46 end
40 47  
41   - @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
  48 + @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
42 49 end
43 50  
44 51 def update
... ... @@ -46,9 +53,10 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
46 53  
47 54 repository = Kalibro::Repository.new( params[:repository] )
48 55 repository.save(project_content.project_id)
49   -
  56 +
50 57 if( repository.errors.empty? )
51   - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
  58 + repository.process
  59 + redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}"
52 60 else
53 61 redirect_to_error_page repository.errors[0].message
54 62 end
... ...
plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb
... ... @@ -2,6 +2,10 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model
2 2  
3 3 attr_accessor :code, :weight, :aggregation_form, :metric, :base_tool_name, :range
4 4  
  5 + def weight=(value)
  6 + @weight = value.to_f
  7 + end
  8 +
5 9 def metric=(value)
6 10 if value.kind_of?(Hash)
7 11 @metric = Kalibro::Metric.to_object(value)
... ... @@ -11,11 +15,24 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model
11 15 end
12 16  
13 17 def range=(value)
14   - @range = Kalibro::RangeSnapshot.to_object value
  18 + value.to_a
  19 + @range = []
  20 +
  21 + value.each do |range_snapshot|
  22 + @range << Kalibro::RangeSnapshot.to_object(range_snapshot)
  23 + end
  24 +
15 25 end
16 26  
17 27 def range_snapshot
18 28 range
19 29 end
20 30  
  31 + def to_hash
  32 + hash = super
  33 + hash[:attributes!][:range] = {'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  34 + 'xsi:type' => 'kalibro:rangeSnapshotXml' }
  35 + hash
  36 + end
  37 +
21 38 end
... ...
plugins/mezuro/lib/kalibro/metric_result.rb
... ... @@ -2,8 +2,19 @@ class Kalibro::MetricResult &lt; Kalibro::Model
2 2  
3 3 attr_accessor :id, :configuration, :value, :error
4 4  
5   - def value=(value)
6   - @value = value.to_f
  5 + def initialize(attributes={})
  6 + value = attributes[:value]
  7 + @value = (value == "NaN") ? attributes[:aggregated_value].to_f : value.to_f
  8 + attributes.each do |field, value|
  9 + if field!= :value and field!= :aggregated_value and self.class.is_valid?(field)
  10 + send("#{field}=", value)
  11 + end
  12 + end
  13 + @errors = []
  14 + end
  15 +
  16 + def id=(value)
  17 + @id = value.to_i
7 18 end
8 19  
9 20 def configuration=(value)
... ... @@ -30,7 +41,7 @@ class Kalibro::MetricResult &lt; Kalibro::Model
30 41 end
31 42  
32 43 def self.history_of(metric_name, module_result_id)
33   - response = self.request(:history_of, {:metric_name => metric_name, :module_result_id => module_result_id})[:date_metric_result]
  44 + response = self.request(:history_of_metric, {:metric_name => metric_name, :module_result_id => module_result_id})[:date_metric_result]
34 45 response = [] if response.nil?
35 46 response = [response] if response.is_a?(Hash)
36 47 response.map {|date_metric_result| Kalibro::DateMetricResult.new date_metric_result}
... ...
plugins/mezuro/lib/kalibro/model.rb
... ... @@ -7,6 +7,7 @@ class Kalibro::Model
7 7 @errors = []
8 8 end
9 9  
  10 +
10 11 def to_hash(options={})
11 12 hash = Hash.new
12 13 excepts = options[:except].nil? ? [] : options[:except]
... ... @@ -15,7 +16,7 @@ class Kalibro::Model
15 16 if(!excepts.include?(field))
16 17 field_value = send(field)
17 18 if !field_value.nil?
18   - hash[field] = convert_to_hash(field_value)
  19 + hash[field] = convert_to_hash(field_value)
19 20 if field_value.is_a?(Kalibro::Model)
20 21 hash = {:attributes! => {}}.merge(hash)
21 22 hash[:attributes!][field.to_sym] = {
... ... @@ -91,7 +92,7 @@ class Kalibro::Model
91 92 return self.class.date_with_milliseconds(value) if value.is_a?(DateTime)
92 93 return 'INF' if value.is_a?(Float) and value.infinite? == 1
93 94 return '-INF' if value.is_a?(Float) and value.infinite? == -1
94   - value
  95 + value.to_s
95 96 end
96 97  
97 98 def xml_instance_class_name(object)
... ...
plugins/mezuro/lib/kalibro/module_result.rb
... ... @@ -22,6 +22,10 @@ class Kalibro::ModuleResult &lt; Kalibro::Model
22 22 end
23 23 end
24 24  
  25 + def id=(value)
  26 + @id = value.to_i
  27 + end
  28 +
25 29 def module=(value)
26 30 @module = Kalibro::Module.to_object value
27 31 end
... ... @@ -30,6 +34,10 @@ class Kalibro::ModuleResult &lt; Kalibro::Model
30 34 @grade = value.to_f
31 35 end
32 36  
  37 + def parent_id=(value)
  38 + @parent_id = value.to_i
  39 + end
  40 +
33 41 def self.history_of(module_result_id)
34 42 response = self.request(:history_of_module, {:module_result_id => module_result_id})[:date_module_result]
35 43 response = [] if response.nil?
... ...
plugins/mezuro/lib/kalibro/process_time.rb
... ... @@ -2,4 +2,8 @@ class Kalibro::ProcessTime &lt; Kalibro::Model
2 2  
3 3 attr_accessor :state, :time
4 4  
  5 + def time=(time)
  6 + @time = time.to_i
  7 + end
  8 +
5 9 end
... ...
plugins/mezuro/lib/kalibro/processing.rb
1   -#TODO arrumar esse modelo e seus testes de unidade
2 1 class Kalibro::Processing < Kalibro::Model
3 2  
4 3 attr_accessor :id, :date, :state, :error, :process_time, :results_root_id
... ... @@ -12,6 +11,7 @@ class Kalibro::Processing &lt; Kalibro::Model
12 11 end
13 12  
14 13 def self.processing_with_date_of(repository_id, date)
  14 + date = date.is_a?(String) ? DateTime.parse(date) : date
15 15 if has_processing_after(repository_id, date)
16 16 first_processing_after(repository_id, date)
17 17 elsif has_processing_before(repository_id, date)
... ... @@ -21,6 +21,10 @@ class Kalibro::Processing &lt; Kalibro::Model
21 21 end
22 22 end
23 23  
  24 + def id=(value)
  25 + @id = value.to_i
  26 + end
  27 +
24 28 def date=(value)
25 29 @date = value.is_a?(String) ? DateTime.parse(value) : value
26 30 end
... ... @@ -41,6 +45,10 @@ class Kalibro::Processing &lt; Kalibro::Model
41 45 @error = Kalibro::Throwable.to_object value
42 46 end
43 47  
  48 + def results_root_id=(value)
  49 + @results_root_id = value.to_i
  50 + end
  51 +
44 52 private
45 53  
46 54 def self.has_processing(repository_id)
... ...
plugins/mezuro/lib/kalibro/project.rb
... ... @@ -2,6 +2,10 @@ class Kalibro::Project &lt; Kalibro::Model
2 2  
3 3 attr_accessor :id, :name, :description
4 4  
  5 + def id=(value)
  6 + @id = value.to_i
  7 + end
  8 +
5 9 def self.all
6 10 response = request(:all_projects)[:project]
7 11 response = [] if response.nil?
... ...
plugins/mezuro/lib/kalibro/range_snapshot.rb
1 1 class Kalibro::RangeSnapshot < Kalibro::Model
2 2  
3   - attr_accessor :end, :label, :grade, :color, :comments
  3 + attr_accessor :beginning, :end, :label, :grade, :color, :comments
  4 +
  5 + def beginning=(value)
  6 + @beginning = ((value == "-INF") ? -1.0/0 : value.to_f)
  7 + end
  8 +
  9 + def end=(value)
  10 + @end = ((value == "INF") ? 1.0/0 : value.to_f)
  11 + end
  12 +
  13 + def grade=(value)
  14 + @grade = value.to_f
  15 + end
4 16  
5 17 end
... ...
plugins/mezuro/lib/kalibro/repository.rb
... ... @@ -17,7 +17,19 @@ class Kalibro::Repository &lt; Kalibro::Model
17 17 response.map {|repository| new repository}
18 18 end
19 19  
20   - def process_repository
  20 + def id=(value)
  21 + @id = value.to_i
  22 + end
  23 +
  24 + def process_period=(value)
  25 + @process_period = value.to_i
  26 + end
  27 +
  28 + def configuration_id=(value)
  29 + @configuration_id = value.to_i
  30 + end
  31 +
  32 + def process
21 33 self.class.request(:process_repository, {:repository_id => self.id})
22 34 end
23 35  
... ... @@ -28,7 +40,6 @@ class Kalibro::Repository &lt; Kalibro::Model
28 40 def save(project_id)
29 41 begin
30 42 self.id = self.class.request(:save_repository, {:repository => self.to_hash, :project_id => project_id})[:repository_id]
31   - process_repository
32 43 true
33 44 rescue Exception => exception
34 45 add_error exception
... ...
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
... ... @@ -7,7 +7,7 @@ class MezuroPlugin::Helpers::ContentViewerHelper
7 7 end
8 8  
9 9 def self.periodicity_options
10   - [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]]
  10 + [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweekly", 15], ["Monthly", 30]]
11 11 end
12 12  
13 13 def self.periodicity_option(periodicity)
... ... @@ -43,10 +43,14 @@ class MezuroPlugin::Helpers::ContentViewerHelper
43 43 )
44 44 end
45 45  
46   -
47 46 def self.format_name(metric_configuration_snapshot)
48 47 metric_configuration_snapshot.metric.name.delete("() ")
49 48 end
  49 +
  50 + def self.format_time(miliseconds)
  51 + seconds = miliseconds/1000
  52 + MezuroPluginModuleResultController.helpers.distance_of_time_in_words(0, seconds, include_seconds = true)
  53 + end
50 54  
51 55 private
52 56  
... ...
plugins/mezuro/lib/mezuro_plugin/helpers/module_result_helper.rb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +class MezuroPlugin::Helpers::ModuleResultHelper
  2 +
  3 + def self.module_name name
  4 + name.is_a?(Array) ? name.last : name
  5 + end
  6 +
  7 +end
... ...
plugins/mezuro/lib/mezuro_plugin/project_content.rb
... ... @@ -83,7 +83,6 @@ class MezuroPlugin::ProjectContent &lt; Article
83 83  
84 84 def create_kalibro_project
85 85 Kalibro::Project.create(
86   - :id => project_id,
87 86 :name => name,
88 87 :description => description
89 88 )
... ...
plugins/mezuro/public/javascripts/processing.js
... ... @@ -2,41 +2,39 @@ var processingTree = false;
2 2 var metricName;
3 3 jQuery(function (){
4 4 jQuery('.source-tree-link').live("click", reloadModule);
5   - jQuery('[show-metric-history]').live("click", display_metric_history); //TODO review for project history
6   - jQuery('[show-grade-history]').live("click", display_grade_history); //TODO review for project history
7   - jQuery('#project_date_submit').live("click", reloadProjectWithDate); //TODO review for project history
  5 + jQuery('[show-metric-history]').live("click", display_metric_history);
  6 + jQuery('[show-grade-history]').live("click", display_grade_history);
  7 + jQuery('#project_date_submit').live("click", reloadProcessingWithDate);
8 8 showLoadingProcess(true);
9 9 showProcessing();
10 10 });
11 11  
12 12 function showProcessing() {
13   - callAction('processing', 'processing', {}, showProcessingFor);
  13 + repository_id = processingData('repository-id');
  14 + callAction('processing', 'state', {repository_id: repository_id}, showProcessingFor);
14 15 }
15 16  
16   -//TODO review for project history
17 17 function display_metric_history() {
18   - var module_name = jQuery(this).attr('data-module-name');
19   - var metric_name = jQuery(this).attr('show-metric-history');
20   - toggle_mezuro("." + metric_name);
21   - metricName = metric_name;
  18 + var module_result_id = jQuery(this).attr('data-module-id');
  19 + var formatted_name = jQuery(this).attr('show-metric-history');
  20 + var metric_name = jQuery(this).attr('data-metric-name');
  21 + toggle_mezuro("." + formatted_name);
  22 + metricName = formatted_name;
22 23 callAction('module_result', 'metric_result_history', {metric_name: metric_name, module_result_id: module_result_id}, show_metrics);
23 24 return false;
24 25 }
25 26  
26   -//TODO review for project history
27 27 function display_grade_history() {
28   - var module_name = jQuery(this).attr('data-module-name');
  28 + var module_result_id = jQuery(this).attr('data-module-id');
29 29 toggle_mezuro("#historical-grade");
30 30 callAction('module_result', 'module_result_history', {module_result_id: module_result_id}, show_grades);
31 31 return false;
32 32 }
33 33  
34   -//TODO review for project history
35 34 function show_metrics(content) {
36 35 jQuery('#historical-' + metricName).html(content);
37 36 }
38 37  
39   -//TODO review for project history
40 38 function show_grades(content) {
41 39 jQuery('#historical-grade').html(content);
42 40 }
... ... @@ -46,93 +44,85 @@ function toggle_mezuro(element){
46 44 return false;
47 45 }
48 46  
49   -//TODO Waiting for ModuleResultController refactoring
50 47 function reloadModule(){
51   - var results_root_id = jQuery(this).attr('results_root_id');
  48 + var module_result_id = jQuery(this).attr('data-module-id');
52 49 showLoadingProcess(false);
53 50 processingTree = true;
54   -// callAction('module_result', 'project_tree', {results_root_id: results_root_id }, showProjectTree);
55   - callAction('module_result', 'module_result', {results_root_id: results_root_id}, showModuleResult);
  51 + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult);
56 52 return false;
57 53 }
58 54  
59   -//TODO review for project history
60   -function reloadProjectWithDate(date){
61   - reloadProject(date + "T00:00:00+00:00");
  55 +function reloadProcessingWithDate(date){
  56 + reloadProcessing(date + "T00:00:00+00:00");
62 57 return false;
63 58 }
64 59  
65   -//TODO review for project history
66   -function reloadProject(date){
  60 +function reloadProcessing(date){
  61 + repository_id = processingData('repository-id');
67 62 showLoadingProcess(true);
68   -
69   - callAction('processing', 'processing', {date: date}, showProjectResult);
70   -// callAction('module_result', 'project_tree', {date: date}, showProjectTree);
71   - callAction('module_result', 'module_result', {date: date}, showModuleResult);
  63 +
  64 + callAction('processing', 'processing', {date: date, repository_id: repository_id}, function(content){
  65 + showReadyProcessing(content);
  66 + var module_result_id = jQuery("#module_result_root_id").attr('module_result_root_id');
  67 + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult);
  68 + }
  69 + );
72 70 }
73 71  
74 72 function showProcessingFor(state){
  73 + repository_id = processingData('repository-id');
75 74 if (state == 'ERROR') {
76   - jQuery('#project-state').html('<div style="color:Red">ERROR</div>');
77   - callAction('processing', 'processing_error', {}, showProcessing);
  75 + jQuery('#processing-state').html('<div style="color:Red">ERROR</div>');
  76 + callAction('processing', 'processing', {repository_id: repository_id}, showReadyProcessing);
  77 + showModuleResult('');
78 78 }
79 79 else if (state == 'READY') {
80 80 jQuery('#msg-time').html('');
81 81 jQuery('#processing-state').html('<div style="color:Green">READY</div>');
82   - callAction('processing', 'processing', {}, showProcessing);
83   -// callAction('processing','project_tree', {}, showProjectTree);
84   - //var module_result_id = jQuery("#processing").attr('results_root_id'); //TODO Waiting for ModuleResultController refactoring
85   - callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); //TODO Waiting for ModuleResultController refactoring
86   - }
  82 + callAction('processing', 'processing', {repository_id: repository_id}, function(content){
  83 + showReadyProcessing(content);
  84 + var module_result_id = jQuery("#module_result_root_id").attr('module_result_root_id');
  85 + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult);
  86 + }
  87 + );
  88 + }
87 89 else if (state.endsWith("ING")) {
88 90 jQuery('#processing-state').html('<div style="color:DarkGoldenRod">'+ state +'</div>');
89 91 jQuery('#msg-time').html("The project analysis may take long. <br/> You'll receive an e-mail when it's ready!");
90   - showProjectContentAfter(20);
91   - }
  92 + showProcessingAfter(20);
  93 + }
92 94 }
93 95  
94   -function showProjectContentAfter(seconds){
  96 +function showProcessingAfter(seconds){
95 97 if (seconds > 0){
96   - setTimeout(function() { showProjectContentAfter(seconds - 10);}, 10000);
  98 + setTimeout(function() { showProcessingAfter(seconds - 10);}, 10000);
97 99 } else {
98   - showProjectContent();
  100 + showProcessing();
99 101 }
100 102 }
101 103  
102   -function showProjectResult(content) {
  104 +function showReadyProcessing(content) {
103 105 jQuery('#processing').html(content);
104 106 }
105 107  
106   -//function showProjectTree(content){
107   -// processingTree = false;
108   -// jQuery('#project-tree').html(content);
109   -// return false;
110   -//}
111   -
112   -//TODO Waiting for ModuleResultController refactoring
113 108 function showModuleResult(content){
114   -// if (processingTree != true){
115 109 jQuery('#module-result').html(content);
116   -// }
117   -// return false;
118 110 }
119 111  
120 112 function callAction(controller, action, params, callback){
121   - var profile = projectContentData('profile');
122   - var content = projectContentData('content');
  113 + var profile = processingData('profile');
  114 + var content = processingData('content');
123 115 var endpoint = '/profile/' + profile + '/plugin/mezuro/' + controller + '/' + action + '/' + content;
124 116 jQuery.get(endpoint, params, callback);
125 117 }
126 118  
127   -function projectContentData(data){
  119 +function processingData(data){
128 120 return jQuery('#processing').attr('data-' + data);
129 121 }
130 122  
131 123 function showLoadingProcess(firstLoad){
132   - if(firstLoad)
133   - showProjectResult("<img src='/images/loading-small.gif'/>");
134   -
135   - showProjectTree("<img src='/images/loading-small.gif'/>");
  124 + if(firstLoad)
  125 + showReadyProcessing("<img src='/images/loading-small.gif'/>");
136 126 showModuleResult("<img src='/images/loading-small.gif'/>");
137 127 }
138 128  
... ...
plugins/mezuro/test/fixtures/configuration_fixtures.rb
... ... @@ -15,7 +15,7 @@ class ConfigurationFixtures
15 15  
16 16 def self.configuration_hash
17 17 {
18   - :id => 42,
  18 + :id => "42",
19 19 :name => 'Sample Configuration',
20 20 :description => 'Kalibro configuration for Java projects.'
21 21 }
... ...
plugins/mezuro/test/fixtures/date_metric_result_fixtures.rb
... ... @@ -21,4 +21,13 @@ class DateMetricResultFixtures
21 21 }
22 22 end
23 23  
  24 + def self.score_history
  25 + result = []
  26 + result << date_metric_result
  27 + newer_date_metric_result = date_metric_result
  28 + newer_date_metric_result.date = '2011-10-25T18:26:43.151+00:00'
  29 + newer_date_metric_result.metric_result.value = 5.0
  30 + result << newer_date_metric_result
  31 + end
  32 +
24 33 end
... ...
plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb
... ... @@ -4,13 +4,13 @@ class MetricConfigurationFixtures
4 4  
5 5 def self.amloc_metric_configuration
6 6 amloc = Kalibro::MetricConfiguration.new amloc_metric_configuration_hash
7   - amloc.configuration_id = 13
  7 + amloc.configuration_id = "13"
8 8 amloc
9 9 end
10 10  
11 11 def self.sc_metric_configuration
12 12 sc = Kalibro::MetricConfiguration.new sc_metric_configuration_hash
13   - sc.configuration_id = 13
  13 + sc.configuration_id = "13"
14 14 sc
15 15 end
16 16  
... ... @@ -19,22 +19,22 @@ class MetricConfigurationFixtures
19 19 :code => 'amloc',
20 20 :metric => MetricFixtures.amloc_hash,
21 21 :base_tool_name => MetricFixtures.amloc_hash[:origin],
22   - :weight => 1.0,
  22 + :weight => "1.0",
23 23 :aggregation_form => 'AVERAGE',
24   - :reading_group_id => 31,
25   - :configuration_id => 13
  24 + :reading_group_id => "31",
  25 + :configuration_id => "13"
26 26 })
27 27 end
28 28  
29 29 def self.amloc_metric_configuration_hash
30 30 {
31   - :id => 42,
  31 + :id => "42",
32 32 :code => 'amloc',
33 33 :metric => MetricFixtures.amloc_hash,
34 34 :base_tool_name => MetricFixtures.amloc_hash[:origin],
35   - :weight => 1.0,
  35 + :weight => "1.0",
36 36 :aggregation_form => 'AVERAGE',
37   - :reading_group_id => 31,
  37 + :reading_group_id => "31",
38 38 :attributes! => {:metric => {
39 39 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
40 40 'xsi:type' => 'kalibro:metricXml' }}
... ... @@ -43,12 +43,12 @@ class MetricConfigurationFixtures
43 43  
44 44 def self.sc_metric_configuration_hash
45 45 {
46   - :id => 42,
  46 + :id => "42",
47 47 :code => 'sc',
48 48 :metric => MetricFixtures.compound_metric_hash,
49   - :weight => 1.0,
  49 + :weight => "1.0",
50 50 :aggregation_form => 'AVERAGE',
51   - :reading_group_id => 31,
  51 + :reading_group_id => "31",
52 52 :attributes! => {:metric => {
53 53 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
54 54 'xsi:type' => 'kalibro:metricXml' }}
... ...
plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb
... ... @@ -10,11 +10,11 @@ class MetricConfigurationSnapshotFixtures
10 10 def self.metric_configuration_snapshot_hash
11 11 {
12 12 :code => "code",
13   - :weight => 1,
  13 + :weight => "1.0",
14 14 :aggregation_form => 'AVERAGE',
15 15 :metric => MetricFixtures.amloc_hash,
16 16 :base_tool_name => "Analizo",
17   - :range => RangeSnapshotFixtures.range_snapshot_hash,
  17 + :range => [RangeSnapshotFixtures.range_snapshot_hash],
18 18 :attributes! => {
19 19 :metric => {
20 20 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
... ... @@ -26,6 +26,16 @@ class MetricConfigurationSnapshotFixtures
26 26 }
27 27 end
28 28  
  29 + def self.metric_configuration_snapshot_with_2_elements
  30 + Kalibro::MetricConfigurationSnapshot.new metric_configuration_snapshot_hash_with_2_elements
  31 + end
  32 +
  33 + def self.metric_configuration_snapshot_hash_with_2_elements
  34 + hash = self.metric_configuration_snapshot_hash
  35 + hash[:range] << RangeSnapshotFixtures.range_snapshot_hash
  36 + hash
  37 + end
  38 +
29 39 def self.compound_metric_configuration_snapshot
30 40 Kalibro::MetricConfigurationSnapshot.new compound_metric_configuration_snapshot_hash
31 41 end
... ... @@ -33,11 +43,11 @@ class MetricConfigurationSnapshotFixtures
33 43 def self.compound_metric_configuration_snapshot_hash
34 44 {
35 45 :code => "code",
36   - :weight => 1,
  46 + :weight => "1.0",
37 47 :aggregation_form => 'AVERAGE',
38 48 :metric => MetricFixtures.compound_metric,
39 49 :base_tool_name => "Analizo",
40   - :range => RangeSnapshotFixtures.range_snapshot_hash,
  50 + :range => [RangeSnapshotFixtures.range_snapshot_hash],
41 51 :attributes! => {
42 52 :metric => {
43 53 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
... ...
plugins/mezuro/test/fixtures/metric_fixtures.rb
... ... @@ -5,7 +5,7 @@ class MetricFixtures
5 5 end
6 6  
7 7 def self.compound_metric_hash
8   - {:name => 'Structural Complexity', :compound => true, :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'}
  8 + {:name => 'Structural Complexity', :compound => "true", :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'}
9 9 end
10 10  
11 11 def self.total_cof
... ... @@ -13,7 +13,7 @@ class MetricFixtures
13 13 end
14 14  
15 15 def self.total_cof_hash
16   - {:name => 'Total Coupling Factor', :compound => false, :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']}
  16 + {:name => 'Total Coupling Factor', :compound => "false", :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']}
17 17 end
18 18  
19 19 def self.amloc
... ... @@ -21,7 +21,7 @@ class MetricFixtures
21 21 end
22 22  
23 23 def self.amloc_hash
24   - {:name => 'Average Method LOC', :compound => false, :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']}
  24 + {:name => 'Average Method LOC', :compound => "false", :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']}
25 25 end
26 26  
27 27 end
... ...
plugins/mezuro/test/fixtures/metric_result_fixtures.rb
... ... @@ -13,7 +13,7 @@ class MetricResultFixtures
13 13  
14 14 def self.metric_result_with_error_hash
15 15 {
16   - :id => 41,
  16 + :id => "41",
17 17 :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash,
18 18 :error => ThrowableFixtures.throwable_hash
19 19 }
... ... @@ -21,9 +21,9 @@ class MetricResultFixtures
21 21  
22 22 def self.native_metric_result_hash
23 23 {
24   - :id => 42,
  24 + :id => "42",
25 25 :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash,
26   - :value => 0.0,
  26 + :value => "0.0",
27 27 :attributes! =>
28 28 {
29 29 :configuration =>
... ... @@ -37,9 +37,9 @@ class MetricResultFixtures
37 37  
38 38 def self.compound_metric_result_hash
39 39 {
40   - :id => 43,
  40 + :id => "43",
41 41 :configuration => MetricConfigurationSnapshotFixtures.compound_metric_configuration_snapshot_hash,
42   - :value => 1.0,
  42 + :value => "1.0",
43 43 :attributes! =>
44 44 {
45 45 :configuration =>
... ...
plugins/mezuro/test/fixtures/module_result_fixtures.rb
... ... @@ -8,10 +8,10 @@ class ModuleResultFixtures
8 8  
9 9 def self.module_result_hash
10 10 {
11   - :id => 42,
  11 + :id => "42",
12 12 :module => ModuleFixtures.module_hash,
13   - :grade => 10.0,
14   - :parent_id => 31,
  13 + :grade => "10.0",
  14 + :parent_id => "31",
15 15 :attributes! =>
16 16 {
17 17 :module =>
... ... @@ -25,12 +25,12 @@ class ModuleResultFixtures
25 25  
26 26 def self.parent_module_result_hash
27 27 {
28   - :id => 31,
  28 + :id => "31",
29 29 :module => {
30 30 :name => 'Qt-Calculator Parent',
31 31 :granularity => 'APPLICATION'
32 32 },
33   - :grade => 10.0,
  33 + :grade => "10.0",
34 34 :attributes! =>
35 35 {
36 36 :module =>
... ...
plugins/mezuro/test/fixtures/process_time_fixtures.rb
... ... @@ -5,7 +5,7 @@ class ProcessTimeFixtures
5 5 end
6 6  
7 7 def self.process_time_hash
8   - {:state => "Ready", :time => 1}
  8 + {:state => "Ready", :time => "1"}
9 9 end
10 10  
11 11 end
... ...
plugins/mezuro/test/fixtures/processing_fixtures.rb
... ... @@ -9,17 +9,17 @@ class ProcessingFixtures
9 9  
10 10 def self.processing_hash
11 11 {
12   - :id => 31,
  12 + :id => "31",
13 13 :date => '2011-10-20T18:26:43.151+00:00',
14 14 :state => 'READY',
15 15 :process_time => [ProcessTimeFixtures.process_time_hash],
16   - :results_root_id => 13
  16 + :results_root_id => "13"
17 17 }
18 18 end
19 19  
20 20 def self.processing_with_error_hash
21 21 {
22   - :id => 31,
  22 + :id => "31",
23 23 :date => '2011-10-20T18:26:43.151+00:00',
24 24 :state => 'ERROR',
25 25 :process_time => [ProcessTimeFixtures.process_time_hash],
... ...
plugins/mezuro/test/fixtures/project_content_fixtures.rb
... ... @@ -3,14 +3,7 @@ class ProjectContentFixtures
3 3 def self.project_content
4 4 content = MezuroPlugin::ProjectContent.new
5 5 content.project_id = 42
6   - #content.name = 'Qt-Calculator'
7   - #content.project_license = 'GPL'
8   - #content.description = 'Calculator for Qt'
9   - #content.repository_type = [RepositoryFixtures.repository_hash[:type]]
10   - #content.repository_url = [RepositoryFixtures.repository_hash[:address]]
11   - #content.configuration_name = 'Kalibro for Java'
12   - #content.periodicity_in_days = 1
13 6 content
14 7 end
15 8  
16   -end
17 9 \ No newline at end of file
  10 +end
... ...
plugins/mezuro/test/fixtures/project_fixtures.rb
... ... @@ -12,7 +12,7 @@ class ProjectFixtures
12 12  
13 13 def self.project_hash
14 14 {
15   - :id => 42,
  15 + :id => "42",
16 16 :name => 'Qt-Calculator',
17 17 :description => 'Calculator for Qt'
18 18 }
... ...
plugins/mezuro/test/fixtures/range_fixtures.rb
... ... @@ -5,11 +5,11 @@ class RangeFixtures
5 5 end
6 6  
7 7 def self.created_range
8   - Kalibro::Range.new :beginning => 19.5, :end => "INF", :reading_id => 1, :comments => "Test range 1"
  8 + Kalibro::Range.new :beginning => "19.5", :end => "INF", :reading_id => "1", :comments => "Test range 1"
9 9 end
10 10  
11 11 def self.range_hash
12   - {:id => 1, :beginning => 19.5, :end => "INF", :reading_id => 1, :comments => "Test range 1"}
  12 + {:id => "1", :beginning => "19.5", :end => "INF", :reading_id => "1", :comments => "Test range 1"}
13 13 end
14 14  
15 15 end
... ...
plugins/mezuro/test/fixtures/range_snapshot_fixtures.rb
... ... @@ -4,8 +4,16 @@ class RangeSnapshotFixtures
4 4 Kalibro::RangeSnapshot.new range_snapshot_hash
5 5 end
6 6  
  7 + def self.range_snapshot_with_infinite_range
  8 + Kalibro::RangeSnapshot.new range_snapshot_with_infinite_range_hash
  9 + end
  10 +
7 11 def self.range_snapshot_hash
8   - { :end => 5, :label => "snapshot", :grade => 10, :color => "FF2284", :comments => "comment" }
  12 + { :beginning => "1.1", :end => "5.1", :label => "snapshot", :grade => "10.1", :color => "FF2284", :comments => "comment" }
9 13 end
10 14  
  15 + def self.range_snapshot_with_infinite_range_hash
  16 + { :beginning => "-INF", :end => "INF", :label => "snapshot", :grade => "10.1", :color => "FF2284", :comments => "comment" }
  17 + end
  18 +
11 19 end
... ...
plugins/mezuro/test/fixtures/reading_fixtures.rb
... ... @@ -5,11 +5,11 @@ class ReadingFixtures
5 5 end
6 6  
7 7 def self.created_reading # A created object has no id before being sent to kalibro
8   - Kalibro::Reading.new :label => "Reading Test Label", :grade => 10.5, :color => "AABBCC"
  8 + Kalibro::Reading.new :label => "Reading Test Label", :grade => "10.5", :color => "AABBCC"
9 9 end
10 10  
11 11 def self.reading_hash
12   - {:id => 42, :label => "Reading Test Label", :grade => 10.5, :color => "AABBCC" }
  12 + {:id => "42", :label => "Reading Test Label", :grade => "10.5", :color => "AABBCC" }
13 13 end
14 14  
15 15 end
... ...
plugins/mezuro/test/fixtures/reading_group_fixtures.rb
... ... @@ -9,7 +9,7 @@ class ReadingGroupFixtures
9 9 end
10 10  
11 11 def self.reading_group_hash
12   - {:id => 42, :name => "Reading Group Test", :description => "Reading group in the fixtures"}
  12 + {:id => "42", :name => "Reading Group Test", :description => "Reading group in the fixtures"}
13 13 end
14 14  
15 15 end
... ...
plugins/mezuro/test/fixtures/repository_fixtures.rb
... ... @@ -12,12 +12,12 @@ class RepositoryFixtures
12 12 :process_period => "1",
13 13 :type => 'SUBVERSION',
14 14 :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator',
15   - :configuration_id => 31
  15 + :configuration_id => "31"
16 16 })
17 17 end
18 18  
19 19 def self.repository_hash
20   - {:id => 42, :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', :configuration_id => 31}
  20 + {:id => "42", :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => "https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator", :configuration_id => "31"}
21 21 end
22 22  
23 23 def self.types
... ...
plugins/mezuro/test/fixtures/stack_trace_element_fixtures.rb
1 1 class StackTraceElementFixtures
2 2  
3   - def self.stack_trace_element(method_name = 'my method name', line_number = 42)
4   - Kalibro::StackTraceElement.new stack_trace_element_hash(method_name, line_number)
  3 + def self.stack_trace_element
  4 + Kalibro::StackTraceElement.new stack_trace_element_hash
5 5 end
6 6  
7   - def self.stack_trace_element_hash(method_name = 'my method name', line_number = 42)
  7 + def self.stack_trace_element_hash
8 8 {
9 9 :declaring_class => 'my.declaring.Class',
10   - :method_name => method_name,
  10 + :method_name => 'my method name',
11 11 :file_name => 'MyFile.java',
12   - :line_number => line_number
  12 + :line_number => '42'
13 13 }
14 14 end
15 15  
... ...
plugins/mezuro/test/fixtures/throwable_fixtures.rb
... ... @@ -11,8 +11,7 @@ class ThrowableFixtures
11 11 :target_string => 'Target String',
12 12 :message => 'Throwable message from ThrowableTest',
13 13 :stack_trace_element => [
14   - StackTraceElementFixtures.stack_trace_element_hash('my method 1', 42),
15   - StackTraceElementFixtures.stack_trace_element_hash('my method 2', 84)
  14 + StackTraceElementFixtures.stack_trace_element_hash, StackTraceElementFixtures.stack_trace_element_hash
16 15 ]
17 16 }
18 17 end
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb
... ... @@ -21,24 +21,24 @@ class MezuroPluginModuleResultControllerTest &lt; ActionController::TestCase
21 21  
22 22 should 'find module result on kalibro' do
23 23 parent_module_result = ModuleResultFixtures.parent_module_result_hash
24   - Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }).
  24 + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id].to_i }).
25 25 returns({:module_result => @module_result_hash})
26   - Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }).
  26 + Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id].to_i }).
27 27 returns({:metric_result => @metric_result_hash})
28   - Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id] }).
  28 + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id].to_i }).
29 29 returns({:module_result => parent_module_result})
30   - Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id]}).
  30 + Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id].to_i}).
31 31 returns({:module_result => nil})
32 32 get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id]
33   - assert_equal @module_result_hash[:grade], assigns(:module_result).grade
34   - assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value
  33 + assert_equal @module_result_hash[:grade].to_f, assigns(:module_result).grade
  34 + assert_equal @metric_result_hash[:value].to_f, assigns(:metric_results).first.value
35 35 assert_response 200
36 36 #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)')
37 37 end
38 38  
39 39 should 'get metric result history' do
40 40 metric_name = @metric_result_hash[:configuration][:metric][:name]
41   - Kalibro::MetricResult.expects(:request).with(:history_of, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id] }).
  41 + Kalibro::MetricResult.expects(:request).with(:history_of_metric, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id].to_i }).
42 42 returns({:date_metric_result => @date_metric_result_hash})
43 43 get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name
44 44 assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date
... ... @@ -47,7 +47,7 @@ class MezuroPluginModuleResultControllerTest &lt; ActionController::TestCase
47 47 end
48 48  
49 49 should 'get module result history' do
50   - Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id] }).
  50 + Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id].to_i }).
51 51 returns({:date_module_result => @date_module_result_hash})
52 52 get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id]
53 53 assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb
... ... @@ -19,8 +19,15 @@ class MezuroPluginProcessingControllerTest &lt; ActionController::TestCase
19 19 end
20 20  
21 21 should 'render last processing state' do
22   - Kalibro::Processing.expects(:request).with(:last_processing_state, :repository_id => @repository_id).returns({:process_state => @processing.state})
23   - get :render_last_state, :profile => @profile.identifier, :repository_id => @repository_id
  22 + Kalibro::Processing.expects(:processing_of).with(@repository_id).returns(@processing)
  23 + get :state, :profile => @profile.identifier, :repository_id => @repository_id
  24 + assert_response 200
  25 + assert_equal @processing.state, @response.body
  26 + end
  27 +
  28 + should 'render a processing state in a specific date' do
  29 + Kalibro::Processing.expects(:processing_with_date_of).with(@repository_id, @processing.date).returns(@processing)
  30 + get :state, :profile => @profile.identifier, :repository_id => @repository_id, :date => @processing.date
24 31 assert_response 200
25 32 assert_equal @processing.state, @response.body
26 33 end
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... ... @@ -31,8 +31,10 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
31 31  
32 32 get :new, :profile => @profile.identifier, :id => @content.id
33 33  
34   - assert_equal @content, assigns(:project_content)
  34 + assert_equal @content.id, assigns(:project_content_id)
  35 + assert_equal @content.name, assigns(:project_name)
35 36 assert_equal @repository_types, assigns(:repository_types)
  37 + assert_equal @content.profile.identifier, assigns(:data_profile)
36 38 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first
37 39 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last
38 40 end
... ... @@ -40,6 +42,7 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
40 42 should 'create a repository' do
41 43 Kalibro::Repository.expects(:new).returns(@repository)
42 44 @repository.expects(:save).with(@content.project_id).returns(true)
  45 + @repository.expects(:process)
43 46 get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash
44 47 assert @repository.errors.empty?
45 48 assert_response :redirect
... ... @@ -62,8 +65,10 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
62 65  
63 66 get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
64 67  
65   - assert_equal @content, assigns(:project_content)
  68 + assert_equal @content.id, assigns(:project_content_id)
  69 + assert_equal @content.name, assigns(:project_name)
66 70 assert_equal @repository_types, assigns(:repository_types)
  71 + assert_equal @content.profile.identifier, assigns(:data_profile)
67 72 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first
68 73 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last
69 74 assert_equal @repository, assigns(:repository)
... ... @@ -72,6 +77,7 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
72 77 should 'update a repository' do
73 78 Kalibro::Repository.expects(:new).returns(@repository)
74 79 @repository.expects(:save).with(@content.project_id).returns(true)
  80 + Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id})
75 81 get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash
76 82 assert @repository.errors.empty?
77 83 assert_response :redirect
... ... @@ -91,6 +97,7 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
91 97 Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration)
92 98  
93 99 get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
  100 +
94 101 assert_equal @content.name, assigns(:project_name)
95 102 assert_equal @repository, assigns(:repository)
96 103 assert_equal @configuration.name, assigns(:configuration_name)
... ...
plugins/mezuro/test/unit/kalibro/date_metric_result_test.rb
... ... @@ -10,7 +10,7 @@ class DateMetricResultTest &lt; ActiveSupport::TestCase
10 10 end
11 11  
12 12 should 'create date_metric_result from hash' do
13   - assert_equal @hash[:metric_result][:id], Kalibro::DateMetricResult.new(@hash).metric_result.id
  13 + assert_equal @hash[:metric_result][:id].to_i, Kalibro::DateMetricResult.new(@hash).metric_result.id
14 14 end
15 15  
16 16 should 'convert date_metric_result to hash' do
... ...
plugins/mezuro/test/unit/kalibro/date_module_result_test.rb
... ... @@ -10,7 +10,7 @@ class DateModuleResultTest &lt; ActiveSupport::TestCase
10 10 end
11 11  
12 12 should 'create date_module_result from hash' do
13   - assert_equal @hash[:module_result][:id], Kalibro::DateModuleResult.new(@hash).module_result.id
  13 + assert_equal @hash[:module_result][:id].to_i, Kalibro::DateModuleResult.new(@hash).module_result.id
14 14 end
15 15  
16 16 should 'convert date_module_result to hash' do
... ...
plugins/mezuro/test/unit/kalibro/metric_configuration_snapshot_test.rb
... ... @@ -6,15 +6,19 @@ class MetricConfigurationSnapshotTest &lt; ActiveSupport::TestCase
6 6  
7 7 def setup
8 8 @hash = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash
  9 + @hash2 = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash_with_2_elements
9 10 @metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot
  11 + @metric_configuration_snapshot2 = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_with_2_elements
10 12 end
11 13  
12   - should 'create metric configuration snapshot from hash' do
  14 + should 'create and convert metric configuration snapshot from hash' do
13 15 assert_equal @hash[:code], Kalibro::MetricConfigurationSnapshot.new(@hash).code
  16 + assert_equal @hash[:weight].to_f, @metric_configuration_snapshot.weight
14 17 end
15 18  
16   - should 'convert metric configuration snapshot to hash' do
17   - assert_equal @hash, @metric_configuration_snapshot.to_hash
  19 + should 'create and convert metric configuration snapshot from hash with 2 elements' do
  20 + assert_equal @hash2[:code], Kalibro::MetricConfigurationSnapshot.new(@hash2).code
  21 + assert_equal @hash2, @metric_configuration_snapshot2.to_hash
18 22 end
19 23  
20 24 end
... ...
plugins/mezuro/test/unit/kalibro/metric_result_test.rb
... ... @@ -12,7 +12,18 @@ class MetricResultTest &lt; ActiveSupport::TestCase
12 12 end
13 13  
14 14 should 'create metric result from hash' do
15   - assert_equal @native_hash[:configuration][:code], Kalibro::MetricResult.new(@native_hash).configuration.code
  15 + metric_result = Kalibro::MetricResult.new(@native_hash)
  16 + assert_equal @native_hash[:configuration][:code], metric_result.configuration.code
  17 + assert_equal @native_hash[:id].to_i, metric_result.id
  18 + assert_equal @native_hash[:value].to_f, metric_result.value
  19 + end
  20 +
  21 + should 'create metric result with aggregated value from hash' do
  22 + hash = @native_hash
  23 + hash[:aggregated_value] = "2.0"
  24 + hash[:value] = "NaN"
  25 + metric_result = Kalibro::MetricResult.new(hash)
  26 + assert_equal @native_hash[:aggregated_value].to_f, metric_result.value
16 27 end
17 28  
18 29 should 'convert metric result to hash' do
... ... @@ -28,13 +39,13 @@ class MetricResultTest &lt; ActiveSupport::TestCase
28 39 should 'return metric results of a module result' do
29 40 id = 31
30 41 Kalibro::MetricResult.expects(:request).with(:metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash])
31   - assert_equal @native_hash[:id], Kalibro::MetricResult.metric_results_of(id).first.id
  42 + assert_equal @native_hash[:id].to_i, Kalibro::MetricResult.metric_results_of(id).first.id
32 43 end
33 44  
34 45 should 'return history of a metric with a module result id' do
35 46 module_result_id = 31
36   - Kalibro::MetricResult.expects(:request).with(:history_of, {:metric_name => @result.configuration.metric.name, :module_result_id => module_result_id}).returns({:date_metric_result => DateMetricResultFixtures.date_metric_result_hash})
37   - assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id], Kalibro::MetricResult.history_of(@result.configuration.metric.name, module_result_id).first.metric_result.id
  47 + Kalibro::MetricResult.expects(:request).with(:history_of_metric, {:metric_name => @result.configuration.metric.name, :module_result_id => module_result_id}).returns({:date_metric_result => DateMetricResultFixtures.date_metric_result_hash})
  48 + assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id].to_i, Kalibro::MetricResult.history_of(@result.configuration.metric.name, module_result_id).first.metric_result.id
38 49 end
39 50  
40 51 end
... ...
plugins/mezuro/test/unit/kalibro/module_result_test.rb
... ... @@ -11,7 +11,10 @@ class ModuleResultTest &lt; ActiveSupport::TestCase
11 11 end
12 12  
13 13 should 'create module result' do
14   - assert_equal @hash[:id] , Kalibro::ModuleResult.new(@hash).id
  14 + module_result = Kalibro::ModuleResult.new(@hash)
  15 + assert_equal @hash[:id].to_i , module_result.id
  16 + assert_equal @hash[:grade].to_f , module_result.grade
  17 + assert_equal @hash[:parent_id].to_i , module_result.parent_id
15 18 end
16 19  
17 20 should 'convert module result to hash' do
... ... @@ -41,7 +44,7 @@ class ModuleResultTest &lt; ActiveSupport::TestCase
41 44  
42 45 should 'return history of a module result' do
43 46 Kalibro::ModuleResult.expects(:request).with(:history_of_module, {:module_result_id => @module_result.id}).returns({:date_module_result => [DateModuleResultFixtures.date_module_result_hash]})
44   - assert_equal DateModuleResultFixtures.date_module_result_hash[:module_result][:id], Kalibro::ModuleResult.history_of(@module_result.id).first.module_result.id
  47 + assert_equal DateModuleResultFixtures.date_module_result_hash[:module_result][:id].to_i, Kalibro::ModuleResult.history_of(@module_result.id).first.module_result.id
45 48 end
46 49  
47 50 end
... ...
plugins/mezuro/test/unit/kalibro/process_time_test.rb
... ... @@ -11,10 +11,15 @@ class ProcessTimeTest &lt; ActiveSupport::TestCase
11 11  
12 12 should 'create process time from hash' do
13 13 assert_equal @hash[:state], Kalibro::ProcessTime.new(@hash).state
  14 + assert_equal @hash[:time].to_i, Kalibro::ProcessTime.new(@hash).time
14 15 end
15 16  
16 17 should 'convert process time to hash' do
17 18 assert_equal @hash, @process_time.to_hash
18 19 end
19 20  
  21 + should 'get time as an integer' do
  22 + assert_equal 1.class, @process_time.time.class
  23 + end
  24 +
20 25 end
... ...
plugins/mezuro/test/unit/kalibro/processing_test.rb
1 1 require "test_helper"
2 2  
3 3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures"
4   -#TODO arrumar os testes de unidade
5 4 class ProcessingTest < ActiveSupport::TestCase
6 5  
7 6 def setup
... ... @@ -11,12 +10,14 @@ class ProcessingTest &lt; ActiveSupport::TestCase
11 10 @repository_id = 31
12 11 end
13 12  
14   - should 'create project result from hash' do
15   - assert_equal @hash[:results_root_id], Kalibro::Processing.new(@hash).results_root_id
16   - assert_equal @hash[:process_time].first[:state], Kalibro::Processing.new(@hash).process_times.first.state
  13 + should 'create processing from hash' do
  14 + processing = Kalibro::Processing.new(@hash)
  15 + assert_equal @hash[:results_root_id].to_i, processing.results_root_id
  16 + assert_equal @hash[:process_time].first[:state], processing.process_times.first.state
  17 + assert_equal @hash[:id].to_i, processing.id
17 18 end
18 19  
19   - should 'convert project result to hash' do
  20 + should 'convert processing to hash' do
20 21 assert_equal @hash, @processing.to_hash
21 22 end
22 23  
... ... @@ -94,56 +95,4 @@ class ProcessingTest &lt; ActiveSupport::TestCase
94 95 assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id
95 96 end
96 97  
97   -=begin
98   - should 'get processing of a repository' do
99   - Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(true)
100   - Kalibro::Processing.expects(:last_ready_processing_of).with(@repository.id).returns(@processing)
101   - assert_equal @processing, @project_content.processing(@repository.id)
102   - end
103   -
104   - should 'get not ready processing of a repository' do
105   - Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(false)
106   - Kalibro::Processing.expects(:last_processing_of).with(@repository.id).returns(@processing)
107   - assert_equal @processing, @project_content.processing(@repository.id)
108   - end
109   -
110   - should 'get processing of a repository after date' do
111   - Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(true)
112   - Kalibro::Processing.expects(:first_processing_after).with(@repository.id, @date).returns(@processing)
113   - assert_equal @processing, @project_content.processing_with_date(@repository.id, @date)
114   - end
115   -
116   - should 'get processing of a repository before date' do
117   - Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(false)
118   - Kalibro::Processing.expects(:has_processing_before).with(@repository.id, @date).returns(true)
119   - Kalibro::Processing.expects(:last_processing_before).with(@repository.id, @date).returns(@processing)
120   - assert_equal @processing, @project_content.processing_with_date(@repository.id, @date)
121   - end
122   -
123   - should 'get module result' do
124   - @project_content.expects(:processing).with(@repository.id).returns(@processing)
125   - Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result)
126   - assert_equal @module_result, @project_content.module_result(@repository.id)
127   -
128   - end
129   -
130   - should 'get module result with date' do
131   - @project_content.expects(:processing_with_date).with(@repository.id,@date.to_s).returns(@processing)
132   - Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result)
133   - assert_equal @module_result, @project_content.module_result(@repository.id, @date.to_s)
134   - end
135   -
136   - should 'get result history' do
137   - Kalibro::MetricResult.expects(:history_of).with(@module_result.id).returns([@date_metric_result])
138   - assert_equal [@date_metric_result], @project_content.result_history(@module_result.id)
139   - end
140   -
141   - should 'add error to base when the module_result does not exist' do
142   - Kalibro::MetricResult.expects(:history_of).with(@module_result.id).raises(Kalibro::Errors::RecordNotFound)
143   - assert_nil @project_content.errors[:base]
144   - @project_content.result_history(@module_result.id)
145   - assert_not_nil @project_content.errors[:base]
146   - end
147   -=end
148   -
149 98 end
... ...
plugins/mezuro/test/unit/kalibro/project_test.rb
... ... @@ -13,6 +13,7 @@ class ProjectTest &lt; ActiveSupport::TestCase
13 13 should 'initialize new project from hash' do
14 14 project = Kalibro::Project.new @hash
15 15 assert_equal @hash[:name], project.name
  16 + assert_equal @hash[:id].to_i, project.id
16 17 end
17 18  
18 19 should 'convert project to hash' do
... ...
plugins/mezuro/test/unit/kalibro/range_snapshot_test.rb
... ... @@ -6,11 +6,23 @@ class RangeSnapshotTest &lt; ActiveSupport::TestCase
6 6  
7 7 def setup
8 8 @hash = RangeSnapshotFixtures.range_snapshot_hash
  9 + @range_snapshot_with_infinite_range_hash = RangeSnapshotFixtures.range_snapshot_with_infinite_range_hash
9 10 @range_snapshot = RangeSnapshotFixtures.range_snapshot
  11 + @range_snapshot_with_infinite_range = RangeSnapshotFixtures.range_snapshot_with_infinite_range
10 12 end
11 13  
12 14 should 'create range_snapshot from hash' do
13   - assert_equal @hash[:comments], Kalibro::RangeSnapshot.new(@hash).comments
  15 + range_snapshot = Kalibro::RangeSnapshot.new(@hash)
  16 + assert_equal @hash[:comments], range_snapshot.comments
  17 + assert_equal @hash[:beginning].to_f, range_snapshot.beginning
  18 + assert_equal @hash[:end].to_f, range_snapshot.end
  19 + assert_equal @hash[:grade].to_f, range_snapshot.grade
  20 + end
  21 +
  22 + should 'create range_snapshot from hash with infinity values' do
  23 + range_snapshot = Kalibro::RangeSnapshot.new(@range_snapshot_with_infinite_range_hash)
  24 + assert_equal -1.0/0, range_snapshot.beginning
  25 + assert_equal 1.0/0, range_snapshot.end
14 26 end
15 27  
16 28 should 'convert range_snapshot to hash' do
... ...
plugins/mezuro/test/unit/kalibro/repository_test.rb
... ... @@ -11,7 +11,11 @@ class RepositoryTest &lt; ActiveSupport::TestCase
11 11 end
12 12  
13 13 should 'new repository from hash' do
14   - assert_equal @repository.type, Kalibro::Repository.new(@hash).type
  14 + repository = Kalibro::Repository.new(@hash)
  15 + assert_equal @hash[:type], repository.type
  16 + assert_equal @hash[:id].to_i, repository.id
  17 + assert_equal @hash[:process_period].to_i, repository.process_period
  18 + assert_equal @hash[:configuration_id].to_i, repository.configuration_id
15 19 end
16 20  
17 21 should 'convert repository to hash' do
... ... @@ -40,7 +44,6 @@ class RepositoryTest &lt; ActiveSupport::TestCase
40 44 id_from_kalibro = 1
41 45 project_id = 56
42 46 Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash, :project_id => project_id}).returns(:repository_id => id_from_kalibro)
43   - Kalibro::Repository.expects(:request).with(:process_repository, :repository_id => id_from_kalibro).returns(:repository_id => id_from_kalibro)
44 47 assert @created_repository.save(project_id)
45 48 assert_equal id_from_kalibro, @created_repository.id
46 49 end
... ... @@ -59,7 +62,7 @@ class RepositoryTest &lt; ActiveSupport::TestCase
59 62  
60 63 should 'process repository' do
61 64 Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id});
62   - @repository.process_repository
  65 + @repository.process
63 66 end
64 67  
65 68 should 'cancel processing of a repository' do
... ...
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb
1 1 require "test_helper"
2 2 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures"
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/date_metric_result_fixtures"
3 4  
4 5 class ContentViewerHelperTest < ActiveSupport::TestCase
5 6  
  7 + def setup
  8 + @helper = MezuroPlugin::Helpers::ContentViewerHelper
  9 + end
  10 +
6 11 should 'get the number rounded by two decimal points' do
7   - assert_equal '4.22', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4.22344')
8   - assert_equal '4.10', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4.1')
9   - assert_equal '4.00', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4')
  12 + assert_equal '4.22', @helper.format_grade('4.22344')
  13 + assert_equal '4.10', @helper.format_grade('4.1')
  14 + assert_equal '4.00', @helper.format_grade('4')
10 15 end
11 16  
12 17 should 'create the periodicity options array' do
13   - assert_equal [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]], MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options
  18 + assert_equal [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweekly", 15], ["Monthly", 30]], @helper.periodicity_options
  19 + end
  20 +
  21 + should 'return the correct string for a given periodicity' do
  22 + assert_equal "Not Periodically", @helper.periodicity_option(0)
  23 + assert_equal "1 day", @helper.periodicity_option(1)
  24 + assert_equal "2 days", @helper.periodicity_option(2)
  25 + assert_equal "Weekly", @helper.periodicity_option(7)
  26 + assert_equal "Biweekly", @helper.periodicity_option(15)
  27 + assert_equal "Monthly", @helper.periodicity_option(30)
  28 + end
  29 +
  30 + should 'create the license options array' do
  31 + options = YAML.load_file("#{RAILS_ROOT}/plugins/mezuro/licenses.yml")
  32 + options = options.split(";")
  33 + formated_options = []
  34 + options.each { |option| formated_options << [option, option] }
  35 + assert_equal formated_options, @helper.license_options
14 36 end
15 37  
  38 + should 'generate chart from metric result history' do
  39 + chart = "http://chart.apis.google.com/chart?chxt=y,x&chco=c4a000&chf=bg,ls,90,efefef,0.2,ffffff,0.2&chd=s:A9&chl=2011-10-20T18%3A26%3A43%2B00%3A00|2011-10-25T18%3A26%3A43%2B00%3A00&cht=lc&chs=600x180&chxr=0,0.0,5.0"
  40 + metric_history = DateMetricResultFixtures.score_history
  41 +
  42 + assert_equal chart, @helper.generate_chart(metric_history)
  43 + end
  44 +
  45 + should 'format time to show a sentence' do
  46 + assert_equal 'less than 5 seconds', @helper.format_time(0)
  47 + assert_equal 'less than 5 seconds', @helper.format_time(4999)
  48 + assert_equal 'less than 10 seconds', @helper.format_time(5000)
  49 + assert_equal '1 minute', @helper.format_time(70000)
  50 + assert_equal 'about 2 hours', @helper.format_time(7000000)
  51 + end
  52 +
16 53 should 'format metric name for metric configuration snapshot' do
17 54 metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot
18   - assert_equal 'AverageMethodLOC', MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot)
  55 + assert_equal 'AverageMethodLOC', @helper.format_name(metric_configuration_snapshot)
19 56 end
20 57  
21 58 end
... ...
plugins/mezuro/test/unit/mezuro_plugin/helpers/module_result_helper_test.rb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +require "test_helper"
  2 +
  3 +class ModuleResultHelperTest < ActiveSupport::TestCase
  4 +
  5 + should 'return last module name when receive a string' do
  6 + name = 'Class'
  7 + assert_equal name, MezuroPlugin::Helpers::ModuleResultHelper.module_name(name)
  8 + end
  9 +
  10 + should 'return last module name when receive an array of strings' do
  11 + name = ['Class', 'Module']
  12 + assert_equal name.last, MezuroPlugin::Helpers::ModuleResultHelper.module_name(name)
  13 + end
  14 +
  15 +end
... ...
plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml
... ... @@ -9,19 +9,22 @@
9 9 <tbody>
10 10 <% @metric_results.each do |metric_result| %>
11 11 <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%>
12   - <% range_snapshot = metric_configuration_snapshot.range_snapshot %>
13   - <% formatted_name = MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) %>
14   - <% if !range_snapshot.nil? %>
  12 + <% range_snapshots = metric_configuration_snapshot.range_snapshot %>
  13 + <% metric_name = metric_configuration_snapshot.metric.name %>
  14 + <% formatted_name = metric_name.delete("() ") %>
  15 + <% if !range_snapshots.nil? %>
15 16 <tr>
16   - <td style="width: 74%"><a href="#" show-metric-history="<%= formatted_name %>" data-module-id="<%= @module_result_id %>"><%= metric_configuration_snapshot.metric.name %></a></td>
  17 + <td style="width: 74%"><a href="#" show-metric-history="<%= formatted_name %>" data-metric-name="<%= metric_name %>" data-module-id="<%= @module_result.id %>"><%= metric_name %></a></td>
17 18 <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td>
18 19 <td><%= metric_configuration_snapshot.weight %></td>
  20 + <% range_snapshots.each do |range_snapshot| %>
  21 + <% if range_snapshot.beginning <= metric_result.value and range_snapshot.end > metric_result.value %>
19 22 <td style="background-color: #<%= range_snapshot.color %>">
20 23 <span title="<%= range_snapshot.comments %>" >
21 24 <%= range_snapshot.label %>
22 25 </span>
23 26 </td>
24   - </tr>
  27 + </tr>
25 28 <tr class="<%= formatted_name %>" style="display: none;">
26 29 <td colspan="3">
27 30 <div id='historical-<%= formatted_name %>'>
... ... @@ -29,8 +32,10 @@
29 32 </td>
30 33 <td align="right">
31 34 <%= range_snapshot.comments.nil? ? '' : range_snapshot.comments %>
32   - </td>
  35 + </td>
33 36 </tr>
  37 + <% end %>
  38 + <% end %>
34 39 <% end %>
35 40 <% end %>
36 41 </tbody>
... ...
plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml
1   -<% render :partial => "source_tree", :locals => {:module_result => @module_result} %>
2   -<h5><%= _('Metric results for: #{@module_result.module.name} (#{@module_result.module.granularity}) ') %> </h5>
  1 +<%= render :partial => "source_tree", :locals => {:module_result => @module_result} %>
  2 +<h5><%= _"Metric results for: #{@module_result.module.name} (#{@module_result.module.granularity})" %> </h5>
3 3  
4 4 <hr/>
5 5 <div class="zoomable-image">
... ...
plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml
1 1 <h4><%= _('Source tree') %></h4>
2   -<% module_name = module_result.module.name %>
  2 +<% helper = MezuroPlugin::Helpers::ModuleResultHelper %>
  3 +<% module_name = helper.module_name(module_result.module.name) %>
3 4 <% module_label = "#{module_name} (#{module_result.module.granularity})" %>
4 5  
5 6 <p>
6 7 <h2 class="path">
7 8 <% module_result.parents.each do |parent| %>
8 9 /<a href="#" class="source-tree-link" data-module-id="<%= parent.id %>">
9   - <%= parent.module.name %>
  10 + <%= helper.module_name parent.module.name %>
10 11 </a>
11   - <% end %>
  12 + <% end %>/ <%= helper.module_name module_name %>
12 13 </h2>
13 14 </p>
14 15  
... ... @@ -17,14 +18,14 @@
17 18 <% if child.module.granularity=='PACKAGE' %>
18 19 <tr>
19 20 <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td>
20   - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-id="<%= child.id %>"><%= child.module.name %></a></td>
  21 + <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-id="<%= child.id %>"><%= helper.module_name child.module.name %></a></td>
21 22 </tr>
22 23 <% else %>
23 24 <tr>
24 25 <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td>
25 26 <td class="source-tree-text">
26 27 <a href='#' class="source-tree-link" data-module-id="<%= child.id %>">
27   - <%= child.module.name %>
  28 + <%= helper.module_name child.module.name %>
28 29 </a>
29 30 </td>
30 31 </tr>
... ...
plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml
... ... @@ -5,12 +5,12 @@
5 5 <table>
6 6 <tr>
7 7 <td><%= _('Date') %></td>
8   - <td><%= @processing.date %></td>
  8 + <td><%= @processing.date.inspect %></td>
9 9 </tr>
10 10 <% @processing.process_time.each do |process_time| %>
11 11 <tr>
12 12 <td><%= _(process_time.state + ' time') %></td>
13   - <td><%= process_time.time %></td>
  13 + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_time(process_time.time) %></td>
14 14 </tr>
15 15 <% end %>
16 16 <tr>
... ... @@ -25,10 +25,12 @@
25 25 jQuery(document).ready(function($) {
26 26 $("#datepicker").datepicker({
27 27 onSelect: function(dateText, inst) {
28   - reloadProjectWithDate(dateText) } });
  28 + reloadProcessingWithDate(dateText) } });
29 29 $("#datepicker").toggle();
30 30 var date = jQuery("#current_processing_date").attr('data-date').substr(0,10);
31   - $("#datepicker").datepicker( "setDate" , date );
  31 + $("#datepicker").datepicker( "setDate" , date.substr(5,2)+"/"+date.substr(8,2)+"/"+date.substr(0,4));
32 32  
33 33 });
34 34 </script>
  35 +
  36 +<span id="module_result_root_id" module_result_root_id="<%= @processing.results_root_id %>">
... ...
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
1   -<h2><%= @project_content.name %> Project</h2>
  1 +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
2 2  
3 3 <% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @project_content.id %>
  4 + <%= hidden_field_tag :id, @project_content_id %>
5 5  
6 6 <%= f.hidden_field :id%>
7 7 <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
... ...
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
1   -<h2><%= @project_content.name %> Project</h2>
  1 +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
2 2  
3 3 <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @project_content.id %>
  4 + <%= hidden_field_tag :id, @project_content_id %>
5 5  
6 6 <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
7 7  
... ...
plugins/mezuro/views/mezuro_plugin_repository/show.html.erb
1 1 <script src="/plugins/mezuro/javascripts/processing.js" type="text/javascript"></script>
2   -<h3><%= @project_name %></h3>
  2 +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
3 3  
4 4 <table>
5 5 <tr>
... ... @@ -14,7 +14,7 @@
14 14 <td><%= _('License') %></td>
15 15 <td><%= @repository.license %></td>
16 16 </tr>
17   - <tr>
  17 + <tr>
18 18 <td><%= _('Process Period') %></td>
19 19 <td><%= MezuroPlugin::Helpers::ContentViewerHelper.periodicity_option(@repository.process_period.to_i) %></td>
20 20 </tr>
... ... @@ -34,7 +34,7 @@
34 34 <td><%= _('Status')%></td>
35 35 <td>
36 36 <div id="processing-state" style="color:DarkGoldenRod">Retrieving</div>
37   - <div id="msg-time"></div>
  37 + <div id="msg-time"></div>
38 38 </td>
39 39 </tr>
40 40 </table>
... ...