From 7f2ab5e0738cd831dcd1445c087cdaf359174830 Mon Sep 17 00:00:00 2001 From: Diego Araújo Date: Wed, 30 Mar 2016 15:27:58 -0300 Subject: [PATCH] Adjust Prezento to the new KalibroClient's API --- Gemfile | 2 +- Gemfile.lock | 12 ++++++++---- app/controllers/application_controller.rb | 2 +- app/controllers/base_metric_configurations_controller.rb | 4 ++-- app/models/kalibro_configuration.rb | 2 +- app/models/project.rb | 2 +- app/models/reading_group.rb | 2 +- db/migrate/20150225170704_create_project_attributes.rb | 2 +- spec/controllers/metric_configurations_controller_spec.rb | 2 +- spec/controllers/projects_controller_spec.rb | 2 +- spec/controllers/repositories_controller_spec.rb | 2 +- spec/models/kalibro_configuration_spec.rb | 2 +- spec/models/project_spec.rb | 2 +- spec/models/reading_group_spec.rb | 2 +- 14 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 8de7c91..734795f 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ gem 'jbuilder', '~> 2.0' gem 'devise', '~> 3.5.1' # Kalibro integration -gem 'kalibro_client', '~> 3.0.0' +gem 'kalibro_client', '~> 4.0.0.alpha1' # PostgreSQL integration gem "pg", "~> 0.18.1" diff --git a/Gemfile.lock b/Gemfile.lock index 04235bc..9fde025 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -154,9 +154,10 @@ GEM railties (>= 3.2) sprockets-rails json (1.8.3) - kalibro_client (3.0.0) + kalibro_client (4.0.0.alpha1) activesupport (>= 2.2.1) - faraday_middleware (~> 0.10.0) + faraday_middleware (~> 0.9) + likeno (~> 1.1) konacha (3.7.0) actionpack (>= 3.1, < 5) capybara @@ -172,6 +173,9 @@ GEM sprockets (> 2, < 4) tilt libv8 (3.16.14.11) + likeno (1.1.0) + activesupport (>= 2.2.1) + faraday_middleware loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.3) @@ -356,7 +360,7 @@ DEPENDENCIES jquery-rails jquery-ui-rails (~> 5.0.0) js-routes (~> 1.1.0) - kalibro_client (~> 3.0.0) + kalibro_client (~> 4.0.0.alpha1) konacha less-rails (~> 2.7.0) mocha @@ -381,4 +385,4 @@ DEPENDENCIES web-console (~> 2.0.0) BUNDLED WITH - 1.10.6 + 1.11.2 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 334c08b..fcc316e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base before_filter :set_locale rescue_from ActiveRecord::RecordNotFound, with: :not_found - rescue_from KalibroClient::Errors::RecordNotFound, with: :not_found + rescue_from Likeno::Errors::RecordNotFound, with: :not_found class << self # This is necessary for correct devise routing with locales: https://github.com/plataformatec/devise/wiki/How-To:--Redirect-with-locale-after-authentication-failure diff --git a/app/controllers/base_metric_configurations_controller.rb b/app/controllers/base_metric_configurations_controller.rb index 7a5d04d..ae87174 100644 --- a/app/controllers/base_metric_configurations_controller.rb +++ b/app/controllers/base_metric_configurations_controller.rb @@ -110,7 +110,7 @@ class BaseMetricConfigurationsController < ApplicationController # Make sure the metric configuration is really from the kalibro configuration we're being told it is if @metric_configuration.kalibro_configuration_id != @kalibro_configuration.id - raise KalibroClient::Errors::RecordNotFound + raise Likeno::Errors::RecordNotFound end end @@ -136,7 +136,7 @@ class BaseMetricConfigurationsController < ApplicationController def set_reading_group! begin @reading_group = ReadingGroup.find(@metric_configuration.reading_group_id) - rescue KalibroClient::Errors::RecordNotFound + rescue Likeno::Errors::RecordNotFound respond_to do |format| failed_action(format, t('invalid_model', model: ReadingGroup.model_name.human)) end diff --git a/app/models/kalibro_configuration.rb b/app/models/kalibro_configuration.rb index e127ae3..9d7172d 100644 --- a/app/models/kalibro_configuration.rb +++ b/app/models/kalibro_configuration.rb @@ -9,7 +9,7 @@ class KalibroConfiguration < KalibroClient::Entities::Configurations::KalibroCon kalibro_configuration_attributes.map { |kalibro_configuration_attribute| begin self.find(kalibro_configuration_attribute.kalibro_configuration_id) - rescue KalibroClient::Errors::RecordNotFound + rescue Likeno::Errors::RecordNotFound nil end }.compact diff --git a/app/models/project.rb b/app/models/project.rb index 586a9a0..58e0664 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -10,7 +10,7 @@ class Project < KalibroClient::Entities::Processor::Project project_attributes.map do |attribute| begin self.find(attribute.project_id) - rescue KalibroClient::Errors::RecordNotFound + rescue Likeno::Errors::RecordNotFound nil end end.compact diff --git a/app/models/reading_group.rb b/app/models/reading_group.rb index 683ad41..60e2283 100644 --- a/app/models/reading_group.rb +++ b/app/models/reading_group.rb @@ -9,7 +9,7 @@ class ReadingGroup < KalibroClient::Entities::Configurations::ReadingGroup reading_group_attributes.map { |reading_group_attribute| begin self.find(reading_group_attribute.reading_group_id) - rescue KalibroClient::Errors::RecordNotFound + rescue Likeno::Errors::RecordNotFound nil end }.compact diff --git a/db/migrate/20150225170704_create_project_attributes.rb b/db/migrate/20150225170704_create_project_attributes.rb index 1562fb2..dc3bc3e 100644 --- a/db/migrate/20150225170704_create_project_attributes.rb +++ b/db/migrate/20150225170704_create_project_attributes.rb @@ -22,7 +22,7 @@ class CreateProjectAttributes < ActiveRecord::Migration end ProjectAttributes.create(user_id: project_ownership.user_id, project_id: project_ownership.project_id, image_url: image_url, hidden: hidden) - rescue KalibroClient::Errors::RecordNotFound + rescue Likeno::Errors::RecordNotFound puts "Could not find project with id #{project_ownership.project_id} owned by user with #{project_ownership.user_id} and image url #{image_url}" end end diff --git a/spec/controllers/metric_configurations_controller_spec.rb b/spec/controllers/metric_configurations_controller_spec.rb index 9d26f5d..e27c26a 100644 --- a/spec/controllers/metric_configurations_controller_spec.rb +++ b/spec/controllers/metric_configurations_controller_spec.rb @@ -141,7 +141,7 @@ describe MetricConfigurationsController, :type => :controller do context 'with invalid parameters' do before :each do - ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).raises(KalibroClient::Errors::RecordNotFound) + ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).raises(Likeno::Errors::RecordNotFound) get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 58ff33c..00f4b67 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -75,7 +75,7 @@ describe ProjectsController, :type => :controller do context 'when the project does not exists' do before :each do - Project.expects(:find).with(project.id).raises(KalibroClient::Errors::RecordNotFound) + Project.expects(:find).with(project.id).raises(Likeno::Errors::RecordNotFound) end context 'when the request format is known' do diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb index a18fa76..ab03031 100644 --- a/spec/controllers/repositories_controller_spec.rb +++ b/spec/controllers/repositories_controller_spec.rb @@ -517,7 +517,7 @@ describe RepositoriesController, :type => :controller do context 'with an invalid repository' do before :each do - Repository.expects(:find).with(repository.id).raises(KalibroClient::Errors::RecordNotFound) + Repository.expects(:find).with(repository.id).raises(Likeno::Errors::RecordNotFound) post_push end diff --git a/spec/models/kalibro_configuration_spec.rb b/spec/models/kalibro_configuration_spec.rb index 8f61484..fdf5dde 100644 --- a/spec/models/kalibro_configuration_spec.rb +++ b/spec/models/kalibro_configuration_spec.rb @@ -59,7 +59,7 @@ describe KalibroConfiguration, :type => :model do before :each do # Map the kalibro_configuration attributes to the corresponding Kalibro Configuration kalibro_configurations.each do |kc| - KalibroConfiguration.stubs(:find).with(kc.id).raises(KalibroClient::Errors::RecordNotFound) + KalibroConfiguration.stubs(:find).with(kc.id).raises(Likeno::Errors::RecordNotFound) end KalibroConfigurationAttributes.expects(:where).with(public: true).returns(public_attrs) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 4c5b201..89602cd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -139,7 +139,7 @@ describe Project, :type => :model do context 'when no reading groups exist' do before :each do all_projects.each do |project| - described_class.stubs(:find).with(project.id).raises(KalibroClient::Errors::RecordNotFound) + described_class.stubs(:find).with(project.id).raises(Likeno::Errors::RecordNotFound) end ProjectAttributes.expects(:where).with(public: true).returns(public_attrs) diff --git a/spec/models/reading_group_spec.rb b/spec/models/reading_group_spec.rb index 08d8e66..e166d86 100644 --- a/spec/models/reading_group_spec.rb +++ b/spec/models/reading_group_spec.rb @@ -123,7 +123,7 @@ describe ReadingGroup, :type => :model do before :each do # Map the reading group attributes to the corresponding Reading Group all_reading_groups.each do |reading_group| - ReadingGroup.stubs(:find).with(reading_group.id).raises(KalibroClient::Errors::RecordNotFound) + ReadingGroup.stubs(:find).with(reading_group.id).raises(Likeno::Errors::RecordNotFound) end ReadingGroupAttributes.expects(:where).with(public: true).returns(public_attrs) -- libgit2 0.21.2