Commit cd669e2b66afb16510973ed3641f8fa77dc14613

Authored by Rafael Manzo
2 parents c6921d9e 70a04eb8

Merge pull request #287 from mezuro/hotspot_listing

Hotspot listing
Showing 72 changed files with 634 additions and 368 deletions   Show diff stats
@@ -5,10 +5,12 @@ addons: @@ -5,10 +5,12 @@ addons:
5 postgresql: "9.3" 5 postgresql: "9.3"
6 6
7 before_script: 7 before_script:
8 - - git clone https://github.com/mezuro/kalibro_install.git -b v3.6 kalibro_install 8 + - git clone https://github.com/mezuro/kalibro_install.git -b v4.0 kalibro_install
9 - pushd kalibro_install 9 - pushd kalibro_install
10 # Remove bugged libzmq3 package, see https://github.com/travis-ci/travis-ci/issues/982 and https://github.com/travis-ci/travis-ci/issues/1715 for details 10 # Remove bugged libzmq3 package, see https://github.com/travis-ci/travis-ci/issues/982 and https://github.com/travis-ci/travis-ci/issues/1715 for details
11 - sudo apt-get remove libzmq3 11 - sudo apt-get remove libzmq3
  12 + - export KALIBRO_PROCESSOR_VERSION=v1.1.2
  13 + - export KALIBRO_CONFIGURATIONS_VERSION=v1.2.0
12 - bash install.sh 14 - bash install.sh
13 - popd 15 - popd
14 - cp config/database.yml.sample config/database.yml 16 - cp config/database.yml.sample config/database.yml
@@ -28,7 +28,7 @@ gem 'jbuilder', '~> 2.0' @@ -28,7 +28,7 @@ gem 'jbuilder', '~> 2.0'
28 gem 'devise', '~> 3.5.1' 28 gem 'devise', '~> 3.5.1'
29 29
30 # Kalibro integration 30 # Kalibro integration
31 -gem 'kalibro_client', '~> 1.4' 31 +gem 'kalibro_client', '~> 2.1.2'
32 32
33 # PostgreSQL integration 33 # PostgreSQL integration
34 gem "pg", "~> 0.18.1" 34 gem "pg", "~> 0.18.1"
@@ -119,7 +119,7 @@ GEM @@ -119,7 +119,7 @@ GEM
119 factory_girl_rails (4.5.0) 119 factory_girl_rails (4.5.0)
120 factory_girl (~> 4.5.0) 120 factory_girl (~> 4.5.0)
121 railties (>= 3.0.0) 121 railties (>= 3.0.0)
122 - faraday (0.9.1) 122 + faraday (0.9.2)
123 multipart-post (>= 1.2, < 3) 123 multipart-post (>= 1.2, < 3)
124 faraday_middleware (0.10.0) 124 faraday_middleware (0.10.0)
125 faraday (>= 0.7.4, < 0.10) 125 faraday (>= 0.7.4, < 0.10)
@@ -152,7 +152,7 @@ GEM @@ -152,7 +152,7 @@ GEM
152 railties (>= 3.2) 152 railties (>= 3.2)
153 sprockets-rails 153 sprockets-rails
154 json (1.8.3) 154 json (1.8.3)
155 - kalibro_client (1.4.1) 155 + kalibro_client (2.1.2)
156 activesupport (>= 2.2.1) 156 activesupport (>= 2.2.1)
157 faraday_middleware (~> 0.10.0) 157 faraday_middleware (~> 0.10.0)
158 konacha (3.7.0) 158 konacha (3.7.0)
@@ -353,7 +353,7 @@ DEPENDENCIES @@ -353,7 +353,7 @@ DEPENDENCIES
353 jquery-rails 353 jquery-rails
354 jquery-ui-rails (~> 5.0.0) 354 jquery-ui-rails (~> 5.0.0)
355 js-routes (~> 1.1.0) 355 js-routes (~> 1.1.0)
356 - kalibro_client (~> 1.4) 356 + kalibro_client (~> 2.1.2)
357 konacha 357 konacha
358 less-rails (~> 2.7.0) 358 less-rails (~> 2.7.0)
359 mocha 359 mocha
app/assets/javascripts/module/tree.js.coffee
1 class Module.Tree 1 class Module.Tree
2 @load: (loading_html, module_id) -> 2 @load: (loading_html, module_id) ->
  3 + # FIXME: The messages we send on loading_html are the same already
  4 + # shown on the Repository's show page
3 $('div#module_tree').html(loading_html) 5 $('div#module_tree').html(loading_html)
4 $('div#metric_results').html(loading_html) 6 $('div#metric_results').html(loading_html)
  7 + $('div#hotspot_metric_results').html(loading_html)
5 $.post Routes.module_tree_path(module_id) 8 $.post Routes.module_tree_path(module_id)
app/controllers/compound_metric_configurations_controller.rb
@@ -7,7 +7,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle @@ -7,7 +7,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle
7 respond_to do |format| 7 respond_to do |format|
8 create_and_redir(format) 8 create_and_redir(format)
9 end 9 end
10 - Rails.cache.delete("#{params[:kalibro_configuration_id].to_i}_metric_configurations") 10 + Rails.cache.delete("#{params[:kalibro_configuration_id].to_i}_tree_metric_configurations")
11 end 11 end
12 12
13 def show 13 def show
@@ -30,7 +30,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle @@ -30,7 +30,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle
30 else 30 else
31 failed_action(format, 'edit') 31 failed_action(format, 'edit')
32 end 32 end
33 - Rails.cache.delete("#{@compound_metric_configuration.kalibro_configuration_id}_metric_configurations") 33 + Rails.cache.delete("#{@compound_metric_configuration.kalibro_configuration_id}_tree_metric_configurations")
34 end 34 end
35 end 35 end
36 36
app/controllers/kalibro_configurations_controller.rb
@@ -28,8 +28,11 @@ class KalibroConfigurationsController &lt; ApplicationController @@ -28,8 +28,11 @@ class KalibroConfigurationsController &lt; ApplicationController
28 # GET /kalibro_configurations/1 28 # GET /kalibro_configurations/1
29 # GET /kalibro_configurations/1.json 29 # GET /kalibro_configurations/1.json
30 def show 30 def show
31 - Rails.cache.fetch("#{@kalibro_configuration.id}_metric_configurations") do  
32 - @kalibro_configuration.metric_configurations 31 + Rails.cache.fetch("#{@kalibro_configuration.id}_tree_metric_configurations") do
  32 + @kalibro_configuration.tree_metric_configurations
  33 + end
  34 + Rails.cache.fetch("#{@kalibro_configuration.id}_hotspot_metric_configurations") do
  35 + @kalibro_configuration.hotspot_metric_configurations
