Merge branch 'dev'

This commit is contained in:
Simon Lehericey 2017-07-10 11:21:09 +02:00
commit 3816209562
11 changed files with 42 additions and 8 deletions

View file

@ -68,7 +68,7 @@ jobs:
- "0a:67:42:7d:7e:b7:e1:3c:48:8f:bf:68:10:51:a8:44" - "0a:67:42:7d:7e:b7:e1:3c:48:8f:bf:68:10:51:a8:44"
- deploy: - deploy:
command: | command: |
if [ "${CIRCLE_BRANCH}" == "develop" ]; then if [ "${CIRCLE_BRANCH}" == "dev" ]; then
bundle exec rake deploy_ha bundle exec rake deploy_ha
fi fi

View file

@ -106,6 +106,7 @@ gem 'select2-rails'
gem 'prawn', '~> 2.0.1' gem 'prawn', '~> 2.0.1'
gem 'prawn_rails', '~> 0.0.11' gem 'prawn_rails', '~> 0.0.11'
gem 'chunky_png'
gem 'sentry-raven' gem 'sentry-raven'
group :test do group :test do

View file

@ -108,6 +108,7 @@ GEM
mime-types (>= 1.16) mime-types (>= 1.16)
mimemagic (>= 0.3.0) mimemagic (>= 0.3.0)
chartkick (2.2.1) chartkick (2.2.1)
chunky_png (1.3.8)
clamav-client (3.1.0) clamav-client (3.1.0)
cliver (0.3.2) cliver (0.3.2)
coderay (1.1.1) coderay (1.1.1)
@ -686,6 +687,7 @@ DEPENDENCIES
capybara capybara
carrierwave carrierwave
chartkick chartkick
chunky_png
clamav-client clamav-client
copy_carrierwave_file copy_carrierwave_file
database_cleaner database_cleaner

View file

@ -57,8 +57,26 @@ class Admin::AttestationTemplatesController < AdminController
private private
def activated_attestation_params def activated_attestation_params
params.require(:attestation_template) # cache result to avoid multiple uninterlaced computations
.permit(:title, :body, :footer, :logo, :signature) if @activated_attestation_params.nil?
.merge(activated: true) @activated_attestation_params = params.require(:attestation_template)
.permit(:title, :body, :footer, :signature)
.merge(activated: true)
@activated_attestation_params.merge!(logo: uninterlaced_png(params['attestation_template']['logo']))
@activated_attestation_params.merge!(signature: uninterlaced_png(params['attestation_template']['signature']))
end
@activated_attestation_params
end
def uninterlaced_png(uploaded_file)
if uploaded_file.present? && uploaded_file.content_type == 'image/png'
chunky_img = ChunkyPNG::Image.from_io(uploaded_file)
chunky_img.save(uploaded_file.tempfile.to_path, interlace: false)
uploaded_file.tempfile.reopen(uploaded_file.tempfile.to_path, 'rb')
end
uploaded_file
end end
end end

View file

@ -39,7 +39,7 @@ class Users::DossiersController < UsersController
unless params[:procedure_path].nil? unless params[:procedure_path].nil?
procedure_path = ProcedurePath.where(path: params[:procedure_path]).last procedure_path = ProcedurePath.where(path: params[:procedure_path]).last
if procedure_path.nil? if procedure_path.nil? || procedure_path.procedure.nil?
flash.alert = "Procédure inconnue" flash.alert = "Procédure inconnue"
return redirect_to root_path return redirect_to root_path
else else

View file

@ -11,7 +11,7 @@
= image_tag('pdf.svg', width: '20px') = image_tag('pdf.svg', width: '20px')
%p.title= dossier.attestation.title %p.title= dossier.attestation.title
%p.delivery Délivrée le #{l(dossier.attestation.created_at, format: '%d %B %Y')} %p.delivery Délivrée le #{l(dossier.attestation.created_at, format: '%d %B %Y')}
- if user_signed_in? - if user_signed_in? && current_user == dossier.user
= link_to 'Télécharger', dossier_attestation_path(dossier), target: '_blank', class: 'btn btn-primary' = link_to 'Télécharger', dossier_attestation_path(dossier), target: '_blank', class: 'btn btn-primary'
- else - else
= link_to 'Télécharger', procedure_dossier_attestation_path(dossier.procedure, dossier), target: '_blank', class: 'btn btn-primary' = link_to 'Télécharger', procedure_dossier_attestation_path(dossier.procedure, dossier), target: '_blank', class: 'btn btn-primary'

View file

@ -24,7 +24,7 @@ set :deploy_to, '/var/www/tps_dev'
case ENV["to"] case ENV["to"]
when "staging" when "staging"
set :branch, ENV['branch'] || 'develop' set :branch, ENV['branch'] || 'dev'
set :deploy_to, '/var/www/tps_dev' set :deploy_to, '/var/www/tps_dev'
set :user, 'tps_dev' # Username in the server to SSH to. set :user, 'tps_dev' # Username in the server to SSH to.
appname = 'tps_dev' appname = 'tps_dev'

View file

@ -4,6 +4,8 @@ describe Admin::AttestationTemplatesController, type: :controller do
let!(:procedure) { create :procedure, administrateur: admin, attestation_template: attestation_template } let!(:procedure) { create :procedure, administrateur: admin, attestation_template: attestation_template }
let(:logo) { fixture_file_upload('spec/fixtures/white.png', 'image/png') } let(:logo) { fixture_file_upload('spec/fixtures/white.png', 'image/png') }
let(:signature) { fixture_file_upload('spec/fixtures/black.png', 'image/png') } let(:signature) { fixture_file_upload('spec/fixtures/black.png', 'image/png') }
let(:interlaced_logo) { fixture_file_upload('spec/fixtures/interlaced-black.png', 'image/png') }
let(:uninterlaced_logo) { fixture_file_upload('spec/fixtures/uninterlaced-black.png', 'image/png') }
before do before do
sign_in admin sign_in admin
@ -19,6 +21,11 @@ describe Admin::AttestationTemplatesController, type: :controller do
attestation_template: upload_params } attestation_template: upload_params }
end end
context 'with an interlaced png' do
let(:upload_params) { { logo: interlaced_logo } }
it { expect(assigns(:logo).read).to eq(uninterlaced_logo.read) }
end
context 'if an attestation template does not exist on the procedure' do context 'if an attestation template does not exist on the procedure' do
let(:attestation_template) { nil } let(:attestation_template) { nil }
it { expect(subject.status).to eq(200) } it { expect(subject.status).to eq(200) }

View file

@ -152,7 +152,7 @@ describe Users::DossiersController, type: :controller do
end end
describe 'GET #commencer' do describe 'GET #commencer' do
subject { get :commencer, params: {procedure_path: procedure.path} } subject { get :commencer, params: { procedure_path: procedure.path } }
it { expect(subject.status).to eq 302 } it { expect(subject.status).to eq 302 }
it { expect(subject).to redirect_to new_users_dossier_path(procedure_id: procedure.id) } it { expect(subject).to redirect_to new_users_dossier_path(procedure_id: procedure.id) }
@ -166,6 +166,12 @@ describe Users::DossiersController, type: :controller do
it { expect(subject.status).to eq 200 } it { expect(subject.status).to eq 200 }
end end
context 'when procedure is hidden' do
let(:procedure) { create(:procedure, :published, hidden_at: DateTime.now) }
it { expect(subject).to redirect_to(root_path) }
end
end end
describe 'POST #siret_informations' do describe 'POST #siret_informations' do

BIN
spec/fixtures/interlaced-black.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

BIN
spec/fixtures/uninterlaced-black.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B