Commit 8bf9a57a9e7a1cc1237c454d47834d381108e4af

Authored by Heitor
1 parent 4f689b24

Rename MetricResult to TreeMetricResult on unit tests

 * Renamed the classes, mocks and factory class on unit tests

Signed off by: Diego Araújo <diegoamc90@gmail.com>
app/models/module_result.rb
1 1 class ModuleResult < KalibroClient::Entities::Processor::ModuleResult
2 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 4 grade_history = Hash.new
5 5  
6 6 history.each { |date_metric_result| grade_history[date_metric_result.date] = date_metric_result.metric_result.value }
... ...
spec/factories/metric_results.rb
... ... @@ -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/tree_metric_results.rb 0 → 100644
... ... @@ -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 :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
... ... @@ -17,7 +17,7 @@ describe ProcessingsHelper, :type =&gt; :helper do
17 17 end
18 18 end
19 19  
20   - describe 'find_range_snapshot', pending: 'broke after kalibro client major update' do
  20 + describe 'find_range_snapshot' do
21 21 let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id)}
22 22 let(:metric_result) { FactoryGirl.build(:metric_result, {value: 6.0, metric_configuration: metric_configuration})}
23 23  
... ...
spec/models/module_result_spec.rb
... ... @@ -4,7 +4,7 @@ describe ModuleResult, :type =&gt; :model do
4 4 describe 'methods' do
5 5 subject { FactoryGirl.build(:module_result) }
6 6  
7   - describe 'metric_history', pending: 'broke after kalibro client major update' do
  7 + describe 'metric_history' do
8 8 let(:date_module_result) {FactoryGirl.build(:date_module_result)}
9 9 let(:metric_configuration) { FactoryGirl.build(:another_metric_configuration_with_id) }
10 10 let!(:metric_result) { FactoryGirl.build(:metric_result, metric_configuration: metric_configuration) }
... ... @@ -13,7 +13,7 @@ describe ModuleResult, :type =&gt; :model do
13 13 before :each do
14 14 subject.expects(:processing).returns(processing)
15 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])
  16 + KalibroClient::Entities::Processor::TreeMetricResult.expects(:history_of).with(metric_configuration.metric.name, subject.id, processing.repository_id).returns([date_module_result])
17 17 end
18 18  
19 19 it 'should return the history for the given metric name' do
... ...