33 end 36 end
34 end 37 end
35 38
app/controllers/metric_configurations_controller.rb
@@ -7,7 +7,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController @@ -7,7 +7,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController
7 7
8 def new 8 def new
9 super 9 super
10 - # find_by_name throws an exception instead of returning nil, unlike ActiveRecord's API 10 + # FIXME: find_by_name throws an exception instead of returning nil, unlike ActiveRecord's API
11 metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(params[:metric_collector_name]).find_metric_by_code params[:metric_code] 11 metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(params[:metric_collector_name]).find_metric_by_code params[:metric_code]
12 @reading_groups = ReadingGroup.public_or_owned_by_user(current_user).map { |reading_group| 12 @reading_groups = ReadingGroup.public_or_owned_by_user(current_user).map { |reading_group|
13 [reading_group.name, reading_group.id] 13 [reading_group.name, reading_group.id]
@@ -20,11 +20,11 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController @@ -20,11 +20,11 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController
20 respond_to do |format| 20 respond_to do |format|
21 create_and_redir(format) 21 create_and_redir(format)
22 end 22 end
23 - Rails.cache.delete("#{params[:kalibro_configuration_id]}_metric_configurations") 23 + clear_caches
24 end 24 end
25 25
26 def edit 26 def edit
27 - #FIXME: set the configuration id just once! 27 + # FIXME: set the configuration id just once!
28 @kalibro_configuration_id = params[:kalibro_configuration_id] 28 @kalibro_configuration_id = params[:kalibro_configuration_id]
29 @metric_configuration.kalibro_configuration_id = @kalibro_configuration_id 29 @metric_configuration.kalibro_configuration_id = @kalibro_configuration_id
30 @reading_groups = ReadingGroup.public_or_owned_by_user(current_user).map { |reading_group| 30 @reading_groups = ReadingGroup.public_or_owned_by_user(current_user).map { |reading_group|
@@ -38,7 +38,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController @@ -38,7 +38,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController
38 if @metric_configuration.update(metric_configuration_params) 38 if @metric_configuration.update(metric_configuration_params)
39 format.html { redirect_to(kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_updated', :record => t(metric_configuration.class))) } 39 format.html { redirect_to(kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_updated', :record => t(metric_configuration.class))) }
40 format.json { head :no_content } 40 format.json { head :no_content }
41 - Rails.cache.delete("#{@metric_configuration.kalibro_configuration_id}_metric_configurations") 41 + clear_caches
42 else 42 else
43 failed_action(format, 'edit') 43 failed_action(format, 'edit')
44 end 44 end
@@ -51,7 +51,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController @@ -51,7 +51,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController
51 format.html { redirect_to kalibro_configuration_path(params[:kalibro_configuration_id]) } 51 format.html { redirect_to kalibro_configuration_path(params[:kalibro_configuration_id]) }
52 format.json { head :no_content } 52 format.json { head :no_content }
53 end 53 end
54 - Rails.cache.delete("#{params[:kalibro_configuration_id]}_metric_configurations") 54 + clear_caches
55 end 55 end
56 56
57 protected 57 protected
@@ -67,7 +67,12 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController @@ -67,7 +67,12 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController
67 67
68 private 68 private
69 69
70 - # Duplicated code on create and update actions extracted here 70 + def clear_caches
  71 + Rails.cache.delete("#{params[:kalibro_configuration_id]}_tree_metric_configurations")
  72 + Rails.cache.delete("#{params[:kalibro_configuration_id]}_hotspot_metric_configurations")
  73 + end
  74 +
  75 + # FIXME: Duplicated code on create and update actions extracted here
71 def failed_action(format, destiny_action) 76 def failed_action(format, destiny_action)
72 @kalibro_configuration_id = params[:kalibro_configuration_id] 77 @kalibro_configuration_id = params[:kalibro_configuration_id]
73 78
@@ -75,7 +80,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController @@ -75,7 +80,7 @@ class MetricConfigurationsController &lt; BaseMetricConfigurationsController
75 format.json { render json: @metric_configuration.kalibro_errors, status: :unprocessable_entity } 80 format.json { render json: @metric_configuration.kalibro_errors, status: :unprocessable_entity }
76 end 81 end
77 82
78 - #Code extracted from create action 83 + # Code extracted from create action
79 def create_and_redir(format) 84 def create_and_redir(format)
80 if @metric_configuration.save 85 if @metric_configuration.save
81 format.html { redirect_to kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_created', :record => t(metric_configuration.class)) } 86 format.html { redirect_to kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: t('successfully_created', :record => t(metric_configuration.class)) }
app/models/module_result.rb
1 class ModuleResult < KalibroClient::Entities::Processor::ModuleResult 1 class ModuleResult < KalibroClient::Entities::Processor::ModuleResult
2 def metric_history(name) 2 def metric_history(name)
3 - history = KalibroClient::Entities::Processor::MetricResult.history_of(name, self.id, processing.repository_id) 3 + history = KalibroClient::Entities::Processor::TreeMetricResult.history_of(name, self.id, processing.repository_id)
4 grade_history = Hash.new 4 grade_history = Hash.new
5 5
6 history.each { |date_metric_result| grade_history[date_metric_result.date] = date_metric_result.metric_result.value } 6 history.each { |date_metric_result| grade_history[date_metric_result.date] = date_metric_result.metric_result.value }
app/views/kalibro_configurations/_metric_configurations.html.erb
1 <tr> 1 <tr>
2 <td><%= metric_configuration.metric.name %></td> 2 <td><%= metric_configuration.metric.name %></td>
3 <td><%= metric_configuration.metric.code %></td> 3 <td><%= metric_configuration.metric.code %></td>
4 - <td><%= metric_configuration.weight %></td> 4 + <% unless metric_configuration.metric.is_a? KalibroClient::Entities::Miscellaneous::HotspotMetric %>
  5 + <td><%= metric_configuration.weight %></td>
  6 + <% end %>
5 <td> 7 <td>
6 <%= link_to_show_page(metric_configuration, @kalibro_configuration.id) %> 8 <%= link_to_show_page(metric_configuration, @kalibro_configuration.id) %>
7 </td> 9 </td>
app/views/kalibro_configurations/_no_metric_configurations.html.erb
1 <tr> 1 <tr>
2 <% col_number = kalibro_configuration_owner?(@kalibro_configuration.id) ? 5 : 3 %> 2 <% col_number = kalibro_configuration_owner?(@kalibro_configuration.id) ? 5 : 3 %>
3 - <td colspan="<%= col_number %>"><%= t('no_metric_configurations') %></td>  
4 -</tr>  
5 \ No newline at end of file 3 \ No newline at end of file
  4 + <td colspan="<%= col_number %>">
  5 + <%= t(message) %>
  6 + </td>
  7 +</tr>
app/views/kalibro_configurations/show.html.erb
@@ -8,13 +8,13 @@ @@ -8,13 +8,13 @@
8 </p> 8 </p>
9 9
10 <hr> 10 <hr>
11 -<div id="metrics">  
12 -<h2><%= t('metric').pluralize %></h2>  
13 <% if kalibro_configuration_owner? @kalibro_configuration.id %> 11 <% if kalibro_configuration_owner? @kalibro_configuration.id %>
14 <%= link_to t_action(:add, MetricConfiguration), kalibro_configuration_choose_metric_path(@kalibro_configuration.id), class: 'btn btn-info' %> 12 <%= link_to t_action(:add, MetricConfiguration), kalibro_configuration_choose_metric_path(@kalibro_configuration.id), class: 'btn btn-info' %>
15 <% end %> 13 <% end %>
  14 +<div id="tree_metrics">
  15 +<h2><%= t('tree_metric').pluralize %></h2>
16 16
17 -<table class="table table-hover"> 17 +<table class="table table-hover" id="tree_metric_configurations">
18 <thead> 18 <thead>
19 <tr> 19 <tr>
20 <th><%= t('metric') %></th> 20 <th><%= t('metric') %></th>
@@ -24,10 +24,10 @@ @@ -24,10 +24,10 @@
24 </tr> 24 </tr>
25 </thead> 25 </thead>
26 <tbody> 26 <tbody>
27 - <% if Rails.cache.read("#{@kalibro_configuration.id}_metric_configurations").empty? %>  
28 - <%= render partial: 'no_metric_configurations' %> 27 + <% if Rails.cache.read("#{@kalibro_configuration.id}_tree_metric_configurations").empty? %>
  28 + <%= render partial: 'no_metric_configurations', locals: { message: 'no_tree_metric_configurations' } %>
29 <% else %> 29 <% else %>
30 - <%= render partial: 'metric_configurations', collection: Rails.cache.read("#{@kalibro_configuration.id}_metric_configurations"), as: :metric_configuration %> 30 + <%= render partial: 'metric_configurations', collection: Rails.cache.read("#{@kalibro_configuration.id}_tree_metric_configurations"), as: :metric_configuration %>
31 <% end %> 31 <% end %>
32 </tbody> 32 </tbody>
33 </table> 33 </table>
@@ -35,6 +35,28 @@ @@ -35,6 +35,28 @@
35 35
36 <hr> 36 <hr>
37 37
  38 +<div id="hotspot_metrics">
  39 +<h2><%= t('hotspot_metric').pluralize %></h2>
  40 +
  41 +<table class="table table-hover" id="hotspot_metric_configurations">
  42 + <thead>
  43 + <tr>
  44 + <th><%= t('metric') %></th>
  45 + <th><%= t('code') %></th>
  46 + <th colspan="2"></th>
  47 + </tr>
  48 + </thead>
  49 + <tbody>
  50 + <% if Rails.cache.read("#{@kalibro_configuration.id}_hotspot_metric_configurations").empty? %>
  51 + <%= render partial: 'no_metric_configurations', locals: { message: 'no_hotspot_metric_configurations' } %>
  52 + <% else %>
  53 + <%= render partial: 'metric_configurations', collection: Rails.cache.read("#{@kalibro_configuration.id}_hotspot_metric_configurations"), as: :metric_configuration %>
  54 + <% end %>
  55 + </tbody>
  56 +</table>
  57 +</div>
  58 +
  59 +<hr>
38 <p> 60 <p>
39 <%= link_to t('back'), kalibro_configurations_path, class: 'btn btn-default' %> 61 <%= link_to t('back'), kalibro_configurations_path, class: 'btn btn-default' %>
40 <% if kalibro_configuration_owner? @kalibro_configuration.id %> 62 <% if kalibro_configuration_owner? @kalibro_configuration.id %>
app/views/modules/_hotspot_metric_result.html.erb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +<tr>
  2 + <td><%= hotspot_metric_result.module_result.kalibro_module.short_name %></td>
  3 + <td><%= hotspot_metric_result.line_number %></td>
  4 + <td><%= hotspot_metric_result.message %></td>
  5 +</tr>
app/views/modules/_hotspot_metric_results.html.erb 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +<table class="table table-hover metric_results">
  2 + <thead>
  3 + <tr>
  4 + <th><%= t('activemodel.attributes.hotspot_metric_result.module_result.module.name') %></th>
  5 + <th><%= t('activemodel.attributes.hotspot_metric_result.line') %></th>
  6 + <th><%= t('activemodel.attributes.hotspot_metric_result.message') %></th>
  7 + </tr>
  8 + </thead>
  9 +
  10 + <tbody>
  11 + <% cache("#{@root_module_result.id}_hotspot_results") do %>
  12 + <%= render partial: 'hotspot_metric_result', collection: @root_module_result.hotspot_metric_results, locals: {module_result: @root_module_result} %>
  13 + <% end %>
  14 + </tbody>
  15 +</table>
app/views/modules/_metric_result.html.erb
1 <% metric_configuration = metric_result.metric_configuration %> 1 <% metric_configuration = metric_result.metric_configuration %>
2 -<% unless metric_configuration.kalibro_ranges.nil? %> 2 +<% unless metric_configuration.metric.type == "HotspotMetricSnapshot" %>
3 <% range_snapshot = find_range_snapshot(metric_result) 3 <% range_snapshot = find_range_snapshot(metric_result)
4 metric_name = metric_configuration.metric.name 4 metric_name = metric_configuration.metric.name
5 %> 5 %>
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 </tr> 15 </tr>
16 <tr id="container<%= metric_result.id %>" style="display: none"> 16 <tr id="container<%= metric_result.id %>" style="display: none">
17 <td colspan="4"> 17 <td colspan="4">
18 - <span id="loader_container<%= metric_result.id %>"><%= image_tag 'loader.gif' %> <%= t('loading_data') %></span> 18 + <span id="loader_container<%= metric_result.id %>"><%= image_tag 'loader.gif' %> <%= t('repository.show.loading') %></span>
19 <canvas id="container<%= metric_result.id %>" class="graphic_container" style="display: none"></canvas> 19 <canvas id="container<%= metric_result.id %>" class="graphic_container" style="display: none"></canvas>
20 </td> 20 </td>
21 </tr> 21 </tr>
app/views/modules/_metric_results.html.erb
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 10
11 <tbody> 11 <tbody>
12 <% cache("#{@root_module_result.id}_results") do %> 12 <% cache("#{@root_module_result.id}_results") do %>
13 - <%= render partial: 'metric_result', collection: @root_module_result.metric_results, locals: {module_result: @root_module_result} %> 13 + <%= render partial: 'metric_result', collection: @root_module_result.tree_metric_results, locals: {module_result: @root_module_result} %>
14 <% end %> 14 <% end %>
15 </tbody> 15 </tbody>
16 </table> 16 </table>
app/views/modules/_module_result.html.erb
@@ -7,6 +7,6 @@ @@ -7,6 +7,6 @@
7 <% end %> 7 <% end %>
8 <%= link_to format_module_name(module_result.kalibro_module.name), "#module_#{module_result.id}", onClick: "Module.Tree.load('#{escape_javascript(image_tag 'loader.gif')} #{escape_javascript(t('loading_data'))}', #{module_result.id});" %> 8 <%= link_to format_module_name(module_result.kalibro_module.name), "#module_#{module_result.id}", onClick: "Module.Tree.load('#{escape_javascript(image_tag 'loader.gif')} #{escape_javascript(t('loading_data'))}', #{module_result.id});" %>
9 </td> 9 </td>
10 - <td><%= module_result.kalibro_module.granularity %></td> 10 + <td><%= module_result.kalibro_module.granularity["type"] %></td>
11 <td><%= format_grade(module_result.grade) %></td> 11 <td><%= format_grade(module_result.grade) %></td>
12 </tr> 12 </tr>
app/views/modules/_module_tree.html.erb
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 </p> 4 </p>
5 <p> 5 <p>
6 <strong><%= KalibroModule.human_attribute_name('granularity') %>:</strong> 6 <strong><%= KalibroModule.human_attribute_name('granularity') %>:</strong>
7 - <%= @root_module_result.kalibro_module.granularity %> 7 + <%= @root_module_result.kalibro_module.granularity["type"] %>
8 </p> 8 </p>
9 <p> 9 <p>
10 <strong><%= KalibroModule.human_attribute_name('grade') %>:</strong> 10 <strong><%= KalibroModule.human_attribute_name('grade') %>:</strong>
app/views/modules/load_module_tree.js.erb
1 $('div#module_tree').html('<%= escape_javascript(render partial: "module_tree") %>'); 1 $('div#module_tree').html('<%= escape_javascript(render partial: "module_tree") %>');
  2 +$('div#hotspot_metric_results').html('<%= escape_javascript(render partial: "hotspot_metric_results") %>')
2 $('div#metric_results').html('<%= escape_javascript(render partial: "metric_results") %>'); 3 $('div#metric_results').html('<%= escape_javascript(render partial: "metric_results") %>');
app/views/repositories/_hotspot_metric_results_error.html.erb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<p><%= t('activemodel.errors.repository.no_hotspot_metric_results') %></p>
app/views/repositories/load_error.js.erb
1 $('div#processing_information').html('<%= escape_javascript(render partial: "processing_information") %>'); 1 $('div#processing_information').html('<%= escape_javascript(render partial: "processing_information") %>');
2 $('div#module_tree').html('<%= escape_javascript(render partial: "module_tree_error") %>'); 2 $('div#module_tree').html('<%= escape_javascript(render partial: "module_tree_error") %>');
3 -$('div#metric_results').html('<%= escape_javascript(render partial: "metric_results_error") %>');  
4 \ No newline at end of file 3 \ No newline at end of file
  4 +$('div#hotspot_metric_results').html('<%= escape_javascript(render partial: "hotspot_metric_results_error") %>');
  5 +$('div#metric_results').html('<%= escape_javascript(render partial: "metric_results_error") %>');
app/views/repositories/show.html.erb
@@ -64,6 +64,11 @@ @@ -64,6 +64,11 @@
64 <div id="module_tree"><%= image_tag 'loader.gif' %> <%= t('repository.show.loading') %></div> 64 <div id="module_tree"><%= image_tag 'loader.gif' %> <%= t('repository.show.loading') %></div>
65 </div> 65 </div>
66 66
  67 + <div id="hotspot-metric-accordion">
  68 + <h3 class="jquery-ui-accordion"><%= t('repository.show.hotspot_metric_results') %></h3>
  69 + <div id="hotspot_metric_results"><%= image_tag 'loader.gif' %> <%= t('repository.show.loading') %></div>
  70 + </div>
  71 +
67 <div id="metric-accordion"> 72 <div id="metric-accordion">
68 <h3 class="jquery-ui-accordion"><%= t('repository.show.metric_results') %></h3> 73 <h3 class="jquery-ui-accordion"><%= t('repository.show.metric_results') %></h3>
69 <div id="metric_results"><%= image_tag 'loader.gif' %> <%= t('repository.show.loading') %></div> 74 <div id="metric_results"><%= image_tag 'loader.gif' %> <%= t('repository.show.loading') %></div>
@@ -81,6 +86,7 @@ @@ -81,6 +86,7 @@
81 collapsible: true, 86 collapsible: true,
82 }); 87 });
83 $("#module-accordion").accordion({active: false}) 88 $("#module-accordion").accordion({active: false})
  89 + $("#hotspot-metric-accordion").accordion({active: false})
84 $("#metric-accordion").accordion({active: false}) 90 $("#metric-accordion").accordion({active: false})
85 }); 91 });
86 </script> 92 </script>
config/locales/views/en.yml
@@ -47,6 +47,10 @@ en: @@ -47,6 +47,10 @@ en:
47 no_description: "There is no description available" 47 no_description: "There is no description available"
48 welcome: "Welcome" 48 welcome: "Welcome"
49 metrics: "Metrics" 49 metrics: "Metrics"
  50 + tree_metrics: "Tree Metrics"
  51 + tree_metric: "Tree Metric"
  52 + hotspot_metrics: "Hotspot Metrics"
  53 + hotspot_metric: "Hotspot Metric"
50 value: "Value" 54 value: "Value"
51 threshold: "Threshold" 55 threshold: "Threshold"
52 granularity: "Granularity" 56 granularity: "Granularity"
config/locales/views/metric_configurations/en.yml
@@ -23,7 +23,8 @@ en: @@ -23,7 +23,8 @@ en:
23 metric_configurations_base_tool_name: "Base Tool Name:" 23 metric_configurations_base_tool_name: "Base Tool Name:"
24 metric_configurations_aggregation: "Aggregation Form" 24 metric_configurations_aggregation: "Aggregation Form"
25 metric_configurations_reading_group: "Reading Group Name" 25 metric_configurations_reading_group: "Reading Group Name"
26 - no_metric_configurations: "There are no Metric Configurations yet!" 26 + no_tree_metric_configurations: "There are no Tree Metric Configurations yet!"
  27 + no_hotspot_metric_configurations: "There are no Hotspot Metric Configurations yet!"
27 destroy_metric_configuration: "Destroy Metric Configuration" 28 destroy_metric_configuration: "Destroy Metric Configuration"
28 want_destroy_metric_configuration: "Are you sure that you want to destroy this Metric Configuration?" 29 want_destroy_metric_configuration: "Are you sure that you want to destroy this Metric Configuration?"
29 metric_base_tool_name: "Base Tool Name" 30 metric_base_tool_name: "Base Tool Name"
config/locales/views/metric_configurations/pt.yml
@@ -27,7 +27,8 @@ pt: @@ -27,7 +27,8 @@ pt:
27 metric_configurations_base_tool_name: "Nome da ferramenta base:" 27 metric_configurations_base_tool_name: "Nome da ferramenta base:"
28 metric_configurations_aggregation: "Forma de Agregação" 28 metric_configurations_aggregation: "Forma de Agregação"
29 metric_configurations_reading_group: "Nome do grupo" 29 metric_configurations_reading_group: "Nome do grupo"
30 - no_metric_configurations: "Não há configurações de métricas ainda!" 30 + no_tree_metric_configurations: "Não há configurações de métricas escalares ainda!"
  31 + no_hotspot_metric_configurations: "Não há configurações de métricas de Hotspot ainda!"
