Commit 7ac9c4e7142d820bdc909cfa2ca87c86da6eb5ae
Committed by
Diego Camarinha
1 parent
1cf9ed64
Exists in
colab
and in
4 other branches
updated kalibro_gatekeeper_client
Showing
10 changed files
with
19 additions
and
19 deletions
Show diff stats
Gemfile
| @@ -31,7 +31,7 @@ gem 'jbuilder', '~> 2.1.2' | @@ -31,7 +31,7 @@ gem 'jbuilder', '~> 2.1.2' | ||
| 31 | gem 'devise', '~> 3.3.0' | 31 | gem 'devise', '~> 3.3.0' |
| 32 | 32 | ||
| 33 | # Kalibro integration | 33 | # Kalibro integration |
| 34 | -gem 'kalibro_gatekeeper_client', "~> 0.3.1" | 34 | +gem 'kalibro_gatekeeper_client', "~> 1.0.0.rc2" |
| 35 | 35 | ||
| 36 | # PostgreSQL integration | 36 | # PostgreSQL integration |
| 37 | gem "pg", "~> 0.17.0" | 37 | gem "pg", "~> 0.17.0" |
Gemfile.lock
| @@ -136,7 +136,7 @@ GEM | @@ -136,7 +136,7 @@ GEM | ||
| 136 | jquery-ui-rails (5.0.0) | 136 | jquery-ui-rails (5.0.0) |
| 137 | railties (>= 3.2.16) | 137 | railties (>= 3.2.16) |
| 138 | json (1.8.1) | 138 | json (1.8.1) |
| 139 | - kalibro_gatekeeper_client (0.3.2) | 139 | + kalibro_gatekeeper_client (1.0.0.rc2) |
| 140 | activesupport (>= 2.2.1) | 140 | activesupport (>= 2.2.1) |
| 141 | faraday_middleware (~> 0.9.0) | 141 | faraday_middleware (~> 0.9.0) |
| 142 | konacha (3.2.4) | 142 | konacha (3.2.4) |
| @@ -293,7 +293,7 @@ DEPENDENCIES | @@ -293,7 +293,7 @@ DEPENDENCIES | ||
| 293 | jbuilder (~> 2.1.2) | 293 | jbuilder (~> 2.1.2) |
| 294 | jquery-rails | 294 | jquery-rails |
| 295 | jquery-ui-rails (~> 5.0.0) | 295 | jquery-ui-rails (~> 5.0.0) |
| 296 | - kalibro_gatekeeper_client (~> 0.3.1) | 296 | + kalibro_gatekeeper_client (~> 1.0.0.rc2) |
| 297 | konacha (~> 3.2.0) | 297 | konacha (~> 3.2.0) |
| 298 | mocha | 298 | mocha |
| 299 | pg (~> 0.17.0) | 299 | pg (~> 0.17.0) |
app/controllers/metric_configurations_controller.rb
| @@ -2,20 +2,20 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -2,20 +2,20 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
| 2 | def choose_metric | 2 | def choose_metric |
| 3 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i | 3 | @mezuro_configuration_id = params[:mezuro_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 | - @base_tools = KalibroGatekeeperClient::Entities::BaseTool.all | 5 | + @base_tools = KalibroGatekeeperClient::Entities::MetricCollector.all |
| 6 | @exist_metric = params[:exist_metric] | 6 | @exist_metric = params[:exist_metric] |
| 7 | end | 7 | end |
| 8 | 8 | ||
| 9 | def new | 9 | def new |
| 10 | super | 10 | super |
| 11 | - metric_configuration.base_tool_name = params[:base_tool_name] | ||
| 12 | - metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] | 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] | ||
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | def create | 15 | def create |
| 16 | super | 16 | super |
| 17 | - @metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] | ||
| 18 | - @metric_configuration.base_tool_name = params[:base_tool_name] | 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] | ||
| 19 | @metric_configuration.code = @metric_configuration.metric.code | 19 | @metric_configuration.code = @metric_configuration.metric.code |
| 20 | respond_to do |format| | 20 | respond_to do |format| |
| 21 | create_and_redir(format) | 21 | create_and_redir(format) |
app/views/metric_configurations/_form.html.erb
| @@ -47,4 +47,4 @@ | @@ -47,4 +47,4 @@ | ||
| 47 | </div> | 47 | </div> |
| 48 | 48 | ||
| 49 | <%= hidden_field_tag(:metric_name, @metric_configuration.metric.name) %> | 49 | <%= hidden_field_tag(:metric_name, @metric_configuration.metric.name) %> |
| 50 | -<%= hidden_field_tag(:base_tool_name, @metric_configuration.base_tool_name) %> | 50 | +<%= hidden_field_tag(:base_tool_name, @metric_configuration.metric_collector_name) %> |
app/views/metric_configurations/choose_metric.html.erb
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | <% @base_tools.each do |base_tool| %> | 11 | <% @base_tools.each do |base_tool| %> |
| 12 | <h3 class="jquery-ui-accordion"><%= base_tool.name %></h3> | 12 | <h3 class="jquery-ui-accordion"><%= base_tool.name %></h3> |
| 13 | <div> | 13 | <div> |
| 14 | - <% base_tool.supported_metrics.each do |metric| %> | 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> | 15 | <%= link_to metric.name, '#', onclick: "BaseTool.choose_metric(\"#{metric.name}\", \"#{base_tool.name}\");", remote: true %><br> |
| 16 | <% end %> | 16 | <% end %> |
| 17 | </div> | 17 | </div> |
app/views/metric_configurations/new.html.erb
app/views/metric_configurations/show.html.erb
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(:mezuro_configuration_owner?).returns true | 13 | subject.expects(:mezuro_configuration_owner?).returns true |
| 14 | - KalibroGatekeeperClient::Entities::BaseTool.expects(:all).returns([base_tool]) | 14 | + KalibroGatekeeperClient::Entities::MetricCollector.expects(:all).returns([base_tool]) |
| 15 | get :choose_metric, mezuro_configuration_id: mezuro_configuration.id | 15 | get :choose_metric, mezuro_configuration_id: mezuro_configuration.id |
| 16 | end | 16 | end |
| 17 | 17 | ||
| @@ -29,7 +29,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -29,7 +29,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 29 | context 'when the current user owns the mezuro configuration' do | 29 | context 'when the current user owns the mezuro configuration' do |
| 30 | before :each do | 30 | before :each do |
| 31 | subject.expects(:mezuro_configuration_owner?).returns true | 31 | subject.expects(:mezuro_configuration_owner?).returns true |
| 32 | - KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) | 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 | 33 | post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", base_tool_name: base_tool.name |
| 34 | end | 34 | end |
| 35 | 35 | ||
| @@ -65,7 +65,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -65,7 +65,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 65 | context 'with valid fields' do | 65 | context 'with valid fields' do |
| 66 | before :each do | 66 | before :each do |
| 67 | MetricConfiguration.any_instance.expects(:save).returns(true) | 67 | MetricConfiguration.any_instance.expects(:save).returns(true) |
| 68 | - KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) | 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) | 69 | base_tool.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, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name |
| @@ -77,7 +77,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -77,7 +77,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 77 | context 'with invalid fields' do | 77 | context 'with invalid fields' do |
| 78 | before :each do | 78 | before :each do |
| 79 | MetricConfiguration.any_instance.expects(:save).returns(false) | 79 | MetricConfiguration.any_instance.expects(:save).returns(false) |
| 80 | - KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) | 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) | 81 | base_tool.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, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name |
spec/factories/base_tools.rb
| 1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
| 2 | - factory :base_tool, class: KalibroGatekeeperClient::Entities::BaseTool do | 2 | + factory :base_tool, class: KalibroGatekeeperClient::Entities::MetricCollector do |
| 3 | name 'Analizo' | 3 | name 'Analizo' |
| 4 | - supported_metric {FactoryGirl.build(:loc)} | 4 | + supported_metrics { { "total_abstract_classes" => FactoryGirl.build(:metric).to_hash, "loc" => FactoryGirl.build(:loc).to_hash } } |
| 5 | end | 5 | end |
| 6 | end | 6 | end |
spec/factories/metric_configurations.rb
| @@ -3,7 +3,7 @@ FactoryGirl.define do | @@ -3,7 +3,7 @@ FactoryGirl.define do | ||
| 3 | id 1 | 3 | id 1 |
| 4 | code 'total_abstract_classes' | 4 | code 'total_abstract_classes' |
| 5 | metric {FactoryGirl.build(:metric)} | 5 | metric {FactoryGirl.build(:metric)} |
| 6 | - base_tool_name "Analizo" | 6 | + metric_collector_name "Analizo" |
| 7 | weight 1 | 7 | weight 1 |
| 8 | aggregation_form "AVERAGE" | 8 | aggregation_form "AVERAGE" |
| 9 | reading_group_id 1 | 9 | reading_group_id 1 |