From 85e76eb7542a84c8ab299ddb9cdd1c03e3afb5f1 Mon Sep 17 00:00:00 2001 From: Renan Fichberg Date: Mon, 24 Mar 2014 14:00:58 -0300 Subject: [PATCH] WIP - GatekeeperClient migration --- Gemfile | 2 +- Gemfile.lock | 35 +++++++++-------------------------- app/controllers/metric_configurations_controller.rb | 6 +++--- app/models/date_module_result.rb | 2 +- app/models/metric_configuration.rb | 2 +- app/models/mezuro_configuration.rb | 2 +- app/models/mezuro_range.rb | 2 +- app/models/module_result.rb | 4 ++-- app/models/processing.rb | 2 +- app/models/project.rb | 2 +- app/models/reading.rb | 2 +- app/models/reading_group.rb | 2 +- app/models/repository.rb | 2 +- app/views/repositories/_form.html.erb | 3 ++- features/repository/create.feature | 8 ++++---- features/step_definitions/project_steps.rb | 2 +- features/step_definitions/reading_group_steps.rb | 2 +- features/support/env.rb | 6 +++--- spec/controllers/metric_configurations_controller_spec.rb | 8 ++++---- spec/factories/base_tools.rb | 2 +- spec/factories/metric_configurations_snapshot.rb | 2 +- spec/factories/metric_results.rb | 2 +- spec/factories/metrics.rb | 6 +++--- spec/factories/modules.rb | 2 +- spec/factories/process_times.rb | 4 ++-- spec/factories/ranges_snapshot.rb | 2 +- spec/models/module_result_spec.rb | 2 +- 27 files changed, 50 insertions(+), 66 deletions(-) diff --git a/Gemfile b/Gemfile index 78b4826..23d1694 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem 'jbuilder', '~> 2.0.4' gem 'devise', '~> 3.2.4' # Kalibro integration -gem 'kalibro_gem', "~> 0.0.1.rc18" +gem 'kalibro_gatekeeper_client', "~> 0.0.1.rc1" # PostgreSQL integration gem "pg", "~> 0.17.0" diff --git a/Gemfile.lock b/Gemfile.lock index c93a565..c91215e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,9 +25,6 @@ GEM multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - akami (1.2.1) - gyoku (>= 0.4.0) - nokogiri arel (4.0.2) atomic (1.1.16) bcrypt (3.1.7) @@ -103,14 +100,13 @@ GEM factory_girl_rails (4.4.1) factory_girl (~> 4.4.0) railties (>= 3.0.0) + faraday (0.8.9) + multipart-post (~> 1.2.0) + faraday_middleware (0.9.0) + faraday (>= 0.7.4, < 0.9) gherkin (2.12.2) multi_json (~> 1.3) - gyoku (1.1.1) - builder (>= 2.1.2) hike (1.2.3) - httpi (2.1.0) - rack - rubyntlm (~> 0.3.2) i18n (0.6.9) jbuilder (2.0.5) activesupport (>= 3.0.0) @@ -121,9 +117,9 @@ GEM jquery-ui-rails (4.2.0) railties (>= 3.2.16) json (1.8.1) - kalibro_gem (0.0.1) - activesupport (~> 4.0.2) - savon (~> 2.3.3) + kalibro_gatekeeper_client (0.0.1.rc1) + activesupport (>= 2.2.1) + faraday_middleware (~> 0.9.0) konacha (3.2.1) actionpack (>= 3.1, < 5) capybara @@ -143,12 +139,12 @@ GEM modernizr-rails (2.7.1) multi_json (1.9.2) multi_test (0.1.1) + multipart-post (1.2.0) net-scp (1.1.2) net-ssh (>= 2.6.5) net-ssh (2.8.0) nokogiri (1.6.1) mini_portile (~> 0.5.0) - nori (2.3.0) orm_adapter (0.5.0) pg (0.17.1) poltergeist (1.5.0) @@ -191,21 +187,12 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - rubyntlm (0.3.4) sass (3.2.18) sass-rails (4.0.2) railties (>= 4.0.0, < 5.0) sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0.0) - savon (2.3.3) - akami (~> 1.2.0) - builder (>= 2.1.2) - gyoku (~> 1.1.0) - httpi (~> 2.1.0) - nokogiri (>= 1.4.0) - nori (~> 2.3.0) - wasabi (~> 3.2.2) sdoc (0.4.0) json (~> 1.8) rdoc (~> 4.0, < 5.0) @@ -256,10 +243,6 @@ GEM json (>= 1.8.0) warden (1.2.3) rack (>= 1.0) - wasabi (3.2.3) - httpi (~> 2.0) - mime-types (< 2.0.0) - nokogiri (>= 1.4.0) websocket-driver (0.3.2) xpath (2.0.0) nokogiri (~> 1.3) @@ -285,7 +268,7 @@ DEPENDENCIES jbuilder (~> 2.0.4) jquery-rails jquery-ui-rails (~> 4.2.0) - kalibro_gem (~> 0.0.1.rc18) + kalibro_gatekeeper_client (~> 0.0.1.rc1) konacha (~> 3.2.0) mocha modernizr-rails diff --git a/app/controllers/metric_configurations_controller.rb b/app/controllers/metric_configurations_controller.rb index 6575100..f6b2521 100644 --- a/app/controllers/metric_configurations_controller.rb +++ b/app/controllers/metric_configurations_controller.rb @@ -10,7 +10,7 @@ class MetricConfigurationsController < ApplicationController def choose_metric @mezuro_configuration_id = params[:mezuro_configuration_id].to_i @metric_configuration_id = params[:metric_configuration_id].to_i - @base_tools = KalibroGem::Entities::BaseTool.all + @base_tools = KalibroGatekeeperClient::Entities::BaseTool.all @exist_metric = params[:exist_metric] end @@ -18,13 +18,13 @@ class MetricConfigurationsController < ApplicationController @metric_configuration = MetricConfiguration.new @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i @metric_configuration.base_tool_name = params[:base_tool_name] - @metric_configuration.metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] + @metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] end def create @metric_configuration = MetricConfiguration.new(metric_configuration_params) @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i - @metric_configuration.metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] + @metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] @metric_configuration.base_tool_name = params[:base_tool_name] respond_to do |format| create_and_redir(format) diff --git a/app/models/date_module_result.rb b/app/models/date_module_result.rb index 4f6e68f..c8b7109 100644 --- a/app/models/date_module_result.rb +++ b/app/models/date_module_result.rb @@ -1,4 +1,4 @@ -class DateModuleResult < KalibroGem::Entities::DateModuleResult +class DateModuleResult < KalibroGatekeeperClient::Entities::DateModuleResult include KalibroRecord def module_result diff --git a/app/models/metric_configuration.rb b/app/models/metric_configuration.rb index ca1f18a..f534dce 100644 --- a/app/models/metric_configuration.rb +++ b/app/models/metric_configuration.rb @@ -1,6 +1,6 @@ require "validators/code_uniqueness_validator.rb" -class MetricConfiguration < KalibroGem::Entities::MetricConfiguration +class MetricConfiguration < KalibroGatekeeperClient::Entities::MetricConfiguration include KalibroRecord attr_accessor :code, :weight, :aggregation_form diff --git a/app/models/mezuro_configuration.rb b/app/models/mezuro_configuration.rb index 4a57296..c3dbb45 100644 --- a/app/models/mezuro_configuration.rb +++ b/app/models/mezuro_configuration.rb @@ -1,6 +1,6 @@ require "validators/kalibro_uniqueness_validator.rb" -class MezuroConfiguration < KalibroGem::Entities::Configuration +class MezuroConfiguration < KalibroGatekeeperClient::Entities::Configuration include KalibroRecord attr_accessor :name diff --git a/app/models/mezuro_range.rb b/app/models/mezuro_range.rb index 8fc9af7..3f4bd58 100644 --- a/app/models/mezuro_range.rb +++ b/app/models/mezuro_range.rb @@ -1,6 +1,6 @@ require "validators/beginning_uniqueness_validator.rb" -class MezuroRange < KalibroGem::Entities::Range +class MezuroRange < KalibroGatekeeperClient::Entities::Range include KalibroRecord attr_accessor :beginning, :end, :reading_id, :mezuro_configuration_id, :comments diff --git a/app/models/module_result.rb b/app/models/module_result.rb index b988b73..13c03d7 100644 --- a/app/models/module_result.rb +++ b/app/models/module_result.rb @@ -1,8 +1,8 @@ -class ModuleResult < KalibroGem::Entities::ModuleResult +class ModuleResult < KalibroGatekeeperClient::Entities::ModuleResult include KalibroRecord def metric_results - KalibroGem::Entities::MetricResult.metric_results_of(@id) + KalibroGatekeeperClient::Entities::MetricResult.metric_results_of(@id) end def history diff --git a/app/models/processing.rb b/app/models/processing.rb index eb11b43..131e23c 100644 --- a/app/models/processing.rb +++ b/app/models/processing.rb @@ -1,4 +1,4 @@ -class Processing < KalibroGem::Entities::Processing +class Processing < KalibroGatekeeperClient::Entities::Processing include KalibroRecord def ready? diff --git a/app/models/project.rb b/app/models/project.rb index d288bf0..acf47c0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,6 +1,6 @@ require "validators/kalibro_uniqueness_validator.rb" -class Project < KalibroGem::Entities::Project +class Project < KalibroGatekeeperClient::Entities::Project include KalibroRecord attr_accessor :name diff --git a/app/models/reading.rb b/app/models/reading.rb index 933b7d8..a98df6e 100644 --- a/app/models/reading.rb +++ b/app/models/reading.rb @@ -1,4 +1,4 @@ -class Reading < KalibroGem::Entities::Reading +class Reading < KalibroGatekeeperClient::Entities::Reading include KalibroRecord attr_accessor :label, :grade, :color diff --git a/app/models/reading_group.rb b/app/models/reading_group.rb index b5e92a6..596ca31 100644 --- a/app/models/reading_group.rb +++ b/app/models/reading_group.rb @@ -1,6 +1,6 @@ require "validators/kalibro_uniqueness_validator.rb" -class ReadingGroup < KalibroGem::Entities::ReadingGroup +class ReadingGroup < KalibroGatekeeperClient::Entities::ReadingGroup include KalibroRecord attr_accessor :name diff --git a/app/models/repository.rb b/app/models/repository.rb index 71ae666..ec46531 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,4 +1,4 @@ -class Repository < KalibroGem::Entities::Repository +class Repository < KalibroGatekeeperClient::Entities::Repository include KalibroRecord validates :name, presence: true, kalibro_uniqueness: true diff --git a/app/views/repositories/_form.html.erb b/app/views/repositories/_form.html.erb index fa86a08..d089f34 100644 --- a/app/views/repositories/_form.html.erb +++ b/app/views/repositories/_form.html.erb @@ -32,7 +32,8 @@
<%= f.label :configuration, class: 'control-label' %> - <% configuration_list = KalibroGem::Entities::Configuration.all.map { |conf| [conf.name, conf.id] } %> + <% configuration_list = KalibroGatekeeperClient::Entities::Configuration.all.map { |conf| [conf.name, conf.id] } %> + <% p configuration_list %> <%= f.select( :configuration_id, configuration_list, {class: 'form-control'} ) %>