31 destroy_metric_configuration: "Destruir Configuração de Métrica" 32 destroy_metric_configuration: "Destruir Configuração de Métrica"
32 want_destroy_metric_configuration: "Tem certeza que você quer destruir esta Configuração de Métrica?" 33 want_destroy_metric_configuration: "Tem certeza que você quer destruir esta Configuração de Métrica?"
33 metric_base_tool_name: "Coletor" 34 metric_base_tool_name: "Coletor"
config/locales/views/metric_results/en.yml
@@ -17,3 +17,6 @@ en: @@ -17,3 +17,6 @@ en:
17 name: "Name" 17 name: "Name"
18 granularity: "Granularity" 18 granularity: "Granularity"
19 grade: "Grade" 19 grade: "Grade"
  20 + hotspot_metric_result:
  21 + line: "Line"
  22 + message: "Message"
config/locales/views/metric_results/pt.yml
@@ -16,4 +16,7 @@ pt: @@ -16,4 +16,7 @@ pt:
16 kalibro_module: 16 kalibro_module:
17 name: "Nome" 17 name: "Nome"
18 granularity: "Granularidade" 18 granularity: "Granularidade"
19 - grade: "Nota"  
20 \ No newline at end of file 19 \ No newline at end of file
  20 + grade: "Nota"
  21 + hotspot_metric_result:
  22 + line: "Linha"
  23 + message: "Mensagem"
config/locales/views/pt.yml
@@ -50,6 +50,10 @@ pt: @@ -50,6 +50,10 @@ pt:
50 no_description: "Não há descrição disponível." 50 no_description: "Não há descrição disponível."
51 welcome: "Bem-Vindo" 51 welcome: "Bem-Vindo"
52 metrics: "Métricas" 52 metrics: "Métricas"
  53 + tree_metrics: "Métricas escalares"
  54 + tree_metric: "Métrica escalar"
  55 + hotspot_metrics: "Métricas de Hotspot"
  56 + hotspot_metric: "Métrica de Hotspot"
53 value: "Valor" 57 value: "Valor"
54 threshold: "limite" 58 threshold: "limite"
55 granularity: "Granularidade" 59 granularity: "Granularidade"
config/locales/views/repository/en.yml
@@ -25,14 +25,16 @@ en: @@ -25,14 +25,16 @@ en:
25 branch: "The branch to be analyzed." 25 branch: "The branch to be analyzed."
26 errors: 26 errors:
27 repository: 27 repository:
28 - no_metric_results: "Repository process returned with error. There are no metric results."  
29 - no_modeule_tree: "Repository process returned with error. There is no module tree." 28 + no_metric_results: "Repository process returned with error. There are no tree metric results."
  29 + no_hotspot_metric_results: "Repository process returned with error. There are no hotspot metric results."
  30 + no_module_tree: "Repository process returned with error. There is no module tree."
30 unstarted_processing: "This Repository has no processings yet. Please, wait an instant as we start it." 31 unstarted_processing: "This Repository has no processings yet. Please, wait an instant as we start it."
31 repository: 32 repository:
32 show: 33 show:
33 reprocess: "Reprocess" 34 reprocess: "Reprocess"
34 processing_information: "Processing Information" 35 processing_information: "Processing Information"
35 modules_tree: "Modules Tree" 36 modules_tree: "Modules Tree"
36 - metric_results: "Metric Results" 37 + hotspot_metric_results: "Hotspot Metric Results"
  38 + metric_results: "Tree Metric Results"
37 loading: "Loading data. Please, wait." 39 loading: "Loading data. Please, wait."
38 date_processing: "Retrieve the closest processing information from" 40 date_processing: "Retrieve the closest processing information from"
config/locales/views/repository/pt.yml
@@ -26,13 +26,15 @@ pt: @@ -26,13 +26,15 @@ pt:
26 errors: 26 errors:
27 repository: 27 repository:
28 no_metric_results: "O processamento do Repósitório retornou um erro. Não há Resultados de Métrica." 28 no_metric_results: "O processamento do Repósitório retornou um erro. Não há Resultados de Métrica."
29 - no_modeule_tree: "Repository process returned with error. Não há uma Árvore de Módulos." 29 + no_hotspot_metric_results: "O processamento do Repósitório retornou um erro. Não há Resultados de Métricas de Hotspot."
  30 + no_module_tree: "Repository process returned with error. Não há uma Árvore de Módulos."
30 unstarted_processing: "Este Repositório ainda não tem Processamentos. Por favor, aguarde um instante enquanto o iniciamos." 31 unstarted_processing: "Este Repositório ainda não tem Processamentos. Por favor, aguarde um instante enquanto o iniciamos."
31 repository: 32 repository:
32 show: 33 show:
33 reprocess: "Reprocessar" 34 reprocess: "Reprocessar"
34 processing_information: "Informação do Processamento" 35 processing_information: "Informação do Processamento"
35 modules_tree: "Árvore de Módulos" 36 modules_tree: "Árvore de Módulos"
  37 + hotspot_metric_results: "Resultados de Métricas de Hotspot"
36 metric_results: "Resultados de Métrica" 38 metric_results: "Resultados de Métrica"
37 loading: "Carregando os dados. Por favor, aguarde." 39 loading: "Carregando os dados. Por favor, aguarde."
38 date_processing: "Obtenha a informação de processamento mais próxima a" 40 date_processing: "Obtenha a informação de processamento mais próxima a"
features/compound_metric_configuration/create.feature
@@ -9,7 +9,7 @@ Feature: Compound Metric Configuration Creation @@ -9,7 +9,7 @@ Feature: Compound Metric Configuration Creation
9 And I am signed in 9 And I am signed in
10 And I own a sample configuration 10 And I own a sample configuration
11 And I have a reading group named "Scholar" 11 And I have a reading group named "Scholar"
12 - And I have a sample metric configuration within the given mezuro configuration 12 + And I have a sample tree metric configuration within the given mezuro configuration
13 And I am at the Sample Configuration page 13 And I am at the Sample Configuration page
14 And I click the Add Metric link 14 And I click the Add Metric link
15 And I click the Compound Metric link 15 And I click the Compound Metric link
features/compound_metric_configuration/edition.feature
@@ -9,10 +9,10 @@ Feature: Compound Metric Configuration edition @@ -9,10 +9,10 @@ Feature: Compound Metric Configuration edition
9 And I am signed in 9 And I am signed in
10 And I have a sample configuration 10 And I have a sample configuration
11 And I have a sample reading group 11 And I have a sample reading group
12 - And I have a sample metric configuration within the given mezuro configuration 12 + And I have a sample tree metric configuration within the given mezuro configuration
13 And I have a sample compound metric configuration within the given mezuro configuration 13 And I have a sample compound metric configuration within the given mezuro configuration
14 When I am at the Sample Configuration page 14 When I am at the Sample Configuration page
15 - Then I should not see Edit within table 15 + Then I should not find "Edit" within "table#tree_metric_configurations"
16 16
17 @kalibro_configuration_restart 17 @kalibro_configuration_restart
18 Scenario: editing a compound metric configuration successfully 18 Scenario: editing a compound metric configuration successfully
@@ -20,7 +20,7 @@ Feature: Compound Metric Configuration edition @@ -20,7 +20,7 @@ Feature: Compound Metric Configuration edition
20 And I am signed in 20 And I am signed in
21 And I own a sample configuration 21 And I own a sample configuration
22 And I have a sample reading group 22 And I have a sample reading group
23 - And I have a sample metric configuration within the given mezuro configuration 23 + And I have a sample tree metric configuration within the given mezuro configuration
24 And I have a sample compound metric configuration within the given mezuro configuration 24 And I have a sample compound metric configuration within the given mezuro configuration
25 And I am at the Sample Configuration page 25 And I am at the Sample Configuration page
26 When I click the edit link of the Coumpound Metric 26 When I click the edit link of the Coumpound Metric
@@ -30,13 +30,13 @@ Feature: Compound Metric Configuration edition @@ -30,13 +30,13 @@ Feature: Compound Metric Configuration edition
30 Then I should see "Another_code" 30 Then I should see "Another_code"
31 And I should see "Compound Metric Configuration was successfully updated." 31 And I should see "Compound Metric Configuration was successfully updated."
32 32
33 - @kalibro_configuration_restart@javascript 33 + @kalibro_configuration_restart @javascript
34 Scenario: trying to edit with blank fields 34 Scenario: trying to edit with blank fields
35 Given I am a regular user 35 Given I am a regular user
36 And I am signed in 36 And I am signed in
37 And I own a sample configuration 37 And I own a sample configuration
38 And I have a sample reading group 38 And I have a sample reading group
39 - And I have a sample metric configuration within the given mezuro configuration 39 + And I have a sample tree metric configuration within the given mezuro configuration
40 And I have a sample compound metric configuration within the given mezuro configuration 40 And I have a sample compound metric configuration within the given mezuro configuration
41 When I visit the sample compound metric configuration edit page 41 When I visit the sample compound metric configuration edit page
42 And I fill the Name field with " " 42 And I fill the Name field with " "
@@ -57,7 +57,7 @@ Feature: Compound Metric Configuration edition @@ -57,7 +57,7 @@ Feature: Compound Metric Configuration edition
57 And I am signed in 57 And I am signed in
58 And I own a sample configuration 58 And I own a sample configuration
59 And I have a sample reading group 59 And I have a sample reading group
60 - And I have a sample metric configuration within the given mezuro configuration 60 + And I have a sample tree metric configuration within the given mezuro configuration
61 And I have a sample compound metric configuration within the given mezuro configuration 61 And I have a sample compound metric configuration within the given mezuro configuration
62 And I have another compound metric configuration with code "Another_Code" within the given mezuro configuration 62 And I have another compound metric configuration with code "Another_Code" within the given mezuro configuration
63 When I visit the sample compound metric configuration edit page 63 When I visit the sample compound metric configuration edit page
features/hotspot_metric_configuration/create.feature 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +Feature: Hotspot Metric Configuration Creation
  2 + In order to register my metric configurations
  3 + As a regular user
  4 + I should be able to create hotspot metric configurations
  5 +
  6 + @kalibro_configuration_restart @javascript
  7 + Scenario: hotspot metric configuration creation
  8 + Given I am a regular user
  9 + And I am signed in
  10 + And I own a sample configuration
  11 + And I am at the Sample Configuration page
  12 + And I click the Add Metric link
  13 + And I click the "MetricFu" h3
  14 + And I click the Duplicate Code link
  15 + When I fill the Weight field with "2"
  16 + And I press the Save button
  17 + Then I should see "Hotspot Metrics"
  18 + And I should see "Duplicate Code"
features/hotspot_metric_configuration/listing.feature 0 → 100644
@@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
  1 +Feature: Hotspot Configuration listing
  2 + In order to interact with hotspot metric configurations
  3 + As a regular user
  4 + I should see the hotspot metric configurations of a given kalibro configuration
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: When there are hotspot metric configurations and no tree metric configurations
  8 + Given I have a sample configuration
  9 + And I have a sample hotspot metric configuration within the given mezuro configuration
  10 + When I am at the Sample Configuration page
  11 + Then I should see the sample hotspot metric configuration content
  12 + And I should see "There are no Tree Metric Configurations yet!"
  13 +
  14 +
  15 + @kalibro_configuration_restart
  16 + Scenario: When there are hotspot metric configurations and tree metric configurations
  17 + Given I have a sample configuration
  18 + And I have a sample hotspot metric configuration within the given mezuro configuration
  19 + And I have a sample reading group
  20 + And I have a sample tree metric configuration within the given mezuro configuration
  21 + When I am at the Sample Configuration page
  22 + Then I should see the sample hotspot metric configuration content
  23 + And I should not see "There are no Tree Metric Configurations yet!"
features/kalibro_configuration/show.feature
1 Feature: Show Configuration 1 Feature: Show Configuration
2 - In order to know all the contents of a given configuration 2 + In order to know all the contents of a given configuration
3 As a regular user 3 As a regular user
4 I should be able to see each of them 4 I should be able to see each of them
5 5
6 @kalibro_configuration_restart 6 @kalibro_configuration_restart
7 Scenario: Checking configuration contents 7 Scenario: Checking configuration contents
8 Given I have a sample configuration 8 Given I have a sample configuration
  9 + And I have a hotspot metric configuration
  10 + And I have a tree metric configuration
