commit
95c4a47fd9
8 changed files with 30 additions and 21 deletions
|
@ -118,16 +118,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def set_raven_context
|
||||
user = logged_user
|
||||
|
||||
context = {
|
||||
ip_address: request.ip,
|
||||
id: user&.id,
|
||||
email: user&.email,
|
||||
roles: logged_user_roles
|
||||
}.compact
|
||||
|
||||
Raven.user_context(context)
|
||||
Raven.user_context(sentry_user)
|
||||
end
|
||||
|
||||
def append_info_to_payload(payload)
|
||||
|
@ -202,16 +193,19 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def sentry_user
|
||||
user = logged_user
|
||||
{ id: user&.id, role: user&.class&.name || 'Guest' }.compact
|
||||
end
|
||||
|
||||
def sentry_config
|
||||
sentry = Rails.application.secrets.sentry
|
||||
|
||||
{
|
||||
key: sentry[:client_key],
|
||||
enabled: sentry[:enabled],
|
||||
user: {
|
||||
id: current_user&.id,
|
||||
email: current_email
|
||||
}
|
||||
environment: sentry[:environment],
|
||||
user: sentry_user
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
function TypeDeChampDropDownOptions({ isVisible, value, handler }) {
|
||||
function TypeDeChampDropDownOptions({ isVisible, handler }) {
|
||||
if (isVisible) {
|
||||
return (
|
||||
<div className="cell">
|
||||
|
@ -9,7 +9,7 @@ function TypeDeChampDropDownOptions({ isVisible, value, handler }) {
|
|||
<textarea
|
||||
id={handler.id}
|
||||
name={handler.name}
|
||||
value={value}
|
||||
value={handler.value}
|
||||
onChange={handler.onChange}
|
||||
rows={3}
|
||||
cols={40}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
const { key, enabled, user } = gon.sentry || {};
|
||||
const { key, enabled, user, environment } = gon.sentry || {};
|
||||
|
||||
// We need to check for key presence here as we do not have a dsn for browser yet
|
||||
if (enabled && key) {
|
||||
Sentry.init({ dsn: key });
|
||||
Sentry.init({ dsn: key, environment });
|
||||
|
||||
if (user.email) {
|
||||
Sentry.configureScope(scope => {
|
||||
|
|
|
@ -38,6 +38,7 @@ HELPSCOUT_CLIENT_SECRET=""
|
|||
HELPSCOUT_WEBHOOK_SECRET=""
|
||||
|
||||
SENTRY_ENABLED="disabled"
|
||||
SENTRY_CURRENT_ENV="development"
|
||||
SENTRY_DSN_RAILS=""
|
||||
SENTRY_DSN_JS=""
|
||||
|
||||
|
|
|
@ -3,5 +3,6 @@ if ENV['SENTRY_ENABLED'] == 'enabled'
|
|||
|
||||
Raven.configure do |config|
|
||||
config.dsn = ENV['SENTRY_DSN_RAILS']
|
||||
config.environments = ['production', 'staging']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,6 +60,7 @@ defaults: &defaults
|
|||
sentry:
|
||||
enabled: <%= ENV['SENTRY_ENABLED'] == 'enabled' %>
|
||||
client_key: <%= ENV['SENTRY_DSN_JS'] %>
|
||||
environment: <%= ENV['SENTRY_CURRENT_ENV'] %>
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
|
|
@ -34,7 +34,7 @@ describe ApplicationController, type: :controller do
|
|||
context 'when no one is logged in' do
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ ip_address: '0.0.0.0', roles: 'Guest' })
|
||||
.with({ role: 'Guest' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -53,7 +53,7 @@ describe ApplicationController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ ip_address: '0.0.0.0', email: current_user.email, id: current_user.id, roles: 'User' })
|
||||
.with({ id: current_user.id, role: 'User' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -77,7 +77,7 @@ describe ApplicationController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ ip_address: '0.0.0.0', email: current_user.email, id: current_user.id, roles: 'User, Gestionnaire, Administrateur, Administration' })
|
||||
.with({ id: current_user.id, role: 'User' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
|
|
@ -133,4 +133,16 @@ feature 'As an administrateur I can edit types de champ', js: true do
|
|||
expect(page).not_to have_content('Cadastres')
|
||||
end
|
||||
end
|
||||
|
||||
it "Add dropdown champ" do
|
||||
select('Menu déroulant', from: 'champ-0-type_champ')
|
||||
fill_in 'champ-0-libelle', with: 'libellé de champ menu déroulant'
|
||||
blur
|
||||
fill_in 'champ-0-drop_down_list_value', with: 'Un menu'
|
||||
expect(page).to have_content('Formulaire enregistré')
|
||||
|
||||
page.refresh
|
||||
|
||||
expect(page).to have_content('Un menu')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue