Commit ce8d39f96d6e45e32cdda4dd2e7f15a149c313e5
Committed by
Heitor
1 parent
4461895c
Exists in
colab
and in
4 other branches
Add the structure to display hotspot metric results
* WIP: cucumber feature to show hotspot metric results * Add partials to list hotspot metric results * Add necessary JS to render the list of hotspot metric results on the right place div of the accordion * Translations specific to hotspot metric results * HotspotMetric and HotspotMetricConfiguration factories Signed off by: Eduardo Silva Araújo <duduktamg@hotmail.com>
Showing
11 changed files
with
70 additions
and
4 deletions
Show diff stats
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) |
| @@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
| 1 | +<table class="table table-hover metric_results"> | ||
| 2 | + <thead> | ||
| 3 | + <tr> | ||
| 4 | + <th><%= t('activemodel.attributes.hotspot_metric_result.line') %></th> | ||
| 5 | + <th><%= t('activemodel.attributes.hotspot_metric_result.message') %></th> | ||
| 6 | + </tr> | ||
| 7 | + </thead> | ||
| 8 | + | ||
| 9 | + <tbody> | ||
| 10 | + <% cache("#{@root_module_result.id}_hotspot_results") do %> | ||
| 11 | + <%= render partial: 'hotspot_metric_result', collection: @root_module_result.hotspot_metric_results, locals: {module_result: @root_module_result} %> | ||
| 12 | + <% end %> | ||
| 13 | + </tbody> | ||
| 14 | +</table> |
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") %>'); |
config/locales/views/metric_results/en.yml
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" |
features/repository/show/hotspot_metric_results.feature
| @@ -3,6 +3,22 @@ Feature: Repository hotspot metric results | @@ -3,6 +3,22 @@ Feature: Repository hotspot metric results | ||
| 3 | As a regular user | 3 | As a regular user |
| 4 | I should see the hotspot metric results list | 4 | I should see the hotspot metric results list |
| 5 | 5 | ||
| 6 | + @kalibro_configuration_restart @kalibro_processor_restart @javascript @wip | ||
| 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 have a sample project | ||
| 11 | + And I have a sample configuration with hotspot metrics | ||
| 12 | + And I have a sample ruby repository within the sample project | ||
| 13 | + And I start to process that repository | ||
| 14 | + And I wait up for a ready processing | ||
| 15 | + And I ask for the last ready processing of the given repository | ||
| 16 | + And I ask for the module result of the given processing | ||
| 17 | + And I ask for the hotspot metric results of the given module result | ||
| 18 | + When I visit the repository show page | ||
| 19 | + And I click the "Hotspot Metric Results" h3 | ||
| 20 | + Then I should see a list of hotspot metric results | ||
| 21 | + | ||
| 6 | @kalibro_configuration_restart @kalibro_processor_restart @javascript | 22 | @kalibro_configuration_restart @kalibro_processor_restart @javascript |
| 7 | Scenario: Should show the error message when the process fails | 23 | Scenario: Should show the error message when the process fails |
| 8 | Given I am a regular user | 24 | Given I am a regular user |
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/repository_steps.rb
| @@ -99,6 +99,10 @@ Given(/^I ask for the metric results of the given module result$/) do | @@ -99,6 +99,10 @@ Given(/^I ask for the metric results of the given module result$/) do | ||
| 99 | @metric_results = @module_result.tree_metric_results | 99 | @metric_results = @module_result.tree_metric_results |
| 100 | end | 100 | end |
| 101 | 101 | ||
| 102 | +Given(/^I ask for the hotspot metric results of the given module result$/) do | ||
| 103 | + @metric_results = @module_result.hotspot_metric_results | ||
| 104 | +end | ||
| 105 | + | ||
| 102 | Given(/^I see a sample metric's name$/) do | 106 | Given(/^I see a sample metric's name$/) do |
| 103 | expect(page).to have_content(@metric_results.first.metric_configuration.metric.name) | 107 | expect(page).to have_content(@metric_results.first.metric_configuration.metric.name) |
| 104 | end | 108 | end |
| @@ -219,5 +223,3 @@ end | @@ -219,5 +223,3 @@ end | ||
| 219 | Then(/^I should be at the Repositories index$/) do | 223 | 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 | - | ||
| 223 | - |
spec/factories/metric_configurations.rb
| @@ -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/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 |