commit
ec6026ef2c
9 changed files with 70 additions and 15 deletions
1
Gemfile
1
Gemfile
|
@ -93,6 +93,7 @@ group :test do
|
|||
gem 'shoulda-matchers', require: false
|
||||
gem 'timecop'
|
||||
gem 'vcr'
|
||||
gem 'webdrivers', '~> 4.0'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
|
|
11
Gemfile.lock
11
Gemfile.lock
|
@ -162,7 +162,7 @@ GEM
|
|||
carrierwave (>= 0.9)
|
||||
crack (0.4.3)
|
||||
safe_yaml (~> 1.0.0)
|
||||
crass (1.0.4)
|
||||
crass (1.0.5)
|
||||
css_parser (1.6.0)
|
||||
addressable
|
||||
curb (0.9.10)
|
||||
|
@ -356,7 +356,7 @@ GEM
|
|||
railties (>= 4)
|
||||
request_store (~> 1.0)
|
||||
logstash-event (1.2.02)
|
||||
loofah (2.2.3)
|
||||
loofah (2.3.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
lumberjack (1.0.13)
|
||||
|
@ -385,7 +385,7 @@ GEM
|
|||
nenv (0.3.0)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.10.4)
|
||||
nokogiri (1.10.5)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
notiffany (0.1.1)
|
||||
nenv (~> 0.1)
|
||||
|
@ -678,6 +678,10 @@ GEM
|
|||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
webdrivers (4.1.3)
|
||||
nokogiri (~> 1.6)
|
||||
rubyzip (>= 1.3.0)
|
||||
selenium-webdriver (>= 3.0, < 4.0)
|
||||
webfinger (1.1.0)
|
||||
activesupport
|
||||
httpclient (>= 2.4)
|
||||
|
@ -812,6 +816,7 @@ DEPENDENCIES
|
|||
vcr
|
||||
warden
|
||||
web-console
|
||||
webdrivers (~> 4.0)
|
||||
webmock
|
||||
webpacker
|
||||
xray-rails
|
||||
|
|
|
@ -43,8 +43,14 @@ Les informations nécessaire à l'initialisation de la base doivent être pré-c
|
|||
> create user tps_test with password 'tps_test' superuser;
|
||||
> \q
|
||||
|
||||
|
||||
### Initialisation de l'environnement de développement
|
||||
|
||||
Sous Ubuntu, certains packages doivent être installés au préalable :
|
||||
|
||||
sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev libcurl4-gnutls-dev zlib1g-dev
|
||||
|
||||
|
||||
Afin d'initialiser l'environnement de développement, exécutez la commande suivante :
|
||||
|
||||
bin/setup
|
||||
|
|
|
@ -17,8 +17,9 @@ class Admin::AssignsController < AdminController
|
|||
|
||||
not_assign_scope = current_administrateur.instructeurs.where.not(id: assign_scope.ids)
|
||||
|
||||
if params[:filter]
|
||||
not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%")
|
||||
if params[:filter].present?
|
||||
filter = params[:filter].downcase.strip
|
||||
not_assign_scope = not_assign_scope.where('users.email LIKE ?', "%#{filter}%")
|
||||
end
|
||||
|
||||
@instructeurs_not_assign = smart_listing_create :instructeurs_not_assign,
|
||||
|
|
|
@ -12,11 +12,14 @@ class ApiCarto::API
|
|||
private
|
||||
|
||||
def self.call(url, geojson)
|
||||
params = geojson.to_s
|
||||
RestClient.post(url, params, content_type: 'application/json')
|
||||
response = Typhoeus.post(url, body: geojson.to_s, headers: { 'content-type' => 'application/json' })
|
||||
|
||||
rescue RestClient::InternalServerError, RestClient::BadGateway, RestClient::GatewayTimeout, RestClient::ServiceUnavailable => e
|
||||
Rails.logger.error "[ApiCarto] Error on #{url}: #{e}"
|
||||
if response.success?
|
||||
response.body
|
||||
else
|
||||
message = response.code == 0 ? response.return_message : response.code.to_s
|
||||
Rails.logger.error "[ApiCarto] Error on #{url}: #{message}"
|
||||
raise RestClient::ResourceNotFound
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ chdir APP_ROOT do
|
|||
system('bundle check') || system!('bundle install')
|
||||
system! 'bin/yarn install'
|
||||
|
||||
puts "\n== Updating webdrivers =="
|
||||
system! 'RAILS_ENV=test bin/rails webdrivers:chromedriver:update'
|
||||
|
||||
puts "\n== Copying sample files =="
|
||||
unless File.exist?('.env')
|
||||
|
|
|
@ -18,6 +18,9 @@ chdir APP_ROOT do
|
|||
system('bundle check') || system!('bundle install')
|
||||
system! 'bin/yarn install'
|
||||
|
||||
puts "\n== Updating webdrivers =="
|
||||
system! 'RAILS_ENV=test bin/rails webdrivers:chromedriver:update'
|
||||
|
||||
puts "\n== Updating database =="
|
||||
system! 'bin/rails db:migrate'
|
||||
|
||||
|
|
|
@ -2,19 +2,53 @@ require 'spec_helper'
|
|||
|
||||
describe Admin::AssignsController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:procedure) { create :procedure, administrateur: admin }
|
||||
let(:instructeur) { create :instructeur, administrateurs: [admin] }
|
||||
|
||||
before do
|
||||
sign_in(admin.user)
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
subject { get :show, params: { procedure_id: procedure.id } }
|
||||
it { expect(subject.status).to eq(200) }
|
||||
let(:procedure) { create :procedure, administrateur: admin, instructeurs: [instructeur_assigned_1, instructeur_assigned_2] }
|
||||
let!(:instructeur_assigned_1) { create :instructeur, email: 'instructeur_1@ministere_a.gouv.fr', administrateurs: [admin] }
|
||||
let!(:instructeur_assigned_2) { create :instructeur, email: 'instructeur_2@ministere_b.gouv.fr', administrateurs: [admin] }
|
||||
let!(:instructeur_not_assigned_1) { create :instructeur, email: 'instructeur_3@ministere_a.gouv.fr', administrateurs: [admin] }
|
||||
let!(:instructeur_not_assigned_2) { create :instructeur, email: 'instructeur_4@ministere_b.gouv.fr', administrateurs: [admin] }
|
||||
let(:filter) { nil }
|
||||
|
||||
subject! { get :show, params: { procedure_id: procedure.id, filter: filter } }
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
|
||||
it 'sets the assigned and not assigned instructeurs' do
|
||||
expect(assigns(:instructeurs_assign)).to match_array([instructeur_assigned_1, instructeur_assigned_2])
|
||||
expect(assigns(:instructeurs_not_assign)).to match_array([instructeur_not_assigned_1, instructeur_not_assigned_2])
|
||||
end
|
||||
|
||||
context 'with a search filter' do
|
||||
let(:filter) { '@ministere_a.gouv.fr' }
|
||||
|
||||
it 'filters the unassigned instructeurs' do
|
||||
expect(assigns(:instructeurs_not_assign)).to match_array([instructeur_not_assigned_1])
|
||||
end
|
||||
|
||||
it 'does not filter the assigned instructeurs' do
|
||||
expect(assigns(:instructeurs_assign)).to match_array([instructeur_assigned_1, instructeur_assigned_2])
|
||||
end
|
||||
|
||||
context 'when the filter has spaces or a mixed case' do
|
||||
let(:filter) { ' @ministere_A.gouv.fr ' }
|
||||
|
||||
it 'trims spaces and ignores the case' do
|
||||
expect(assigns(:instructeurs_not_assign)).to match_array([instructeur_not_assigned_1])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
let(:procedure) { create :procedure, administrateur: admin }
|
||||
let(:instructeur) { create :instructeur, administrateurs: [admin] }
|
||||
|
||||
subject { put :update, params: { instructeur_id: instructeur.id, procedure_id: procedure.id, to: 'assign' } }
|
||||
|
||||
it { expect(subject).to redirect_to admin_procedure_assigns_path(procedure_id: procedure.id) }
|
||||
|
|
|
@ -83,7 +83,7 @@ VCR.configure do |c|
|
|||
c.hook_into :webmock
|
||||
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
||||
c.configure_rspec_metadata!
|
||||
c.ignore_hosts 'test.host'
|
||||
c.ignore_hosts 'test.host', 'chromedriver.storage.googleapis.com'
|
||||
end
|
||||
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
|
|
Loading…
Reference in a new issue