9 When I am at the Sample Configuration page 11 When I am at the Sample Configuration page
10 Then the sample configuration should be there 12 Then the sample configuration should be there
11 \ No newline at end of file 13 \ No newline at end of file
features/kalibro_range/create.feature
@@ -9,7 +9,7 @@ Feature: Create Kalibro Range @@ -9,7 +9,7 @@ Feature: Create Kalibro Range
9 And I am signed in 9 And I am signed in
10 And I own a sample configuration 10 And I own a sample configuration
11 And I own a sample reading group 11 And I own a sample reading group
12 - And I have a sample metric configuration within the given mezuro configuration 12 + And I have a sample tree metric configuration within the given mezuro configuration
13 And I have a sample reading within the sample reading group labeled "My Reading" 13 And I have a sample reading within the sample reading group labeled "My Reading"
14 And I am at the sample metric configuration page 14 And I am at the sample metric configuration page
15 When I click the Add Range link 15 When I click the Add Range link
@@ -25,7 +25,7 @@ Feature: Create Kalibro Range @@ -25,7 +25,7 @@ Feature: Create Kalibro Range
25 And I am signed in 25 And I am signed in
26 And I own a sample configuration 26 And I own a sample configuration
27 And I have a reading group named "Scholar" 27 And I have a reading group named "Scholar"
28 - And I have a sample metric configuration within the given mezuro configuration 28 + And I have a sample tree metric configuration within the given mezuro configuration
29 And I am at the sample metric configuration page 29 And I am at the sample metric configuration page
30 When I click the Add Range link 30 When I click the Add Range link
31 Then I should be at the New Range page 31 Then I should be at the New Range page
@@ -41,7 +41,7 @@ Feature: Create Kalibro Range @@ -41,7 +41,7 @@ Feature: Create Kalibro Range
41 And I am signed in 41 And I am signed in
42 And I own a sample configuration 42 And I own a sample configuration
43 And I own a sample reading group 43 And I own a sample reading group
44 - And I have a sample metric configuration within the given mezuro configuration 44 + And I have a sample tree metric configuration within the given mezuro configuration
45 And I am at the sample metric configuration page 45 And I am at the sample metric configuration page
46 When I click the Add Range link 46 When I click the Add Range link
47 Then I should be at the New Range page 47 Then I should be at the New Range page
@@ -61,7 +61,7 @@ Feature: Create Kalibro Range @@ -61,7 +61,7 @@ Feature: Create Kalibro Range
61 And I am signed in 61 And I am signed in
62 And I own a sample configuration 62 And I own a sample configuration
63 And I own a sample reading group 63 And I own a sample reading group
64 - And I have a sample metric configuration within the given mezuro configuration 64 + And I have a sample tree metric configuration within the given mezuro configuration
65 And I have a sample reading within the sample reading group labeled "My Reading" 65 And I have a sample reading within the sample reading group labeled "My Reading"
66 And I am at the New Range page 66 And I am at the New Range page
67 And I fill the Beginning field with "42" 67 And I fill the Beginning field with "42"
@@ -77,7 +77,7 @@ Feature: Create Kalibro Range @@ -77,7 +77,7 @@ Feature: Create Kalibro Range
77 And I am signed in 77 And I am signed in
78 And I own a sample configuration 78 And I own a sample configuration
79 And I own a sample reading group 79 And I own a sample reading group
80 - And I have a sample metric configuration within the given mezuro configuration 80 + And I have a sample tree metric configuration within the given mezuro configuration
81 And I have a sample reading within the sample reading group labeled "My Reading" 81 And I have a sample reading within the sample reading group labeled "My Reading"
82 And I am at the New Range page 82 And I am at the New Range page
83 And I fill the Beginning field with "666" 83 And I fill the Beginning field with "666"
@@ -95,7 +95,7 @@ Feature: Create Kalibro Range @@ -95,7 +95,7 @@ Feature: Create Kalibro Range
95 And I am signed in 95 And I am signed in
96 And I own a sample configuration 96 And I own a sample configuration
97 And I own a sample reading group 97 And I own a sample reading group
98 - And I have a sample metric configuration within the given mezuro configuration 98 + And I have a sample tree metric configuration within the given mezuro configuration
99 And I have a sample reading within the sample reading group labeled "My Reading" 99 And I have a sample reading within the sample reading group labeled "My Reading"
100 And I am at the New Range page 100 And I am at the New Range page
101 And I fill the Beginning field with "z" 101 And I fill the Beginning field with "z"
@@ -113,7 +113,7 @@ Feature: Create Kalibro Range @@ -113,7 +113,7 @@ Feature: Create Kalibro Range
113 And I am signed in 113 And I am signed in
114 And I own a sample configuration 114 And I own a sample configuration
115 And I own a sample reading group 115 And I own a sample reading group
116 - And I have a sample metric configuration within the given mezuro configuration 116 + And I have a sample tree metric configuration within the given mezuro configuration
117 And I have a sample reading within the sample reading group labeled "My Reading" 117 And I have a sample reading within the sample reading group labeled "My Reading"
118 And I am at the New Range page 118 And I am at the New Range page
119 And I fill the Beginning field with "-1" 119 And I fill the Beginning field with "-1"
@@ -131,9 +131,9 @@ Feature: Create Kalibro Range @@ -131,9 +131,9 @@ Feature: Create Kalibro Range
131 And I am signed in 131 And I am signed in
132 And I own a sample configuration 132 And I own a sample configuration
133 And I own a sample reading group 133 And I own a sample reading group
134 - And I have a sample metric configuration within the given mezuro configuration 134 + And I have a sample tree metric configuration within the given mezuro configuration
135 And I have a sample reading within the sample reading group labeled "My Reading" 135 And I have a sample reading within the sample reading group labeled "My Reading"
136 - And I have a sample range within the sample metric configuration with beginning "2" 136 + And I have a sample range within the sample tree metric configuration with beginning "2"
137 And I am at the New Range page 137 And I am at the New Range page
138 And I fill the Beginning field with "2" 138 And I fill the Beginning field with "2"
139 And I fill the End field with "666" 139 And I fill the End field with "666"
@@ -151,7 +151,7 @@ Feature: Create Kalibro Range @@ -151,7 +151,7 @@ Feature: Create Kalibro Range
151 And I am signed in 151 And I am signed in
152 And I own a sample configuration 152 And I own a sample configuration
153 And I own a sample reading group 153 And I own a sample reading group
154 - And I have a sample metric configuration within the given mezuro configuration 154 + And I have a sample tree metric configuration within the given mezuro configuration
155 And I have a sample reading within the sample reading group labeled "My Reading" 155 And I have a sample reading within the sample reading group labeled "My Reading"
156 And I am at the New Range page 156 And I am at the New Range page
157 And I click the -∞ link 157 And I click the -∞ link
@@ -169,7 +169,7 @@ Feature: Create Kalibro Range @@ -169,7 +169,7 @@ Feature: Create Kalibro Range
169 And I am signed in 169 And I am signed in
170 And I own a sample configuration 170 And I own a sample configuration
171 And I own a sample reading group 171 And I own a sample reading group
172 - And I have a sample metric configuration within the given mezuro configuration 172 + And I have a sample tree metric configuration within the given mezuro configuration
173 And I have a sample reading within the sample reading group labeled "My Reading" 173 And I have a sample reading within the sample reading group labeled "My Reading"
174 And I am at the New Range page 174 And I am at the New Range page
175 And I fill the Beginning field with "2" 175 And I fill the Beginning field with "2"
@@ -193,7 +193,7 @@ Feature: Create Kalibro Range @@ -193,7 +193,7 @@ Feature: Create Kalibro Range
193 And I am signed in 193 And I am signed in
194 And I own a sample configuration 194 And I own a sample configuration
195 And I own a sample reading group 195 And I own a sample reading group
196 - And I have a sample metric configuration within the given mezuro configuration 196 + And I have a sample tree metric configuration within the given mezuro configuration
197 And I have a sample compound metric configuration within the given mezuro configuration 197 And I have a sample compound metric configuration within the given mezuro configuration
198 And I have a sample reading within the sample reading group labeled "My Reading" 198 And I have a sample reading within the sample reading group labeled "My Reading"
199 And I am at the New Range page for the compound metric configuration 199 And I am at the New Range page for the compound metric configuration
features/kalibro_range/deletion.feature
@@ -9,9 +9,9 @@ Feature: Kalibro Range Deletion @@ -9,9 +9,9 @@ Feature: Kalibro Range Deletion
9 And I am signed in 9 And I am signed in
10 And I own a sample configuration 10 And I own a sample configuration
11 And I have a sample reading group 11 And I have a sample reading group
12 - And I have a sample metric configuration within the given mezuro configuration 12 + And I have a sample tree metric configuration within the given mezuro configuration
13 And I have a sample reading within the sample reading group labeled "My Reading" 13 And I have a sample reading within the sample reading group labeled "My Reading"
14 - And I have a sample range within the sample metric configuration 14 + And I have a sample range within the sample tree metric configuration
15 And I am at the sample metric configuration page 15 And I am at the sample metric configuration page
16 When I click the Destroy link 16 When I click the Destroy link
17 Then I should be at metric configuration sample page 17 Then I should be at metric configuration sample page
@@ -37,8 +37,8 @@ Feature: Kalibro Range Deletion @@ -37,8 +37,8 @@ Feature: Kalibro Range Deletion
37 And I am signed in 37 And I am signed in
38 And I have a sample configuration 38 And I have a sample configuration
39 And I have a sample reading group 39 And I have a sample reading group
40 - And I have a sample metric configuration within the given mezuro configuration 40 + And I have a sample tree metric configuration within the given mezuro configuration
41 And I have a sample reading within the sample reading group labeled "My Reading" 41 And I have a sample reading within the sample reading group labeled "My Reading"
42 - And I have a sample range within the sample metric configuration 42 + And I have a sample range within the sample tree metric configuration
43 When I am at the sample metric configuration page 43 When I am at the sample metric configuration page
44 Then I should not see "Destroy" 44 Then I should not see "Destroy"
features/kalibro_range/edit.feature
@@ -9,9 +9,9 @@ Feature: Kalibro Range Edit @@ -9,9 +9,9 @@ Feature: Kalibro Range Edit
9 And I am signed in 9 And I am signed in
10 And I own a sample configuration 10 And I own a sample configuration
11 And I own a sample reading group 11 And I own a sample reading group
12 - And I have a sample metric configuration within the given mezuro configuration 12 + And I have a sample tree metric configuration within the given mezuro configuration
13 And I have a sample reading within the sample reading group labeled "My Reading" 13 And I have a sample reading within the sample reading group labeled "My Reading"
14 - And I have a sample range within the sample metric configuration with beginning "1.1" 14 + And I have a sample range within the sample tree metric configuration with beginning "1.1"
15 And I am at the Edit Kalibro Range page 15 And I am at the Edit Kalibro Range page
16 And the select field "Reading" is set as "My Reading" 16 And the select field "Reading" is set as "My Reading"
17 And the field "Beginning" should be filled with "1.1" 17 And the field "Beginning" should be filled with "1.1"
@@ -45,9 +45,9 @@ Feature: Kalibro Range Edit @@ -45,9 +45,9 @@ Feature: Kalibro Range Edit
45 And I am signed in 45 And I am signed in
46 And I own a sample configuration 46 And I own a sample configuration
47 And I own a sample reading group 47 And I own a sample reading group
48 - And I have a sample metric configuration within the given mezuro configuration 48 + And I have a sample tree metric configuration within the given mezuro configuration
49 And I have a sample reading within the sample reading group labeled "My Reading" 49 And I have a sample reading within the sample reading group labeled "My Reading"
50 - And I have a sample range within the sample metric configuration with beginning "1" 50 + And I have a sample range within the sample tree metric configuration with beginning "1"
51 And I am at the Edit Kalibro Range page 51 And I am at the Edit Kalibro Range page
52 When I fill the Beginning field with " " 52 When I fill the Beginning field with " "
53 And I press the Save button 53 And I press the Save button
features/metric_configuration/create.feature
@@ -1,91 +0,0 @@ @@ -1,91 +0,0 @@
1 -Feature: Metric Configuration Creation  
2 - In order to register my metric configurations  
3 - As a regular user  
4 - I should be able to create metric configurations  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: Should not create metric configurations without login  
8 - Given I have a sample configuration  
9 - And I am at the Sample Configuration page  
10 - Then I should not see "New Metric Configuration"  
11 -  
12 - @kalibro_configuration_restart @javascript  
13 - Scenario: metric configuration creation  
14 - Given I am a regular user  
15 - And I am signed in  
16 - And I own a sample configuration  
17 - And I have a reading group named "Scholar"  
18 - And I am at the Sample Configuration page  
19 - And I click the Add Metric link  
20 - And I click the "Analizo" h3  
21 - And I click the Total Lines of Code link  
22 - And I fill the Weight field with "2"  
23 - And I set the select field "Aggregation Form" as "Average"  
24 - And I set the select field "Reading Group" as "Scholar"  
25 - When I press the Save button  
26 - Then I should see "Total Lines of Code"  
27 - Then I should see "2"  
28 -  
29 - @kalibro_configuration_restart @javascript  
30 - Scenario: ruby metric configuration creation  
31 - Given I am a regular user  
32 - And I am signed in  
33 - And I own a sample configuration  
34 - And I have a reading group named "Scholar"  
35 - And I am at the Sample Configuration page  
36 - And I click the Add Metric link  
37 - And I click the "MetricFu" h3  
38 - And I click the Pain link  
39 - And I fill the Weight field with "2"  
40 - And I set the select field "Aggregation Form" as "Average"  
41 - And I set the select field "Reading Group" as "Scholar"  
42 - When I press the Save button  
43 - Then I should see "Pain"  
44 - Then I should see "2"  
45 -  
46 - @kalibro_configuration_restart @javascript  
47 - Scenario: metric configuration creation  
48 - Given I am a regular user  
49 - And I am signed in  
50 - And I own a sample configuration  
51 - And I have a reading group named "Scholar"  
52 - And I am at the Sample Configuration page  
53 - And I click the Add Metric link  
54 - And I click the "Analizo" h3  
55 - And I click the Total Lines of Code link  
56 - When I click the Back link  
57 - Then I should be at the choose metric page  
58 -  
59 - @kalibro_configuration_restart @javascript  
60 - Scenario: compound metric configuration creation with same code  
61 - Given I am a regular user  
62 - And I am signed in  
63 - And I own a sample configuration  
64 - And I have a reading group named "Scholar"  
65 - And I have a metric configuration with code "total_abstract_classes" within the given mezuro configuration  
66 - And I am at the Sample Configuration page  
67 - And I click the Add Metric link  
68 - And I click the "Analizo" h3  
69 - And I click the Total Abstract Classes link  
70 - And I fill the Weight field with "2"  
71 - And I set the select field "Aggregation Form" as "Average"  
72 - And I set the select field "Reading Group" as "Scholar"  
73 - When I press the Save button  
74 - Then I should see "Code must be unique within a kalibro configuration"  
75 -  
76 - @kalibro_configuration_restart @javascript  
77 - Scenario: metric configuration creation with count aggregation form  
78 - Given I am a regular user  
79 - And I am signed in  
80 - And I own a sample configuration  
81 - And I have a reading group named "Scholar"  
82 - And I am at the Sample Configuration page  
83 - And I click the Add Metric link  
84 - And I click the "Analizo" h3  
85 - And I click the Lines of Code link  
86 - And I fill the Weight field with "100"  
87 - And I set the select field "Aggregation Form" as "Count"  
88 - And I set the select field "Reading Group" as "Scholar"  
89 - When I press the Save button  
90 - Then I should see "Lines of Code"  
91 - Then I should see "100"  
features/metric_configuration/delete.feature
@@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
1 -Feature: Metric Configuration Deletion  
2 - In order to be able to remove metric configuration  
3 - As a regular user  
4 - The system should have an interface to it  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: Should delete a metric configuration that I own  
8 - Given I am a regular user  
9 - And I am signed in  
10 - And I own a sample configuration  
11 - And I have a sample reading group  
12 - And I have a sample metric configuration within the given mezuro configuration  
13 - When I am at the Sample Configuration page  
14 - And I click destroy Metric Configuration  
15 - Then I should see "There are no Metric Configurations yet!"  
16 -  
17 - @kalibro_configuration_restart  
18 - Scenario: Should not see the destroy metric configuration link in the mezuro configuration that I not own  
19 - Given I am a regular user  
20 - And I am signed in  
21 - And I have a sample configuration  
22 - And I have a sample reading group  
23 - And I have a sample metric configuration within the given mezuro configuration  
24 - When I am at the Sample Configuration page  
25 - Then I should not see "Destroy"  
features/metric_configuration/edition.feature
@@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
1 -Feature: Metric Configuration edition  
2 - In order to interact with metric configurations  
3 - As a regular user  
4 - I should edit the informations of metric configurations  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: the configuration is not mine  
8 - Given I am a regular user  
9 - And I am signed in  
10 - And I have a sample configuration  
11 - And I have a sample reading group  
12 - And I have a sample metric configuration within the given mezuro configuration  
13 - When I am at the Sample Configuration page  
14 - Then I should not see Edit within table  
15 -  
16 - @kalibro_configuration_restart  
17 - Scenario: editing a metric configuration successfully  
18 - Given I am a regular user  
19 - And I am signed in  
20 - And I own a sample configuration  
21 - And I have a sample reading group  
22 - And I have a sample metric configuration within the given mezuro configuration  
23 - And I am at the Sample Configuration page  
24 - When I click the Edit link  
25 - And I fill the Weight field with "3.0"  
26 - And I press the Save button  
27 - Then I should see "3.0"  
28 -  
29 - @kalibro_configuration_restart  
30 - Scenario: trying to edit with blank fields  
31 - Given I am a regular user  
32 - And I am signed in  
33 - And I own a sample configuration  
34 - And I have a sample reading group  
35 - And I have a sample metric configuration within the given mezuro configuration  
36 - When I visit the sample metric configuration edit page  
37 - And I fill the Weight field with " "  
38 - And I press the Save button  
39 - Then I should see "Weight must be greater than 0"  
40 -  
41 - @kalibro_configuration_restart  
42 - Scenario: Should not edit a metric configuration with invalid weight  
43 - Given I am a regular user  
44 - And I am signed in  
45 - And I own a sample configuration  
46 - And I have a sample reading group  
47 - And I have a sample metric configuration within the given mezuro configuration  
48 - When I visit the sample metric configuration edit page  
49 - And I fill the Weight field with "0"  
50 - And I set the select field "Aggregation Form" as "Median"  
51 - When I press the Save button  
52 - Then I should see "Weight must be greater than 0"  
features/metric_configuration/listing.feature
@@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
1 -Feature: Configuration listing  
2 - In order to interact with metric configurations  
3 - As a regular user  
4 - I should see the metric configurations of a given configuration  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: When there are no metric configurations  
8 - Given I have a sample configuration  
9 - When I am at the Sample Configuration page  
10 - Then I should see "Metric"  
11 - And I should see "Code"  
12 - And I should see "Weight"  
13 - And I should see "There are no Metric Configurations yet!"  
14 -  
15 - @kalibro_configuration_restart  
16 - Scenario: When there are metric configurations  
17 - Given I have a sample configuration  
18 - And I have a sample reading group  
19 - And I have a sample metric configuration within the given mezuro configuration  
20 - When I am at the Sample Configuration page  
21 - Then I should see the sample metric configuration content  
22 -  
23 - @kalibro_configuration_restart  
24 - Scenario: I should see the add metric link when I am the owner of the given configuration  
25 - Given I am a regular user  
26 - And I am signed in  
27 - And I own a sample configuration  
28 - When I am at the Sample Configuration page  
29 - Then I should see "Add Metric"  
30 -  
31 - @kalibro_configuration_restart  
32 - Scenario: I should not see the add metric link when I am at a given configuration page  
33 - Given I am a regular user  
34 - And I am signed in  
35 - And I have a sample configuration  
36 - When I am at the Sample Configuration page  
37 - Then I should not see "Add Metric"  
features/metric_configuration/show.feature
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -Feature: Show Metric Configuration  
2 - In order to know all the metric configurations of the given configuration and its contents  
3 - As a regular user  
4 - I should be able to see each of them  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: Checking metric configuration show link  
8 - Given I have a sample configuration  
9 - And I have a sample reading group  
10 - And I have a sample reading within the sample reading group labeled "My Reading"  
11 - And I have a sample metric configuration within the given mezuro configuration  
12 - And I have a sample range within the sample metric configuration  
13 - When I am at the Sample Configuration page  
14 - And I click the Show link  
15 - Then I should be at metric configuration sample page  
16 - And I should see the sample range  
17 -  
18 - @kalibro_configuration_restart @javascript  
19 - Scenario: When there's a range created and I want to see its comments  
20 - Given I have a sample configuration  
21 - And I have a sample reading group  
22 - And I have a sample reading within the sample reading group labeled "My Reading"  
23 - And I have a sample metric configuration within the given mezuro configuration  
24 - And I have a sample range within the sample metric configuration  
25 - And I am at the sample metric configuration page  
26 - When I click the "comment-icon" icon  
27 - Then I should see "Comment"  
28 -  
features/repository/show/hotspot_metric_results.feature 0 → 100644
@@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
  1 +Feature: Repository hotspot metric results
  2 + In order to better understand the results of the analysis
  3 + As a regular user
  4 + I should see the hotspot metric results list
  5 +
  6 + @kalibro_configuration_restart @kalibro_processor_restart @javascript
  7 + Scenario: Should show the message when the graphic of the given metric has only a single point
  8 + Given I am a regular user
  9 + And I am signed in
  10 + And I own a sample configuration
  11 + And I am at the Sample Configuration page
  12 + And I click the Add Metric link
  13 + And I click the "MetricFu" h3
  14 + And I click the Duplicate Code link
  15 + When I fill the Weight field with "2"
  16 + And I press the Save button
  17 + Given I have a sample project
  18 + And I have a sample ruby repository within the sample project
  19 + And I start to process that repository
  20 + And I wait up for a ready processing
  21 + And I ask for the last ready processing of the given repository
  22 + And I ask for the module result of the given processing
  23 + And I ask for the hotspot metric results of the given module result
  24 + When I visit the repository show page
  25 + And I click the "Hotspot Metric Results" h3
  26 + Then I should have at least one hotspot metric result
  27 + And I should see the hotspot metric results file names
  28 + And I should see the hotspot metric results messages
  29 + When I click the "Tree Metric Results" h3
  30 + Then I should not see "Duplicate Code"
  31 +
  32 + @kalibro_configuration_restart @kalibro_processor_restart @javascript
  33 + Scenario: Should show the error message when the process fails
  34 + Given I am a regular user
  35 + And I am signed in
  36 + And I have a sample project
  37 + And I have a sample configuration with native metrics
  38 + And I have a sample of an invalid repository within the sample project
  39 + And I start to process that repository
  40 + And I wait up for a error processing
  41 + When I visit the repository show page
  42 + And I click the "Hotspot Metric Results" h3
  43 + Then I should see "Repository process returned with error. There are no hotspot metric results."
