Commit 68d81c1506eda63b83ca275d85a6129f97c6f50f
Committed by
Diego Camarinha
1 parent
7ac9c4e7
Exists in
colab
and in
4 other branches
All occurences of base_tool were replaced by metric_collector
This broke kalibro_gatekeeper_client MetricConfigurationSnapshot. So the gem was updated to the git version
Showing
10 changed files
with
42 additions
and
36 deletions
Show diff stats
Gemfile
| ... | ... | @@ -31,7 +31,7 @@ gem 'jbuilder', '~> 2.1.2' |
| 31 | 31 | gem 'devise', '~> 3.3.0' |
| 32 | 32 | |
| 33 | 33 | # Kalibro integration |
| 34 | -gem 'kalibro_gatekeeper_client', "~> 1.0.0.rc2" | |
| 34 | +gem 'kalibro_gatekeeper_client', github: 'mezuro/kalibro_gatekeeper_client', branch: 'refactoring_metric_collector' # FIXME: to gem 'kalibro_gatekeeper_client', "~> 1.0.0" as soon as it gets released | |
| 35 | 35 | |
| 36 | 36 | # PostgreSQL integration |
| 37 | 37 | gem "pg", "~> 0.17.0" | ... | ... |
Gemfile.lock
| 1 | 1 | GIT |
| 2 | + remote: git://github.com/mezuro/kalibro_gatekeeper_client.git | |
| 3 | + revision: 071b4cdc6b1ff0d8f1a827b19e0292e87d74d596 | |
| 4 | + branch: refactoring_metric_collector | |
| 5 | + specs: | |
| 6 | + kalibro_gatekeeper_client (1.0.0.rc2) | |
| 7 | + activesupport (>= 2.2.1) | |
| 8 | + faraday_middleware (~> 0.9.0) | |
| 9 | + | |
| 10 | +GIT | |
| 2 | 11 | remote: git://github.com/seyhunak/twitter-bootstrap-rails.git |
| 3 | 12 | revision: 95de3b0e288aede73d38a18cce30cde66e733558 |
| 4 | 13 | ref: 95de3b0 |
| ... | ... | @@ -136,9 +145,6 @@ GEM |
| 136 | 145 | jquery-ui-rails (5.0.0) |
| 137 | 146 | railties (>= 3.2.16) |
| 138 | 147 | json (1.8.1) |
| 139 | - kalibro_gatekeeper_client (1.0.0.rc2) | |
| 140 | - activesupport (>= 2.2.1) | |
| 141 | - faraday_middleware (~> 0.9.0) | |
| 142 | 148 | konacha (3.2.4) |
| 143 | 149 | actionpack (>= 3.1, < 5) |
| 144 | 150 | capybara |
| ... | ... | @@ -293,7 +299,7 @@ DEPENDENCIES |
| 293 | 299 | jbuilder (~> 2.1.2) |
| 294 | 300 | jquery-rails |
| 295 | 301 | jquery-ui-rails (~> 5.0.0) |
| 296 | - kalibro_gatekeeper_client (~> 1.0.0.rc2) | |
| 302 | + kalibro_gatekeeper_client! | |
| 297 | 303 | konacha (~> 3.2.0) |
| 298 | 304 | mocha |
| 299 | 305 | pg (~> 0.17.0) | ... | ... |
app/assets/javascripts/base_tool.js.coffee
| 1 | 1 | class @BaseTool |
| 2 | - | |
| 2 | + | |
| 3 | 3 | # Static Method |
| 4 | - @choose_metric: (metric_name, base_tool_name) -> | |
| 4 | + @choose_metric: (metric_name, metric_collector_name) -> | |
| 5 | 5 | $("#metric_name").val(metric_name) |
| 6 | - $("#base_tool_name").val(base_tool_name) | |
| 6 | + $("#metric_collector_name").val(metric_collector_name) | |
| 7 | 7 | $("form").submit() | ... | ... |
app/controllers/metric_configurations_controller.rb
| ... | ... | @@ -2,20 +2,20 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
| 2 | 2 | def choose_metric |
| 3 | 3 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i |
| 4 | 4 | @metric_configuration_id = params[:metric_configuration_id].to_i |
| 5 | - @base_tools = KalibroGatekeeperClient::Entities::MetricCollector.all | |
| 5 | + @metric_collectors = KalibroGatekeeperClient::Entities::MetricCollector.all | |
| 6 | 6 | @exist_metric = params[:exist_metric] |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | def new |
| 10 | 10 | super |
| 11 | - metric_configuration.metric_collector_name = params[:base_tool_name] | |
| 12 | - metric_configuration.metric = KalibroGatekeeperClient::Entities::MetricCollector.find_by_name(params[:base_tool_name]).metric params[:metric_name] | |
| 11 | + metric_configuration.metric_collector_name = params[:metric_collector_name] | |
| 12 | + metric_configuration.metric = KalibroGatekeeperClient::Entities::MetricCollector.find_by_name(params[:metric_collector_name]).metric params[:metric_name] | |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | def create |
| 16 | 16 | super |
| 17 | - @metric_configuration.metric = KalibroGatekeeperClient::Entities::MetricCollector.find_by_name(params[:base_tool_name]).metric params[:metric_name] | |
| 18 | - @metric_configuration.metric_collector_name = params[:base_tool_name] | |
| 17 | + @metric_configuration.metric = KalibroGatekeeperClient::Entities::MetricCollector.find_by_name(params[:metric_collector_name]).metric params[:metric_name] | |
| 18 | + @metric_configuration.metric_collector_name = params[:metric_collector_name] | |
| 19 | 19 | @metric_configuration.code = @metric_configuration.metric.code |
| 20 | 20 | respond_to do |format| |
| 21 | 21 | create_and_redir(format) | ... | ... |
app/views/metric_configurations/_form.html.erb
| ... | ... | @@ -47,4 +47,4 @@ |
| 47 | 47 | </div> |
| 48 | 48 | |
| 49 | 49 | <%= hidden_field_tag(:metric_name, @metric_configuration.metric.name) %> |
| 50 | -<%= hidden_field_tag(:base_tool_name, @metric_configuration.metric_collector_name) %> | |
| 50 | +<%= hidden_field_tag(:metric_collector_name, @metric_configuration.metric_collector_name) %> | ... | ... |
app/views/metric_configurations/choose_metric.html.erb
| ... | ... | @@ -3,16 +3,16 @@ |
| 3 | 3 | </div> |
| 4 | 4 | |
| 5 | 5 | <%= form_tag mezuro_configuration_new_metric_configuration_path(@mezuro_configuration_id) do %> |
| 6 | - <%= hidden_field_tag(:base_tool_name,) %> | |
| 6 | + <%= hidden_field_tag(:metric_collector_name,) %> | |
| 7 | 7 | <%= hidden_field_tag(:metric_name) %> |
| 8 | 8 | <% end %> |
| 9 | 9 | |
| 10 | 10 | <div id="base-tool-accordion"> |
| 11 | - <% @base_tools.each do |base_tool| %> | |
| 12 | - <h3 class="jquery-ui-accordion"><%= base_tool.name %></h3> | |
| 11 | + <% @metric_collectors.each do |metric_collector| %> | |
| 12 | + <h3 class="jquery-ui-accordion"><%= metric_collector.name %></h3> | |
| 13 | 13 | <div> |
| 14 | - <% base_tool.supported_metrics.each do |code, metric| %> | |
| 15 | - <%= link_to metric.name, '#', onclick: "BaseTool.choose_metric(\"#{metric.name}\", \"#{base_tool.name}\");", remote: true %><br> | |
| 14 | + <% metric_collector.supported_metrics.each do |code, metric| %> | |
| 15 | + <%= link_to metric.name, '#', onclick: "BaseTool.choose_metric(\"#{metric.name}\", \"#{metric_collector.name}\");", remote: true %><br> | |
| 16 | 16 | <% end %> |
| 17 | 17 | </div> |
| 18 | 18 | <% end %> | ... | ... |
spec/controllers/base_metric_configurations_controller_spec.rb
| ... | ... | @@ -88,7 +88,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do |
| 88 | 88 | describe 'create' do |
| 89 | 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 | 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 |
| 91 | - let(:base_tool) { FactoryGirl.build(:base_tool) } | |
| 91 | + let(:metric_collector) { FactoryGirl.build(:metric_collector) } | |
| 92 | 92 | |
| 93 | 93 | before :each do |
| 94 | 94 | sign_in FactoryGirl.create(:user) |
| ... | ... | @@ -101,7 +101,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do |
| 101 | 101 | |
| 102 | 102 | context 'with valid fields' do |
| 103 | 103 | before :each do |
| 104 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name | |
| 104 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name | |
| 105 | 105 | end |
| 106 | 106 | |
| 107 | 107 | it { expect(subject.metric_configuration).not_to be_nil } | ... | ... |
spec/controllers/metric_configurations_controller_spec.rb
| ... | ... | @@ -3,7 +3,7 @@ require 'rails_helper' |
| 3 | 3 | describe MetricConfigurationsController, :type => :controller do |
| 4 | 4 | let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } |
| 5 | 5 | describe 'choose_metric' do |
| 6 | - let(:base_tool) { FactoryGirl.build(:base_tool) } | |
| 6 | + let(:metric_collector) { FactoryGirl.build(:metric_collector) } | |
| 7 | 7 | before :each do |
| 8 | 8 | sign_in FactoryGirl.create(:user) |
| 9 | 9 | end |
| ... | ... | @@ -11,7 +11,7 @@ describe MetricConfigurationsController, :type => :controller do |
| 11 | 11 | context 'when adding new metrics' do |
| 12 | 12 | before :each do |
| 13 | 13 | subject.expects(:mezuro_configuration_owner?).returns true |
| 14 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:all).returns([base_tool]) | |
| 14 | + KalibroGatekeeperClient::Entities::MetricCollector.expects(:all).returns([metric_collector]) | |
| 15 | 15 | get :choose_metric, mezuro_configuration_id: mezuro_configuration.id |
| 16 | 16 | end |
| 17 | 17 | |
| ... | ... | @@ -21,7 +21,7 @@ describe MetricConfigurationsController, :type => :controller do |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | describe 'new' do |
| 24 | - let(:base_tool) { FactoryGirl.build(:base_tool) } | |
| 24 | + let(:metric_collector) { FactoryGirl.build(:metric_collector) } | |
| 25 | 25 | before :each do |
| 26 | 26 | sign_in FactoryGirl.create(:user) |
| 27 | 27 | end |
| ... | ... | @@ -29,8 +29,8 @@ describe MetricConfigurationsController, :type => :controller do |
| 29 | 29 | context 'when the current user owns the mezuro configuration' do |
| 30 | 30 | before :each do |
| 31 | 31 | subject.expects(:mezuro_configuration_owner?).returns true |
| 32 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(base_tool.name).returns(base_tool) | |
| 33 | - post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", base_tool_name: base_tool.name | |
| 32 | + KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | |
| 33 | + post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", metric_collector_name: metric_collector.name | |
| 34 | 34 | end |
| 35 | 35 | |
| 36 | 36 | it { is_expected.to respond_with(:success) } |
| ... | ... | @@ -39,7 +39,7 @@ describe MetricConfigurationsController, :type => :controller do |
| 39 | 39 | |
| 40 | 40 | context "when the current user doesn't owns the mezuro configuration" do |
| 41 | 41 | before :each do |
| 42 | - post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", base_tool_name: base_tool.name | |
| 42 | + post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", metric_collector_name: metric_collector.name | |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | it { is_expected.to redirect_to(mezuro_configurations_url(mezuro_configuration.id)) } |
| ... | ... | @@ -51,7 +51,7 @@ describe MetricConfigurationsController, :type => :controller do |
| 51 | 51 | let!(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
| 52 | 52 | 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 |
| 53 | 53 | let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } |
| 54 | - let(:base_tool) { FactoryGirl.build(:base_tool) } | |
| 54 | + let(:metric_collector) { FactoryGirl.build(:metric_collector) } | |
| 55 | 55 | |
| 56 | 56 | before do |
| 57 | 57 | sign_in FactoryGirl.create(:user) |
| ... | ... | @@ -65,10 +65,10 @@ describe MetricConfigurationsController, :type => :controller do |
| 65 | 65 | context 'with valid fields' do |
| 66 | 66 | before :each do |
| 67 | 67 | MetricConfiguration.any_instance.expects(:save).returns(true) |
| 68 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(base_tool.name).returns(base_tool) | |
| 69 | - base_tool.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
| 68 | + KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | |
| 69 | + metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
| 70 | 70 | |
| 71 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name | |
| 71 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name | |
| 72 | 72 | end |
| 73 | 73 | |
| 74 | 74 | it { is_expected.to respond_with(:redirect) } |
| ... | ... | @@ -77,10 +77,10 @@ describe MetricConfigurationsController, :type => :controller do |
| 77 | 77 | context 'with invalid fields' do |
| 78 | 78 | before :each do |
| 79 | 79 | MetricConfiguration.any_instance.expects(:save).returns(false) |
| 80 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(base_tool.name).returns(base_tool) | |
| 81 | - base_tool.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
| 80 | + KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | |
| 81 | + metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
| 82 | 82 | |
| 83 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name | |
| 83 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name | |
| 84 | 84 | end |
| 85 | 85 | |
| 86 | 86 | it { is_expected.to render_template(:new) } | ... | ... |
spec/factories/base_tools.rb
| 1 | 1 | FactoryGirl.define do |
| 2 | - factory :base_tool, class: KalibroGatekeeperClient::Entities::MetricCollector do | |
| 2 | + factory :metric_collector, class: KalibroGatekeeperClient::Entities::MetricCollector do | |
| 3 | 3 | name 'Analizo' |
| 4 | 4 | supported_metrics { { "total_abstract_classes" => FactoryGirl.build(:metric).to_hash, "loc" => FactoryGirl.build(:loc).to_hash } } |
| 5 | 5 | end | ... | ... |
spec/factories/metric_configurations_snapshot.rb
| ... | ... | @@ -20,7 +20,7 @@ FactoryGirl.define do |
| 20 | 20 | weight "1.0" |
| 21 | 21 | aggregation_form 'AVERAGE' |
| 22 | 22 | metric {FactoryGirl.build(:metric)} |
| 23 | - base_tool_name "Analizo" | |
| 23 | + metric_collector_name "Analizo" | |
| 24 | 24 | range {FactoryGirl.build(:range_snapshot)} |
| 25 | 25 | end |
| 26 | 26 | end |
| 27 | 27 | \ No newline at end of file | ... | ... |