Commit 54a3b38bdf90e5eff70cc7e146040c3339e44dc3

Authored by Rafael Manzo
1 parent 1cde6449

Repository show page almost fully functional

We are missing the date selection and metric history features (which were wiped on cucumber)

kalibro_client was updated
Waiting for PR: https://github.com/mezuro/kalibro_processor/pull/76
Which is expected to fix the metric history graph

Signed off by: Daniel Paulino Alves <danpaulalves@gmail.com>
Signed off by: Heitor Reis Ribeiro <marcheing@gmail.com>
1 GIT 1 GIT
2 remote: https://github.com/mezuro/kalibro_client 2 remote: https://github.com/mezuro/kalibro_client
3 - revision: 00079f05f96c12afe78003ed49f40cb3e404ed0c 3 + revision: 24ea5d64efd7f55515f6e062a6c050186010ff5b
4 specs: 4 specs:
5 kalibro_client (0.0.1) 5 kalibro_client (0.0.1)
6 activesupport (>= 2.2.1) 6 activesupport (>= 2.2.1)
app/models/repository.rb
1 class Repository < KalibroClient::Entities::Processor::Repository 1 class Repository < KalibroClient::Entities::Processor::Repository
2 include KalibroRecord 2 include KalibroRecord
3 -  
4 - def last_processing_of  
5 - if has_processing  
6 - last_processing  
7 - else  
8 - nil  
9 - end  
10 - end  
11 end 3 end
app/views/modules/_metric_result.html.erb
1 -<% metric_configuration_snapshot = metric_result.metric_configuration_snapshot %>  
2 -<% unless metric_configuration_snapshot.range_snapshot.nil? %> 1 +<% metric_configuration = metric_result.metric_configuration %>
  2 +<% unless metric_configuration.kalibro_ranges.nil? %>
3 <% range_snapshot = find_range_snapshot(metric_result) 3 <% range_snapshot = find_range_snapshot(metric_result)
4 - metric_name = metric_configuration_snapshot.metric.name 4 + metric_name = metric_configuration.metric.name
5 %> 5 %>
6 <tr> 6 <tr>
7 <td><%= link_to "<i class='icon-align-left'></i> #{metric_name}".html_safe, "", 7 <td><%= link_to "<i class='icon-align-left'></i> #{metric_name}".html_safe, "",
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 remote: true %> 10 remote: true %>
11 </td> 11 </td>
12 <td><%= format_grade(metric_result.value) %></td> 12 <td><%= format_grade(metric_result.value) %></td>
13 - <td><%= metric_configuration_snapshot.weight %></td> 13 + <td><%= metric_configuration.weight %></td>
14 <td><% if range_snapshot.nil? %>Missing range<% else %><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span><% end %></td> 14 <td><% if range_snapshot.nil? %>Missing range<% else %><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span><% end %></td>
15 </tr> 15 </tr>
16 <tr id="container<%= metric_result.id %>" style="display: none"> 16 <tr id="container<%= metric_result.id %>" style="display: none">
app/views/modules/_module_result.html.erb
@@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
5 <% else %> 5 <% else %>
6 <i class="icon-file"></i> 6 <i class="icon-file"></i>
7 <% end %> 7 <% end %>
8 - <%= link_to format_module_name(module_result.module.name), "#module_#{module_result.id}", onClick: "Module.Tree.load('#{escape_javascript(image_tag 'loader.gif')} Loading data. Please, wait.', #{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')} Loading data. Please, wait.', #{module_result.id});" %>
9 </td> 9 </td>
10 - <td><%= module_result.module.granularity %></td> 10 + <td><%= module_result.kalibro_module.granularity %></td>
11 <td><%= format_grade(module_result.grade) %></td> 11 <td><%= format_grade(module_result.grade) %></td>
12 </tr> 12 </tr>
13 \ No newline at end of file 13 \ No newline at end of file
app/views/modules/_module_tree.html.erb
1 <p> 1 <p>
2 <strong>Name:</strong> 2 <strong>Name:</strong>
3 - <%= format_module_name(@root_module_result.module.name) %> 3 + <%= format_module_name(@root_module_result.kalibro_module.name) %>
4 </p> 4 </p>
5 <p> 5 <p>
6 <strong>Granularity:</strong> 6 <strong>Granularity:</strong>
7 - <%= @root_module_result.module.granularity %> 7 + <%= @root_module_result.kalibro_module.granularity %>
8 </p> 8 </p>
9 <p> 9 <p>
10 <strong>Grade:</strong> 10 <strong>Grade:</strong>
app/views/repositories/_processing_information.html.erb
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 5
6 <p> 6 <p>
7 <strong>Creation date:</strong> 7 <strong>Creation date:</strong>
8 - <%= @processing.date.strftime("%Y/%m/%d at %Hh%M (%z)") %> 8 + <%= @processing.created_at.strftime("%Y/%m/%d at %Hh%M (%z)") %>
9 </p> 9 </p>
10 10
11 <% unless @processing.process_times.nil? %> 11 <% unless @processing.process_times.nil? %>
app/views/repositories/load_ready_processing.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 -Module.Tree.load("<%= escape_javascript(image_tag 'loader.gif') %> Loading data. Please, wait.", <%= @processing.results_root_id %>)  
3 \ No newline at end of file 2 \ No newline at end of file
  3 +Module.Tree.load("<%= escape_javascript(image_tag 'loader.gif') %> Loading data. Please, wait.", <%= @processing.root_module_result_id %>)