features/repository/show/independent.feature
@@ -22,7 +22,7 @@ Feature: Date Select @@ -22,7 +22,7 @@ Feature: Date Select
22 And I should see "AGGREGATING time" 22 And I should see "AGGREGATING time"
23 And I should see "CALCULATING time" 23 And I should see "CALCULATING time"
24 And I should see "INTERPRETING time" 24 And I should see "INTERPRETING time"
25 - When I click the "Metric Results" h3 25 + When I click the "Tree Metric Results" h3
26 And I click the "Modules Tree" h3 26 And I click the "Modules Tree" h3
27 Then I should see "Metric" 27 Then I should see "Metric"
28 And I should see "Value" 28 And I should see "Value"
@@ -35,4 +35,4 @@ Feature: Date Select @@ -35,4 +35,4 @@ Feature: Date Select
35 Then I should see "PREPARING" 35 Then I should see "PREPARING"
36 When I click the Back link 36 When I click the Back link
37 And I wait for "5" seconds 37 And I wait for "5" seconds
38 - Then I should be at the Repositories index  
39 \ No newline at end of file 38 \ No newline at end of file
  39 + Then I should be at the Repositories index
features/repository/show/metric_results.feature
@@ -3,7 +3,7 @@ Feature: Repository metric results @@ -3,7 +3,7 @@ Feature: Repository metric results
3 As a regular user 3 As a regular user
4 I should see the metric results table with its graphics 4 I should see the metric results table with its graphics
5 5
6 - @kalibro_configuration_restart @kalibro_processor_restart @javascript @wip 6 + @kalibro_configuration_restart @kalibro_processor_restart @javascript
7 Scenario: Should show the message when the graphic of the given metric has only a single point 7 Scenario: Should show the message when the graphic of the given metric has only a single point
8 Given I am a regular user 8 Given I am a regular user
9 And I am signed in 9 And I am signed in
@@ -16,12 +16,10 @@ Feature: Repository metric results @@ -16,12 +16,10 @@ Feature: Repository metric results
16 And I ask for the module result of the given processing 16 And I ask for the module result of the given processing
17 And I ask for the metric results of the given module result 17 And I ask for the metric results of the given module result
18 When I visit the repository show page 18 When I visit the repository show page
19 - And I click the "Metric Results" h3 19 + And I click the "Tree Metric Results" h3
20 And I see a sample metric's name 20 And I see a sample metric's name
21 And I click on the sample metric's name 21 And I click on the sample metric's name
22 Then I should see "Loading data. Please, wait." 22 Then I should see "Loading data. Please, wait."
23 - When I wait up for the ajax request  
24 - Then I should see "There is only one point and it will not be printed into a chart."  
25 23
26 @kalibro_configuration_restart @kalibro_processor_restart @javascript 24 @kalibro_configuration_restart @kalibro_processor_restart @javascript
27 Scenario: Should show no range message after a process without range 25 Scenario: Should show no range message after a process without range
@@ -36,7 +34,7 @@ Feature: Repository metric results @@ -36,7 +34,7 @@ Feature: Repository metric results
36 And I ask for the module result of the given processing 34 And I ask for the module result of the given processing
37 And I ask for the metric results of the given module result 35 And I ask for the metric results of the given module result
38 When I visit the repository show page 36 When I visit the repository show page
39 - And I click the "Metric Results" h3 37 + And I click the "Tree Metric Results" h3
40 And I see a sample metric's name 38 And I see a sample metric's name
41 Then I should see "Missing range" 39 Then I should see "Missing range"
42 40
@@ -50,8 +48,8 @@ Feature: Repository metric results @@ -50,8 +48,8 @@ Feature: Repository metric results
50 And I start to process that repository 48 And I start to process that repository
51 And I wait up for a error processing 49 And I wait up for a error processing
52 When I visit the repository show page 50 When I visit the repository show page
53 - And I click the "Metric Results" h3  
54 - Then I should see "Repository process returned with error. There are no metric results." 51 + And I click the "Tree Metric Results" h3
  52 + Then I should see "Repository process returned with error. There are no tree metric results."
55 53
56 # TODO: Scenario: Should show the graphic of a given metric 54 # TODO: Scenario: Should show the graphic of a given metric
57 # It was getting really difficult to test this because of Poltergeist's timeouts 55 # It was getting really difficult to test this because of Poltergeist's timeouts
features/repository/show/modules_tree.feature
@@ -36,14 +36,12 @@ Feature: Repository modules tree @@ -36,14 +36,12 @@ Feature: Repository modules tree
36 And I should see "Granularity" 36 And I should see "Granularity"
37 And I should see "Grade" 37 And I should see "Grade"
38 38
39 - # This test is broken under analizo 1.17.0: https://www.pivotaltracker.com/story/show/80377258  
40 - @wip @kalibro_configuration_restart @kalibro_processor_restart @javascript 39 + @kalibro_configuration_restart @kalibro_processor_restart @javascript
41 Scenario: Module navigation 40 Scenario: Module navigation
42 Given I am a regular user 41 Given I am a regular user
43 And I am signed in 42 And I am signed in
44 - And I have a sample project  
45 - And I have a sample configuration with native metrics  
46 - And I have a sample repository within the sample project 43 + And I have a sample configuration with ruby native metrics
  44 + And I have a sample repository
47 And I start to process that repository 45 And I start to process that repository
48 And I wait up for a ready processing 46 And I wait up for a ready processing
49 And I ask for the last ready processing of the given repository 47 And I ask for the last ready processing of the given repository
@@ -66,4 +64,5 @@ Feature: Repository modules tree @@ -66,4 +64,5 @@ Feature: Repository modules tree
66 And I ask for the module result of the given processing 64 And I ask for the module result of the given processing
67 When I visit the repository show page 65 When I visit the repository show page
68 And I click the "Modules Tree" h3 66 And I click the "Modules Tree" h3
  67 + And I take a picture of the page
