Commit 18794d7f90be6b6e19a0162cd55abdede5c902ae
Committed by
Rafael Manzo
1 parent
9567b36a
Exists in
colab
and in
4 other branches
[WIP] Fixing prezento's unit tests according to the new kalibro client gem
Signed off by: Daniel Paulino Alves <danpaulalves@gmail.com>
Showing
28 changed files
with
118 additions
and
161 deletions
Show diff stats
app/controllers/base_metric_configurations_controller.rb
| @@ -10,14 +10,12 @@ class BaseMetricConfigurationsController < ApplicationController | @@ -10,14 +10,12 @@ class BaseMetricConfigurationsController < ApplicationController | ||
| 10 | 10 | ||
| 11 | def new | 11 | def new |
| 12 | update_metric_configuration(MetricConfiguration.new) | 12 | update_metric_configuration(MetricConfiguration.new) |
| 13 | - metric_configuration.configuration_id = params[:kalibro_configuration_id].to_i | ||
| 14 | end | 13 | end |
| 15 | 14 | ||
| 16 | def show | 15 | def show |
| 17 | if metric_configuration | 16 | if metric_configuration |
| 18 | @reading_group = ReadingGroup.find(metric_configuration.reading_group_id) | 17 | @reading_group = ReadingGroup.find(metric_configuration.reading_group_id) |
| 19 | @mezuro_ranges = metric_configuration.kalibro_ranges | 18 | @mezuro_ranges = metric_configuration.kalibro_ranges |
| 20 | - metric_configuration.configuration_id = params[:kalibro_configuration_id].to_i | ||
| 21 | else | 19 | else |
| 22 | raise NotImplementedError | 20 | raise NotImplementedError |
| 23 | end | 21 | end |
| @@ -25,7 +23,6 @@ class BaseMetricConfigurationsController < ApplicationController | @@ -25,7 +23,6 @@ class BaseMetricConfigurationsController < ApplicationController | ||
| 25 | 23 | ||
| 26 | def create | 24 | def create |
| 27 | update_metric_configuration(MetricConfiguration.new(metric_configuration_params)) | 25 | update_metric_configuration(MetricConfiguration.new(metric_configuration_params)) |
| 28 | - metric_configuration.configuration_id = params[:kalibro_configuration_id].to_i | ||
| 29 | end | 26 | end |
| 30 | 27 | ||
| 31 | protected | 28 | protected |
| @@ -43,4 +40,4 @@ class BaseMetricConfigurationsController < ApplicationController | @@ -43,4 +40,4 @@ class BaseMetricConfigurationsController < ApplicationController | ||
| 43 | def metric_configuration_params | 40 | def metric_configuration_params |
| 44 | params[:metric_configuration] | 41 | params[:metric_configuration] |
| 45 | end | 42 | end |
| 46 | -end | ||
| 47 | \ No newline at end of file | 43 | \ No newline at end of file |
| 44 | +end |
app/controllers/compound_metric_configurations_controller.rb
| @@ -17,19 +17,19 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle | @@ -17,19 +17,19 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle | ||
| 17 | 17 | ||
| 18 | def edit | 18 | def edit |
| 19 | @compound_metric_configuration = @metric_configuration | 19 | @compound_metric_configuration = @metric_configuration |
| 20 | - @compound_metric_configuration.configuration_id = params[:kalibro_configuration_id].to_i | 20 | + @compound_metric_configuration.kalibro_configuration_id = params[:kalibro_configuration_id].to_i |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | def update | 23 | def update |
| 24 | respond_to do |format| | 24 | respond_to do |format| |
| 25 | edit | 25 | edit |
| 26 | if @compound_metric_configuration.update(metric_configuration_params) | 26 | if @compound_metric_configuration.update(metric_configuration_params) |
| 27 | - format.html { redirect_to kalibro_configuration_path(@compound_metric_configuration.configuration_id), notice: 'Compound Metric Configuration was successfully updated.' } | 27 | + format.html { redirect_to kalibro_configuration_path(@compound_metric_configuration.kalibro_configuration_id), notice: 'Compound Metric Configuration was successfully updated.' } |
| 28 | format.json { head :no_content } | 28 | format.json { head :no_content } |
| 29 | else | 29 | else |
| 30 | failed_action(format, 'edit') | 30 | failed_action(format, 'edit') |
| 31 | end | 31 | end |
| 32 | - Rails.cache.delete("#{@compound_metric_configuration.configuration_id}_metric_configurations") | 32 | + Rails.cache.delete("#{@compound_metric_configuration.kalibro_configuration_id}_metric_configurations") |
| 33 | end | 33 | end |
| 34 | end | 34 | end |
| 35 | 35 | ||
| @@ -62,7 +62,7 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle | @@ -62,7 +62,7 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle | ||
| 62 | #Code extracted from create action | 62 | #Code extracted from create action |
| 63 | def create_and_redir(format) | 63 | def create_and_redir(format) |
| 64 | if @compound_metric_configuration.save | 64 | if @compound_metric_configuration.save |
| 65 | - format.html { redirect_to kalibro_configuration_path(@compound_metric_configuration.configuration_id), notice: 'Compound Metric Configuration was successfully created.' } | 65 | + format.html { redirect_to kalibro_configuration_path(@compound_metric_configuration.kalibro_configuration_id), notice: 'Compound Metric Configuration was successfully created.' } |
| 66 | else | 66 | else |
| 67 | failed_action(format, 'new') | 67 | failed_action(format, 'new') |
| 68 | end | 68 | end |
app/controllers/metric_configurations_controller.rb
| @@ -2,20 +2,17 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -2,20 +2,17 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 2 | def choose_metric | 2 | def choose_metric |
| 3 | @kalibro_configuration = KalibroConfiguration.find(params[:kalibro_configuration_id].to_i) | 3 | @kalibro_configuration = KalibroConfiguration.find(params[:kalibro_configuration_id].to_i) |
| 4 | @metric_configuration_id = params[:metric_configuration_id].to_i | 4 | @metric_configuration_id = params[:metric_configuration_id].to_i |
| 5 | - @metric_collectors_names = KalibroClient::Processor::MetricCollector.all_names | 5 | + @metric_collectors_names = KalibroClient::Entities::Processor::MetricCollectorDetails.all_names |
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | def new | 8 | def new |
| 9 | super | 9 | super |
| 10 | - metric_configuration.metric_collector_name = params[:metric_collector_name] | ||
| 11 | - metric_configuration.metric = KalibroClient::Processor::MetricCollector.find(params[:metric_collector_name]).metric params[:metric_code] | 10 | + metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find(params[:metric_collector_name]).metric params[:metric_code] |
| 12 | end | 11 | end |
| 13 | 12 | ||
| 14 | def create | 13 | def create |
| 15 | super | 14 | super |
| 16 | - @metric_configuration.metric = KalibroClient::Processor::MetricCollector.find(params[:metric_collector_name]).metric params[:metric_name] | ||
| 17 | - @metric_configuration.metric_collector_name = params[:metric_collector_name] | ||
| 18 | - @metric_configuration.code = @metric_configuration.metric.code | 15 | + @metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find(params[:metric_collector_name]).metric params[:metric_name] |
| 19 | respond_to do |format| | 16 | respond_to do |format| |
| 20 | create_and_redir(format) | 17 | create_and_redir(format) |
| 21 | end | 18 | end |
| @@ -25,16 +22,16 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -25,16 +22,16 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 25 | def edit | 22 | def edit |
| 26 | #FIXME: set the configuration id just once! | 23 | #FIXME: set the configuration id just once! |
| 27 | @kalibro_configuration_id = params[:kalibro_configuration_id] | 24 | @kalibro_configuration_id = params[:kalibro_configuration_id] |
| 28 | - @metric_configuration.configuration_id = @kalibro_configuration_id | 25 | + @metric_configuration.kalibro_configuration_id = @kalibro_configuration_id |
| 29 | end | 26 | end |
| 30 | 27 | ||
| 31 | def update | 28 | def update |
| 32 | respond_to do |format| | 29 | respond_to do |format| |
| 33 | - @metric_configuration.configuration_id = params[:kalibro_configuration_id] | 30 | + @metric_configuration.kalibro_configuration_id = params[:kalibro_configuration_id] |
| 34 | if @metric_configuration.update(metric_configuration_params) | 31 | if @metric_configuration.update(metric_configuration_params) |
| 35 | - format.html { redirect_to(kalibro_configuration_path(@metric_configuration.configuration_id), notice: 'Metric Configuration was successfully updated.') } | 32 | + format.html { redirect_to(kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: 'Metric Configuration was successfully updated.') } |
| 36 | format.json { head :no_content } | 33 | format.json { head :no_content } |
| 37 | - Rails.cache.delete("#{@metric_configuration.configuration_id}_metric_configurations") | 34 | + Rails.cache.delete("#{@metric_configuration.kalibro_configuration_id}_metric_configurations") |
| 38 | else | 35 | else |
| 39 | failed_action(format, 'edit') | 36 | failed_action(format, 'edit') |
| 40 | end | 37 | end |
| @@ -73,7 +70,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -73,7 +70,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 73 | #Code extracted from create action | 70 | #Code extracted from create action |
| 74 | def create_and_redir(format) | 71 | def create_and_redir(format) |
| 75 | if @metric_configuration.save | 72 | if @metric_configuration.save |
| 76 | - format.html { redirect_to kalibro_configuration_path(@metric_configuration.configuration_id), notice: 'Metric Configuration was successfully created.' } | 73 | + format.html { redirect_to kalibro_configuration_path(@metric_configuration.kalibro_configuration_id), notice: 'Metric Configuration was successfully created.' } |
| 77 | else | 74 | else |
| 78 | failed_action(format, 'new') | 75 | failed_action(format, 'new') |
| 79 | end | 76 | end |
app/controllers/readings_controller.rb
| @@ -8,13 +8,11 @@ class ReadingsController < ApplicationController | @@ -8,13 +8,11 @@ class ReadingsController < ApplicationController | ||
| 8 | before_action :set_reading, only: [:edit, :update, :destroy] | 8 | before_action :set_reading, only: [:edit, :update, :destroy] |
| 9 | 9 | ||
| 10 | def new | 10 | def new |
| 11 | - @reading_group_id = params[:reading_group_id] | ||
| 12 | @reading = Reading.new | 11 | @reading = Reading.new |
| 13 | end | 12 | end |
| 14 | 13 | ||
| 15 | def create | 14 | def create |
| 16 | @reading = Reading.new(reading_params) | 15 | @reading = Reading.new(reading_params) |
| 17 | - @reading.group_id = params[:reading_group_id].to_i | ||
| 18 | respond_to do |format| | 16 | respond_to do |format| |
| 19 | create_and_redir(format) | 17 | create_and_redir(format) |
| 20 | end | 18 | end |
| @@ -22,16 +20,14 @@ class ReadingsController < ApplicationController | @@ -22,16 +20,14 @@ class ReadingsController < ApplicationController | ||
| 22 | 20 | ||
| 23 | # GET /readings/1/edit | 21 | # GET /readings/1/edit |
| 24 | def edit | 22 | def edit |
| 25 | - @reading_group_id = params[:reading_group_id] | ||
| 26 | end | 23 | end |
| 27 | 24 | ||
| 28 | # PUT /reading_groups/1/readings/1 | 25 | # PUT /reading_groups/1/readings/1 |
| 29 | # PUT /reading_groups/1/readings/1.json | 26 | # PUT /reading_groups/1/readings/1.json |
| 30 | def update | 27 | def update |
| 31 | - @reading.group_id = params[:reading_group_id].to_i | ||
| 32 | respond_to do |format| | 28 | respond_to do |format| |
| 33 | if @reading.update(reading_params) | 29 | if @reading.update(reading_params) |
| 34 | - format.html { redirect_to(reading_group_path(params[:reading_group_id].to_i), notice: 'Reading was successfully updated.') } | 30 | + format.html { redirect_to(reading_group_path(@reading.reading_group_id), notice: 'Reading was successfully updated.') } |
| 35 | format.json { head :no_content } | 31 | format.json { head :no_content } |
| 36 | else | 32 | else |
| 37 | failed_action(format, 'edit') | 33 | failed_action(format, 'edit') |
| @@ -58,8 +54,6 @@ class ReadingsController < ApplicationController | @@ -58,8 +54,6 @@ class ReadingsController < ApplicationController | ||
| 58 | 54 | ||
| 59 | # Duplicated code on create and update actions extracted here | 55 | # Duplicated code on create and update actions extracted here |
| 60 | def failed_action(format, destiny_action) | 56 | def failed_action(format, destiny_action) |
| 61 | - @reading_group_id = params[:reading_group_id] | ||
| 62 | - | ||
| 63 | format.html { render action: destiny_action } | 57 | format.html { render action: destiny_action } |
| 64 | format.json { render json: @reading.errors, status: :unprocessable_entity } | 58 | format.json { render json: @reading.errors, status: :unprocessable_entity } |
| 65 | end | 59 | end |
| @@ -67,7 +61,7 @@ class ReadingsController < ApplicationController | @@ -67,7 +61,7 @@ class ReadingsController < ApplicationController | ||
| 67 | # Code extracted from create action | 61 | # Code extracted from create action |
| 68 | def create_and_redir(format) | 62 | def create_and_redir(format) |
| 69 | if @reading.save | 63 | if @reading.save |
| 70 | - format.html { redirect_to reading_group_path(@reading.group_id), notice: 'Reading was successfully created.' } | 64 | + format.html { redirect_to reading_group_path(@reading.reading_group_id), notice: 'Reading was successfully created.' } |
| 71 | else | 65 | else |
| 72 | failed_action(format, 'new') | 66 | failed_action(format, 'new') |
| 73 | end | 67 | end |
app/controllers/repositories_controller.rb
| @@ -109,7 +109,7 @@ private | @@ -109,7 +109,7 @@ private | ||
| 109 | end | 109 | end |
| 110 | 110 | ||
| 111 | def set_kalibro_configuration | 111 | def set_kalibro_configuration |
| 112 | - @kalibro_configuration = KalibroConfiguration.find(@repository.configuration_id) | 112 | + @kalibro_configuration = KalibroConfiguration.find(@repository.kalibro_configuration_id) |
| 113 | end | 113 | end |
| 114 | 114 | ||
| 115 | # Never trust parameters from the scary internet, only allow the white list through. | 115 | # Never trust parameters from the scary internet, only allow the white list through. |
app/helpers/kalibro_configurations_helper.rb
| @@ -4,7 +4,7 @@ module KalibroConfigurationsHelper | @@ -4,7 +4,7 @@ module KalibroConfigurationsHelper | ||
| 4 | end | 4 | end |
| 5 | 5 | ||
| 6 | def link_to_edit_form(metric_configuration, kalibro_configuration_id) | 6 | def link_to_edit_form(metric_configuration, kalibro_configuration_id) |
| 7 | - if (metric_configuration.metric.compound) | 7 | + if (metric_configuration.metric.is_a? KalibroClient::Entities::Miscellaneous::CompoundMetric) |
| 8 | link_to('Edit', edit_kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') | 8 | link_to('Edit', edit_kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') |
| 9 | else | 9 | else |
| 10 | link_to('Edit', edit_kalibro_configuration_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') | 10 | link_to('Edit', edit_kalibro_configuration_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') |
| @@ -12,7 +12,7 @@ module KalibroConfigurationsHelper | @@ -12,7 +12,7 @@ module KalibroConfigurationsHelper | ||
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | def link_to_show_page(metric_configuration, kalibro_configuration_id) | 14 | def link_to_show_page(metric_configuration, kalibro_configuration_id) |
| 15 | - if (metric_configuration.metric.compound) | 15 | + if (metric_configuration.metric.is_a? KalibroClient::Entities::Miscellaneous::CompoundMetric) |
| 16 | link_to('Show', kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') | 16 | link_to('Show', kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') |
| 17 | else | 17 | else |
| 18 | link_to('Show', kalibro_configuration_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') | 18 | link_to('Show', kalibro_configuration_metric_configuration_path(kalibro_configuration_id, metric_configuration.id), class: 'btn btn-info') |
app/helpers/metric_configurations_helper.rb
| @@ -10,11 +10,11 @@ module MetricConfigurationsHelper | @@ -10,11 +10,11 @@ module MetricConfigurationsHelper | ||
| 10 | 10 | ||
| 11 | def native_metrics_of(kalibro_configuration_id) | 11 | def native_metrics_of(kalibro_configuration_id) |
| 12 | MetricConfiguration.metric_configurations_of(kalibro_configuration_id).map do |metric_configuration| | 12 | MetricConfiguration.metric_configurations_of(kalibro_configuration_id).map do |metric_configuration| |
| 13 | - [ metric_configuration.code, metric_configuration.metric.name ] | 13 | + [ metric_configuration.metric.code, metric_configuration.metric.name ] |
| 14 | end | 14 | end |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | def supported_metrics_of(metric_collector_name) | 17 | def supported_metrics_of(metric_collector_name) |
| 18 | - KalibroClient::Processor::MetricCollector.find(metric_collector_name).supported_metrics | 18 | + KalibroClient::Processor::MetricCollectorDetails.find(metric_collector_name).supported_metrics |
| 19 | end | 19 | end |
| 20 | end | 20 | end |
app/models/module_result.rb
| @@ -13,6 +13,6 @@ class ModuleResult < KalibroClient::Entities::Processor::ModuleResult | @@ -13,6 +13,6 @@ class ModuleResult < KalibroClient::Entities::Processor::ModuleResult | ||
| 13 | private | 13 | private |
| 14 | 14 | ||
| 15 | def find_grade_by_metric_name(metric_results, name) | 15 | def find_grade_by_metric_name(metric_results, name) |
| 16 | - metric_results.each { |metric_result| return metric_result.value if metric_result.metric_configuration.metric_snapshot.name == name } | 16 | + metric_results.each { |metric_result| return metric_result.value if metric_result.metric_configuration.metric.name == name } |
| 17 | end | 17 | end |
| 18 | end | 18 | end |
spec/controllers/base_metric_configurations_controller_spec.rb
| @@ -86,8 +86,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | @@ -86,8 +86,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | ||
| 86 | end | 86 | end |
| 87 | 87 | ||
| 88 | describe 'create' do | 88 | describe 'create' do |
| 89 | - let!(:metric_configuration_params) { Hash[FactoryGirl.attributes_for(:metric_configuration).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers | ||
| 90 | - let!(:metric_params) { Hash[FactoryGirl.attributes_for(:metric).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers | 89 | + let!(:metric_configuration_params) { FactoryGirl.build(:metric_configuration, metric: FactoryGirl.build(:metric)).to_hash } |
| 91 | let(:metric_collector) { FactoryGirl.build(:metric_collector) } | 90 | let(:metric_collector) { FactoryGirl.build(:metric_collector) } |
| 92 | 91 | ||
| 93 | before :each do | 92 | before :each do |
| @@ -121,7 +120,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | @@ -121,7 +120,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | ||
| 121 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) | 120 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 122 | metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) | 121 | metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) |
| 123 | 122 | ||
| 124 | - get :show, kalibro_configuration_id: metric_configuration.configuration_id.to_s, id: metric_configuration.id | 123 | + get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id |
| 125 | end | 124 | end |
| 126 | 125 | ||
| 127 | it { expect(subject.mezuro_ranges).not_to be_nil} | 126 | it { expect(subject.mezuro_ranges).not_to be_nil} |
spec/controllers/compound_metric_configurations_controller_spec.rb
| @@ -79,7 +79,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -79,7 +79,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 79 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) | 79 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) |
| 80 | compound_metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) | 80 | compound_metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) |
| 81 | 81 | ||
| 82 | - get :show, kalibro_configuration_id: compound_metric_configuration.configuration_id.to_s, id: compound_metric_configuration.id | 82 | + get :show, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id.to_s, id: compound_metric_configuration.id |
| 83 | end | 83 | end |
| 84 | 84 | ||
| 85 | it { is_expected.to render_template(:show) } | 85 | it { is_expected.to render_template(:show) } |
| @@ -98,7 +98,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -98,7 +98,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 98 | subject.expects(:metric_configuration_owner?).returns(true) | 98 | subject.expects(:metric_configuration_owner?).returns(true) |
| 99 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) | 99 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) |
| 100 | MetricConfiguration.expects(:metric_configurations_of).with(kalibro_configuration.id).returns([compound_metric_configuration]) | 100 | MetricConfiguration.expects(:metric_configurations_of).with(kalibro_configuration.id).returns([compound_metric_configuration]) |
| 101 | - get :edit, id: compound_metric_configuration.id, kalibro_configuration_id: compound_metric_configuration.configuration_id.to_s | 101 | + get :edit, id: compound_metric_configuration.id, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id.to_s |
| 102 | end | 102 | end |
| 103 | 103 | ||
| 104 | it { is_expected.to render_template(:edit) } | 104 | it { is_expected.to render_template(:edit) } |
| @@ -106,7 +106,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -106,7 +106,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 106 | 106 | ||
| 107 | context 'when the user does not own the compound metric configuration' do | 107 | context 'when the user does not own the compound metric configuration' do |
| 108 | before do | 108 | before do |
| 109 | - get :edit, id: compound_metric_configuration.id, kalibro_configuration_id: compound_metric_configuration.configuration_id.to_s | 109 | + get :edit, id: compound_metric_configuration.id, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id.to_s |
| 110 | end | 110 | end |
| 111 | 111 | ||
| 112 | it { is_expected.to redirect_to(kalibro_configurations_path(kalibro_configuration.id)) } | 112 | it { is_expected.to redirect_to(kalibro_configurations_path(kalibro_configuration.id)) } |
| @@ -117,7 +117,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -117,7 +117,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 117 | 117 | ||
| 118 | context 'with no user logged in' do | 118 | context 'with no user logged in' do |
| 119 | before :each do | 119 | before :each do |
| 120 | - get :edit, id: compound_metric_configuration.id, kalibro_configuration_id: compound_metric_configuration.configuration_id.to_s | 120 | + get :edit, id: compound_metric_configuration.id, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id.to_s |
| 121 | end | 121 | end |
| 122 | 122 | ||
| 123 | it { is_expected.to redirect_to new_user_session_path } | 123 | it { is_expected.to redirect_to new_user_session_path } |
| @@ -143,10 +143,10 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -143,10 +143,10 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 143 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) | 143 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) |
| 144 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(true) | 144 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(true) |
| 145 | 145 | ||
| 146 | - post :update, kalibro_configuration_id: compound_metric_configuration.configuration_id, id: compound_metric_configuration.id, metric_configuration: metric_configuration_params | 146 | + post :update, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id, id: compound_metric_configuration.id, metric_configuration: metric_configuration_params |
| 147 | end | 147 | end |
| 148 | 148 | ||
| 149 | - it { should redirect_to(kalibro_configuration_path(compound_metric_configuration.configuration_id)) } | 149 | + it { should redirect_to(kalibro_configuration_path(compound_metric_configuration.kalibro_configuration_id)) } |
| 150 | it { should respond_with(:redirect) } | 150 | it { should respond_with(:redirect) } |
| 151 | end | 151 | end |
| 152 | 152 | ||
| @@ -156,7 +156,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -156,7 +156,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 156 | MetricConfiguration.expects(:metric_configurations_of).with(kalibro_configuration.id).returns([compound_metric_configuration]) | 156 | MetricConfiguration.expects(:metric_configurations_of).with(kalibro_configuration.id).returns([compound_metric_configuration]) |
| 157 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(false) | 157 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(false) |
| 158 | 158 | ||
| 159 | - post :update, kalibro_configuration_id: compound_metric_configuration.configuration_id, id: compound_metric_configuration.id, metric_configuration: metric_configuration_params | 159 | + post :update, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id, id: compound_metric_configuration.id, metric_configuration: metric_configuration_params |
| 160 | end | 160 | end |
| 161 | 161 | ||
| 162 | it { should render_template(:edit) } | 162 | it { should render_template(:edit) } |
| @@ -165,10 +165,10 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -165,10 +165,10 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 165 | 165 | ||
| 166 | context 'when the user does not own the reading' do | 166 | context 'when the user does not own the reading' do |
| 167 | before :each do | 167 | before :each do |
| 168 | - post :update, kalibro_configuration_id: compound_metric_configuration.configuration_id, id: compound_metric_configuration.id, metric_configuration: metric_configuration_params | 168 | + post :update, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id, id: compound_metric_configuration.id, metric_configuration: metric_configuration_params |
| 169 | end | 169 | end |
| 170 | 170 | ||
| 171 | - it { should redirect_to kalibro_configurations_path(compound_metric_configuration.configuration_id) } | 171 | + it { should redirect_to kalibro_configurations_path(compound_metric_configuration.kalibro_configuration_id) } |
| 172 | end | 172 | end |
| 173 | end | 173 | end |
| 174 | end | 174 | end |
spec/controllers/metric_configurations_controller_spec.rb
| @@ -11,7 +11,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -11,7 +11,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 11 | context 'when adding new metrics' do | 11 | context 'when adding new metrics' do |
| 12 | before :each do | 12 | before :each do |
| 13 | subject.expects(:kalibro_configuration_owner?).returns true | 13 | subject.expects(:kalibro_configuration_owner?).returns true |
| 14 | - KalibroClient::Processor::MetricCollector.expects(:all_names).returns([metric_collector]) | 14 | + KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:all_names).returns([metric_collector]) |
| 15 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) | 15 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) |
| 16 | get :choose_metric, kalibro_configuration_id: kalibro_configuration.id | 16 | get :choose_metric, kalibro_configuration_id: kalibro_configuration.id |
| 17 | end | 17 | end |
| @@ -31,7 +31,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -31,7 +31,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 31 | context 'when the current user owns the mezuro configuration' do | 31 | context 'when the current user owns the mezuro configuration' do |
| 32 | before :each do | 32 | before :each do |
| 33 | subject.expects(:kalibro_configuration_owner?).returns true | 33 | subject.expects(:kalibro_configuration_owner?).returns true |
| 34 | - KalibroClient::Processor::MetricCollector.expects(:find).with(metric_collector.name).returns(metric_collector) | 34 | + KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find).with(metric_collector.name).returns(metric_collector) |
| 35 | metric_collector.expects(:metric).with(native_metric.code).returns(native_metric) | 35 | metric_collector.expects(:metric).with(native_metric.code).returns(native_metric) |
| 36 | post :new, kalibro_configuration_id: kalibro_configuration.id, metric_code: native_metric.code, metric_collector_name: metric_collector.name | 36 | post :new, kalibro_configuration_id: kalibro_configuration.id, metric_code: native_metric.code, metric_collector_name: metric_collector.name |
| 37 | end | 37 | end |
| @@ -52,7 +52,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -52,7 +52,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 52 | 52 | ||
| 53 | describe 'create' do | 53 | describe 'create' do |
| 54 | let!(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 54 | let!(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 55 | - let(:metric_configuration_params) { Hash[FactoryGirl.attributes_for(:metric_configuration).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers | 55 | + let(:metric_configuration_params) { metric_configuration.to_hash } |
| 56 | let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration) } | 56 | let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration) } |
| 57 | let(:metric_collector) { FactoryGirl.build(:metric_collector) } | 57 | let(:metric_collector) { FactoryGirl.build(:metric_collector) } |
| 58 | 58 | ||
| @@ -68,7 +68,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -68,7 +68,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 68 | context 'with valid fields' do | 68 | context 'with valid fields' do |
| 69 | before :each do | 69 | before :each do |
| 70 | MetricConfiguration.any_instance.expects(:save).returns(true) | 70 | MetricConfiguration.any_instance.expects(:save).returns(true) |
| 71 | - KalibroClient::Processor::MetricCollector.expects(:find).with(metric_collector.name).returns(metric_collector) | 71 | + KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find).with(metric_collector.name).returns(metric_collector) |
| 72 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | 72 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) |
| 73 | 73 | ||
| 74 | post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name | 74 | post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name |
| @@ -80,7 +80,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -80,7 +80,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 80 | context 'with invalid fields' do | 80 | context 'with invalid fields' do |
| 81 | before :each do | 81 | before :each do |
| 82 | MetricConfiguration.any_instance.expects(:save).returns(false) | 82 | MetricConfiguration.any_instance.expects(:save).returns(false) |
| 83 | - KalibroClient::Processor::MetricCollector.expects(:find).with(metric_collector.name).returns(metric_collector) | 83 | + KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find).with(metric_collector.name).returns(metric_collector) |
| 84 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | 84 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) |
| 85 | 85 | ||
| 86 | post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name | 86 | post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name |
| @@ -101,7 +101,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -101,7 +101,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 101 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) | 101 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 102 | metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) | 102 | metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) |
| 103 | 103 | ||
| 104 | - get :show, kalibro_configuration_id: metric_configuration.configuration_id.to_s, id: metric_configuration.id | 104 | + get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id |
| 105 | end | 105 | end |
| 106 | 106 | ||
| 107 | it { is_expected.to render_template(:show) } | 107 | it { is_expected.to render_template(:show) } |
| @@ -119,7 +119,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -119,7 +119,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 119 | before :each do | 119 | before :each do |
| 120 | subject.expects(:metric_configuration_owner?).returns(true) | 120 | subject.expects(:metric_configuration_owner?).returns(true) |
| 121 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) | 121 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 122 | - get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 122 | + get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 123 | end | 123 | end |
| 124 | 124 | ||
| 125 | it { is_expected.to render_template(:edit) } | 125 | it { is_expected.to render_template(:edit) } |
| @@ -127,10 +127,10 @@ describe MetricConfigurationsController, :type => :controller do | @@ -127,10 +127,10 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 127 | 127 | ||
| 128 | context 'when the user does not own the metric configuration' do | 128 | context 'when the user does not own the metric configuration' do |
| 129 | before do | 129 | before do |
| 130 | - get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 130 | + get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 131 | end | 131 | end |
| 132 | 132 | ||
| 133 | - it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.configuration_id)) } | 133 | + it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } |
| 134 | it { is_expected.to respond_with(:redirect) } | 134 | it { is_expected.to respond_with(:redirect) } |
| 135 | it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") } | 135 | it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") } |
| 136 | end | 136 | end |
| @@ -138,7 +138,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -138,7 +138,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 138 | 138 | ||
| 139 | context 'with no user logged in' do | 139 | context 'with no user logged in' do |
| 140 | before :each do | 140 | before :each do |
| 141 | - get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 141 | + get :edit, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 142 | end | 142 | end |
| 143 | 143 | ||
| 144 | it { is_expected.to redirect_to new_user_session_path } | 144 | it { is_expected.to redirect_to new_user_session_path } |
| @@ -164,10 +164,10 @@ describe MetricConfigurationsController, :type => :controller do | @@ -164,10 +164,10 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 164 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) | 164 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 165 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(true) | 165 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(true) |
| 166 | 166 | ||
| 167 | - post :update, kalibro_configuration_id: metric_configuration.configuration_id, id: metric_configuration.id, metric_configuration: metric_configuration_params | 167 | + post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: metric_configuration.id, metric_configuration: metric_configuration_params |
| 168 | end | 168 | end |
| 169 | 169 | ||
| 170 | - it { is_expected.to redirect_to(kalibro_configuration_path(metric_configuration.configuration_id)) } | 170 | + it { is_expected.to redirect_to(kalibro_configuration_path(metric_configuration.kalibro_configuration_id)) } |
| 171 | it { is_expected.to respond_with(:redirect) } | 171 | it { is_expected.to respond_with(:redirect) } |
| 172 | end | 172 | end |
| 173 | 173 | ||
| @@ -176,7 +176,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -176,7 +176,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 176 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) | 176 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 177 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(false) | 177 | MetricConfiguration.any_instance.expects(:update).with(metric_configuration_params).returns(false) |
| 178 | 178 | ||
| 179 | - post :update, kalibro_configuration_id: metric_configuration.configuration_id, id: metric_configuration.id, metric_configuration: metric_configuration_params | 179 | + post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: metric_configuration.id, metric_configuration: metric_configuration_params |
| 180 | end | 180 | end |
| 181 | 181 | ||
| 182 | it { is_expected.to render_template(:edit) } | 182 | it { is_expected.to render_template(:edit) } |
| @@ -185,10 +185,10 @@ describe MetricConfigurationsController, :type => :controller do | @@ -185,10 +185,10 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 185 | 185 | ||
| 186 | context 'when the user does not own the reading' do | 186 | context 'when the user does not own the reading' do |
| 187 | before :each do | 187 | before :each do |
| 188 | - post :update, kalibro_configuration_id: metric_configuration.configuration_id, id: metric_configuration.id, metric_configuration: metric_configuration_params | 188 | + post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: metric_configuration.id, metric_configuration: metric_configuration_params |
| 189 | end | 189 | end |
| 190 | 190 | ||
| 191 | - it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.configuration_id) } | 191 | + it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.kalibro_configuration_id) } |
| 192 | end | 192 | end |
| 193 | end | 193 | end |
| 194 | end | 194 | end |
| @@ -208,19 +208,19 @@ describe MetricConfigurationsController, :type => :controller do | @@ -208,19 +208,19 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 208 | metric_configuration.expects(:destroy) | 208 | metric_configuration.expects(:destroy) |
| 209 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) | 209 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 210 | 210 | ||
| 211 | - delete :destroy, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 211 | + delete :destroy, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 212 | end | 212 | end |
| 213 | 213 | ||
| 214 | - it { is_expected.to redirect_to(kalibro_configuration_path(metric_configuration.configuration_id)) } | 214 | + it { is_expected.to redirect_to(kalibro_configuration_path(metric_configuration.kalibro_configuration_id)) } |
| 215 | it { is_expected.to respond_with(:redirect) } | 215 | it { is_expected.to respond_with(:redirect) } |
| 216 | end | 216 | end |
| 217 | 217 | ||
| 218 | context "when the user doesn't own the configuration" do | 218 | context "when the user doesn't own the configuration" do |
| 219 | before :each do | 219 | before :each do |
| 220 | - delete :destroy, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 220 | + delete :destroy, id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 221 | end | 221 | end |
| 222 | 222 | ||
| 223 | - it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.configuration_id)) } | 223 | + it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } |
| 224 | it { is_expected.to respond_with(:redirect) } | 224 | it { is_expected.to respond_with(:redirect) } |
| 225 | end | 225 | end |
| 226 | end | 226 | end |
spec/controllers/mezuro_ranges_controller_spec.rb
| @@ -82,26 +82,26 @@ describe MezuroRangesController, :type => :controller do | @@ -82,26 +82,26 @@ describe MezuroRangesController, :type => :controller do | ||
| 82 | mezuro_range.expects(:destroy) | 82 | mezuro_range.expects(:destroy) |
| 83 | subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | 83 | subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) |
| 84 | 84 | ||
| 85 | - delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 85 | + delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 86 | end | 86 | end |
| 87 | 87 | ||
| 88 | - it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.configuration_id, metric_configuration.id)) } | 88 | + it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) } |
| 89 | it { is_expected.to respond_with(:redirect) } | 89 | it { is_expected.to respond_with(:redirect) } |
| 90 | end | 90 | end |
| 91 | 91 | ||
| 92 | context "when the user doesn't own the metric configuration" do | 92 | context "when the user doesn't own the metric configuration" do |
| 93 | before :each do | 93 | before :each do |
| 94 | - delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 94 | + delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 95 | end | 95 | end |
| 96 | 96 | ||
| 97 | - it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.configuration_id)) } | 97 | + it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } |
| 98 | it { is_expected.to respond_with(:redirect) } | 98 | it { is_expected.to respond_with(:redirect) } |
| 99 | end | 99 | end |
| 100 | end | 100 | end |
| 101 | 101 | ||
| 102 | context 'with no User logged in' do | 102 | context 'with no User logged in' do |
| 103 | before :each do | 103 | before :each do |
| 104 | - delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.configuration_id.to_s | 104 | + delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s |
| 105 | end | 105 | end |
| 106 | 106 | ||
| 107 | it { is_expected.to redirect_to new_user_session_path } | 107 | it { is_expected.to redirect_to new_user_session_path } |
| @@ -111,7 +111,7 @@ describe MezuroRangesController, :type => :controller do | @@ -111,7 +111,7 @@ describe MezuroRangesController, :type => :controller do | ||
| 111 | describe 'edit' do | 111 | describe 'edit' do |
| 112 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 112 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 113 | let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) } | 113 | let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) } |
| 114 | - let(:reading) { FactoryGirl.build(:reading, group_id: metric_configuration.reading_group_id) } | 114 | + let(:reading) { FactoryGirl.build(:reading, reading_group_id: metric_configuration.reading_group_id) } |
| 115 | 115 | ||
| 116 | context 'with an User logged in' do | 116 | context 'with an User logged in' do |
| 117 | before do | 117 | before do |
| @@ -124,7 +124,7 @@ describe MezuroRangesController, :type => :controller do | @@ -124,7 +124,7 @@ describe MezuroRangesController, :type => :controller do | ||
| 124 | subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | 124 | subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) |
| 125 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | 125 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) |
| 126 | Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) | 126 | Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) |
| 127 | - get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.configuration_id, metric_configuration_id: metric_configuration.id | 127 | + get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id |
| 128 | end | 128 | end |
| 129 | 129 | ||
| 130 | it { is_expected.to render_template(:edit) } | 130 | it { is_expected.to render_template(:edit) } |
| @@ -134,10 +134,10 @@ describe MezuroRangesController, :type => :controller do | @@ -134,10 +134,10 @@ describe MezuroRangesController, :type => :controller do | ||
| 134 | let!(:reading_group) { FactoryGirl.build(:reading_group, id: metric_configuration.reading_group_id) } | 134 | let!(:reading_group) { FactoryGirl.build(:reading_group, id: metric_configuration.reading_group_id) } |
| 135 | 135 | ||
| 136 | before do | 136 | before do |
| 137 | - get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.configuration_id, metric_configuration_id: metric_configuration.id | 137 | + get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id |
| 138 | end | 138 | end |
| 139 | 139 | ||
| 140 | - it { is_expected.to redirect_to(kalibro_configurations_url(metric_configuration.configuration_id)) } | 140 | + it { is_expected.to redirect_to(kalibro_configurations_url(metric_configuration.kalibro_configuration_id)) } |
| 141 | it { is_expected.to respond_with(:redirect) } | 141 | it { is_expected.to respond_with(:redirect) } |
| 142 | it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") } | 142 | it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") } |
| 143 | end | 143 | end |
| @@ -145,7 +145,7 @@ describe MezuroRangesController, :type => :controller do | @@ -145,7 +145,7 @@ describe MezuroRangesController, :type => :controller do | ||
| 145 | 145 | ||
| 146 | context 'with no user logged in' do | 146 | context 'with no user logged in' do |
| 147 | before :each do | 147 | before :each do |
| 148 | - get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.configuration_id, metric_configuration_id: metric_configuration.id | 148 | + get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id |
| 149 | end | 149 | end |
| 150 | 150 | ||
| 151 | it { is_expected.to redirect_to new_user_session_path } | 151 | it { is_expected.to redirect_to new_user_session_path } |
| @@ -156,7 +156,7 @@ describe MezuroRangesController, :type => :controller do | @@ -156,7 +156,7 @@ describe MezuroRangesController, :type => :controller do | ||
| 156 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 156 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 157 | let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) } | 157 | let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) } |
| 158 | let(:mezuro_range_params) { Hash[FactoryGirl.attributes_for(:mezuro_range).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers | 158 | let(:mezuro_range_params) { Hash[FactoryGirl.attributes_for(:mezuro_range).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers |
| 159 | - let(:reading) { FactoryGirl.build(:reading, group_id: metric_configuration.reading_group_id) } | 159 | + let(:reading) { FactoryGirl.build(:reading, reading_group_id: metric_configuration.reading_group_id) } |
| 160 | 160 | ||
| 161 | context 'when the user is logged in' do | 161 | context 'when the user is logged in' do |
| 162 | before do | 162 | before do |
| @@ -173,10 +173,10 @@ describe MezuroRangesController, :type => :controller do | @@ -173,10 +173,10 @@ describe MezuroRangesController, :type => :controller do | ||
| 173 | subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | 173 | subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) |
| 174 | MezuroRange.any_instance.expects(:update).with(mezuro_range_params).returns(true) | 174 | MezuroRange.any_instance.expects(:update).with(mezuro_range_params).returns(true) |
| 175 | 175 | ||
| 176 | - post :update, kalibro_configuration_id: metric_configuration.configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params | 176 | + post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params |
| 177 | end | 177 | end |
| 178 | 178 | ||
| 179 | - it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.configuration_id, metric_configuration.id)) } | 179 | + it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) } |
| 180 | it { is_expected.to respond_with(:redirect) } | 180 | it { is_expected.to respond_with(:redirect) } |
| 181 | end | 181 | end |
| 182 | 182 | ||
| @@ -187,7 +187,7 @@ describe MezuroRangesController, :type => :controller do | @@ -187,7 +187,7 @@ describe MezuroRangesController, :type => :controller do | ||
| 187 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | 187 | MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) |
| 188 | Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) | 188 | Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) |
| 189 | 189 | ||
| 190 | - post :update, kalibro_configuration_id: metric_configuration.configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params | 190 | + post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params |
| 191 | end | 191 | end |
| 192 | 192 | ||
| 193 | it { is_expected.to render_template(:edit) } | 193 | it { is_expected.to render_template(:edit) } |
| @@ -196,10 +196,10 @@ describe MezuroRangesController, :type => :controller do | @@ -196,10 +196,10 @@ describe MezuroRangesController, :type => :controller do | ||
| 196 | 196 | ||
| 197 | context 'when the user does not own the mezuro range' do | 197 | context 'when the user does not own the mezuro range' do |
| 198 | before :each do | 198 | before :each do |
| 199 | - post :update, kalibro_configuration_id: metric_configuration.configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params | 199 | + post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params |
| 200 | end | 200 | end |
| 201 | 201 | ||
| 202 | - it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.configuration_id) } | 202 | + it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.kalibro_configuration_id) } |
| 203 | end | 203 | end |
| 204 | end | 204 | end |
| 205 | end | 205 | end |
spec/controllers/readings_controller_spec.rb
| @@ -102,7 +102,7 @@ describe ReadingsController, :type => :controller do | @@ -102,7 +102,7 @@ describe ReadingsController, :type => :controller do | ||
| 102 | end | 102 | end |
| 103 | 103 | ||
| 104 | describe 'update' do | 104 | describe 'update' do |
| 105 | - let(:reading) { FactoryGirl.build(:reading) } | 105 | + let(:reading) { FactoryGirl.build(:reading, reading_group_id: reading_group.id) } |
| 106 | let(:reading_params) { Hash[FactoryGirl.attributes_for(:reading).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers | 106 | let(:reading_params) { Hash[FactoryGirl.attributes_for(:reading).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers |
| 107 | 107 | ||
| 108 | context 'when the user is logged in' do | 108 | context 'when the user is logged in' do |
| @@ -171,30 +171,30 @@ describe ReadingsController, :type => :controller do | @@ -171,30 +171,30 @@ describe ReadingsController, :type => :controller do | ||
| 171 | reading.expects(:destroy) | 171 | reading.expects(:destroy) |
| 172 | subject.expects(:find_resource).with(Reading, reading.id).returns(reading) | 172 | subject.expects(:find_resource).with(Reading, reading.id).returns(reading) |
| 173 | 173 | ||
| 174 | - delete :destroy, id: reading.id, reading_group_id: reading.group_id.to_s | 174 | + delete :destroy, id: reading.id, reading_group_id: reading.reading_group_id.to_s |
| 175 | end | 175 | end |
| 176 | 176 | ||
| 177 | - it { is_expected.to redirect_to(reading_group_path(reading.group_id)) } | 177 | + it { is_expected.to redirect_to(reading_group_path(reading.reading_group_id)) } |
| 178 | it { is_expected.to respond_with(:redirect) } | 178 | it { is_expected.to respond_with(:redirect) } |
| 179 | end | 179 | end |
| 180 | 180 | ||
| 181 | context "when the user doesn't own the reading group" do | 181 | context "when the user doesn't own the reading group" do |
| 182 | before :each do | 182 | before :each do |
| 183 | - delete :destroy, id: reading.id, reading_group_id: reading.group_id.to_s | 183 | + delete :destroy, id: reading.id, reading_group_id: reading.reading_group_id.to_s |
| 184 | end | 184 | end |
| 185 | 185 | ||
| 186 | - it { is_expected.to redirect_to(reading_group_path(reading.group_id)) } | 186 | + it { is_expected.to redirect_to(reading_group_path(reading.reading_group_id)) } |
| 187 | it { is_expected.to respond_with(:redirect) } | 187 | it { is_expected.to respond_with(:redirect) } |
| 188 | end | 188 | end |
| 189 | end | 189 | end |
| 190 | 190 | ||
| 191 | context 'with no User logged in' do | 191 | context 'with no User logged in' do |
| 192 | before :each do | 192 | before :each do |
| 193 | - delete :destroy, id: reading.id, reading_group_id: reading.group_id.to_s | 193 | + delete :destroy, id: reading.id, reading_group_id: reading.reading_group_id.to_s |
| 194 | end | 194 | end |
| 195 | 195 | ||
| 196 | it { is_expected.to redirect_to new_user_session_path } | 196 | it { is_expected.to redirect_to new_user_session_path } |
| 197 | end | 197 | end |
| 198 | end | 198 | end |
| 199 | 199 | ||
| 200 | -end | ||
| 201 | \ No newline at end of file | 200 | \ No newline at end of file |
| 201 | +end |
spec/factories/metric_collectors.rb
| @@ -2,7 +2,7 @@ FactoryGirl.define do | @@ -2,7 +2,7 @@ FactoryGirl.define do | ||
| 2 | factory :metric_collector, class: KalibroClient::Entities::Processor::MetricCollectorDetails do | 2 | factory :metric_collector, class: KalibroClient::Entities::Processor::MetricCollectorDetails do |
| 3 | name 'Analizo' | 3 | name 'Analizo' |
| 4 | description 'A metric collector' | 4 | description 'A metric collector' |
| 5 | - supported_metrics { { "total_abstract_classes" => FactoryGirl.build(:metric), "loc" => FactoryGirl.build(:loc)} } | 5 | + supported_metrics { { "total_abstract_classes" => FactoryGirl.build(:metric).to_hash, "loc" => FactoryGirl.build(:loc).to_hash} } |
| 6 | 6 | ||
| 7 | initialize_with { new({"name" => name, "description" => description, "supported_metrics" => supported_metrics}) } | 7 | initialize_with { new({"name" => name, "description" => description, "supported_metrics" => supported_metrics}) } |
| 8 | end | 8 | end |
spec/factories/metric_configurations.rb
| 1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
| 2 | factory :metric_configuration, class: MetricConfiguration do | 2 | factory :metric_configuration, class: MetricConfiguration do |
| 3 | id 1 | 3 | id 1 |
| 4 | - code 'total_abstract_classes' | ||
| 5 | - metric {FactoryGirl.build(:metric)} | ||
| 6 | - metric_collector_name "Analizo" | 4 | + metric {FactoryGirl.build(:metric, code: 'total_abstract_classes')} |
| 7 | weight 1 | 5 | weight 1 |
| 8 | aggregation_form "AVERAGE" | 6 | aggregation_form "AVERAGE" |
| 9 | reading_group_id 1 | 7 | reading_group_id 1 |
| @@ -12,19 +10,16 @@ FactoryGirl.define do | @@ -12,19 +10,16 @@ FactoryGirl.define do | ||
| 12 | 10 | ||
| 13 | factory :compound_metric_configuration, class: MetricConfiguration do | 11 | factory :compound_metric_configuration, class: MetricConfiguration do |
| 14 | id 1 | 12 | id 1 |
| 15 | - code 'compound' | ||
| 16 | - metric { FactoryGirl.build(:compound_metric, script: 'native*2;') } | 13 | + metric { FactoryGirl.build(:compound_metric, script: 'native*2;', code: 'compound') } |
| 17 | weight 1 | 14 | weight 1 |
| 18 | aggregation_form "AVERAGE" | 15 | aggregation_form "AVERAGE" |
| 19 | reading_group_id 1 | 16 | reading_group_id 1 |
| 20 | kalibro_configuration_id 1 | 17 | kalibro_configuration_id 1 |
| 21 | end | 18 | end |
| 22 | 19 | ||
| 23 | - factory :metric_configuration_with_snapshot, class: MetricConfiguration do | 20 | + factory :another_metric_configuration, class: MetricConfiguration do |
| 24 | id 1 | 21 | id 1 |
| 25 | - code 'total_modules' | ||
| 26 | - metric_snapshot {FactoryGirl.build(:metric)} | ||
| 27 | - metric_collector_name "Analizo" | 22 | + metric {FactoryGirl.build(:metric, code: 'total_modules')} |
| 28 | weight 1 | 23 | weight 1 |
| 29 | aggregation_form "MEDIAN" | 24 | aggregation_form "MEDIAN" |
| 30 | reading_group_id 1 | 25 | reading_group_id 1 |
spec/factories/metric_configurations_snapshot.rb
| @@ -1,26 +0,0 @@ | @@ -1,26 +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_configuration_snapshot, class: KalibroClient::Entities::Configurations::MetricSnapshot do | ||
| 19 | - code "code" | ||
| 20 | - weight "1.0" | ||
| 21 | - aggregation_form 'AVERAGE' | ||
| 22 | - metric {FactoryGirl.build(:metric)} | ||
| 23 | - metric_collector_name "Analizo" | ||
| 24 | - range {FactoryGirl.build(:range_snapshot)} | ||
| 25 | - end | ||
| 26 | -end |
spec/factories/metric_results.rb
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | FactoryGirl.define do | 17 | FactoryGirl.define do |
| 18 | factory :metric_result, class: KalibroClient::Entities::Processor::MetricResult do | 18 | factory :metric_result, class: KalibroClient::Entities::Processor::MetricResult do |
| 19 | id "42" | 19 | id "42" |
| 20 | - self.configuration { FactoryGirl.build(:metric_configuration) } | 20 | + metric_configuration { FactoryGirl.build(:metric_configuration) } |
| 21 | value "10.0" | 21 | value "10.0" |
| 22 | aggregated_value "21" | 22 | aggregated_value "21" |
| 23 | end | 23 | end |
spec/factories/metrics.rb
| 1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
| 2 | - factory :metric, class: KalibroClient::Entities::Processor::NativeMetric do | 2 | + factory :metric, class: KalibroClient::Entities::Miscellaneous::NativeMetric do |
| 3 | name "Total Abstract Classes" | 3 | name "Total Abstract Classes" |
| 4 | code "total_abstract_classes" | 4 | code "total_abstract_classes" |
| 5 | scope "SOFTWARE" | 5 | scope "SOFTWARE" |
| 6 | description nil | 6 | description nil |
| 7 | languages { [:C] } | 7 | languages { [:C] } |
| 8 | + metric_collector_name "Analizo" | ||
| 8 | 9 | ||
| 9 | initialize_with { new(name, code, scope, description, languages) } | 10 | initialize_with { new(name, code, scope, description, languages) } |
| 10 | end | 11 | end |
| 11 | 12 | ||
| 12 | - factory :loc, class: KalibroClient::Entities::Processor::NativeMetric do | 13 | + factory :loc, class: KalibroClient::Entities::Miscellaneous::NativeMetric do |
| 13 | name "Lines of Code" | 14 | name "Lines of Code" |
| 14 | code "loc" | 15 | code "loc" |
| 15 | scope "CLASS" | 16 | scope "CLASS" |
| 16 | description nil | 17 | description nil |
| 17 | languages { [:C] } | 18 | languages { [:C] } |
| 19 | + metric_collector_name "Analizo" | ||
| 18 | 20 | ||
| 19 | initialize_with { new(name, code, scope, description, languages) } | 21 | initialize_with { new(name, code, scope, description, languages) } |
| 20 | end | 22 | end |
| 21 | 23 | ||
| 22 | - factory :compound_metric, class: KalibroClient::Entities::Processor::CompoundMetric do | 24 | + factory :compound_metric, class: KalibroClient::Entities::Miscellaneous::CompoundMetric do |
| 23 | name "Compound" | 25 | name "Compound" |
| 24 | code "compound" | 26 | code "compound" |
| 25 | scope "CLASS" | 27 | scope "CLASS" |
| 26 | description nil | 28 | description nil |
| 27 | script "" | 29 | script "" |
| 28 | 30 | ||
| 29 | - initialize_with { new(name, code, scope, description, script) } | 31 | + initialize_with { new(name, code, scope, script) } |
| 30 | end | 32 | end |
| 31 | end | 33 | end |
spec/factories/module_results.rb
| 1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
| 2 | factory :module_result, class: ModuleResult do | 2 | factory :module_result, class: ModuleResult do |
| 3 | id 42 | 3 | id 42 |
| 4 | - self.module { FactoryGirl.build(:module) } | 4 | + kalibro_module { FactoryGirl.build(:kalibro_module) } |
| 5 | grade 10.0 | 5 | grade 10.0 |
| 6 | parent_id 21 | 6 | parent_id 21 |
| 7 | height 6 | 7 | height 6 |
| @@ -9,7 +9,7 @@ FactoryGirl.define do | @@ -9,7 +9,7 @@ FactoryGirl.define do | ||
| 9 | 9 | ||
| 10 | factory :root_module_result, class: ModuleResult do | 10 | factory :root_module_result, class: ModuleResult do |
| 11 | id 21 | 11 | id 21 |
| 12 | - self.module { FactoryGirl.build(:module) } | 12 | + kalibro_module { FactoryGirl.build(:kalibro_module) } |
| 13 | grade 6.0 | 13 | grade 6.0 |
| 14 | parent_id nil | 14 | parent_id nil |
| 15 | height 1 | 15 | height 1 |
spec/factories/modules.rb
spec/factories/processings.rb
| @@ -3,8 +3,7 @@ FactoryGirl.define do | @@ -3,8 +3,7 @@ FactoryGirl.define do | ||
| 3 | id "31" | 3 | id "31" |
| 4 | date "2011-10-20T18:26:43.151+00:00" | 4 | date "2011-10-20T18:26:43.151+00:00" |
| 5 | state "READY" | 5 | state "READY" |
| 6 | - process_time {[FactoryGirl.build(:process_time)]} | ||
| 7 | - results_root_id "13" | 6 | + root_module_result_id "13" |
| 8 | 7 | ||
| 9 | trait :errored do | 8 | trait :errored do |
| 10 | state "ERROR" | 9 | state "ERROR" |
| @@ -12,4 +11,4 @@ FactoryGirl.define do | @@ -12,4 +11,4 @@ FactoryGirl.define do | ||
| 12 | 11 | ||
| 13 | factory :errored_processing, traits: [:errored] | 12 | factory :errored_processing, traits: [:errored] |
| 14 | end | 13 | end |
| 15 | -end | ||
| 16 | \ No newline at end of file | 14 | \ No newline at end of file |
| 15 | +end |
spec/factories/ranges_snapshot.rb
| @@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | 16 | ||
| 17 | FactoryGirl.define do | 17 | FactoryGirl.define do |
| 18 | - factory :range_snapshot, class: KalibroClient::Entities::Configurations::KalibroRange do | 18 | + factory :range_snapshot, class: KalibroClient::Entities::Configurations::RangeSnapshot do |
| 19 | beginning 1.1 | 19 | beginning 1.1 |
| 20 | self.end 5.1 | 20 | self.end 5.1 |
| 21 | label "Snapshot" | 21 | label "Snapshot" |
spec/factories/repositories.rb
| @@ -19,10 +19,10 @@ FactoryGirl.define do | @@ -19,10 +19,10 @@ FactoryGirl.define do | ||
| 19 | name "SBKing" | 19 | name "SBKing" |
| 20 | description "A simple calculator" | 20 | description "A simple calculator" |
| 21 | license "GPLv3" | 21 | license "GPLv3" |
| 22 | - process_period 1 | ||
| 23 | - type "GIT" | 22 | + period 1 |
| 23 | + scm_type "GIT" | ||
| 24 | address "https://git.gitorious.org/sbking/sbking.git" | 24 | address "https://git.gitorious.org/sbking/sbking.git" |
| 25 | - configuration_id 1 | 25 | + kalibro_configuration_id 1 |
| 26 | project_id 1 | 26 | project_id 1 |
| 27 | send_email "test@test.com" | 27 | send_email "test@test.com" |
| 28 | end | 28 | end |
| @@ -30,4 +30,4 @@ FactoryGirl.define do | @@ -30,4 +30,4 @@ FactoryGirl.define do | ||
| 30 | factory :another_repository, parent: :repository do | 30 | factory :another_repository, parent: :repository do |
| 31 | id 2 | 31 | id 2 |
| 32 | end | 32 | end |
| 33 | -end | ||
| 34 | \ No newline at end of file | 33 | \ No newline at end of file |
| 34 | +end |
spec/helpers/metric_configurations_helper_spec.rb
| @@ -24,11 +24,11 @@ describe MetricConfigurationsHelper, :type => :helper do | @@ -24,11 +24,11 @@ describe MetricConfigurationsHelper, :type => :helper do | ||
| 24 | let! (:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 24 | let! (:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 25 | 25 | ||
| 26 | before :each do | 26 | before :each do |
| 27 | - MetricConfiguration.expects(:metric_configurations_of).with(metric_configuration.configuration_id).returns([metric_configuration]) | 27 | + MetricConfiguration.expects(:metric_configurations_of).with(metric_configuration.kalibro_configuration_id).returns([metric_configuration]) |
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | it 'should return a pair with the metric configuration code and metric name' do | 30 | it 'should return a pair with the metric configuration code and metric name' do |
| 31 | - expect(helper.native_metrics_of(metric_configuration.configuration_id)).to eq [[metric_configuration.code, metric_configuration.metric.name]] | 31 | + expect(helper.native_metrics_of(metric_configuration.kalibro_configuration_id)).to eq [[metric_configuration.metric.code, metric_configuration.metric.name]] |
| 32 | end | 32 | end |
| 33 | end | 33 | end |
| 34 | end | 34 | end |
spec/helpers/mezuro_configurations_helper_spec.rb
| @@ -45,32 +45,32 @@ describe KalibroConfigurationsHelper, :type => :helper do | @@ -45,32 +45,32 @@ describe KalibroConfigurationsHelper, :type => :helper do | ||
| 45 | describe 'link to edit form' do | 45 | describe 'link to edit form' do |
| 46 | context 'when the metric is native' do | 46 | context 'when the metric is native' do |
| 47 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 47 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 48 | - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.configuration_id}/metric_configurations/#{metric_configuration.id}/edit\">Edit</a>"} | 48 | + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.kalibro_configuration_id}/metric_configurations/#{metric_configuration.id}/edit\">Edit</a>"} |
| 49 | 49 | ||
| 50 | - it { expect(helper.link_to_edit_form(metric_configuration, metric_configuration.configuration_id)).to eq(response_link) } | 50 | + it { expect(helper.link_to_edit_form(metric_configuration, metric_configuration.kalibro_configuration_id)).to eq(response_link) } |
| 51 | end | 51 | end |
| 52 | 52 | ||
| 53 | context 'when the metric is compound' do | 53 | context 'when the metric is compound' do |
| 54 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } | 54 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } |
| 55 | - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}/edit\">Edit</a>"} | 55 | + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.kalibro_configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}/edit\">Edit</a>"} |
| 56 | 56 | ||
| 57 | - it { expect(helper.link_to_edit_form(compound_metric_configuration, compound_metric_configuration.configuration_id)).to eq(response_link) } | 57 | + it { expect(helper.link_to_edit_form(compound_metric_configuration, compound_metric_configuration.kalibro_configuration_id)).to eq(response_link) } |
| 58 | end | 58 | end |
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | describe 'link to show page' do | 61 | describe 'link to show page' do |
| 62 | context 'when the metric is native' do | 62 | context 'when the metric is native' do |
| 63 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | 63 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 64 | - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.configuration_id}/metric_configurations/#{metric_configuration.id}\">Show</a>"} | 64 | + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.kalibro_configuration_id}/metric_configurations/#{metric_configuration.id}\">Show</a>"} |
| 65 | 65 | ||
| 66 | - it { expect(helper.link_to_show_page(metric_configuration, metric_configuration.configuration_id)).to eq(response_link) } | 66 | + it { expect(helper.link_to_show_page(metric_configuration, metric_configuration.kalibro_configuration_id)).to eq(response_link) } |
| 67 | end | 67 | end |
| 68 | 68 | ||
| 69 | context 'when the metric is compound' do | 69 | context 'when the metric is compound' do |
| 70 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } | 70 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } |
| 71 | - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}\">Show</a>"} | 71 | + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.kalibro_configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}\">Show</a>"} |
| 72 | 72 | ||
| 73 | - it { expect(helper.link_to_show_page(compound_metric_configuration, compound_metric_configuration.configuration_id)).to eq(response_link) } | 73 | + it { expect(helper.link_to_show_page(compound_metric_configuration, compound_metric_configuration.kalibro_configuration_id)).to eq(response_link) } |
| 74 | end | 74 | end |
| 75 | end | 75 | end |
| 76 | end | 76 | end |
spec/helpers/processings_helper_spec.rb
| @@ -14,15 +14,15 @@ describe ProcessingsHelper, :type => :helper do | @@ -14,15 +14,15 @@ describe ProcessingsHelper, :type => :helper do | ||
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | describe 'find_range_snapshot' do | 16 | describe 'find_range_snapshot' do |
| 17 | - let(:metric_configuration_snapshot) { FactoryGirl.build(:metric_configuration_snapshot)} | ||
| 18 | - let(:metric_result) { FactoryGirl.build(:metric_result, {value: 6.0, configuration: metric_configuration_snapshot})} | 17 | + let(:metric_configuration) { FactoryGirl.build(:metric_configuration)} |
| 18 | + let(:metric_result) { FactoryGirl.build(:metric_result, {value: 6.0, metric_configuration: metric_configuration})} | ||
| 19 | let(:range_snapshot_1_to_5) { FactoryGirl.build(:range_snapshot, {beginning: 1.0, end: 5.0}) } | 19 | let(:range_snapshot_1_to_5) { FactoryGirl.build(:range_snapshot, {beginning: 1.0, end: 5.0}) } |
| 20 | let(:range_snapshot_5dot1_to_10) { FactoryGirl.build(:range_snapshot, {beginning: 5.1, end: 10.0}) } | 20 | let(:range_snapshot_5dot1_to_10) { FactoryGirl.build(:range_snapshot, {beginning: 5.1, end: 10.0}) } |
| 21 | let(:range_snapshot_10dot1_to_15) { FactoryGirl.build(:range_snapshot, {beginning: 10.1, end: 15.0}) } | 21 | let(:range_snapshot_10dot1_to_15) { FactoryGirl.build(:range_snapshot, {beginning: 10.1, end: 15.0}) } |
| 22 | 22 | ||
| 23 | before :each do | 23 | before :each do |
| 24 | - metric_result.expects(:metric_configuration).returns(metric_result.configuration) | ||
| 25 | - metric_configuration_snapshot.expects(:kalibro_ranges). | 24 | + metric_result.expects(:metric_configuration).returns(metric_result.metric_configuration) |
| 25 | + metric_configuration.expects(:kalibro_ranges). | ||
| 26 | returns([range_snapshot_1_to_5, | 26 | returns([range_snapshot_1_to_5, |
| 27 | range_snapshot_5dot1_to_10, | 27 | range_snapshot_5dot1_to_10, |
| 28 | range_snapshot_10dot1_to_15]) | 28 | range_snapshot_10dot1_to_15]) |
spec/models/module_result_spec.rb
| @@ -6,20 +6,20 @@ describe ModuleResult, :type => :model do | @@ -6,20 +6,20 @@ describe ModuleResult, :type => :model do | ||
| 6 | 6 | ||
| 7 | describe 'metric_history' do | 7 | describe 'metric_history' do |
| 8 | let(:date_module_result) {FactoryGirl.build(:date_module_result)} | 8 | let(:date_module_result) {FactoryGirl.build(:date_module_result)} |
| 9 | - let(:metric_result) { FactoryGirl.build(:metric_result, configuration: FactoryGirl.build(:metric_configuration_with_snapshot)) } | 9 | + let!(:metric_result) { FactoryGirl.build(:metric_result, metric_configuration: FactoryGirl.build(:another_metric_configuration)) } |
| 10 | let(:processing) {FactoryGirl.build(:processing)} | 10 | let(:processing) {FactoryGirl.build(:processing)} |
| 11 | let(:repository) {FactoryGirl.build(:repository)} | 11 | let(:repository) {FactoryGirl.build(:repository)} |
| 12 | 12 | ||
| 13 | before :each do | 13 | before :each do |
| 14 | subject.expects(:processing).returns(processing) | 14 | subject.expects(:processing).returns(processing) |
| 15 | - metric_result.expects(:metric_configuration).returns(metric_result.configuration) | 15 | + metric_result.expects(:metric_configuration).returns(metric_result.metric_configuration) |
| 16 | processing.expects(:repository).returns(repository) | 16 | processing.expects(:repository).returns(repository) |
| 17 | repository.expects(:module_result_history_of).with(subject).returns([date_module_result]) | 17 | repository.expects(:module_result_history_of).with(subject).returns([date_module_result]) |
| 18 | ModuleResult.any_instance.expects(:metric_results).returns([metric_result]) | 18 | ModuleResult.any_instance.expects(:metric_results).returns([metric_result]) |
| 19 | end | 19 | end |
| 20 | 20 | ||
| 21 | it 'should return the history for the given metric name' do | 21 | it 'should return the history for the given metric name' do |
| 22 | - expect(subject.metric_history(metric_result.configuration.metric_snapshot.name)).to eq({date_module_result.date => metric_result.value}) | 22 | + expect(subject.metric_history(metric_result.metric_configuration.metric.name)).to eq({date_module_result.date => metric_result.value}) |
| 23 | end | 23 | end |
| 24 | end | 24 | end |
| 25 | end | 25 | end |