4 \ No newline at end of file 4 \ No newline at end of file
features/repository/show/date_select.feature
@@ -3,22 +3,22 @@ Feature: Date Select @@ -3,22 +3,22 @@ Feature: Date Select
3 As a regular user 3 As a regular user
4 I should be able to select a specific date 4 I should be able to select a specific date
5 5
6 - @kalibro_configuration_restart @kalibro_processor_restart @javascript 6 + @kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
7 Scenario: With a specific date selected 7 Scenario: With a specific date selected
8 Given I have a sample project 8 Given I have a sample project
9 And I have a sample configuration with native metrics 9 And I have a sample configuration with native metrics
10 And I have a sample repository within the sample project 10 And I have a sample repository within the sample project
11 And I start to process that repository 11 And I start to process that repository
12 And I wait up for a ready processing 12 And I wait up for a ready processing
13 - And I wait for "60" seconds  
14 And I start to process that repository 13 And I start to process that repository
15 - And I wait up for a ready processing 14 + And I wait up for the last processing to get ready
16 When I visit the repository show page 15 When I visit the repository show page
17 Then I should see "Retrieve the closest processing information from:" 16 Then I should see "Retrieve the closest processing information from:"
18 When I set the select field "day" as "1" 17 When I set the select field "day" as "1"
19 And I set the select field "month" as "1" 18 And I set the select field "month" as "1"
20 And I set the select field "year" as "2013" 19 And I set the select field "year" as "2013"
21 And I press the Search button 20 And I press the Search button
  21 + And I wait for "60" seconds
22 And I get the Creation date information as "before" 22 And I get the Creation date information as "before"
23 When I set the select field "day" as "1" 23 When I set the select field "day" as "1"
24 And I set the select field "month" as "1" 24 And I set the select field "month" as "1"
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 6 + @kalibro_configuration_restart @kalibro_processor_restart @javascript @wip
7 Scenario: Should show the message when the graphic of the given metric have only a single point 7 Scenario: Should show the message when the graphic of the given metric have 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
features/step_definitions/repository_steps.rb
@@ -52,6 +52,16 @@ Given(/^I wait up for a ready processing$/) do @@ -52,6 +52,16 @@ Given(/^I wait up for a ready processing$/) do
52 end 52 end
53 end 53 end
54 54
  55 +Given(/^I wait up for the last processing to get ready$/) do
  56 + while(true)
  57 + if Processing.last_processing_of(@repository.id).state == "READY"
  58 + break
  59 + else
  60 + sleep(10)
  61 + end
  62 + end
  63 +end
  64 +
