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"
- deploy:
command: |
if [ "${CIRCLE_BRANCH}" == "develop" ]; then
if [ "${CIRCLE_BRANCH}" == "dev" ]; then
bundle exec rake deploy_ha
fi

View file

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

View file

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

View file

@ -57,8 +57,26 @@ class Admin::AttestationTemplatesController < AdminController
private
def activated_attestation_params
params.require(:attestation_template)
.permit(:title, :body, :footer, :logo, :signature)
.merge(activated: true)
# cache result to avoid multiple uninterlaced computations
if @activated_attestation_params.nil?
@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

View file

@ -39,7 +39,7 @@ class Users::DossiersController < UsersController
unless params[:procedure_path].nil?
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"
return redirect_to root_path
else

View file

@ -11,7 +11,7 @@
= image_tag('pdf.svg', width: '20px')
%p.title= dossier.attestation.title
%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'
- else
= 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"]
when "staging"
set :branch, ENV['branch'] || 'develop'
set :branch, ENV['branch'] || 'dev'
set :deploy_to, '/var/www/tps_dev'
set :user, 'tps_dev' # Username in the server to SSH to.
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(:logo) { fixture_file_upload('spec/fixtures/white.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
sign_in admin
@ -19,6 +21,11 @@ describe Admin::AttestationTemplatesController, type: :controller do
attestation_template: upload_params }
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
let(:attestation_template) { nil }
it { expect(subject.status).to eq(200) }

View file

@ -152,7 +152,7 @@ describe Users::DossiersController, type: :controller do
end
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).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 }
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
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