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 | 1 | class Module.Tree |
| 2 | 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 | 5 | $('div#module_tree').html(loading_html) |
| 4 | 6 | $('div#metric_results').html(loading_html) |
| 7 | + $('div#hotspot_metric_results').html(loading_html) | |
| 5 | 8 | $.post Routes.module_tree_path(module_id) | ... | ... |
| ... | ... | @@ -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 | 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 | 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
features/repository/show/hotspot_metric_results.feature
| ... | ... | @@ -3,6 +3,22 @@ Feature: Repository hotspot metric results |
| 3 | 3 | As a regular user |
| 4 | 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 | 22 | @kalibro_configuration_restart @kalibro_processor_restart @javascript |
| 7 | 23 | Scenario: Should show the error message when the process fails |
| 8 | 24 | Given I am a regular user | ... | ... |
features/step_definitions/kalibro_configuration_steps.rb
| ... | ... | @@ -13,7 +13,14 @@ end |
| 13 | 13 | Given(/^I have a sample configuration$/) do |
| 14 | 14 | @kalibro_configuration = FactoryGirl.create(:kalibro_configuration) |
| 15 | 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 | 24 | end |
| 18 | 25 | |
| 19 | 26 | Given(/^I own a sample configuration$/) do |
| ... | ... | @@ -94,4 +101,3 @@ Then(/^the private configuration should not be there$/) do |
| 94 | 101 | expect(page).to have_no_content(@private_kc.name) |
| 95 | 102 | expect(page).to have_no_content(@private_kc.description) |
| 96 | 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 | 99 | @metric_results = @module_result.tree_metric_results |
| 100 | 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 | 106 | Given(/^I see a sample metric's name$/) do |
| 103 | 107 | expect(page).to have_content(@metric_results.first.metric_configuration.metric.name) |
| 104 | 108 | end |
| ... | ... | @@ -219,5 +223,3 @@ end |
| 219 | 223 | Then(/^I should be at the Repositories index$/) do |
| 220 | 224 | expect(page.current_path).to end_with(repositories_path) # We use end_with in order to avoid the language route |
| 221 | 225 | end |
| 222 | - | |
| 223 | - | ... | ... |
spec/factories/metric_configurations.rb
spec/factories/metrics.rb
| ... | ... | @@ -52,4 +52,14 @@ FactoryGirl.define do |
| 52 | 52 | |
| 53 | 53 | initialize_with { new(name, code, scope, script) } |
| 54 | 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 | 65 | end | ... | ... |