55 Given(/^I wait up for a error processing$/) do 65 Given(/^I wait up for a error processing$/) do
56 unless Processing.last_processing_state_of(@repository.id) == "ERROR" 66 unless Processing.last_processing_state_of(@repository.id) == "ERROR"
57 while(true) 67 while(true)
@@ -77,7 +87,7 @@ Given(/^I ask for the last ready processing of the given repository$/) do @@ -77,7 +87,7 @@ Given(/^I ask for the last ready processing of the given repository$/) do
77 end 87 end
78 88
79 Given(/^I ask for the module result of the given processing$/) do 89 Given(/^I ask for the module result of the given processing$/) do
80 - @module_result = ModuleResult.find @processing.results_root_id 90 + @module_result = ModuleResult.find @processing.root_module_result_id
81 end 91 end
82 92
83 Given(/^I ask for the metric results of the given module result$/) do 93 Given(/^I ask for the metric results of the given module result$/) do
@@ -85,11 +95,11 @@ Given(/^I ask for the metric results of the given module result$/) do @@ -85,11 +95,11 @@ Given(/^I ask for the metric results of the given module result$/) do
85 end 95 end
86 96
87 Given(/^I see a sample metric's name$/) do 97 Given(/^I see a sample metric's name$/) do
88 - expect(page).to have_content(@metric_results.first.metric_configuration_snapshot.metric.name) 98 + expect(page).to have_content(@metric_results.first.metric_configuration.metric.name)
89 end 99 end
90 100
91 When(/^I click on the sample metric's name$/) do 101 When(/^I click on the sample metric's name$/) do
92 - find_link(@metric_results.first.metric_configuration_snapshot.metric.name).trigger('click') 102 + find_link(@metric_results.first.metric_configuration.metric.name).trigger('click')
93 end 103 end
94 104
95 When(/^I set the select field "(.+)" as "(.+)"$/) do |field, text| 105 When(/^I set the select field "(.+)" as "(.+)"$/) do |field, text|
@@ -101,7 +111,7 @@ When(/^I visit the repository show page$/) do @@ -101,7 +111,7 @@ When(/^I visit the repository show page$/) do
101 end 111 end
102 112
103 When(/^I click on the sample child's name$/) do 113 When(/^I click on the sample child's name$/) do
104 - click_link @module_result.children.first.module.name 114 + click_link @module_result.children.first.kalibro_module.name
105 end 115 end
106 116
107 When(/^I click the "(.*?)" h3$/) do |text| 117 When(/^I click the "(.*?)" h3$/) do |text|
@@ -128,11 +138,11 @@ Then(/^the field &quot;(.*?)&quot; should be filled with &quot;(.*?)&quot;$/) do |field, value| @@ -128,11 +138,11 @@ Then(/^the field &quot;(.*?)&quot; should be filled with &quot;(.*?)&quot;$/) do |field, value|
128 end 138 end
129 139
130 Then(/^I should see the given module result$/) do 140 Then(/^I should see the given module result$/) do
131 - expect(page).to have_content(@module_result.module.name) 141 + expect(page).to have_content(@module_result.kalibro_module.name)
132 end 142 end
133 143
134 Then(/^I should see a sample child's name$/) do 144 Then(/^I should see a sample child's name$/) do
135 - expect(page).to have_content(@module_result.children.first.module.name) 145 + expect(page).to have_content(@module_result.children.first.kalibro_module.name)
136 end 146 end
137 147
138 Then(/^I should see the given repository's content$/) do 148 Then(/^I should see the given repository's content$/) do
@@ -176,5 +186,6 @@ end @@ -176,5 +186,6 @@ end
176 Then(/^"(.*?)" should be less than "(.*?)"$/) do |arg1, arg2| 186 Then(/^"(.*?)" should be less than "(.*?)"$/) do |arg1, arg2|
177 v1 = eval "@#{arg1}" 187 v1 = eval "@#{arg1}"
178 v2 = eval "@#{arg2}" 188 v2 = eval "@#{arg2}"
  189 +
179 expect(v1 < v2).to be_truthy 190 expect(v1 < v2).to be_truthy
180 end 191 end