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>
Gemfile.lock
1 1 GIT
2 2 remote: https://github.com/mezuro/kalibro_client
3   - revision: 00079f05f96c12afe78003ed49f40cb3e404ed0c
  3 + revision: 24ea5d64efd7f55515f6e062a6c050186010ff5b
4 4 specs:
5 5 kalibro_client (0.0.1)
6 6 activesupport (>= 2.2.1)
... ...
app/models/repository.rb
1 1 class Repository < KalibroClient::Entities::Processor::Repository
2 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 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 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 6 <tr>
7 7 <td><%= link_to "<i class='icon-align-left'></i> #{metric_name}".html_safe, "",
... ... @@ -10,7 +10,7 @@
10 10 remote: true %>
11 11 </td>
12 12 <td><%= format_grade(metric_result.value) %></td>
13   - <td><%= metric_configuration_snapshot.weight %></td>
  13 + <td><%= metric_configuration.weight %></td>
14 14 <td><% if range_snapshot.nil? %>Missing range<% else %><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span><% end %></td>
15 15 </tr>
16 16 <tr id="container<%= metric_result.id %>" style="display: none">
... ...
app/views/modules/_module_result.html.erb
... ... @@ -5,8 +5,8 @@
5 5 <% else %>
6 6 <i class="icon-file"></i>
7 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 9 </td>
10   - <td><%= module_result.module.granularity %></td>
  10 + <td><%= module_result.kalibro_module.granularity %></td>
11 11 <td><%= format_grade(module_result.grade) %></td>
12 12 </tr>
13 13 \ No newline at end of file
... ...
app/views/modules/_module_tree.html.erb
1 1 <p>
2 2 <strong>Name:</strong>
3   - <%= format_module_name(@root_module_result.module.name) %>
  3 + <%= format_module_name(@root_module_result.kalibro_module.name) %>
4 4 </p>
5 5 <p>
6 6 <strong>Granularity:</strong>
7   - <%= @root_module_result.module.granularity %>
  7 + <%= @root_module_result.kalibro_module.granularity %>
8 8 </p>
9 9 <p>
10 10 <strong>Grade:</strong>
... ...
app/views/repositories/_processing_information.html.erb
... ... @@ -5,7 +5,7 @@
5 5  
6 6 <p>
7 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 9 </p>
10 10  
11 11 <% unless @processing.process_times.nil? %>
... ...
app/views/repositories/load_ready_processing.js.erb
1 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 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 4 \ No newline at end of file
... ...
features/repository/show/date_select.feature
... ... @@ -3,22 +3,22 @@ Feature: Date Select
3 3 As a regular user
4 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 7 Scenario: With a specific date selected
8 8 Given I have a sample project
9 9 And I have a sample configuration with native metrics
10 10 And I have a sample repository within the sample project
11 11 And I start to process that repository
12 12 And I wait up for a ready processing
13   - And I wait for "60" seconds
14 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 15 When I visit the repository show page
17 16 Then I should see "Retrieve the closest processing information from:"
18 17 When I set the select field "day" as "1"
19 18 And I set the select field "month" as "1"
20 19 And I set the select field "year" as "2013"
21 20 And I press the Search button
  21 + And I wait for "60" seconds
22 22 And I get the Creation date information as "before"
23 23 When I set the select field "day" as "1"
24 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 3 As a regular user
4 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 7 Scenario: Should show the message when the graphic of the given metric have only a single point
8 8 Given I am a regular user
9 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 52 end
53 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 65 Given(/^I wait up for a error processing$/) do
56 66 unless Processing.last_processing_state_of(@repository.id) == "ERROR"
57 67 while(true)
... ... @@ -77,7 +87,7 @@ Given(/^I ask for the last ready processing of the given repository$/) do
77 87 end
78 88  
79 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 91 end
82 92  
83 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 95 end
86 96  
87 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 99 end
90 100  
91 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 103 end
94 104  
95 105 When(/^I set the select field "(.+)" as "(.+)"$/) do |field, text|
... ... @@ -101,7 +111,7 @@ When(/^I visit the repository show page$/) do
101 111 end
102 112  
103 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 115 end
106 116  
107 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 138 end
129 139  
130 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 142 end
133 143  
134 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 146 end
137 147  
138 148 Then(/^I should see the given repository's content$/) do
... ... @@ -176,5 +186,6 @@ end
176 186 Then(/^"(.*?)" should be less than "(.*?)"$/) do |arg1, arg2|
177 187 v1 = eval "@#{arg1}"
178 188 v2 = eval "@#{arg2}"
  189 +
179 190 expect(v1 < v2).to be_truthy
180 191 end
... ...