69 Then I should see the given module result 68 Then I should see the given module result
features/repository/show/repository_info.feature
@@ -40,7 +40,7 @@ Feature: Show Repository @@ -40,7 +40,7 @@ Feature: Show Repository
40 And I should see "AGGREGATING time" 40 And I should see "AGGREGATING time"
41 And I should see "CALCULATING time" 41 And I should see "CALCULATING time"
42 And I should see "INTERPRETING time" 42 And I should see "INTERPRETING time"
43 - When I click the "Metric Results" h3 43 + When I click the "Tree Metric Results" h3
44 And I click the "Modules Tree" h3 44 And I click the "Modules Tree" h3
45 Then I should see "Metric" 45 Then I should see "Metric"
46 And I should see "Value" 46 And I should see "Value"
@@ -67,7 +67,7 @@ Feature: Show Repository @@ -67,7 +67,7 @@ Feature: Show Repository
67 And I should see "Configuration" 67 And I should see "Configuration"
68 And I should see "State" 68 And I should see "State"
69 And I should see "Creation Date" 69 And I should see "Creation Date"
70 - When I click the "Metric Results" h3 70 + When I click the "Tree Metric Results" h3
71 Then I should see "Loading data. Please, wait." 71 Then I should see "Loading data. Please, wait."
72 When I click the "Modules Tree" h3 72 When I click the "Modules Tree" h3
73 Then I should see "Loading data. Please, wait." 73 Then I should see "Loading data. Please, wait."
features/step_definitions/kalibro_configuration_steps.rb
@@ -13,7 +13,14 @@ end @@ -13,7 +13,14 @@ end
13 Given(/^I have a sample configuration$/) do 13 Given(/^I have a sample configuration$/) do
14 @kalibro_configuration = FactoryGirl.create(:kalibro_configuration) 14 @kalibro_configuration = FactoryGirl.create(:kalibro_configuration)
15 FactoryGirl.create(:kalibro_configuration_attributes, user_id: FactoryGirl.create(:another_user).id, kalibro_configuration_id: @kalibro_configuration.id) 15 FactoryGirl.create(:kalibro_configuration_attributes, user_id: FactoryGirl.create(:another_user).id, kalibro_configuration_id: @kalibro_configuration.id)
  16 +end
16 17
  18 +Given(/^I have a sample configuration with hotspot metrics$/) do
  19 + @kalibro_configuration = FactoryGirl.create(:kalibro_configuration, name: 'Sample Ruby Configuration')
  20 + FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id})
  21 +
  22 + metric_configuration = FactoryGirl.create(:hotspot_metric_configuration,
  23 + { kalibro_configuration_id: @kalibro_configuration.id} )
17 end 24 end
18 25
19 Given(/^I own a sample configuration$/) do 26 Given(/^I own a sample configuration$/) do
@@ -94,4 +101,3 @@ Then(/^the private configuration should not be there$/) do @@ -94,4 +101,3 @@ Then(/^the private configuration should not be there$/) do
94 expect(page).to have_no_content(@private_kc.name) 101 expect(page).to have_no_content(@private_kc.name)
95 expect(page).to have_no_content(@private_kc.description) 102 expect(page).to have_no_content(@private_kc.description)
96 end 103 end
97 -  
features/step_definitions/kalibro_range_steps.rb
1 -Given(/^I have a sample range within the sample metric configuration with beginning "(.*?)"$/) do |beginning| 1 +Given(/^I have a sample range within the sample tree metric configuration with beginning "(.*?)"$/) do |beginning|
2 @kalibro_range = FactoryGirl.create(:kalibro_range, {beginning: beginning, metric_configuration_id: @metric_configuration.id, 2 @kalibro_range = FactoryGirl.create(:kalibro_range, {beginning: beginning, metric_configuration_id: @metric_configuration.id,
3 reading_id: @reading.id}) 3 reading_id: @reading.id})
4 end 4 end
@@ -20,7 +20,7 @@ Given(/^the select field &quot;(.*?)&quot; is set as &quot;(.*?)&quot;$/) do |field, text| @@ -20,7 +20,7 @@ Given(/^the select field &quot;(.*?)&quot; is set as &quot;(.*?)&quot;$/) do |field, text|
20 select text, from: field 20 select text, from: field
21 end 21 end
22 22
23 -Given(/^I have a sample range within the sample metric configuration$/) do 23 +Given(/^I have a sample range within the sample tree metric configuration$/) do
24 @kalibro_range = FactoryGirl.create(:kalibro_range, {metric_configuration_id: @metric_configuration.id, 24 @kalibro_range = FactoryGirl.create(:kalibro_range, {metric_configuration_id: @metric_configuration.id,
25 reading_id: @reading.id}) 25 reading_id: @reading.id})
26 end 26 end
features/step_definitions/metric_configuration_steps.rb
1 -Given(/^I have a sample metric configuration within the given mezuro configuration$/) do 1 +Given(/^I have a sample tree metric configuration within the given mezuro configuration$/) do
2 @metric_configuration = FactoryGirl.create(:metric_configuration_with_id, 2 @metric_configuration = FactoryGirl.create(:metric_configuration_with_id,
3 {kalibro_configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id} ) 3 {kalibro_configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id} )
4 end 4 end
5 5
  6 +Given(/^I have a sample hotspot metric configuration within the given mezuro configuration$/) do
  7 + @metric_configuration = FactoryGirl.create(:hotspot_metric_configuration,
  8 + kalibro_configuration_id: @kalibro_configuration.id)
  9 +end
  10 +
  11 +
6 Given(/^I have a metric configuration with code "(.*?)" within the given mezuro configuration$/) do |code| 12 Given(/^I have a metric configuration with code "(.*?)" within the given mezuro configuration$/) do |code|
7 @metric_configuration = FactoryGirl.create(:metric_configuration_with_id, 13 @metric_configuration = FactoryGirl.create(:metric_configuration_with_id,
8 {kalibro_configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id, metric: FactoryGirl.build(:metric, code: code)}) 14 {kalibro_configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id, metric: FactoryGirl.build(:metric, code: code)})
@@ -23,6 +29,16 @@ Given(/^I have a sample configuration with MetricFu metrics$/) do @@ -23,6 +29,16 @@ Given(/^I have a sample configuration with MetricFu metrics$/) do
23 kalibro_configuration_id: @kalibro_configuration.id}) 29 kalibro_configuration_id: @kalibro_configuration.id})
24 end 30 end
25 31
  32 +Given(/^I have a tree metric configuration$/) do
  33 + @tree_metric_configuration = FactoryGirl.create(:metric_configuration_with_id,
  34 + {kalibro_configuration_id: @kalibro_configuration.id, metric: FactoryGirl.build(:hotspot_metric)})
  35 +end
  36 +
  37 +Given(/^I have a hotspot metric configuration$/) do
  38 + @hotspot_metric_configuration = FactoryGirl.create(:metric_configuration_with_id,
  39 + {kalibro_configuration_id: @kalibro_configuration.id, metric: FactoryGirl.build(:pain)})
  40 +end
  41 +
26 When(/^I visit the sample metric configuration edit page$/) do 42 When(/^I visit the sample metric configuration edit page$/) do
27 visit edit_kalibro_configuration_metric_configuration_path(kalibro_configuration_id: @metric_configuration.kalibro_configuration_id, id: @metric_configuration.id) 43 visit edit_kalibro_configuration_metric_configuration_path(kalibro_configuration_id: @metric_configuration.kalibro_configuration_id, id: @metric_configuration.id)
28 end 44 end
@@ -41,12 +57,17 @@ Then(/^I am at the sample metric configuration page$/) do @@ -41,12 +57,17 @@ Then(/^I am at the sample metric configuration page$/) do
41 expect(page).to have_content("Ranges") 57 expect(page).to have_content("Ranges")
42 end 58 end
43 59
44 -Then(/^I should see the sample metric configuration content$/) do 60 +Then(/^I should see the sample tree metric configuration content$/) do
45 expect(page).to have_content(@metric_configuration.metric.name) 61 expect(page).to have_content(@metric_configuration.metric.name)
46 expect(page).to have_content(@metric_configuration.metric.code) 62 expect(page).to have_content(@metric_configuration.metric.code)
47 expect(page).to have_content(@metric_configuration.weight) 63 expect(page).to have_content(@metric_configuration.weight)
48 end 64 end
49 65
  66 +Then(/^I should see the sample hotspot metric configuration content$/) do
  67 + expect(page).to have_content(@metric_configuration.metric.name)
  68 + expect(page).to have_content(@metric_configuration.metric.code)
  69 +end
  70 +
50 Then(/^I should be at metric configuration sample page$/) do 71 Then(/^I should be at metric configuration sample page$/) do
51 expect(page).to have_content(@metric_configuration.metric.name) 72 expect(page).to have_content(@metric_configuration.metric.name)
52 expect(page).to have_content("Ranges") 73 expect(page).to have_content("Ranges")
@@ -56,6 +77,16 @@ Then(/^I should be at the choose metric page$/) do @@ -56,6 +77,16 @@ Then(/^I should be at the choose metric page$/) do
56 expect(page).to have_content("Choose a metric from a Base Tool:") 77 expect(page).to have_content("Choose a metric from a Base Tool:")
57 end 78 end
58 79
  80 +Then(/^the tree configuration should be there$/) do
  81 + expect(page).to have_content(@tree_metric_configuration.metric.name)
  82 + expect(page).to have_content(@tree_metric_configuration.metric.code)
  83 +end
  84 +
  85 +Then(/^the hotspot configuration should be there$/) do
  86 + expect(page).to have_content(@hotspot_metric_configuration.metric.name)
  87 + expect(page).to have_content(@hotspot_metric_configuration.metric.code)
  88 +end
  89 +
59 When(/^I click destroy Metric Configuration$/) do 90 When(/^I click destroy Metric Configuration$/) do
60 - find('#metrics').first(:link, "Destroy").click 91 + find('#tree_metrics').first(:link, "Destroy").click
61 end 92 end
features/step_definitions/project_steps.rb
@@ -50,6 +50,10 @@ Then(/^I should not see (.+) within (.+)$/) do |text, selector| @@ -50,6 +50,10 @@ Then(/^I should not see (.+) within (.+)$/) do |text, selector|
50 expect(page.find(selector)).to_not have_content(text) 50 expect(page.find(selector)).to_not have_content(text)
51 end 51 end
52 52
  53 +Then(/^I should not find "(.+)" within "(.+)"$/) do |text, selector|
  54 + step "I should not see #{text} within #{selector}"
  55 +end
  56 +
53 Then(/^the sample project should be there$/) do 57 Then(/^the sample project should be there$/) do
54 expect(page).to have_content(@project.name) 58 expect(page).to have_content(@project.name)
55 expect(page).to have_content(@project.description) 59 expect(page).to have_content(@project.description)
features/step_definitions/repository_steps.rb
@@ -96,7 +96,11 @@ Given(/^I ask for the module result of the given processing$/) do @@ -96,7 +96,11 @@ Given(/^I ask for the module result of the given processing$/) do
96 end 96 end
97 97
98 Given(/^I ask for the metric results of the given module result$/) do 98 Given(/^I ask for the metric results of the given module result$/) do
99 - @metric_results = @module_result.metric_results 99 + @metric_results = @module_result.tree_metric_results
  100 +end
  101 +
  102 +Given(/^I ask for the hotspot metric results of the given module result$/) do
  103 + @metric_results = @module_result.hotspot_metric_results
100 end 104 end
101 105
102 Given(/^I see a sample metric's name$/) do 106 Given(/^I see a sample metric's name$/) do
@@ -220,4 +224,18 @@ Then(/^I should be at the Repositories index$/) do @@ -220,4 +224,18 @@ Then(/^I should be at the Repositories index$/) do
220 expect(page.current_path).to end_with(repositories_path) # We use end_with in order to avoid the language route 224 expect(page.current_path).to end_with(repositories_path) # We use end_with in order to avoid the language route
221 end 225 end
222 226
  227 +Then(/^I should have at least one hotspot metric result$/) do
  228 + expect(@metric_results.count).to be > 0
  229 +end
  230 +
  231 +Then(/^I should see the hotspot metric results messages$/) do
  232 + @metric_results.each do |metric_result|
  233 + expect(page).to have_content(metric_result.message)
  234 + end
  235 +end
223 236
  237 +Then(/^I should see the hotspot metric results file names$/) do
  238 + @metric_results.each do |metric_result|
  239 + expect(page).to have_content(metric_result.module_result.kalibro_module.short_name)
  240 + end
  241 +end
features/support/hooks.rb
@@ -15,3 +15,8 @@ Before do |scenario| @@ -15,3 +15,8 @@ Before do |scenario|
15 15
16 I18n.locale = I18n.default_locale 16 I18n.locale = I18n.default_locale
17 end 17 end
  18 +
  19 +AfterConfiguration do |config|
  20 + KalibroClient::KalibroCucumberHelpers.clean_configurations
  21 + KalibroClient::KalibroCucumberHelpers.clean_processor
  22 +end