diff --git a/features/repository/create.feature b/features/repository/create.feature index aede6d5..31ec57c 100644 --- a/features/repository/create.feature +++ b/features/repository/create.feature @@ -3,7 +3,7 @@ Feature: Repository Creation As a regular user I should be able to create repositories -@kalibro_restart +@kalibro_restart @javascript Scenario: repository creation Given I am a regular user And I am signed in @@ -20,7 +20,7 @@ Scenario: repository creation When I press the Save button Then I should see the saved repository's content -@kalibro_restart +@kalibro_restart @javascript Scenario: repository creation blank validations Given I am a regular user And I am signed in @@ -35,7 +35,7 @@ Scenario: repository creation blank validations Then I should see "Name can't be blank" And I should see "Address can't be blank" -@kalibro_restart +@kalibro_restart @javascript @wip Scenario: repository creation with name already taken Given I am a regular user And I am signed in @@ -49,6 +49,6 @@ Scenario: repository creation with name already taken And I set the select field "Type" as "GIT" And I fill the Address field with "https://github.com/mezuro/kalibro_gem.git" And I set the select field "Process Period" as "1 day" - And I set the select field "repository_configuration_id" as "Java" + And I set the select field "Configuration" as "Java" When I press the Save button Then I should see "There's already" \ No newline at end of file diff --git a/features/step_definitions/project_steps.rb b/features/step_definitions/project_steps.rb index 5bdaaf0..7a8953d 100644 --- a/features/step_definitions/project_steps.rb +++ b/features/step_definitions/project_steps.rb @@ -1,4 +1,4 @@ -require 'kalibro_gem/errors' +require 'kalibro_gatekeeper_client/errors' Given(/^I am at the All Projects page$/) do visit projects_path diff --git a/features/step_definitions/reading_group_steps.rb b/features/step_definitions/reading_group_steps.rb index 15c928e..ecad611 100644 --- a/features/step_definitions/reading_group_steps.rb +++ b/features/step_definitions/reading_group_steps.rb @@ -1,4 +1,4 @@ -require 'kalibro_gem/errors' +require 'kalibro_gatekeeper_client/errors' Given(/^I am at the All Reading Groups page$/) do visit reading_groups_path diff --git a/features/support/env.rb b/features/support/env.rb index fa550f2..29be7aa 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -77,11 +77,11 @@ end # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature Cucumber::Rails::Database.javascript_strategy = :truncation -# Kalibro hooks -require 'kalibro_gem/kalibro_cucumber_helpers/hooks' +# KalibroGatekeeper hooks +require 'kalibro_gatekeeper_client/kalibro_cucumber_helpers/hooks.rb' # Configuring the right hooks -KalibroGem::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml") +KalibroGatekeeperClient::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml") # Warden test helpers so the user authentication can be as fast as possible include Warden::Test::Helpers diff --git a/spec/controllers/metric_configurations_controller_spec.rb b/spec/controllers/metric_configurations_controller_spec.rb index 488ba4c..a3e633c 100644 --- a/spec/controllers/metric_configurations_controller_spec.rb +++ b/spec/controllers/metric_configurations_controller_spec.rb @@ -11,7 +11,7 @@ describe MetricConfigurationsController do context 'when adding new metrics' do before :each do subject.expects(:mezuro_configuration_owner?).returns true - KalibroGem::Entities::BaseTool.expects(:all).returns([base_tool]) + KalibroGatekeeperClient::Entities::BaseTool.expects(:all).returns([base_tool]) get :choose_metric, mezuro_configuration_id: mezuro_configuration.id end @@ -29,7 +29,7 @@ describe MetricConfigurationsController do context 'when the current user owns the mezuro configuration' do before :each do subject.expects(:mezuro_configuration_owner?).returns true - KalibroGem::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) + KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", base_tool_name: base_tool.name end @@ -64,7 +64,7 @@ describe MetricConfigurationsController do context 'with valid fields' do before :each do MetricConfiguration.any_instance.expects(:save).returns(true) - KalibroGem::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) + KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name end @@ -75,7 +75,7 @@ describe MetricConfigurationsController do context 'with invalid fields' do before :each do MetricConfiguration.any_instance.expects(:save).returns(false) - KalibroGem::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) + KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name end diff --git a/spec/factories/base_tools.rb b/spec/factories/base_tools.rb index 0573d0e..64ed2a4 100644 --- a/spec/factories/base_tools.rb +++ b/spec/factories/base_tools.rb @@ -1,5 +1,5 @@ FactoryGirl.define do - factory :base_tool, class: KalibroGem::Entities::BaseTool do + factory :base_tool, class: KalibroGatekeeperClient::Entities::BaseTool do name 'Analizo' supported_metric {FactoryGirl.build(:loc)} end diff --git a/spec/factories/metric_configurations_snapshot.rb b/spec/factories/metric_configurations_snapshot.rb index 254ab35..3b2ec0d 100644 --- a/spec/factories/metric_configurations_snapshot.rb +++ b/spec/factories/metric_configurations_snapshot.rb @@ -15,7 +15,7 @@ # along with this program. If not, see . FactoryGirl.define do - factory :metric_configuration_snapshot, class: KalibroGem::Entities::MetricConfigurationSnapshot do + factory :metric_configuration_snapshot, class: KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do code "code" weight "1.0" aggregation_form 'AVERAGE' diff --git a/spec/factories/metric_results.rb b/spec/factories/metric_results.rb index 0c0b582..c58098d 100644 --- a/spec/factories/metric_results.rb +++ b/spec/factories/metric_results.rb @@ -15,7 +15,7 @@ # along with this program. If not, see . FactoryGirl.define do - factory :metric_result, class: KalibroGem::Entities::MetricResult do + factory :metric_result, class: KalibroGatekeeperClient::Entities::MetricResult do id "42" self.configuration { FactoryGirl.build(:metric_configuration_snapshot) } value "10.0" diff --git a/spec/factories/metrics.rb b/spec/factories/metrics.rb index 804300a..2ddc281 100644 --- a/spec/factories/metrics.rb +++ b/spec/factories/metrics.rb @@ -1,5 +1,5 @@ FactoryGirl.define do - factory :metric, class: KalibroGem::Entities::Metric do + factory :metric, class: KalibroGatekeeperClient::Entities::Metric do name "Total Abstract Classes" compound false scope "SOFTWARE" @@ -8,7 +8,7 @@ FactoryGirl.define do language ["C", "CPP", "JAVA"] end - factory :loc, class: KalibroGem::Entities::Metric do + factory :loc, class: KalibroGatekeeperClient::Entities::Metric do name "Lines of Code" compound false scope "CLASS" @@ -17,7 +17,7 @@ FactoryGirl.define do language ["C", "CPP", "JAVA"] end - factory :compound_metric, class: KalibroGem::Entities::Metric do + factory :compound_metric, class: KalibroGatekeeperClient::Entities::Metric do name "Compound" compound true scope "CLASS" diff --git a/spec/factories/modules.rb b/spec/factories/modules.rb index ae8910e..e06c5d0 100644 --- a/spec/factories/modules.rb +++ b/spec/factories/modules.rb @@ -1,5 +1,5 @@ FactoryGirl.define do - factory :module, class: KalibroGem::Entities::Module do + factory :module, class: KalibroGatekeeperClient::Entities::Module do name 'Qt-Calculator' granularity 'APPLICATION' end diff --git a/spec/factories/process_times.rb b/spec/factories/process_times.rb index 69f25ef..aa07b97 100644 --- a/spec/factories/process_times.rb +++ b/spec/factories/process_times.rb @@ -1,10 +1,10 @@ FactoryGirl.define do - factory :process_time, class: KalibroGem::Entities::ProcessTime do + factory :process_time, class: KalibroGatekeeperClient::Entities::ProcessTime do state "Ready" time "3600" end - factory :analyzing_process_time, class: KalibroGem::Entities::ProcessTime do + factory :analyzing_process_time, class: KalibroGatekeeperClient::Entities::ProcessTime do state "Analyzing" time "12345" end diff --git a/spec/factories/ranges_snapshot.rb b/spec/factories/ranges_snapshot.rb index f38dd67..9e739af 100644 --- a/spec/factories/ranges_snapshot.rb +++ b/spec/factories/ranges_snapshot.rb @@ -15,7 +15,7 @@ # along with this program. If not, see . FactoryGirl.define do - factory :range_snapshot, class: KalibroGem::Entities::RangeSnapshot do + factory :range_snapshot, class: KalibroGatekeeperClient::Entities::RangeSnapshot do beginning 1.1 self.end 5.1 label "Snapshot" diff --git a/spec/models/module_result_spec.rb b/spec/models/module_result_spec.rb index bd1d430..a2a7bc6 100644 --- a/spec/models/module_result_spec.rb +++ b/spec/models/module_result_spec.rb @@ -6,7 +6,7 @@ describe ModuleResult do describe 'metric_results' do it 'should call the metric_results_of method' do - KalibroGem::Entities::MetricResult.expects(:metric_results_of).with(subject.id).returns(nil) + KalibroGatekeeperClient::Entities::MetricResult.expects(:metric_results_of).with(subject.id).returns(nil) subject.metric_results end -- libgit2 0.21.2