features/tree_metric_configuration/create.feature 0 → 100644
@@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
  1 +Feature: Tree Metric Configuration Creation
  2 + In order to register my metric configurations
  3 + As a regular user
  4 + I should be able to create metric configurations
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: Should not create metric configurations without login
  8 + Given I have a sample configuration
  9 + And I am at the Sample Configuration page
  10 + Then I should not see "New Metric Configuration"
  11 +
  12 + @kalibro_configuration_restart @javascript
  13 + Scenario: metric configuration creation
  14 + Given I am a regular user
  15 + And I am signed in
  16 + And I own a sample configuration
  17 + And I have a reading group named "Scholar"
  18 + And I am at the Sample Configuration page
  19 + And I click the Add Metric link
  20 + And I click the "Analizo" h3
  21 + And I click the Total Lines of Code link
  22 + And I fill the Weight field with "2"
  23 + And I set the select field "Aggregation Form" as "Average"
  24 + And I set the select field "Reading Group" as "Scholar"
  25 + When I press the Save button
  26 + Then I should see "Total Lines of Code"
  27 + Then I should see "2"
  28 +
  29 + @kalibro_configuration_restart @javascript
  30 + Scenario: ruby metric configuration creation
  31 + Given I am a regular user
  32 + And I am signed in
  33 + And I own a sample configuration
  34 + And I have a reading group named "Scholar"
  35 + And I am at the Sample Configuration page
  36 + And I click the Add Metric link
  37 + And I click the "MetricFu" h3
  38 + And I click the Pain link
  39 + And I fill the Weight field with "2"
  40 + And I set the select field "Aggregation Form" as "Average"
  41 + And I set the select field "Reading Group" as "Scholar"
  42 + When I press the Save button
  43 + Then I should see "Pain"
  44 + Then I should see "2"
  45 +
  46 + @kalibro_configuration_restart @javascript
  47 + Scenario: metric configuration creation
  48 + Given I am a regular user
  49 + And I am signed in
  50 + And I own a sample configuration
  51 + And I have a reading group named "Scholar"
  52 + And I am at the Sample Configuration page
  53 + And I click the Add Metric link
  54 + And I click the "Analizo" h3
  55 + And I click the Total Lines of Code link
  56 + When I click the Back link
  57 + Then I should be at the choose metric page
  58 +
  59 + @kalibro_configuration_restart @javascript
  60 + Scenario: compound metric configuration creation with same code
  61 + Given I am a regular user
  62 + And I am signed in
  63 + And I own a sample configuration
  64 + And I have a reading group named "Scholar"
  65 + And I have a metric configuration with code "total_abstract_classes" within the given mezuro configuration
  66 + And I am at the Sample Configuration page
  67 + And I click the Add Metric link
  68 + And I click the "Analizo" h3
  69 + And I click the Total Abstract Classes link
  70 + And I fill the Weight field with "2"
  71 + And I set the select field "Aggregation Form" as "Average"
  72 + And I set the select field "Reading Group" as "Scholar"
  73 + When I press the Save button
  74 + Then I should see "Code must be unique within a kalibro configuration"
  75 +
  76 + @kalibro_configuration_restart @javascript
  77 + Scenario: metric configuration creation with count aggregation form
  78 + Given I am a regular user
  79 + And I am signed in
  80 + And I own a sample configuration
  81 + And I have a reading group named "Scholar"
  82 + And I am at the Sample Configuration page
  83 + And I click the Add Metric link
  84 + And I click the "Analizo" h3
  85 + And I click the Lines of Code link
  86 + And I fill the Weight field with "100"
  87 + And I set the select field "Aggregation Form" as "Count"
  88 + And I set the select field "Reading Group" as "Scholar"
  89 + When I press the Save button
  90 + Then I should see "Lines of Code"
  91 + Then I should see "100"
features/tree_metric_configuration/delete.feature 0 → 100644
@@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
  1 +Feature: Metric Configuration Deletion
  2 + In order to be able to remove metric configuration
  3 + As a regular user
  4 + The system should have an interface to it
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: Should delete a metric configuration that I own
  8 + Given I am a regular user
  9 + And I am signed in
  10 + And I own a sample configuration
  11 + And I have a sample reading group
  12 + And I have a sample tree metric configuration within the given mezuro configuration
  13 + When I am at the Sample Configuration page
  14 + And I click destroy Metric Configuration
  15 + Then I should see "There are no Tree Metric Configurations yet!"
  16 +
  17 + @kalibro_configuration_restart
  18 + Scenario: Should not see the destroy metric configuration link in the mezuro configuration that I not own
  19 + Given I am a regular user
  20 + And I am signed in
  21 + And I have a sample configuration
  22 + And I have a sample reading group
  23 + And I have a sample tree metric configuration within the given mezuro configuration
  24 + When I am at the Sample Configuration page
  25 + Then I should not see "Destroy"
features/tree_metric_configuration/edition.feature 0 → 100644
@@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
  1 +Feature: Metric Configuration edition
  2 + In order to interact with metric configurations
  3 + As a regular user
  4 + I should edit the informations of metric configurations
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: the configuration is not mine
  8 + Given I am a regular user
  9 + And I am signed in
  10 + And I have a sample configuration
  11 + And I have a sample reading group
  12 + And I have a sample tree metric configuration within the given mezuro configuration
  13 + When I am at the Sample Configuration page
  14 + Then I should not see Edit within table#tree_metric_configurations
  15 +
  16 + @kalibro_configuration_restart
  17 + Scenario: editing a metric configuration successfully
  18 + Given I am a regular user
  19 + And I am signed in
  20 + And I own a sample configuration
  21 + And I have a sample reading group
  22 + And I have a sample tree metric configuration within the given mezuro configuration
  23 + And I am at the Sample Configuration page
  24 + When I click the Edit link
  25 + And I fill the Weight field with "3.0"
  26 + And I press the Save button
  27 + Then I should see "3.0"
  28 +
  29 + @kalibro_configuration_restart
  30 + Scenario: trying to edit with blank fields
  31 + Given I am a regular user
  32 + And I am signed in
  33 + And I own a sample configuration
  34 + And I have a sample reading group
  35 + And I have a sample tree metric configuration within the given mezuro configuration
  36 + When I visit the sample metric configuration edit page
  37 + And I fill the Weight field with " "
  38 + And I press the Save button
  39 + Then I should see "Weight must be greater than 0"
  40 +
  41 + @kalibro_configuration_restart
  42 + Scenario: Should not edit a metric configuration with invalid weight
  43 + Given I am a regular user
  44 + And I am signed in
  45 + And I own a sample configuration
  46 + And I have a sample reading group
  47 + And I have a sample tree metric configuration within the given mezuro configuration
  48 + When I visit the sample metric configuration edit page
  49 + And I fill the Weight field with "0"
  50 + And I set the select field "Aggregation Form" as "Median"
  51 + When I press the Save button
  52 + Then I should see "Weight must be greater than 0"
features/tree_metric_configuration/listing.feature 0 → 100644
@@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
  1 +Feature: Metric Configuration listing
  2 + In order to interact with metric configurations
  3 + As a regular user
  4 + I should see the metric configurations of a given configuration
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: When there are no tree metric configurations
  8 + Given I have a sample configuration
  9 + When I am at the Sample Configuration page
  10 + Then I should see "Metric"
  11 + And I should see "Code"
  12 + And I should see "Weight"
  13 + And I should see "There are no Tree Metric Configurations yet!"
  14 +
  15 + @kalibro_configuration_restart
  16 + Scenario: When there are tree metric configurations and no hotspot metric configurations
  17 + Given I have a sample configuration
  18 + And I have a sample reading group
  19 + And I have a sample tree metric configuration within the given mezuro configuration
  20 + When I am at the Sample Configuration page
  21 + Then I should see the sample tree metric configuration content
  22 + And I should see "There are no Hotspot Metric Configurations yet!"
  23 +
  24 + @kalibro_configuration_restart
  25 + Scenario: I should see the add metric link when I am the owner of the given configuration
  26 + Given I am a regular user
  27 + And I am signed in
  28 + And I own a sample configuration
  29 + When I am at the Sample Configuration page
  30 + Then I should see "Add Metric"
  31 +
  32 + @kalibro_configuration_restart
  33 + Scenario: I should not see the add metric link when I am at a given configuration page
  34 + Given I am a regular user
  35 + And I am signed in
  36 + And I have a sample configuration
  37 + When I am at the Sample Configuration page
  38 + Then I should not see "Add Metric"
features/tree_metric_configuration/show.feature 0 → 100644
@@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
  1 +Feature: Show Metric Configuration
  2 + In order to know all the metric configurations of the given configuration and its contents
  3 + As a regular user
  4 + I should be able to see each of them
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: Checking metric configuration show link
  8 + Given I have a sample configuration
  9 + And I have a sample reading group
  10 + And I have a sample reading within the sample reading group labeled "My Reading"
  11 + And I have a sample tree metric configuration within the given mezuro configuration
  12 + And I have a sample range within the sample tree metric configuration
  13 + When I am at the Sample Configuration page
  14 + And I click the Show link
  15 + Then I should be at metric configuration sample page
  16 + And I should see the sample range
  17 +
  18 + @kalibro_configuration_restart @javascript
  19 + Scenario: When there's a range created and I want to see its comments
  20 + Given I have a sample configuration
  21 + And I have a sample reading group
  22 + And I have a sample reading within the sample reading group labeled "My Reading"
  23 + And I have a sample tree metric configuration within the given mezuro configuration
  24 + And I have a sample range within the sample tree metric configuration
  25 + And I am at the sample metric configuration page
  26 + When I click the "comment-icon" icon
  27 + Then I should see "Comment"
  28 +
spec/controllers/compound_metric_configurations_controller_spec.rb
@@ -43,6 +43,7 @@ describe CompoundMetricConfigurationsController, :type =&gt; :controller do @@ -43,6 +43,7 @@ describe CompoundMetricConfigurationsController, :type =&gt; :controller do
43 context 'when the current user owns the reading group' do 43 context 'when the current user owns the reading group' do
44 before :each do 44 before :each do
45 subject.expects(:kalibro_configuration_owner?).returns true 45 subject.expects(:kalibro_configuration_owner?).returns true
  46 + Rails.cache.expects(:delete).with("#{kalibro_configuration.id}_tree_metric_configurations")
46 end 47 end
47 48
48 context 'with valid fields' do 49 context 'with valid fields' do
@@ -134,6 +135,7 @@ describe CompoundMetricConfigurationsController, :type =&gt; :controller do @@ -134,6 +135,7 @@ describe CompoundMetricConfigurationsController, :type =&gt; :controller do
134 context 'when user owns the metric configuration' do 135 context 'when user owns the metric configuration' do
135 before :each do 136 before :each do
136 subject.expects(:metric_configuration_owner?).returns true 137 subject.expects(:metric_configuration_owner?).returns true
  138 + Rails.cache.expects(:delete).with("#{kalibro_configuration.id}_tree_metric_configurations")
137 end 139 end
138 140
139 context 'with valid fields' do 141 context 'with valid fields' do
@@ -170,5 +172,4 @@ describe CompoundMetricConfigurationsController, :type =&gt; :controller do @@ -170,5 +172,4 @@ describe CompoundMetricConfigurationsController, :type =&gt; :controller do
170 end 172 end
171 end 173 end
172 end 174 end
173 -  
174 end 175 end
spec/controllers/kalibro_configurations_controller_spec.rb
@@ -73,7 +73,8 @@ describe KalibroConfigurationsController, :type =&gt; :controller do @@ -73,7 +73,8 @@ describe KalibroConfigurationsController, :type =&gt; :controller do
73 let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } 73 let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
74 74
75 before :each do 75 before :each do
76 - kalibro_configuration.expects(:metric_configurations).returns(metric_configuration) 76 + kalibro_configuration.expects(:tree_metric_configurations).returns([metric_configuration])
  77 + kalibro_configuration.expects(:hotspot_metric_configurations).returns([])
77 KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) 78 KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration)
78 79
79 get :show, :id => kalibro_configuration.id 80 get :show, :id => kalibro_configuration.id
spec/controllers/modules_controller_spec.rb
@@ -16,7 +16,7 @@ describe ModulesController, :type =&gt; :controller do @@ -16,7 +16,7 @@ describe ModulesController, :type =&gt; :controller do
16 let (:module_id){ 1 } 16 let (:module_id){ 1 }
17 let (:metric_name ){ FactoryGirl.build(:loc).name } 17 let (:metric_name ){ FactoryGirl.build(:loc).name }
18 let (:date ){ DateTime.parse("2011-10-20T18:26:43.151+00:00") } 18 let (:date ){ DateTime.parse("2011-10-20T18:26:43.151+00:00") }
19 - let (:metric_result){ FactoryGirl.build(:metric_result) } 19 + let (:tree_metric_result){ FactoryGirl.build(:tree_metric_result) }
20 let! (:module_result){ FactoryGirl.build(:module_result) } 20 let! (:module_result){ FactoryGirl.build(:module_result) }
21 21
22 before :each do 22 before :each do
@@ -29,4 +29,4 @@ describe ModulesController, :type =&gt; :controller do @@ -29,4 +29,4 @@ describe ModulesController, :type =&gt; :controller do
29 it { is_expected.to respond_with(:success) } 29 it { is_expected.to respond_with(:success) }
30 it { is_expected.to render_template(:metric_history) } 30 it { is_expected.to render_template(:metric_history) }
31 end 31 end
32 -end  
33 \ No newline at end of file 32 \ No newline at end of file
  33 +end
spec/factories/date_metric_results.rb 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +FactoryGirl.define do
  2 + factory :date_metric_result, class: KalibroClient::Entities::Miscellaneous::DateMetricResult do
  3 + date '2011-10-20T18:26:43.151+00:00'
  4 +
  5 + # FIXME: A DateMetricResult should be able to create either a TreeMetricResult or a HotspotMetricResult based on
  6 + # the arguments passed to it
  7 + metric_result_attributes { FactoryGirl.attributes_for(:tree_metric_result).except(:aggregated_value) }
  8 +
  9 + initialize_with { new('date' => date, 'metric_result' => metric_result_attributes) }
  10 + end
  11 +end
spec/factories/kalibro_modules.rb
1 FactoryGirl.define do 1 FactoryGirl.define do
2 factory :kalibro_module, class: KalibroClient::Entities::Processor::KalibroModule do 2 factory :kalibro_module, class: KalibroClient::Entities::Processor::KalibroModule do
3 name 'Qt-Calculator' 3 name 'Qt-Calculator'
4 - granlrty 'SOFTWARE' 4 + granularity 'SOFTWARE'
5 5
6 trait :package do 6 trait :package do
7 - granlrty 'PACKAGE' 7 + granularity 'PACKAGE'
8 end 8 end
9 9
10 trait :class do 10 trait :class do
11 - granlrty 'CLASS' 11 + granularity 'CLASS'
12 end 12 end
13 13
14 trait :function do 14 trait :function do
15 - granlrty 'FUNCTION' 15 + granularity 'FUNCTION'
16 end 16 end
17 17
18 trait :method do 18 trait :method do
19 - granlrty 'METHOD' 19 + granularity 'METHOD'
20 end 20 end
21 21
22 factory :kalibro_module_package, traits: [:package] 22 factory :kalibro_module_package, traits: [:package]
spec/factories/metric_configurations.rb
@@ -2,7 +2,7 @@ FactoryGirl.define do @@ -2,7 +2,7 @@ FactoryGirl.define do
2 factory :metric_configuration, class: MetricConfiguration do 2 factory :metric_configuration, class: MetricConfiguration do
3 metric {FactoryGirl.build(:metric, code: 'total_abstract_classes')} 3 metric {FactoryGirl.build(:metric, code: 'total_abstract_classes')}
4 weight 1 4 weight 1
5 - aggregation_form "AVERAGE" 5 + aggregation_form "MEAN"
6 reading_group_id 1 6 reading_group_id 1
7 kalibro_configuration_id 1 7 kalibro_configuration_id 1
8 8
@@ -35,4 +35,8 @@ FactoryGirl.define do @@ -35,4 +35,8 @@ FactoryGirl.define do
35 kalibro_configuration_id 1 35 kalibro_configuration_id 1
36 end 36 end
37 37
  38 + factory :hotspot_metric_configuration, class: MetricConfiguration do
  39 + metric { FactoryGirl.build(:hotspot_metric) }
  40 + kalibro_configuration_id 1
  41 + end
38 end 42 end
spec/factories/metric_results.rb
@@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
1 -# This file is part of KalibroEntities  
2 -# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)  
3 -#  
4 -# This program is free software: you can redistribute it and/or modify  
5 -# it under the terms of the GNU General Public License as published by  
6 -# the Free Software Foundation, either version 3 of the License, or  
7 -# (at your option) any later version.  
8 -#  
9 -# This program is distributed in the hope that it will be useful,  
10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of  
11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
12 -# GNU General Public License for more details.  
13 -  
14 -# You should have received a copy of the GNU General Public License  
15 -# along with this program. If not, see <http://www.gnu.org/licenses/>.  
16 -  
17 -FactoryGirl.define do  
18 - factory :metric_result, class: KalibroClient::Entities::Processor::MetricResult do  
19 - id "42"  
20 - metric_configuration { FactoryGirl.build(:metric_configuration_with_id) }  
21 - value "10.0"  
22 - aggregated_value "21"  
23 - end  
24 -end  
spec/factories/metrics.rb
@@ -52,4 +52,14 @@ FactoryGirl.define do @@ -52,4 +52,14 @@ FactoryGirl.define do
52 52
53 initialize_with { new(name, code, scope, script) } 53 initialize_with { new(name, code, scope, script) }
54 end 54 end
  55 +
  56 + factory :hotspot_metric, class: KalibroClient::Entities::Miscellaneous::HotspotMetric do
  57 + name "Flay"
  58 + code "flay"
  59 + description ""
  60 + metric_collector_name "MetricFu"
  61 + languages nil
  62 +
  63 + initialize_with { new(name, code, languages, metric_collector_name) }
  64 + end
55 end 65 end
spec/factories/tree_metric_results.rb 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +# This file is part of KalibroEntities
  2 +# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
  3 +#
  4 +# This program is free software: you can redistribute it and/or modify
  5 +# it under the terms of the GNU General Public License as published by
  6 +# the Free Software Foundation, either version 3 of the License, or
  7 +# (at your option) any later version.
  8 +#
  9 +# This program is distributed in the hope that it will be useful,
  10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 +# GNU General Public License for more details.
  13 +
  14 +# You should have received a copy of the GNU General Public License
  15 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  16 +
  17 +FactoryGirl.define do
  18 + factory :tree_metric_result, class: KalibroClient::Entities::Processor::TreeMetricResult do
  19 + id "42"
  20 + metric_configuration { FactoryGirl.build(:metric_configuration_with_id) }
  21 + value "10.0"
  22 + aggregated_value "21"
  23 + end
  24 +end
spec/helpers/processings_helper_spec.rb
@@ -19,10 +19,10 @@ describe ProcessingsHelper, :type =&gt; :helper do @@ -19,10 +19,10 @@ describe ProcessingsHelper, :type =&gt; :helper do
19 19
20 describe 'find_range_snapshot' do 20 describe 'find_range_snapshot' do
21 let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id)} 21 let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id)}
22 - let(:metric_result) { FactoryGirl.build(:metric_result, {value: 6.0, metric_configuration: metric_configuration})} 22 + let(:tree_metric_result) { FactoryGirl.build(:tree_metric_result, {value: 6.0, metric_configuration: metric_configuration})}
23 23
24 before :each do 24 before :each do
25 - metric_result.expects(:metric_configuration).returns(metric_configuration) 25 + tree_metric_result.expects(:metric_configuration).returns(metric_configuration)
26 metric_configuration.expects(:kalibro_ranges).returns(range_snapshots) 26 metric_configuration.expects(:kalibro_ranges).returns(range_snapshots)
27 end 27 end
28 28
@@ -30,7 +30,7 @@ describe ProcessingsHelper, :type =&gt; :helper do @@ -30,7 +30,7 @@ describe ProcessingsHelper, :type =&gt; :helper do
30 let!(:range_snapshots) { [make_range(1.0, 5.0), make_range(5.1, 10.0), make_range(10.1, 15.0)] } 30 let!(:range_snapshots) { [make_range(1.0, 5.0), make_range(5.1, 10.0), make_range(10.1, 15.0)] }
31 31
32 it 'should return the range snapshot which contains the value' do 32 it 'should return the range snapshot which contains the value' do
33 - expect(helper.find_range_snapshot(metric_result)).to eq(range_snapshots[1]) 33 + expect(helper.find_range_snapshot(tree_metric_result)).to eq(range_snapshots[1])
34 end 34 end
35 end 35 end
36 36
@@ -38,7 +38,7 @@ describe ProcessingsHelper, :type =&gt; :helper do @@ -38,7 +38,7 @@ describe ProcessingsHelper, :type =&gt; :helper do
38 let!(:range_snapshots) { [make_range('-INF', 0.0), make_range(0, 'INF')] } 38 let!(:range_snapshots) { [make_range('-INF', 0.0), make_range(0, 'INF')] }
39 39
40 it 'should return the range snapshot which contains the value' do 40 it 'should return the range snapshot which contains the value' do
41 - expect(helper.find_range_snapshot(metric_result)).to eq(range_snapshots[1]) 41 + expect(helper.find_range_snapshot(tree_metric_result)).to eq(range_snapshots[1])
42 end 42 end
43 end 43 end
44 44
@@ -46,7 +46,7 @@ describe ProcessingsHelper, :type =&gt; :helper do @@ -46,7 +46,7 @@ describe ProcessingsHelper, :type =&gt; :helper do
46 let!(:range_snapshots) { [make_range('-INF', 'INF')] } 46 let!(:range_snapshots) { [make_range('-INF', 'INF')] }
47 47
48 it 'should return the range snapshot which contains the value' do 48 it 'should return the range snapshot which contains the value' do
49 - expect(helper.find_range_snapshot(metric_result)).to eq(range_snapshots[0]) 49 + expect(helper.find_range_snapshot(tree_metric_result)).to eq(range_snapshots[0])
50 end 50 end
51 end 51 end
52 52
@@ -54,7 +54,7 @@ describe ProcessingsHelper, :type =&gt; :helper do @@ -54,7 +54,7 @@ describe ProcessingsHelper, :type =&gt; :helper do
54 let!(:range_snapshots) { [make_range('-INF', 6.0), make_range(6.1, 'INF')] } 54 let!(:range_snapshots) { [make_range('-INF', 6.0), make_range(6.1, 'INF')] }
55 55
56 it 'should return nil' do 56 it 'should return nil' do
57 - expect(helper.find_range_snapshot(metric_result)).to be_nil 57 + expect(helper.find_range_snapshot(tree_metric_result)).to be_nil
58 end 58 end
59 end 59 end
60 60
spec/models/kalibro_configuration_spec.rb
@@ -87,6 +87,7 @@ describe KalibroConfiguration, :type =&gt; :model do @@ -87,6 +87,7 @@ describe KalibroConfiguration, :type =&gt; :model do
87 it 'is expected to clean the attributes memoization' do 87 it 'is expected to clean the attributes memoization' do
88 # Call attributes once so it memoizes 88 # Call attributes once so it memoizes
89 KalibroConfigurationAttributes.expects(:find_by).with(kalibro_configuration_id: kalibro_configuration.id).returns(kalibro_configuration_attributes) 89 KalibroConfigurationAttributes.expects(:find_by).with(kalibro_configuration_id: kalibro_configuration.id).returns(kalibro_configuration_attributes)
  90 + KalibroClient::Entities::Configurations::KalibroConfiguration.any_instance.expects(:destroy).returns(kalibro_configuration)
90 expect(kalibro_configuration.attributes).to eq(kalibro_configuration_attributes) 91 expect(kalibro_configuration.attributes).to eq(kalibro_configuration_attributes)
91 92
92 # Destroying 93 # Destroying
spec/models/module_result_spec.rb
@@ -5,19 +5,19 @@ describe ModuleResult, :type =&gt; :model do @@ -5,19 +5,19 @@ describe ModuleResult, :type =&gt; :model do
5 subject { FactoryGirl.build(:module_result) } 5 subject { FactoryGirl.build(:module_result) }
6 6
7 describe 'metric_history' do 7 describe 'metric_history' do
8 - let(:date_module_result) {FactoryGirl.build(:date_module_result)} 8 + let(:date_metric_result) {FactoryGirl.build(:date_metric_result)}
9 let(:metric_configuration) { FactoryGirl.build(:another_metric_configuration_with_id) } 9 let(:metric_configuration) { FactoryGirl.build(:another_metric_configuration_with_id) }
10 - let!(:metric_result) { FactoryGirl.build(:metric_result, metric_configuration: metric_configuration) } 10 + let!(:tree_metric_result) { FactoryGirl.build(:tree_metric_result, metric_configuration: metric_configuration) }
11 let(:processing) {FactoryGirl.build(:processing)} 11 let(:processing) {FactoryGirl.build(:processing)}
12 12
13 before :each do 13 before :each do
14 subject.expects(:processing).returns(processing) 14 subject.expects(:processing).returns(processing)
15 - date_module_result.expects(:metric_result).returns(metric_result)  
16 - KalibroClient::Entities::Processor::MetricResult.expects(:history_of).with(metric_configuration.metric.name, subject.id, processing.repository_id).returns([date_module_result]) 15 + date_metric_result.expects(:metric_result).returns(tree_metric_result)
  16 + KalibroClient::Entities::Processor::TreeMetricResult.expects(:history_of).with(metric_configuration.metric.name, subject.id, processing.repository_id).returns([date_metric_result])
17 end 17 end
18 18
19 it 'should return the history for the given metric name' do 19 it 'should return the history for the given metric name' do
20 - expect(subject.metric_history(metric_configuration.metric.name)).to eq({date_module_result.date => metric_result.value}) 20 + expect(subject.metric_history(metric_configuration.metric.name)).to eq({date_metric_result.date => tree_metric_result.value})
21 end 21 end
22 end 22 end
23 end 23 end
spec/models/project_spec.rb
@@ -54,6 +54,7 @@ describe Project, :type =&gt; :model do @@ -54,6 +54,7 @@ describe Project, :type =&gt; :model do
54 it 'is expected to clean the attributes memoization' do 54 it 'is expected to clean the attributes memoization' do
55 # Call attributes once so it memoizes 55 # Call attributes once so it memoizes
56 ProjectAttributes.expects(:find_by).with(project_id: project.id).returns(project_attributes) 56 ProjectAttributes.expects(:find_by).with(project_id: project.id).returns(project_attributes)
  57 + KalibroClient::Entities::Processor::Project.any_instance.expects(:destroy).returns(project)
57 expect(project.attributes).to eq(project_attributes) 58 expect(project.attributes).to eq(project_attributes)
58 59
59 # Destroying 60 # Destroying
spec/models/reading_group_spec.rb
@@ -61,6 +61,7 @@ describe ReadingGroup, :type =&gt; :model do @@ -61,6 +61,7 @@ describe ReadingGroup, :type =&gt; :model do
61 it 'is expected to clean the attributes memoization' do 61 it 'is expected to clean the attributes memoization' do
62 # Call attributes once so it memoizes 62 # Call attributes once so it memoizes
63 ReadingGroupAttributes.expects(:find_by).with(reading_group_id: reading_group.id).returns(reading_group_attributes) 63 ReadingGroupAttributes.expects(:find_by).with(reading_group_id: reading_group.id).returns(reading_group_attributes)
  64 + KalibroClient::Entities::Configurations::ReadingGroup.any_instance.expects(:destroy).returns(reading_group)
64 expect(reading_group.attributes).to eq(reading_group_attributes) 65 expect(reading_group.attributes).to eq(reading_group_attributes)
65 66
66 # Destroying 67 # Destroying