diff --git a/.circleci/config.yml b/.circleci/config.yml
index 45417e72c..c27c968f1 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,6 +1,7 @@
version: 2
jobs:
build:
+ parallelism: 2
docker:
- image: ruby:2.3.1
- image: postgres:9.4.1
@@ -53,6 +54,9 @@ jobs:
command: |
TESTFILES=$(circleci tests glob "spec/**/*.rb"| xargs -n 1 echo | grep -v "spec/factories/" | tr " " "\n" | circleci tests split --split-by=timings)
bundle exec rspec --color --require spec_helper -- ${TESTFILES}
+ - run:
+ name: Run rubocop
+ command: bundle exec rubocop
- run:
name: Run haml-lint
command: bundle exec haml-lint app/views/
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 000000000..ede1689a7
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,1062 @@
+AllCops:
+ Exclude:
+ - "db/schema.rb"
+
+Bundler/DuplicatedGem:
+ Enabled: true
+
+Bundler/OrderedGems:
+ Enabled: false
+
+Layout/AccessModifierIndentation:
+ Enabled: true
+
+Layout/AlignArray:
+ Enabled: true
+
+Layout/AlignHash:
+ Enabled: false
+
+Layout/AlignParameters:
+ Enabled: true
+ EnforcedStyle: with_fixed_indentation
+
+Layout/BlockEndNewline:
+ Enabled: true
+
+Layout/CaseIndentation:
+ Enabled: true
+ EnforcedStyle: end
+
+Layout/ClosingParenthesisIndentation:
+ Enabled: true
+
+Layout/CommentIndentation:
+ Enabled: true
+
+Layout/DotPosition:
+ Enabled: true
+
+Layout/ElseAlignment:
+ Enabled: true
+
+Layout/EmptyLineAfterMagicComment:
+ Enabled: true
+
+Layout/EmptyLineBetweenDefs:
+ Enabled: true
+
+Layout/EmptyLines:
+ Enabled: true
+
+Layout/EmptyLinesAroundAccessModifier:
+ Enabled: true
+
+Layout/EmptyLinesAroundBeginBody:
+ Enabled: true
+
+Layout/EmptyLinesAroundBlockBody:
+ Enabled: true
+
+Layout/EmptyLinesAroundClassBody:
+ Enabled: true
+
+Layout/EmptyLinesAroundExceptionHandlingKeywords:
+ Enabled: false
+
+Layout/EmptyLinesAroundMethodBody:
+ Enabled: true
+
+Layout/EmptyLinesAroundModuleBody:
+ Enabled: true
+
+Layout/EndOfLine:
+ Enabled: true
+ EnforcedStyle: lf
+
+Layout/ExtraSpacing:
+ Enabled: true
+ Exclude:
+ - "Guardfile"
+
+Layout/FirstArrayElementLineBreak:
+ Enabled: false
+
+Layout/FirstHashElementLineBreak:
+ Enabled: false
+
+Layout/FirstMethodArgumentLineBreak:
+ Enabled: false
+
+Layout/FirstMethodParameterLineBreak:
+ Enabled: false
+
+Layout/FirstParameterIndentation:
+ Enabled: false
+
+Layout/IndentArray:
+ Enabled: false
+
+Layout/IndentAssignment:
+ Enabled: false
+
+Layout/IndentHash:
+ Enabled: false
+
+Layout/IndentHeredoc:
+ Enabled: false
+
+Layout/IndentationConsistency:
+ Enabled: false
+
+Layout/IndentationWidth:
+ Enabled: false
+
+Layout/InitialIndentation:
+ Enabled: false
+
+Layout/LeadingCommentSpace:
+ Enabled: false
+
+Layout/MultilineArrayBraceLayout:
+ Enabled: false
+
+Layout/MultilineAssignmentLayout:
+ Enabled: false
+
+Layout/MultilineBlockLayout:
+ Enabled: false
+
+Layout/MultilineHashBraceLayout:
+ Enabled: false
+
+Layout/MultilineMethodCallBraceLayout:
+ Enabled: false
+
+Layout/MultilineMethodCallIndentation:
+ Enabled: false
+
+Layout/MultilineMethodDefinitionBraceLayout:
+ Enabled: false
+
+Layout/MultilineOperationIndentation:
+ Enabled: false
+
+Layout/RescueEnsureAlignment:
+ Enabled: false
+
+Layout/SpaceAfterColon:
+ Enabled: false
+
+Layout/SpaceAfterComma:
+ Enabled: false
+
+Layout/SpaceAfterMethodName:
+ Enabled: false
+
+Layout/SpaceAfterNot:
+ Enabled: false
+
+Layout/SpaceAfterSemicolon:
+ Enabled: false
+
+Layout/SpaceAroundBlockParameters:
+ Enabled: false
+
+Layout/SpaceAroundEqualsInParameterDefault:
+ Enabled: false
+
+Layout/SpaceAroundKeyword:
+ Enabled: false
+
+Layout/SpaceAroundOperators:
+ Enabled: false
+
+Layout/SpaceBeforeBlockBraces:
+ Enabled: false
+
+Layout/SpaceBeforeComma:
+ Enabled: false
+
+Layout/SpaceBeforeComment:
+ Enabled: false
+
+Layout/SpaceBeforeFirstArg:
+ Enabled: false
+
+Layout/SpaceBeforeSemicolon:
+ Enabled: false
+
+Layout/SpaceInLambdaLiteral:
+ Enabled: false
+
+Layout/SpaceInsideArrayPercentLiteral:
+ Enabled: false
+
+Layout/SpaceInsideBlockBraces:
+ Enabled: false
+
+Layout/SpaceInsideBrackets:
+ Enabled: false
+
+Layout/SpaceInsideHashLiteralBraces:
+ Enabled: false
+
+Layout/SpaceInsideParens:
+ Enabled: false
+
+Layout/SpaceInsidePercentLiteralDelimiters:
+ Enabled: false
+
+Layout/SpaceInsideRangeLiteral:
+ Enabled: false
+
+Layout/SpaceInsideStringInterpolation:
+ Enabled: false
+
+Layout/Tab:
+ Enabled: false
+
+Layout/TrailingBlankLines:
+ Enabled: false
+
+Layout/TrailingWhitespace:
+ Enabled: false
+
+Lint/AmbiguousBlockAssociation:
+ Enabled: false
+
+Lint/AmbiguousOperator:
+ Enabled: false
+
+Lint/AmbiguousRegexpLiteral:
+ Enabled: false
+
+Lint/AssignmentInCondition:
+ Enabled: false
+
+Lint/BlockAlignment:
+ Enabled: false
+
+Lint/CircularArgumentReference:
+ Enabled: false
+
+Lint/ConditionPosition:
+ Enabled: false
+
+Lint/Debugger:
+ Enabled: false
+
+Lint/DefEndAlignment:
+ Enabled: false
+
+Lint/DeprecatedClassMethods:
+ Enabled: false
+
+Lint/DuplicateCaseCondition:
+ Enabled: false
+
+Lint/DuplicateMethods:
+ Enabled: false
+
+Lint/DuplicatedKey:
+ Enabled: false
+
+Lint/EachWithObjectArgument:
+ Enabled: false
+
+Lint/ElseLayout:
+ Enabled: false
+
+Lint/EmptyEnsure:
+ Enabled: false
+
+Lint/EmptyExpression:
+ Enabled: false
+
+Lint/EmptyInterpolation:
+ Enabled: false
+
+Lint/EmptyWhen:
+ Enabled: false
+
+Lint/EndAlignment:
+ Enabled: true
+ EnforcedStyleAlignWith: variable
+
+Lint/EndInMethod:
+ Enabled: false
+
+Lint/EnsureReturn:
+ Enabled: false
+
+Lint/FloatOutOfRange:
+ Enabled: false
+
+Lint/FormatParameterMismatch:
+ Enabled: false
+
+Lint/HandleExceptions:
+ Enabled: false
+
+Lint/ImplicitStringConcatenation:
+ Enabled: false
+
+Lint/IneffectiveAccessModifier:
+ Enabled: false
+
+Lint/InheritException:
+ Enabled: false
+
+Lint/InvalidCharacterLiteral:
+ Enabled: false
+
+Lint/LiteralInCondition:
+ Enabled: false
+
+Lint/LiteralInInterpolation:
+ Enabled: false
+
+Lint/Loop:
+ Enabled: false
+
+Lint/MultipleCompare:
+ Enabled: false
+
+Lint/NestedMethodDefinition:
+ Enabled: false
+
+Lint/NextWithoutAccumulator:
+ Enabled: false
+
+Lint/NonLocalExitFromIterator:
+ Enabled: false
+
+Lint/ParenthesesAsGroupedExpression:
+ Enabled: false
+
+Lint/PercentStringArray:
+ Enabled: false
+
+Lint/PercentSymbolArray:
+ Enabled: false
+
+Lint/RandOne:
+ Enabled: false
+
+Lint/RequireParentheses:
+ Enabled: false
+
+Lint/RescueException:
+ Enabled: false
+
+Lint/RescueType:
+ Enabled: false
+
+Lint/ReturnInVoidContext:
+ Enabled: false
+
+Lint/SafeNavigationChain:
+ Enabled: false
+
+Lint/ScriptPermission:
+ Enabled: false
+
+Lint/ShadowedException:
+ Enabled: false
+
+Lint/ShadowingOuterLocalVariable:
+ Enabled: false
+
+Lint/StringConversionInInterpolation:
+ Enabled: false
+
+Lint/Syntax:
+ Enabled: false
+
+Lint/UnderscorePrefixedVariableName:
+ Enabled: false
+
+Lint/UnifiedInteger:
+ Enabled: false
+
+Lint/UnneededDisable:
+ Enabled: false
+
+Lint/UnneededSplatExpansion:
+ Enabled: false
+
+Lint/UnreachableCode:
+ Enabled: false
+
+Lint/UnusedBlockArgument:
+ Enabled: false
+
+Lint/UnusedMethodArgument:
+ Enabled: false
+
+Lint/UselessAccessModifier:
+ Enabled: false
+
+Lint/UselessAssignment:
+ Enabled: false
+
+Lint/UselessComparison:
+ Enabled: false
+
+Lint/UselessElseWithoutRescue:
+ Enabled: false
+
+Lint/UselessSetterCall:
+ Enabled: false
+
+Lint/Void:
+ Enabled: false
+
+Metrics/AbcSize:
+ Enabled: false
+
+Metrics/BlockLength:
+ Enabled: false
+
+Metrics/BlockNesting:
+ Enabled: false
+
+Metrics/ClassLength:
+ Enabled: false
+
+Metrics/CyclomaticComplexity:
+ Enabled: false
+
+Metrics/LineLength:
+ Enabled: false
+
+Metrics/MethodLength:
+ Enabled: false
+
+Metrics/ModuleLength:
+ Enabled: false
+
+Metrics/ParameterLists:
+ Enabled: false
+
+Metrics/PerceivedComplexity:
+ Enabled: false
+
+Performance/Caller:
+ Enabled: false
+
+Performance/CaseWhenSplat:
+ Enabled: false
+
+Performance/Casecmp:
+ Enabled: false
+
+Performance/CompareWithBlock:
+ Enabled: false
+
+Performance/Count:
+ Enabled: false
+
+Performance/Detect:
+ Enabled: false
+
+Performance/DoubleStartEndWith:
+ Enabled: false
+
+Performance/EndWith:
+ Enabled: false
+
+Performance/FixedSize:
+ Enabled: false
+
+Performance/FlatMap:
+ Enabled: false
+
+Performance/HashEachMethods:
+ Enabled: false
+
+Performance/LstripRstrip:
+ Enabled: false
+
+Performance/RangeInclude:
+ Enabled: false
+
+Performance/RedundantBlockCall:
+ Enabled: false
+
+Performance/RedundantMatch:
+ Enabled: false
+
+Performance/RedundantMerge:
+ Enabled: false
+
+Performance/RedundantSortBy:
+ Enabled: false
+
+Performance/RegexpMatch:
+ Enabled: false
+
+Performance/ReverseEach:
+ Enabled: false
+
+Performance/Sample:
+ Enabled: false
+
+Performance/Size:
+ Enabled: false
+
+Performance/StartWith:
+ Enabled: false
+
+Performance/StringReplacement:
+ Enabled: false
+
+Performance/TimesMap:
+ Enabled: false
+
+Rails/ActionFilter:
+ Enabled: false
+
+Rails/ActiveSupportAliases:
+ Enabled: false
+
+Rails/ApplicationJob:
+ Enabled: false
+
+Rails/ApplicationRecord:
+ Enabled: false
+
+Rails/Blank:
+ Enabled: false
+
+Rails/Date:
+ Enabled: false
+
+Rails/Delegate:
+ Enabled: false
+
+Rails/DelegateAllowBlank:
+ Enabled: false
+
+Rails/DynamicFindBy:
+ Enabled: false
+
+Rails/EnumUniqueness:
+ Enabled: false
+
+Rails/Exit:
+ Enabled: false
+
+Rails/FilePath:
+ Enabled: false
+
+Rails/FindBy:
+ Enabled: false
+
+Rails/FindEach:
+ Enabled: false
+
+Rails/HasAndBelongsToMany:
+ Enabled: false
+
+Rails/HttpPositionalArguments:
+ Enabled: false
+
+Rails/NotNullColumn:
+ Enabled: false
+
+Rails/Output:
+ Enabled: false
+
+Rails/OutputSafety:
+ Enabled: false
+
+Rails/PluralizationGrammar:
+ Enabled: false
+
+Rails/Present:
+ Enabled: false
+
+Rails/ReadWriteAttribute:
+ Enabled: false
+
+Rails/RelativeDateConstant:
+ Enabled: false
+
+Rails/RequestReferer:
+ Enabled: false
+
+Rails/ReversibleMigration:
+ Enabled: false
+
+Rails/SafeNavigation:
+ Enabled: false
+
+Rails/SaveBang:
+ Enabled: false
+
+Rails/ScopeArgs:
+ Enabled: false
+
+Rails/SkipsModelValidations:
+ Enabled: false
+
+Rails/TimeZone:
+ Enabled: false
+
+Rails/UniqBeforePluck:
+ Enabled: false
+
+Rails/Validation:
+ Enabled: false
+
+Rails:
+ Enabled: false
+
+Security/Eval:
+ Enabled: false
+
+Security/JSONLoad:
+ Enabled: false
+
+Security/MarshalLoad:
+ Enabled: false
+
+Security/YAMLLoad:
+ Enabled: false
+
+Style/AccessorMethodName:
+ Enabled: false
+
+Style/Alias:
+ Enabled: false
+
+Style/AndOr:
+ Enabled: false
+
+Style/ArrayJoin:
+ Enabled: false
+
+Style/AsciiComments:
+ Enabled: false
+
+Style/AsciiIdentifiers:
+ Enabled: false
+
+Style/Attr:
+ Enabled: false
+
+Style/AutoResourceCleanup:
+ Enabled: false
+
+Style/BarePercentLiterals:
+ Enabled: false
+
+Style/BeginBlock:
+ Enabled: false
+
+Style/BlockComments:
+ Enabled: false
+
+Style/BlockDelimiters:
+ Enabled: false
+
+Style/BracesAroundHashParameters:
+ Enabled: false
+
+Style/CaseEquality:
+ Enabled: false
+
+Style/CharacterLiteral:
+ Enabled: false
+
+Style/ClassAndModuleCamelCase:
+ Enabled: false
+
+Style/ClassAndModuleChildren:
+ Enabled: false
+
+Style/ClassCheck:
+ Enabled: false
+
+Style/ClassMethods:
+ Enabled: false
+
+Style/ClassVars:
+ Enabled: false
+
+Style/CollectionMethods:
+ Enabled: false
+
+Style/ColonMethodCall:
+ Enabled: false
+
+Style/CommandLiteral:
+ Enabled: false
+
+Style/CommentAnnotation:
+ Enabled: false
+
+Style/ConditionalAssignment:
+ Enabled: false
+
+Style/ConstantName:
+ Enabled: false
+
+Style/Copyright:
+ Enabled: false
+
+Style/DefWithParentheses:
+ Enabled: false
+
+Style/Documentation:
+ Enabled: false
+
+Style/DocumentationMethod:
+ Enabled: false
+
+Style/DoubleNegation:
+ Enabled: false
+
+Style/EachForSimpleLoop:
+ Enabled: false
+
+Style/EachWithObject:
+ Enabled: false
+
+Style/EmptyCaseCondition:
+ Enabled: false
+
+Style/EmptyElse:
+ Enabled: false
+
+Style/EmptyLiteral:
+ Enabled: false
+
+Style/EmptyMethod:
+ Enabled: false
+
+Style/Encoding:
+ Enabled: false
+
+Style/EndBlock:
+ Enabled: false
+
+Style/EvenOdd:
+ Enabled: false
+
+Style/FileName:
+ Enabled: false
+
+Style/FlipFlop:
+ Enabled: false
+
+Style/For:
+ Enabled: false
+
+Style/FormatString:
+ Enabled: false
+
+Style/FormatStringToken:
+ Enabled: false
+
+Style/FrozenStringLiteralComment:
+ Enabled: false
+
+Style/GlobalVars:
+ Enabled: false
+
+Style/GuardClause:
+ Enabled: false
+
+Style/HashSyntax:
+ Enabled: false
+
+Style/HeredocDelimiters:
+ Enabled: false
+
+Style/IdenticalConditionalBranches:
+ Enabled: false
+
+Style/IfInsideElse:
+ Enabled: false
+
+Style/IfUnlessModifier:
+ Enabled: false
+
+Style/IfUnlessModifierOfIfUnless:
+ Enabled: false
+
+Style/IfWithSemicolon:
+ Enabled: false
+
+Style/ImplicitRuntimeError:
+ Enabled: false
+
+Style/InfiniteLoop:
+ Enabled: false
+
+Style/InlineComment:
+ Enabled: false
+
+Style/InverseMethods:
+ Enabled: false
+
+Style/Lambda:
+ Enabled: false
+
+Style/LambdaCall:
+ Enabled: false
+
+Style/LineEndConcatenation:
+ Enabled: false
+
+Style/MethodCallWithArgsParentheses:
+ Enabled: false
+
+Style/MethodCallWithoutArgsParentheses:
+ Enabled: false
+
+Style/MethodCalledOnDoEndBlock:
+ Enabled: false
+
+Style/MethodDefParentheses:
+ Enabled: false
+
+Style/MethodMissing:
+ Enabled: false
+
+Style/MethodName:
+ Enabled: false
+
+Style/MissingElse:
+ Enabled: false
+
+Style/MixinGrouping:
+ Enabled: false
+
+Style/ModuleFunction:
+ Enabled: false
+
+Style/MultilineBlockChain:
+ Enabled: false
+
+Style/MultilineIfModifier:
+ Enabled: false
+
+Style/MultilineIfThen:
+ Enabled: false
+
+Style/MultilineMemoization:
+ Enabled: false
+
+Style/MultilineTernaryOperator:
+ Enabled: false
+
+Style/MultipleComparison:
+ Enabled: false
+
+Style/MutableConstant:
+ Enabled: false
+
+Style/NegatedIf:
+ Enabled: false
+
+Style/NegatedWhile:
+ Enabled: false
+
+Style/NestedModifier:
+ Enabled: false
+
+Style/NestedParenthesizedCalls:
+ Enabled: false
+
+Style/NestedTernaryOperator:
+ Enabled: false
+
+Style/Next:
+ Enabled: false
+
+Style/NilComparison:
+ Enabled: false
+
+Style/NonNilCheck:
+ Enabled: false
+
+Style/Not:
+ Enabled: false
+
+Style/NumericLiteralPrefix:
+ Enabled: false
+
+Style/NumericLiterals:
+ Enabled: false
+
+Style/NumericPredicate:
+ Enabled: false
+
+Style/OneLineConditional:
+ Enabled: false
+
+Style/OpMethod:
+ Enabled: false
+
+Style/OptionHash:
+ Enabled: false
+
+Style/OptionalArguments:
+ Enabled: false
+
+Style/ParallelAssignment:
+ Enabled: false
+
+Style/ParenthesesAroundCondition:
+ Enabled: false
+
+Style/PercentLiteralDelimiters:
+ Enabled: false
+
+Style/PercentQLiterals:
+ Enabled: false
+
+Style/PerlBackrefs:
+ Enabled: false
+
+Style/PredicateName:
+ Enabled: false
+
+Style/PreferredHashMethods:
+ Enabled: false
+
+Style/Proc:
+ Enabled: false
+
+Style/RaiseArgs:
+ Enabled: false
+
+Style/RedundantBegin:
+ Enabled: false
+
+Style/RedundantException:
+ Enabled: false
+
+Style/RedundantFreeze:
+ Enabled: false
+
+Style/RedundantParentheses:
+ Enabled: false
+
+Style/RedundantReturn:
+ Enabled: false
+
+Style/RedundantSelf:
+ Enabled: false
+
+Style/RegexpLiteral:
+ Enabled: false
+
+Style/RescueModifier:
+ Enabled: false
+
+Style/SafeNavigation:
+ Enabled: false
+
+Style/SelfAssignment:
+ Enabled: false
+
+Style/Semicolon:
+ Enabled: false
+
+Style/Send:
+ Enabled: false
+
+Style/SignalException:
+ Enabled: false
+
+Style/SingleLineBlockParams:
+ Enabled: false
+
+Style/SingleLineMethods:
+ Enabled: false
+
+Style/SpecialGlobalVars:
+ Enabled: false
+
+Style/StabbyLambdaParentheses:
+ Enabled: false
+
+Style/StringLiterals:
+ Enabled: false
+
+Style/StringLiteralsInInterpolation:
+ Enabled: false
+
+Style/StringMethods:
+ Enabled: false
+
+Style/StructInheritance:
+ Enabled: false
+
+Style/SymbolArray:
+ Enabled: false
+
+Style/SymbolLiteral:
+ Enabled: false
+
+Style/SymbolProc:
+ Enabled: false
+
+Style/TernaryParentheses:
+ Enabled: false
+
+Style/TrailingCommaInArguments:
+ Enabled: false
+
+Style/TrailingCommaInLiteral:
+ Enabled: false
+
+Style/TrailingUnderscoreVariable:
+ Enabled: false
+
+Style/TrivialAccessors:
+ Enabled: false
+
+Style/UnlessElse:
+ Enabled: false
+
+Style/UnneededCapitalW:
+ Enabled: false
+
+Style/UnneededInterpolation:
+ Enabled: false
+
+Style/UnneededPercentQ:
+ Enabled: false
+
+Style/VariableInterpolation:
+ Enabled: false
+
+Style/VariableName:
+ Enabled: false
+
+Style/VariableNumber:
+ Enabled: false
+
+Style/WhenThen:
+ Enabled: false
+
+Style/WhileUntilDo:
+ Enabled: false
+
+Style/WhileUntilModifier:
+ Enabled: false
+
+Style/WordArray:
+ Enabled: false
+
+Style/YodaCondition:
+ Enabled: false
+
+Style/ZeroLengthPredicate:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index 246e589dd..c7b560dd2 100644
--- a/Gemfile
+++ b/Gemfile
@@ -52,6 +52,7 @@ gem 'rest-client'
gem 'clamav-client', require: 'clamav/client'
gem 'carrierwave'
+gem 'copy_carrierwave_file'
gem 'fog'
gem 'fog-openstack'
@@ -101,6 +102,12 @@ gem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', require: false
gem 'select2-rails'
+# PDF Generation
+gem 'prawn', '~> 2.0.1'
+gem 'prawn_rails', '~> 0.0.11'
+
+gem 'sentry-raven'
+
group :test do
gem 'capybara'
gem 'launchy'
@@ -122,6 +129,7 @@ group :development do
gem 'web-console'
gem 'rack-handlers'
gem 'xray-rails'
+ gem 'rubocop', require: false
gem 'haml-lint'
gem 'scss_lint', require: false
end
@@ -142,8 +150,3 @@ group :development, :test do
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'dotenv-rails'
end
-
-group :production, :staging do
- gem 'sentry-raven'
-end
-
diff --git a/Gemfile.lock b/Gemfile.lock
index 07225ea01..5ff8a870a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -120,6 +120,8 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
+ copy_carrierwave_file (1.3.0)
+ carrierwave (>= 0.9)
crack (0.4.3)
safe_yaml (~> 1.0.0)
database_cleaner (1.5.3)
@@ -417,14 +419,22 @@ GEM
openstack (3.3.7)
json
orm_adapter (0.5.0)
+ parallel (1.11.2)
parser (2.4.0.0)
ast (~> 2.2)
+ pdf-core (0.6.1)
pg (0.19.0)
poltergeist (1.14.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
powerpack (0.1.1)
+ prawn (2.0.2)
+ pdf-core (~> 0.6.0)
+ ttfunk (~> 1.4.0)
+ prawn_rails (0.0.11)
+ prawn (>= 0.11.1)
+ railties (>= 3.0.0)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@@ -471,7 +481,8 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
- rainbow (2.2.1)
+ rainbow (2.2.2)
+ rake
raindrops (0.17.0)
rake (12.0.0)
rb-fsevent (0.9.8)
@@ -522,7 +533,8 @@ GEM
rspec-mocks (~> 3.5.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
- rubocop (0.48.1)
+ rubocop (0.49.1)
+ parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
@@ -608,6 +620,7 @@ GEM
tilt (2.0.5)
timecop (0.8.1)
trollop (2.1.2)
+ ttfunk (1.4.0)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
@@ -618,7 +631,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
- unicode-display_width (1.1.3)
+ unicode-display_width (1.2.1)
unicode_utils (1.4.0)
unicorn (5.2.0)
kgio (~> 2.6)
@@ -674,6 +687,7 @@ DEPENDENCIES
carrierwave
chartkick
clamav-client
+ copy_carrierwave_file
database_cleaner
deep_cloneable (~> 2.2.1)
devise
@@ -703,6 +717,8 @@ DEPENDENCIES
openstack
pg
poltergeist
+ prawn (~> 2.0.1)
+ prawn_rails (~> 0.0.11)
pry-byebug
rack-handlers
rails (= 5.0.0.1)
@@ -711,6 +727,7 @@ DEPENDENCIES
rest-client
rgeo-geojson
rspec-rails (~> 3.0)
+ rubocop
sass-rails (~> 5.0)
scenic
scss_lint
diff --git a/Guardfile b/Guardfile
index 5a91521bb..ed798d43e 100644
--- a/Guardfile
+++ b/Guardfile
@@ -24,7 +24,6 @@
# * zeus: 'zeus rspec' (requires the server to be started separetly)
# * 'just' rspec: 'rspec'
-
guard 'livereload' do
extensions = {
css: :css,
diff --git a/README.md b/README.md
index 61d22b1c9..02e3a3db2 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,7 @@ Pour exécuter les tests de l'application, plusieurs possibilités :
## Linting
+- Faire tourner RuboCop : `bundle exec rubocop`
- Linter les fichiers HAML : `bundle exec haml-lint app/views/`
- Linter les fichiers SCSS : `bundle exec scss-lint app/assets/stylesheets/`
diff --git a/Rakefile b/Rakefile
index 7cde3d716..bdb67ab62 100644
--- a/Rakefile
+++ b/Rakefile
@@ -19,7 +19,6 @@ task :deploy_ha do
end
end
-
task :deploy_old do
domains = %w(37.187.154.237 37.187.249.111)
domains.each do |domain|
@@ -27,7 +26,6 @@ task :deploy_old do
end
end
-
task :deploy_test do
domains = %w(192.168.0.116)
branch = 'clamav'
diff --git a/app/assets/images/flag_of_europe.svg b/app/assets/images/flag_of_europe.svg
new file mode 100644
index 000000000..754f1480f
--- /dev/null
+++ b/app/assets/images/flag_of_europe.svg
@@ -0,0 +1 @@
+European flag
\ No newline at end of file
diff --git a/app/assets/images/icons/account-circle.svg b/app/assets/images/icons/account-circle.svg
new file mode 100644
index 000000000..ec478f66c
--- /dev/null
+++ b/app/assets/images/icons/account-circle.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/images/icons/search-blue.svg b/app/assets/images/icons/search-blue.svg
new file mode 100644
index 000000000..e1b35abf2
--- /dev/null
+++ b/app/assets/images/icons/search-blue.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/images/icons/sign-out.svg b/app/assets/images/icons/sign-out.svg
new file mode 100644
index 000000000..30022a12b
--- /dev/null
+++ b/app/assets/images/icons/sign-out.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/images/icons/switch-profile.svg b/app/assets/images/icons/switch-profile.svg
new file mode 100644
index 000000000..e5d63c13c
--- /dev/null
+++ b/app/assets/images/icons/switch-profile.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/images/login-with-fc-hover.svg b/app/assets/images/login-with-fc-hover.svg
new file mode 100644
index 000000000..e3e0ef572
--- /dev/null
+++ b/app/assets/images/login-with-fc-hover.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/images/login-with-fc.svg b/app/assets/images/login-with-fc.svg
new file mode 100644
index 000000000..258e58174
--- /dev/null
+++ b/app/assets/images/login-with-fc.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/images/mailer/gestionnaire_mailer/logo-beta-gouv-fr.png b/app/assets/images/mailer/gestionnaire_mailer/logo-beta-gouv-fr.png
new file mode 100644
index 000000000..7cb725c37
Binary files /dev/null and b/app/assets/images/mailer/gestionnaire_mailer/logo-beta-gouv-fr.png differ
diff --git a/app/assets/images/pdf.svg b/app/assets/images/pdf.svg
new file mode 100644
index 000000000..88bfb51a6
--- /dev/null
+++ b/app/assets/images/pdf.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/assets/javascripts/new_design/application.js b/app/assets/javascripts/new_design/application.js
new file mode 100644
index 000000000..700bc74fb
--- /dev/null
+++ b/app/assets/javascripts/new_design/application.js
@@ -0,0 +1,18 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// compiled file.
+//
+// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
+// about supported directives.
+//
+//= require jquery
+//= require jquery_ujs
+//= require turbolinks
+//= require highcharts
+//= require chartkick
+//= require_tree .
diff --git a/app/assets/javascripts/new_design/header.js b/app/assets/javascripts/new_design/header.js
new file mode 100644
index 000000000..903b0ff96
--- /dev/null
+++ b/app/assets/javascripts/new_design/header.js
@@ -0,0 +1,10 @@
+window.TPS = window.TPS || {};
+
+$(document).on("click", "body", function () {
+ $(".header-menu").removeClass("open fade-in-down");
+});
+
+TPS.toggleHeaderMenu = function(event) {
+ event.stopPropagation();
+ $(".header-menu").toggleClass("open fade-in-down");
+}
diff --git a/app/assets/javascripts/toggle_chart.js b/app/assets/javascripts/new_design/toggle_chart.js
similarity index 100%
rename from app/assets/javascripts/toggle_chart.js
rename to app/assets/javascripts/new_design/toggle_chart.js
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index aac24c497..9375b0288 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -44,6 +44,8 @@
// = require switch_menu
// = require typeahead
// = require users
+// = require attestation_template_edit
+// = require attestation_recapitulatif
// = require_self
// = require bootstrap-datepicker3
diff --git a/app/assets/stylesheets/attestation_recapitulatif.scss b/app/assets/stylesheets/attestation_recapitulatif.scss
new file mode 100644
index 000000000..7f3f80008
--- /dev/null
+++ b/app/assets/stylesheets/attestation_recapitulatif.scss
@@ -0,0 +1,31 @@
+#attestation-recapitulatif {
+ margin-top: 40px;
+
+ .details {
+ padding: 15px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ background-color: #FFFFFF;
+
+ .left {
+ position: relative;
+ padding-left: 30px;
+
+ img {
+ position: absolute;
+ left: 0px;
+ top: 15px;
+ }
+
+ .title {
+ font-weight: bold;
+ margin: 0;
+ }
+
+ .delivery {
+ color: #999999;
+ }
+ }
+ }
+}
diff --git a/app/assets/stylesheets/attestation_template_edit.scss b/app/assets/stylesheets/attestation_template_edit.scss
new file mode 100644
index 000000000..f6105a8f6
--- /dev/null
+++ b/app/assets/stylesheets/attestation_template_edit.scss
@@ -0,0 +1,30 @@
+#attestation-template-edit {
+ .notice {
+ margin-bottom: 30px;
+ }
+
+ .image-upload {
+ display: flex;
+ align-items: center;
+
+ input {
+ margin: 10px 0;
+ }
+ }
+
+ .thumbnail {
+ width: 90px;
+ margin-right: 15px;
+ }
+
+ .balises {
+ max-height: 180px;
+ overflow-y: scroll;
+ margin-bottom: 20px;
+ }
+
+ .table {
+ border: 1px solid #DDDDDD;
+ margin-bottom: 0px;
+ }
+}
diff --git a/app/assets/stylesheets/left_panel.scss b/app/assets/stylesheets/left_panel.scss
index c594715a2..e35b6494f 100644
--- a/app/assets/stylesheets/left_panel.scss
+++ b/app/assets/stylesheets/left_panel.scss
@@ -281,3 +281,8 @@
}
}
}
+
+.motivation-text-area {
+ color: #000000;
+ margin-bottom: 15px;
+}
diff --git a/app/assets/stylesheets/new_design/_placeholders.scss b/app/assets/stylesheets/new_design/_placeholders.scss
index fbb5bf9d5..086e5ecfe 100644
--- a/app/assets/stylesheets/new_design/_placeholders.scss
+++ b/app/assets/stylesheets/new_design/_placeholders.scss
@@ -19,3 +19,8 @@
max-width: $page-width + 2 * $default-padding;
margin: 0 auto;
}
+
+%animation {
+ animation-fill-mode: forwards;
+ animation-duration: 0.3s;
+}
diff --git a/app/assets/stylesheets/new_design/animations.scss b/app/assets/stylesheets/new_design/animations.scss
new file mode 100644
index 000000000..c9df122d2
--- /dev/null
+++ b/app/assets/stylesheets/new_design/animations.scss
@@ -0,0 +1,18 @@
+@import "placeholders";
+
+@keyframes fade-in-down {
+ 0% {
+ opacity: 0;
+ margin-top: -10px;
+ }
+
+ 100% {
+ opacity: 1;
+ margin-top: 0;
+ }
+}
+
+.fade-in-down {
+ @extend %animation;
+ animation-name: fade-in-down;
+}
diff --git a/app/assets/stylesheets/new_design/auth.scss b/app/assets/stylesheets/new_design/auth.scss
new file mode 100644
index 000000000..6f292b928
--- /dev/null
+++ b/app/assets/stylesheets/new_design/auth.scss
@@ -0,0 +1,108 @@
+@import "colors";
+@import "placeholders";
+@import "mixins";
+
+$auth-breakpoint: 820px;
+
+@media (max-width: $auth-breakpoint) {
+ .preview {
+ display: none;
+ }
+
+ .two-columns .column.auth-form {
+ @include horizontal-padding(0);
+ width: 100%;
+ }
+}
+
+@media (max-width: $auth-breakpoint) {
+ .two-columns.auth {
+ background: #FFFFFF;
+ }
+}
+
+.preview {
+ font-size: 24px;
+
+ .paperless-logo {
+ width: 100%;
+ margin-bottom: 60px;
+ }
+
+ h3 {
+ color: $blue;
+ font-weight: bold;
+ }
+
+ .close-procedure {
+ font-size: 12px;
+ }
+
+ .procedure-title {
+ font-size: 30px;
+ margin: 50px 0 32px;
+ }
+
+ .procedure-description {
+ font-size: 14px;
+ }
+
+ .procedure-logos {
+ display: flex;
+ justify-content: space-around;
+
+ img {
+ max-height: 130px;
+ margin: 0 10px;
+ }
+ }
+}
+
+.auth-form {
+ font-size: 14px;
+
+ .reset-password {
+ margin-top: 8px;
+ }
+
+ .separation {
+ font-size: 14px;
+ color: $grey;
+ margin: 24px 0;
+ }
+
+ .login-with-fc {
+ display: inline-block;
+ height: 52px;
+ width: 186px;
+ margin: auto;
+ margin-bottom: 8px;
+ background-image: image-url("login-with-fc.svg");
+ background-repeat: no-repeat;
+ background-size: cover;
+ cursor: pointer;
+
+ &:hover {
+ background-image: image-url("login-with-fc-hover.svg");
+ }
+ }
+
+ hr {
+ margin-top: 60px;
+ margin-bottom: 20px;
+ background-color: $grey;
+ border: none;
+ height: 1px;
+ }
+
+ .register {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ span {
+ font-size: 18px;
+ font-weight: bold;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/new_design/avis_sign_up.scss b/app/assets/stylesheets/new_design/avis_sign_up.scss
index 9c94d35af..f202205c9 100644
--- a/app/assets/stylesheets/new_design/avis_sign_up.scss
+++ b/app/assets/stylesheets/new_design/avis_sign_up.scss
@@ -2,14 +2,6 @@
@import "colors";
.avis-sign-up {
- display: flex;
-
- .left,
- .right {
- width: 50%;
- padding: 60px 86px;
- }
-
.left {
p {
margin: auto;
@@ -28,64 +20,4 @@
margin-top: 15px;
}
}
-
- .right {
- background-color: $light-grey;
-
- h1 {
- font-size: 36px;
- font-weight: bold;
- margin-bottom: 60px;
- }
-
- form {
- max-width: 420px;
- }
-
- label,
- input {
- display: block;
- width: 100%;
- }
-
- label {
- font-size: 14px;
- line-height: 1.57;
- margin: 24px 0 8px;
- }
-
- input {
- border: solid 1px $border-grey;
- border-radius: 4px;
- height: 56px;
- padding: 0 15px;
- font-family: Muli;
- font-size: 14px;
-
- &:disabled {
- background-color: $border-grey;
- }
- }
-
- button {
- display: inline-block;
- height: 60px;
- line-height: 60px;
- border: none;
- border-radius: 60px;
- background-color: $blue;
- color: #FFFFFF;
- font-size: 16px;
- text-align: center;
- width: 100%;
- margin: 55px 0;
-
- &:hover {
- color: #FFFFFF;
- text-decoration: none;
- background-color: $light-blue;
- cursor: pointer;
- }
- }
- }
}
diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss
new file mode 100644
index 000000000..bd4a512b8
--- /dev/null
+++ b/app/assets/stylesheets/new_design/buttons.scss
@@ -0,0 +1,51 @@
+@import "colors";
+
+.button {
+ display: inline-block;
+ padding: 8px 16px;
+ border-radius: 30px;
+ border: 1px solid $border-grey;
+ font-size: 14px;
+ background-color: #FFFFFF;
+ color: $black;
+ cursor: pointer;
+
+ &:hover {
+ background: $light-grey;
+ text-decoration: none;
+ }
+
+ &.primary {
+ color: #FFFFFF;
+ border-color: $blue;
+ background-color: $blue;
+
+ &:hover {
+ background: $light-blue;
+ }
+ }
+
+ &.secondary {
+ color: $blue;
+ border-color: $blue;
+ background-color: #FFFFFF;
+
+ &:hover {
+ color: #FFFFFF;
+ background: $light-blue;
+ }
+ }
+
+ &.large {
+ font-size: 18px;
+ padding: 15px 32px;
+ }
+
+ &.expand {
+ width: 100%;
+ }
+}
+
+.link {
+ color: $blue;
+}
diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss
index bbf87837b..2ee0e05d7 100644
--- a/app/assets/stylesheets/new_design/common.scss
+++ b/app/assets/stylesheets/new_design/common.scss
@@ -5,3 +5,8 @@ body {
font-size: 16px;
line-height: 1.42857143;
}
+
+h1 {
+ font-size: 36px;
+ font-weight: bold;
+}
diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss
new file mode 100644
index 000000000..e1616d1e7
--- /dev/null
+++ b/app/assets/stylesheets/new_design/forms.scss
@@ -0,0 +1,37 @@
+@import "colors";
+
+.form {
+ h1 {
+ text-align: center;
+ margin-bottom: 20px;
+ }
+
+ label,
+ input {
+ font-size: 14px;
+ }
+
+ label,
+ input[type=submit] {
+ margin-top: 24px;
+ }
+
+ label {
+ margin-bottom: 8px;
+ display: inline-block;
+ }
+
+ input[type=text],
+ input[type=email],
+ input[type=password] {
+ display: block;
+ width: 100%;
+ border-radius: 4px;
+ border: solid 1px $border-grey;
+ padding: 16px;
+
+ &:disabled {
+ background-color: $border-grey;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/new_design/landing.scss b/app/assets/stylesheets/new_design/landing.scss
index b5fa9cb12..769f49622 100644
--- a/app/assets/stylesheets/new_design/landing.scss
+++ b/app/assets/stylesheets/new_design/landing.scss
@@ -70,6 +70,7 @@ $landing-breakpoint: 1040px;
color: #FFFFFF;
font-size: 24px;
margin-top: 30px;
+ cursor: pointer;
&:hover {
color: #FFFFFF;
@@ -286,6 +287,7 @@ $cta-panel-button-border-size: 2px;
color: #FFFFFF;
font-size: 24px;
text-align: center;
+ cursor: pointer;
&:hover {
color: #FFFFFF;
diff --git a/app/assets/stylesheets/new_design/layouts.scss b/app/assets/stylesheets/new_design/layouts.scss
new file mode 100644
index 000000000..98fcfe043
--- /dev/null
+++ b/app/assets/stylesheets/new_design/layouts.scss
@@ -0,0 +1,32 @@
+@import "colors";
+@import "constants";
+@import "placeholders";
+
+.two-columns {
+ $column-padding: 60px;
+ $two-columns-breakpoint: $page-width + (2 * $column-padding);
+
+ background: linear-gradient(to right, #FFFFFF 0%, #FFFFFF 50%, $light-grey 50%, $light-grey 100%);
+
+ .columns-container {
+ @extend %page-width-container;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ }
+
+ .column {
+ width: 50%;
+ padding: $column-padding;
+
+ @media (min-width: $two-columns-breakpoint) {
+ &:first-child {
+ padding-left: 0;
+ }
+
+ &:last-child {
+ padding-right: 0;
+ }
+ }
+ }
+}
diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss
index aa542550e..9ea00b625 100644
--- a/app/assets/stylesheets/new_design/new_header.scss
+++ b/app/assets/stylesheets/new_design/new_header.scss
@@ -17,39 +17,100 @@
@extend %page-width-container;
display: flex;
justify-content: space-between;
+ padding-top: 17px;
}
-.header-logo {
- margin-top: 17px;
+.header-right-content {
+ display: flex;
+ align-items: center;
+
+ > li {
+ @include horizontal-padding(8px);
+
+ &:last-child {
+ padding-right: 0;
+ }
+ }
}
-$header-login-button-height: 36px;
-$header-login-button-border-size: 1px;
+.header-search {
+ position: relative;
-.header-login-button {
- @include horizontal-padding(16px);
+ .form input[type=text] {
+ padding: 9px;
+ padding-right: 42px;
+ float: right;
+ width: 300px;
+ }
- display: inline-block;
- height: $header-login-button-height;
- line-height: $header-login-button-height - (2 * $header-login-button-border-size);
- border-radius: $header-login-button-height;
- border: $header-login-button-border-size solid $blue;
- color: $blue;
+ button {
+ padding: 6px 9px;
+ border: none;
+ background: none;
+ cursor: pointer;
+ position: absolute;
+ right: 0;
+
+ &:hover {
+ opacity: 0.8;
+ }
+ }
+}
+
+.header-menu-opener {
+ position: relative;
+
+ img {
+ cursor: pointer;
+
+ &:hover {
+ opacity: 0.8;
+ }
+ }
+}
+
+.header-menu {
+ display: none;
+ position: absolute;
+ right: 0;
+ top: 34px;
font-size: 14px;
- margin-top: 18px;
+ background: #FFFFFF;
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
+ border: 1px solid $border-grey;
+ min-width: 270px;
+ max-width: 340px;
- &:hover {
- color: #FFFFFF;
- text-decoration: none;
- background-color: $light-blue;
+ &.open {
+ display: block;
}
- &:focus {
- color: $blue;
- text-decoration: none;
- }
+ li {
+ border-bottom: 1px solid $border-grey;
- &:hover:focus {
- color: #FFFFFF;
+ &:last-child {
+ border-bottom: none;
+ }
+
+ .menu-item {
+ align-items: center;
+ padding: 14px;
+ color: $grey;
+ overflow: hidden;
+ text-overflow: ellipsis;
+
+ img {
+ margin-right: 14px;
+ }
+ }
+
+ .menu-link {
+ display: flex;
+ color: $black;
+
+ &:hover {
+ background: $light-grey;
+ }
+ }
}
}
diff --git a/app/assets/stylesheets/new_design/patron.scss b/app/assets/stylesheets/new_design/patron.scss
new file mode 100644
index 000000000..54bc0e0d3
--- /dev/null
+++ b/app/assets/stylesheets/new_design/patron.scss
@@ -0,0 +1,11 @@
+@import "placeholders";
+
+.patron {
+ .patron-container {
+ @extend %page-width-container;
+ }
+
+ p {
+ margin-bottom: 20px;
+ }
+}
diff --git a/app/assets/stylesheets/new_design/utils.scss b/app/assets/stylesheets/new_design/utils.scss
index 958f8ff9c..2880cfe30 100644
--- a/app/assets/stylesheets/new_design/utils.scss
+++ b/app/assets/stylesheets/new_design/utils.scss
@@ -14,6 +14,10 @@
text-align: center;
}
+.text-right {
+ text-align: right;
+}
+
.hidden {
display: none;
}
diff --git a/app/controllers/admin/accompagnateurs_controller.rb b/app/controllers/admin/accompagnateurs_controller.rb
index dcdb3ae46..6f6314851 100644
--- a/app/controllers/admin/accompagnateurs_controller.rb
+++ b/app/controllers/admin/accompagnateurs_controller.rb
@@ -7,17 +7,17 @@ class Admin::AccompagnateursController < AdminController
def show
assign_scope = @procedure.gestionnaires
@accompagnateurs_assign = smart_listing_create :accompagnateurs_assign,
- assign_scope,
- partial: "admin/accompagnateurs/list_assign",
- array: true
+ assign_scope,
+ partial: "admin/accompagnateurs/list_assign",
+ array: true
not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids)
not_assign_scope = not_assign_scope.where("email LIKE '%#{params[:filter]}%'") if params[:filter]
@accompagnateurs_not_assign = smart_listing_create :accompagnateurs_not_assign,
- not_assign_scope,
- partial: "admin/accompagnateurs/list_not_assign",
- array: true
+ not_assign_scope,
+ partial: "admin/accompagnateurs/list_not_assign",
+ array: true
@gestionnaire ||= Gestionnaire.new
end
diff --git a/app/controllers/admin/attestation_templates_controller.rb b/app/controllers/admin/attestation_templates_controller.rb
new file mode 100644
index 000000000..bc3bf0f40
--- /dev/null
+++ b/app/controllers/admin/attestation_templates_controller.rb
@@ -0,0 +1,64 @@
+class Admin::AttestationTemplatesController < AdminController
+ before_action :retrieve_procedure
+
+ def edit
+ @attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure)
+ end
+
+ def update
+ attestation_template = @procedure.attestation_template
+
+ if attestation_template.update_attributes(activated_attestation_params)
+ flash.notice = "L'attestation a bien été modifiée"
+ else
+ flash.alert = attestation_template.errors.full_messages.join(' ')
+ end
+
+ redirect_to edit_admin_procedure_attestation_template_path(@procedure)
+ end
+
+ def create
+ attestation_template = AttestationTemplate.new(activated_attestation_params.merge(procedure_id: @procedure.id))
+
+ if attestation_template.save
+ flash.notice = "L'attestation a bien été sauvegardée"
+ else
+ flash.alert = attestation_template.errors.full_messages.join(' ')
+ end
+
+ redirect_to edit_admin_procedure_attestation_template_path(@procedure)
+ end
+
+ def disactivate
+ attestation_template = @procedure.attestation_template
+ attestation_template.activated = false
+ attestation_template.save
+
+ flash.notice = "L'attestation a bien été désactivée"
+
+ redirect_to edit_admin_procedure_attestation_template_path(@procedure)
+ end
+
+ def preview
+ @title = activated_attestation_params[:title]
+ @body = activated_attestation_params[:body]
+ @footer = activated_attestation_params[:footer]
+ @created_at = DateTime.now
+
+ # In a case of a preview, when the user does not change its images,
+ # the images are not uploaded and thus should be retrieved from previous
+ # attestation_template
+ @logo = activated_attestation_params[:logo] || @procedure.attestation_template&.logo
+ @signature = activated_attestation_params[:signature] || @procedure.attestation_template&.signature
+
+ render 'admin/attestation_templates/show', formats: [:pdf]
+ end
+
+ private
+
+ def activated_attestation_params
+ params.require(:attestation_template)
+ .permit(:title, :body, :footer, :logo, :signature)
+ .merge(activated: true)
+ end
+end
diff --git a/app/controllers/admin/gestionnaires_controller.rb b/app/controllers/admin/gestionnaires_controller.rb
index da082c5f3..1964edfe2 100644
--- a/app/controllers/admin/gestionnaires_controller.rb
+++ b/app/controllers/admin/gestionnaires_controller.rb
@@ -4,13 +4,13 @@ class Admin::GestionnairesController < AdminController
def index
@gestionnaires = smart_listing_create :gestionnaires,
- current_administrateur.gestionnaires,
- partial: "admin/gestionnaires/list",
- array: true
+ current_administrateur.gestionnaires,
+ partial: "admin/gestionnaires/list",
+ array: true
+
@gestionnaire ||= Gestionnaire.new
end
-
def create
@gestionnaire = Gestionnaire.find_by_email(params[:gestionnaire][:email])
procedure_id = params[:procedure_id]
@@ -47,7 +47,6 @@ class Admin::GestionnairesController < AdminController
User.create(attributes)
flash.notice = 'Accompagnateur ajouté'
GestionnaireMailer.new_gestionnaire(@gestionnaire.email, @gestionnaire.password).deliver_now!
- GestionnaireMailer.new_assignement(@gestionnaire.email, current_administrateur.email).deliver_now!
else
flash.alert = @gestionnaire.errors.full_messages.join(' ').html_safe
end
@@ -57,7 +56,6 @@ class Admin::GestionnairesController < AdminController
if current_administrateur.gestionnaires.include? @gestionnaire
flash.alert = 'Accompagnateur déjà ajouté'
else
- GestionnaireMailer.new_assignement(@gestionnaire.email, current_administrateur.email).deliver_now!
@gestionnaire.administrateurs.push current_administrateur
flash.notice = 'Accompagnateur ajouté'
#TODO Mailer no assign_to
diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb
index 639c79242..5f7731658 100644
--- a/app/controllers/admin/procedures_controller.rb
+++ b/app/controllers/admin/procedures_controller.rb
@@ -6,18 +6,18 @@ class Admin::ProceduresController < AdminController
def index
@procedures = smart_listing_create :procedures,
- current_administrateur.procedures.where(published: true, archived: false).order(created_at: :desc),
- partial: "admin/procedures/list",
- array: true
+ current_administrateur.procedures.where(published: true, archived: false).order(created_at: :desc),
+ partial: "admin/procedures/list",
+ array: true
active_class
end
def archived
@procedures = smart_listing_create :procedures,
- current_administrateur.procedures.where(archived: true).order(created_at: :desc),
- partial: "admin/procedures/list",
- array: true
+ current_administrateur.procedures.where(archived: true).order(created_at: :desc),
+ partial: "admin/procedures/list",
+ array: true
archived_class
@@ -26,9 +26,9 @@ class Admin::ProceduresController < AdminController
def draft
@procedures = smart_listing_create :procedures,
- current_administrateur.procedures.where(published: false, archived: false).order(created_at: :desc),
- partial: "admin/procedures/list",
- array: true
+ current_administrateur.procedures.where(published: false, archived: false).order(created_at: :desc),
+ partial: "admin/procedures/list",
+ array: true
draft_class
@@ -40,7 +40,14 @@ class Admin::ProceduresController < AdminController
end
def edit
+ end
+ def hide
+ procedure = Procedure.find(params[:id])
+ procedure.hide!
+
+ flash.notice = "Procédure supprimée, en cas d'erreur contactez nous : contact@tps.apientreprise.fr"
+ redirect_to admin_procedures_draft_path
end
def destroy
@@ -122,19 +129,21 @@ class Admin::ProceduresController < AdminController
end
def transfer
- admin = Administrateur.find_by_email(params[:email_admin])
+ admin = Administrateur.find_by_email(params[:email_admin].downcase)
- return render '/admin/procedures/transfer', formats: 'js', status: 404 if admin.nil?
+ if admin.nil?
+ render '/admin/procedures/transfer', formats: 'js', status: 404
+ else
+ procedure = current_administrateur.procedures.find(params[:procedure_id])
+ clone_procedure = procedure.clone
- procedure = current_administrateur.procedures.find(params[:procedure_id])
- clone_procedure = procedure.clone
+ clone_procedure.administrateur = admin
+ clone_procedure.save
- clone_procedure.administrateur = admin
- clone_procedure.save
+ flash.now.notice = "La procédure a correctement été clonée vers le nouvel administrateur."
- flash.now.notice = "La procédure a correctement été cloné vers le nouvel administrateur."
-
- render '/admin/procedures/transfer', formats: 'js', status: 200
+ render '/admin/procedures/transfer', formats: 'js', status: 200
+ end
end
def archive
diff --git a/app/controllers/administrateurs/sessions_controller.rb b/app/controllers/administrateurs/sessions_controller.rb
index be676864f..3c8328e30 100644
--- a/app/controllers/administrateurs/sessions_controller.rb
+++ b/app/controllers/administrateurs/sessions_controller.rb
@@ -1,4 +1,6 @@
class Administrateurs::SessionsController < Sessions::SessionsController
+ layout "new_application"
+
def demo
return redirect_to root_path if Rails.env.production?
diff --git a/app/controllers/administrations_controller.rb b/app/controllers/administrations_controller.rb
index e610ffcf5..8a36c6fc5 100644
--- a/app/controllers/administrations_controller.rb
+++ b/app/controllers/administrations_controller.rb
@@ -8,11 +8,9 @@ class AdministrationsController < ApplicationController
@admin = Administrateur.new
@admins = smart_listing_create :admins,
- Administrateur.all.order(:email),
- partial: "administrations/list",
- array: true
-
-
+ Administrateur.all.order(:email),
+ partial: "administrations/list",
+ array: true
end
def create
@@ -20,7 +18,7 @@ class AdministrationsController < ApplicationController
if admin.save
flash.notice = "Administrateur créé"
- NewAdminMailer.new_admin_email(admin, params[:administrateur][:password]).deliver_now!
+ NewAdminMailer.new_admin_email(admin).deliver_now!
else
flash.alert = admin.errors.full_messages.join(' ').html_safe
end
diff --git a/app/controllers/api/v1/procedures_controller.rb b/app/controllers/api/v1/procedures_controller.rb
index cf370a8ff..74895e845 100644
--- a/app/controllers/api/v1/procedures_controller.rb
+++ b/app/controllers/api/v1/procedures_controller.rb
@@ -13,5 +13,4 @@ class API::V1::ProceduresController < APIController
Rails.logger.error(e.message)
render json: {}, status: 404
end
-
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index afcbf7916..191d2bcf8 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :check_browser
before_action :load_navbar_left_pannel_partial_url
+ before_action :set_raven_context
def default_url_options
return {protocol: 'https'} if Rails.env.staging? || Rails.env.production?
@@ -40,4 +41,25 @@ class ApplicationController < ActionController::Base
redirect_to new_user_session_path
end
end
+
+ private
+
+ def set_raven_context
+ context = { ip_address: request.ip }
+
+ logged_models = [
+ current_user,
+ current_gestionnaire,
+ current_administrateur,
+ current_administration
+ ].compact
+
+ context[:email] = logged_models.first&.email
+ context[:id] = logged_models.first&.id
+
+ class_names = logged_models.map { |model| model.class.name }
+ context[:classes] = class_names.any? ? class_names.join(', ') : 'Guest'
+
+ Raven.user_context(context)
+ end
end
diff --git a/app/controllers/backoffice/avis_controller.rb b/app/controllers/backoffice/avis_controller.rb
index 4d77496d2..fc773fb40 100644
--- a/app/controllers/backoffice/avis_controller.rb
+++ b/app/controllers/backoffice/avis_controller.rb
@@ -1,5 +1,4 @@
class Backoffice::AvisController < ApplicationController
-
before_action :authenticate_gestionnaire!, except: [:sign_up, :create_gestionnaire]
before_action :redirect_if_no_sign_up_needed, only: [:sign_up]
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_gestionnaire]
@@ -50,7 +49,7 @@ class Backoffice::AvisController < ApplicationController
avis = Avis.find(params[:id])
redirect_to url_for(backoffice_dossier_path(avis.dossier_id))
else
- flash[:alert] = gestionnaire.errors.full_messages.join(' ')
+ flash[:alert] = gestionnaire.errors.full_messages
redirect_to url_for(avis_sign_up_path(params[:id], email))
end
end
diff --git a/app/controllers/backoffice/dossiers/procedure_controller.rb b/app/controllers/backoffice/dossiers/procedure_controller.rb
index 5f96c1508..00ccbb3b5 100644
--- a/app/controllers/backoffice/dossiers/procedure_controller.rb
+++ b/app/controllers/backoffice/dossiers/procedure_controller.rb
@@ -21,5 +21,4 @@ class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListContro
def retrieve_procedure
current_gestionnaire.procedures.find params[:id]
end
-
end
diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb
index 753b40302..0c153122d 100644
--- a/app/controllers/backoffice/dossiers_controller.rb
+++ b/app/controllers/backoffice/dossiers_controller.rb
@@ -1,4 +1,6 @@
class Backoffice::DossiersController < Backoffice::DossiersListController
+ include ActionView::Helpers::NumberHelper
+
respond_to :html, :xlsx, :ods, :csv
prepend_before_action :store_current_location, only: :show
@@ -79,17 +81,17 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
end
smart_listing_create :search,
- @dossiers,
- partial: "backoffice/dossiers/list",
- array: true,
- default_sort: dossiers_list_facade.service.default_sort
+ @dossiers,
+ partial: "backoffice/dossiers/list",
+ array: true,
+ default_sort: dossiers_list_facade.service.default_sort
rescue RuntimeError
smart_listing_create :search,
- [],
- partial: "backoffice/dossiers/list",
- array: true,
- default_sort: dossiers_list_facade.service.default_sort
+ [],
+ partial: "backoffice/dossiers/list",
+ array: true,
+ default_sort: dossiers_list_facade.service.default_sort
end
def receive
@@ -103,41 +105,44 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
redirect_to backoffice_dossier_path(id: dossier.id)
end
- def refuse
+ def process_dossier
create_dossier_facade params[:dossier_id]
+ if params[:dossier] && params[:dossier][:motivation].present?
+ motivation = params[:dossier][:motivation]
+ end
+
dossier = @facade.dossier
- dossier.next_step! 'gestionnaire', 'refuse'
- flash.notice = 'Dossier considéré comme refusé.'
+ case params[:process_action]
+ when "refuse"
+ next_step = "refuse"
+ notice = "Dossier considéré comme refusé."
+ template = dossier.procedure.refused_mail_template
+ when "without_continuation"
+ next_step = "without_continuation"
+ notice = "Dossier considéré comme sans suite."
+ template = dossier.procedure.without_continuation_mail_template
+ when "close"
+ next_step = "close"
+ notice = "Dossier traité avec succès."
+ template = dossier.procedure.closed_mail_template
+ end
- NotificationMailer.send_notification(dossier, dossier.procedure.refused_mail_template).deliver_now!
+ dossier.next_step! 'gestionnaire', next_step, motivation
- redirect_to backoffice_dossier_path(id: dossier.id)
- end
+ # needed to force Carrierwave to provide dossier.attestation.pdf.read
+ # when the Feature.remote_storage is true, otherwise pdf.read is a closed stream.
+ dossier.reload
- def without_continuation
- create_dossier_facade params[:dossier_id]
+ attestation_pdf = nil
+ if check_attestation_emailable(dossier)
+ attestation_pdf = dossier.attestation.pdf.read
+ end
- dossier = @facade.dossier
+ flash.notice = notice
- dossier.next_step! 'gestionnaire', 'without_continuation'
- flash.notice = 'Dossier considéré comme sans suite.'
-
- NotificationMailer.send_notification(dossier, dossier.procedure.without_continuation_mail_template).deliver_now!
-
- redirect_to backoffice_dossier_path(id: dossier.id)
- end
-
- def close
- create_dossier_facade params[:dossier_id]
-
- dossier = @facade.dossier
-
- dossier.next_step! 'gestionnaire', 'close'
- flash.notice = 'Dossier traité avec succès.'
-
- NotificationMailer.send_notification(dossier, dossier.procedure.closed_mail_template).deliver_now!
+ NotificationMailer.send_notification(dossier, template, attestation_pdf).deliver_now!
redirect_to backoffice_dossier_path(id: dossier.id)
end
@@ -172,7 +177,6 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
redirect_to backoffice_dossiers_path
end
-
def unarchive
@dossier = Dossier.find(params[:id])
if @dossier.archived
@@ -193,6 +197,16 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
private
+ def check_attestation_emailable(dossier)
+ if dossier&.attestation&.emailable? == false
+ human_size = number_to_human_size(dossier.attestation.pdf.size)
+ msg = "the attestation of the dossier #{dossier.id} cannot be mailed because it is too heavy: #{human_size}"
+ capture_message(msg, level: 'error')
+ end
+
+ dossier&.attestation&.emailable?
+ end
+
def store_current_location
if !gestionnaire_signed_in?
store_location_for(:gestionnaire, request.url)
diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb
index 52274bb79..be3294fab 100644
--- a/app/controllers/backoffice/dossiers_list_controller.rb
+++ b/app/controllers/backoffice/dossiers_list_controller.rb
@@ -31,7 +31,6 @@ class Backoffice::DossiersListController < ApplicationController
dossiers_list_facade liste
service = dossiers_list_facade.service
-
if param_page.nil?
params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page}
end
@@ -48,10 +47,10 @@ class Backoffice::DossiersListController < ApplicationController
def default_smart_listing_create name, collection
smart_listing_create name,
- collection,
- partial: 'backoffice/dossiers/list',
- array: true,
- default_sort: dossiers_list_facade.service.default_sort
+ collection,
+ partial: 'backoffice/dossiers/list',
+ array: true,
+ default_sort: dossiers_list_facade.service.default_sort
end
def param_smart_listing
diff --git a/app/controllers/backoffice/private_formulaires_controller.rb b/app/controllers/backoffice/private_formulaires_controller.rb
index 0353b02f3..edd45dbd2 100644
--- a/app/controllers/backoffice/private_formulaires_controller.rb
+++ b/app/controllers/backoffice/private_formulaires_controller.rb
@@ -11,7 +11,7 @@ class Backoffice::PrivateFormulairesController < ApplicationController
if champs_service_errors.empty?
flash[:notice] = "Formulaire enregistré"
else
- flash[:alert] = champs_service_errors.join(' ').html_safe
+ flash[:alert] = champs_service_errors
end
end
diff --git a/app/controllers/backoffice_controller.rb b/app/controllers/backoffice_controller.rb
index 5f426be36..3188124c6 100644
--- a/app/controllers/backoffice_controller.rb
+++ b/app/controllers/backoffice_controller.rb
@@ -15,14 +15,14 @@ class BackofficeController < ApplicationController
def invitations
pending_avis = current_gestionnaire.avis.without_answer.includes(dossier: [:procedure]).by_latest
@pending_avis = smart_listing_create :pending_avis,
- pending_avis,
- partial: 'backoffice/dossiers/list_invitations',
- array: true
+ pending_avis,
+ partial: 'backoffice/dossiers/list_invitations',
+ array: true
avis_with_answer = current_gestionnaire.avis.with_answer.includes(dossier: [:procedure]).by_latest
@avis_with_answer = smart_listing_create :avis_with_answer,
- avis_with_answer,
- partial: 'backoffice/dossiers/list_invitations',
- array: true
+ avis_with_answer,
+ partial: 'backoffice/dossiers/list_invitations',
+ array: true
end
end
diff --git a/app/controllers/cgu_controller.rb b/app/controllers/cgu_controller.rb
index 2c7b968d8..4d3f2e1ed 100644
--- a/app/controllers/cgu_controller.rb
+++ b/app/controllers/cgu_controller.rb
@@ -1,5 +1,4 @@
class CguController < ApplicationController
def index
-
end
end
diff --git a/app/controllers/commentaires_controller.rb b/app/controllers/commentaires_controller.rb
index b22ada7eb..7a4dcc8db 100644
--- a/app/controllers/commentaires_controller.rb
+++ b/app/controllers/commentaires_controller.rb
@@ -1,9 +1,9 @@
class CommentairesController < ApplicationController
def index
@facade = DossierFacades.new(
- params[:dossier_id],
- (current_gestionnaire || current_user).email,
- params[:champs_id]
+ params[:dossier_id],
+ (current_gestionnaire || current_user).email,
+ params[:champs_id]
)
render layout: false
rescue ActiveRecord::RecordNotFound
diff --git a/app/controllers/demo_controller.rb b/app/controllers/demo_controller.rb
index 5933c5735..54f45464d 100644
--- a/app/controllers/demo_controller.rb
+++ b/app/controllers/demo_controller.rb
@@ -6,8 +6,8 @@ class DemoController < ApplicationController
return redirect_to root_path if Rails.env.production?
smart_listing_create :procedures,
- Procedure.where(archived: false, published: true).order("id DESC"),
- partial: "demo/list",
- array: true
+ Procedure.where(archived: false, published: true).order("id DESC"),
+ partial: "demo/list",
+ array: true
end
end
diff --git a/app/controllers/gestionnaires/sessions_controller.rb b/app/controllers/gestionnaires/sessions_controller.rb
index c0f7d7b9b..326cf2200 100644
--- a/app/controllers/gestionnaires/sessions_controller.rb
+++ b/app/controllers/gestionnaires/sessions_controller.rb
@@ -1,4 +1,6 @@
class Gestionnaires::SessionsController < Sessions::SessionsController
+ layout "new_application"
+
def demo
return redirect_to root_path if Rails.env.production?
diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb
new file mode 100644
index 000000000..417e90ea8
--- /dev/null
+++ b/app/controllers/new_gestionnaire/dossiers_controller.rb
@@ -0,0 +1,13 @@
+module NewGestionnaire
+ class DossiersController < ProceduresController
+ def attestation
+ send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
+ end
+
+ private
+
+ def dossier
+ Dossier.find(params[:dossier_id])
+ end
+ end
+end
diff --git a/app/controllers/new_gestionnaire/gestionnaire_controller.rb b/app/controllers/new_gestionnaire/gestionnaire_controller.rb
new file mode 100644
index 000000000..76ef0b937
--- /dev/null
+++ b/app/controllers/new_gestionnaire/gestionnaire_controller.rb
@@ -0,0 +1,5 @@
+module NewGestionnaire
+ class GestionnaireController < ApplicationController
+ before_action :authenticate_gestionnaire!
+ end
+end
diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb
new file mode 100644
index 000000000..bfffad1fa
--- /dev/null
+++ b/app/controllers/new_gestionnaire/procedures_controller.rb
@@ -0,0 +1,18 @@
+module NewGestionnaire
+ class ProceduresController < GestionnaireController
+ before_action :ensure_ownership!
+
+ private
+
+ def procedure
+ Procedure.find(params[:procedure_id])
+ end
+
+ def ensure_ownership!
+ if !procedure.gestionnaires.include?(current_gestionnaire)
+ flash[:alert] = "Vous n'avez pas accès à cette procédure"
+ redirect_to root_path
+ end
+ end
+ end
+end
diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb
new file mode 100644
index 000000000..bc7df485d
--- /dev/null
+++ b/app/controllers/new_user/dossiers_controller.rb
@@ -0,0 +1,22 @@
+module NewUser
+ class DossiersController < UserController
+ before_action :ensure_ownership!
+
+ def attestation
+ send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
+ end
+
+ private
+
+ def dossier
+ Dossier.find(params[:dossier_id])
+ end
+
+ def ensure_ownership!
+ if dossier.user != current_user
+ flash[:alert] = "Vous n'avez pas accès à ce dossier"
+ redirect_to root_path
+ end
+ end
+ end
+end
diff --git a/app/controllers/new_user/user_controller.rb b/app/controllers/new_user/user_controller.rb
new file mode 100644
index 000000000..5cd85ae0f
--- /dev/null
+++ b/app/controllers/new_user/user_controller.rb
@@ -0,0 +1,5 @@
+module NewUser
+ class UserController < ApplicationController
+ before_action :authenticate_user!
+ end
+end
diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb
index 6736fc88c..b65437fa7 100644
--- a/app/controllers/root_controller.rb
+++ b/app/controllers/root_controller.rb
@@ -1,4 +1,6 @@
class RootController < ApplicationController
+ layout 'new_application'
+
def index
if administrateur_signed_in?
return redirect_to admin_procedures_path
@@ -26,6 +28,9 @@ class RootController < ApplicationController
return redirect_to administrations_path
end
- render 'landing', :layout => 'new_application'
+ render 'landing'
+ end
+
+ def patron
end
end
diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb
index eb96939c1..a4ac3cbb1 100644
--- a/app/controllers/stats_controller.rb
+++ b/app/controllers/stats_controller.rb
@@ -29,13 +29,20 @@ class StatsController < ApplicationController
@avis_usage = avis_usage
@avis_average_answer_time = avis_average_answer_time
@avis_answer_percentages = avis_answer_percentages
+
+ @motivation_usage_dossier = motivation_usage_dossier
+ @motivation_usage_procedure = motivation_usage_procedure
end
private
def last_four_months_hash(association, date_attribute = :created_at)
min_date = 3.months.ago.beginning_of_month.to_date
- max_date = Time.now.to_date
+ if administration_signed_in?
+ max_date = Time.now.to_date
+ else
+ max_date = Time.now.beginning_of_month - 1.second
+ end
association
.where(date_attribute => min_date..max_date)
@@ -61,7 +68,7 @@ class StatsController < ApplicationController
count_per_administrateur = procedures.group(:administrateur_id).count.values
{
'Une procédure' => count_per_administrateur.select { |count| count == 1 }.count,
- 'Entre deux et cinq procédures' => count_per_administrateur.select { |count| 2 <= count && count <= 5 }.count,
+ 'Entre deux et cinq procédures' => count_per_administrateur.select { |count| 2 <= count && count <= 5 }.count,
'Plus de cinq procédures' => count_per_administrateur.select { |count| 5 < count }.count
}
end
@@ -70,6 +77,10 @@ class StatsController < ApplicationController
(collection.sum.to_f / collection.size).round(2)
end
+ def percentage(numerator, denominator)
+ ((numerator.to_f / denominator) * 100).round(2)
+ end
+
def dossier_instruction_mean_time(dossiers)
# In the 12 last months, we compute for each month
# the average time it took to instruct a dossier
@@ -166,7 +177,7 @@ class StatsController < ApplicationController
result = 0
else
weekly_dossier_with_avis_count = weekly_dossiers.select { |dossier| dossier.avis.present? }.count
- result = ((weekly_dossier_with_avis_count.to_f / weekly_dossiers_count) * 100).round(2)
+ result = percentage(weekly_dossier_with_avis_count, weekly_dossiers_count)
end
[min_date.to_i, result]
@@ -199,10 +210,58 @@ class StatsController < ApplicationController
[min_date.to_i, 0]
else
answered_weekly_avis_count = weekly_avis.with_answer.count
- result = ((answered_weekly_avis_count.to_f / weekly_avis_count) * 100).round(2)
+ result = percentage(answered_weekly_avis_count, weekly_avis_count)
[min_date.to_i, result]
end
end
end
+
+ def motivation_usage_dossier
+ [3.week.ago, 2.week.ago, 1.week.ago].map do |date|
+ min_date = date.beginning_of_week
+ max_date = date.end_of_week
+
+ weekly_termine_dossiers = Dossier.where(processed_at: min_date..max_date)
+ weekly_termine_dossiers_count = weekly_termine_dossiers.count
+ weekly_termine_dossiers_with_motivation_count = weekly_termine_dossiers.where.not(motivation: nil).count
+
+ if weekly_termine_dossiers_count == 0
+ result = 0
+ else
+ result = percentage(weekly_termine_dossiers_with_motivation_count, weekly_termine_dossiers_count)
+ end
+
+ [l(max_date, format: '%d/%m/%Y'), result]
+ end
+ end
+
+ def motivation_usage_procedure
+ [3.week.ago, 2.week.ago, 1.week.ago].map do |date|
+ min_date = date.beginning_of_week
+ max_date = date.end_of_week
+
+ procedures_with_dossier_processed_this_week = Procedure
+ .joins(:dossiers)
+ .where(dossiers: { processed_at: min_date..max_date })
+
+ procedures_with_dossier_processed_this_week_count = procedures_with_dossier_processed_this_week
+ .uniq
+ .count
+
+ procedures_with_dossier_processed_this_week_and_with_motivation_count = procedures_with_dossier_processed_this_week
+ .where
+ .not(dossiers: { motivation: nil })
+ .uniq
+ .count
+
+ if procedures_with_dossier_processed_this_week_count == 0
+ result = 0
+ else
+ result = percentage(procedures_with_dossier_processed_this_week_and_with_motivation_count, procedures_with_dossier_processed_this_week_count)
+ end
+
+ [l(max_date, format: '%d/%m/%Y'), result]
+ end
+ end
end
diff --git a/app/controllers/users/dossiers/add_siret_controller.rb b/app/controllers/users/dossiers/add_siret_controller.rb
index 4190e304f..92ab6ee45 100644
--- a/app/controllers/users/dossiers/add_siret_controller.rb
+++ b/app/controllers/users/dossiers/add_siret_controller.rb
@@ -1,6 +1,6 @@
class Users::Dossiers::AddSiretController < ApplicationController
def show
- @facade = DossierFacades.new params[:dossier_id], current_user.email
+ @facade = DossierFacades.new params[:dossier_id], current_user.email
raise ActiveRecord::RecordNotFound unless @facade.procedure.individual_with_siret?
diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb
index 1d9964d72..8decc82ca 100644
--- a/app/controllers/users/dossiers_controller.rb
+++ b/app/controllers/users/dossiers_controller.rb
@@ -30,9 +30,9 @@ class Users::DossiersController < UsersController
end
@dossiers = smart_listing_create :dossiers,
- @dossiers_filtered,
- partial: "users/dossiers/list",
- array: true
+ @dossiers_filtered,
+ partial: "users/dossiers/list",
+ array: true
end
def commencer
diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
index fbb10dc8a..3de89b1cd 100644
--- a/app/controllers/users/registrations_controller.rb
+++ b/app/controllers/users/registrations_controller.rb
@@ -1,6 +1,8 @@
class Users::RegistrationsController < Devise::RegistrationsController
-# before_action :configure_sign_up_params, only: [:create]
-# before_action :configure_account_update_params, only: [:update]
+ layout "new_application"
+
+ # before_action :configure_sign_up_params, only: [:create]
+ # before_action :configure_account_update_params, only: [:update]
def after_sign_up_path_for(resource_or_scope)
WelcomeMailer.welcome_email(resource_or_scope).deliver_now!
diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb
index 2a990beaf..994240a97 100644
--- a/app/controllers/users/sessions_controller.rb
+++ b/app/controllers/users/sessions_controller.rb
@@ -1,5 +1,7 @@
class Users::SessionsController < Sessions::SessionsController
-# before_action :configure_sign_in_params, only: [:create]
+ layout "new_application"
+
+ # before_action :configure_sign_in_params, only: [:create]
def demo
return redirect_to root_path if Rails.env.production?
@@ -8,7 +10,7 @@ class Users::SessionsController < Sessions::SessionsController
render 'new'
end
-# GET /resource/sign_in
+ # GET /resource/sign_in
def new
unless user_return_to_procedure_id.nil? # WTF ?
@dossier = Dossier.new(procedure: Procedure.active(user_return_to_procedure_id))
@@ -19,7 +21,7 @@ class Users::SessionsController < Sessions::SessionsController
error_procedure
end
-#POST /resource/sign_in
+ #POST /resource/sign_in
def create
remember_me = params[:user][:remember_me] == '1'
try_to_authenticate(User, remember_me)
@@ -44,7 +46,7 @@ class Users::SessionsController < Sessions::SessionsController
end
end
-# DELETE /resource/sign_out
+ # DELETE /resource/sign_out
def destroy
sign_out :gestionnaire if gestionnaire_signed_in?
sign_out :administrateur if administrateur_signed_in?
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 67c94e85f..d2948b456 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -16,9 +16,9 @@ class UsersController < ApplicationController
end
def authorized_routes? controller
- redirect_to_root_path 'Le status de votre dossier n\'autorise pas cette URL' unless UserRoutesAuthorizationService.authorized_route?(
- controller,
- current_user_dossier)
+ redirect_to_root_path 'Le statut de votre dossier n\'autorise pas cette URL' unless UserRoutesAuthorizationService.authorized_route?(
+ controller,
+ current_user_dossier)
rescue ActiveRecord::RecordNotFound
redirect_to_root_path 'Vous n’avez pas accès à ce dossier.'
end
diff --git a/app/decorators/dossiers_decorator.rb b/app/decorators/dossiers_decorator.rb
index 6e8571b6f..159bb6aa9 100644
--- a/app/decorators/dossiers_decorator.rb
+++ b/app/decorators/dossiers_decorator.rb
@@ -1,4 +1,3 @@
class DossiersDecorator < Draper::CollectionDecorator
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
-
end
diff --git a/app/decorators/etablissement_decorator.rb b/app/decorators/etablissement_decorator.rb
index 23f809c79..b6e03db6a 100644
--- a/app/decorators/etablissement_decorator.rb
+++ b/app/decorators/etablissement_decorator.rb
@@ -1,4 +1,3 @@
class EtablissementDecorator < Draper::Decorator
delegate_all
-
end
diff --git a/app/decorators/procedure_decorator.rb b/app/decorators/procedure_decorator.rb
index 561e6754b..50f64c2ab 100644
--- a/app/decorators/procedure_decorator.rb
+++ b/app/decorators/procedure_decorator.rb
@@ -1,5 +1,4 @@
class ProcedureDecorator < Draper::Decorator
-
delegate_all
def lien
diff --git a/app/decorators/procedures_decorator.rb b/app/decorators/procedures_decorator.rb
index 380965078..7059df10d 100644
--- a/app/decorators/procedures_decorator.rb
+++ b/app/decorators/procedures_decorator.rb
@@ -1,4 +1,3 @@
class ProceduresDecorator < Draper::CollectionDecorator
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
-
end
diff --git a/app/decorators/type_de_champ_decorator.rb b/app/decorators/type_de_champ_decorator.rb
index d54293195..32cbbbdd6 100644
--- a/app/decorators/type_de_champ_decorator.rb
+++ b/app/decorators/type_de_champ_decorator.rb
@@ -1,5 +1,4 @@
class TypeDeChampDecorator < Draper::Decorator
-
delegate_all
def button_up params
diff --git a/app/decorators/type_de_champ_private_decorator.rb b/app/decorators/type_de_champ_private_decorator.rb
index 31d4d3299..ea9f715a2 100644
--- a/app/decorators/type_de_champ_private_decorator.rb
+++ b/app/decorators/type_de_champ_private_decorator.rb
@@ -1,3 +1,2 @@
class TypeDeChampPrivateDecorator < TypeDeChampDecorator
-
end
diff --git a/app/facades/dossier_facades.rb b/app/facades/dossier_facades.rb
index 6d707f7fc..dfb7f73ab 100644
--- a/app/facades/dossier_facades.rb
+++ b/app/facades/dossier_facades.rb
@@ -1,5 +1,4 @@
class DossierFacades
-
#TODO rechercher en fonction de la personne/email
def initialize(dossier_id, email, champ_id = nil)
@dossier = Dossier.find(dossier_id)
diff --git a/app/facades/dossiers_list_facades.rb b/app/facades/dossiers_list_facades.rb
index 0a05a4148..ac9cc952c 100644
--- a/app/facades/dossiers_list_facades.rb
+++ b/app/facades/dossiers_list_facades.rb
@@ -80,5 +80,4 @@ class DossiersListFacades
def base_url liste
@procedure.nil? ? backoffice_dossiers_path(liste: liste) : backoffice_dossiers_procedure_path(id: @procedure.id, liste: liste)
end
-
end
diff --git a/app/facades/invite_dossier_facades.rb b/app/facades/invite_dossier_facades.rb
index ce52f0b3c..6aaad2450 100644
--- a/app/facades/invite_dossier_facades.rb
+++ b/app/facades/invite_dossier_facades.rb
@@ -1,5 +1,4 @@
class InviteDossierFacades < DossierFacades
-
#TODO rechercher en fonction de la personne/email
def initialize id, email
@dossier = Invite.where(email: email, id: id).first!.dossier
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
new file mode 100644
index 000000000..f5572c1d9
--- /dev/null
+++ b/app/helpers/application_helper.rb
@@ -0,0 +1,14 @@
+module ApplicationHelper
+ def flash_class(level)
+ case level
+ when "notice" then "alert-success"
+ when "alert" then "alert-danger"
+ end
+ end
+
+ def current_email
+ current_user.try(:email) ||
+ current_gestionnaire.try(:email) ||
+ current_administrateur.try(:email)
+ end
+end
diff --git a/app/helpers/devise_helper.rb b/app/helpers/devise_helper.rb
new file mode 100644
index 000000000..14afe134f
--- /dev/null
+++ b/app/helpers/devise_helper.rb
@@ -0,0 +1,8 @@
+module DeviseHelper
+ def devise_error_messages!
+ if resource.errors.full_messages.any?
+ flash.now[:alert] = resource.errors.full_messages
+ end
+ ''
+ end
+end
diff --git a/app/lib/carto/geo_api/driver.rb b/app/lib/carto/geo_api/driver.rb
index 01825be40..d37e17e87 100644
--- a/app/lib/carto/geo_api/driver.rb
+++ b/app/lib/carto/geo_api/driver.rb
@@ -1,7 +1,6 @@
module Carto
module GeoAPI
class Driver
-
def self.regions
call regions_url
end
@@ -29,7 +28,6 @@ module Carto
rescue RestClient::ServiceUnavailable
nil
end
-
end
end
end
diff --git a/app/lib/carto/sgmap/api.rb b/app/lib/carto/sgmap/api.rb
index db29d7d0b..ef72fc062 100644
--- a/app/lib/carto/sgmap/api.rb
+++ b/app/lib/carto/sgmap/api.rb
@@ -18,8 +18,8 @@ class CARTO::SGMAP::API
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
RestClient::Resource.new(
- url,
- verify_ssl: verify_ssl_mode,
+ url,
+ verify_ssl: verify_ssl_mode,
).post params[:geojson], content_type: 'application/json'
rescue RestClient::InternalServerError
diff --git a/app/lib/siade/rna_adapter.rb b/app/lib/siade/rna_adapter.rb
index 85893eff8..80580c336 100644
--- a/app/lib/siade/rna_adapter.rb
+++ b/app/lib/siade/rna_adapter.rb
@@ -12,7 +12,6 @@ class SIADE::RNAAdapter
data_source[:association].each do |k, v|
params[k] = v if attr_to_fetch.include?(k)
-
end
params[:association_id] = params[:id]
diff --git a/app/mailers/avis_mailer.rb b/app/mailers/avis_mailer.rb
index cf435cefc..c84d6a74e 100644
--- a/app/mailers/avis_mailer.rb
+++ b/app/mailers/avis_mailer.rb
@@ -1,9 +1,7 @@
class AvisMailer < ApplicationMailer
-
def avis_invitation(avis)
@avis = avis
email = @avis.gestionnaire.try(:email) || @avis.email
mail(to: email, subject: "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})")
end
-
end
diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb
index 118537a8d..ac8124191 100644
--- a/app/mailers/gestionnaire_mailer.rb
+++ b/app/mailers/gestionnaire_mailer.rb
@@ -1,16 +1,13 @@
class GestionnaireMailer < ApplicationMailer
+ layout 'mailers/layout'
def new_gestionnaire email, password
send_mail email, password, "Vous avez été nommé accompagnateur sur la plateforme TPS"
end
- def new_assignement email, email_admin
- send_mail email, email_admin, "Vous avez été assigné à un nouvel administrateur sur la plateforme TPS"
- end
-
def last_week_overview(gestionnaire, overview)
headers['X-mailjet-campaign'] = 'last_week_overview'
- send_mail gestionnaire.email, overview, 'Résumé de la semaine'
+ send_mail gestionnaire.email, overview, 'Vos activités sur TPS'
end
private
diff --git a/app/mailers/invite_mailer.rb b/app/mailers/invite_mailer.rb
index 09b58f229..a7d6e4d8d 100644
--- a/app/mailers/invite_mailer.rb
+++ b/app/mailers/invite_mailer.rb
@@ -1,5 +1,4 @@
class InviteMailer < ApplicationMailer
-
def invite_user invite
vars_mailer invite
diff --git a/app/mailers/new_admin_mailer.rb b/app/mailers/new_admin_mailer.rb
index 4527451a0..71ea69b4f 100644
--- a/app/mailers/new_admin_mailer.rb
+++ b/app/mailers/new_admin_mailer.rb
@@ -1,8 +1,6 @@
class NewAdminMailer < ApplicationMailer
- def new_admin_email admin, password
-
+ def new_admin_email admin
@admin = admin
- @password = password
mail(to: 'tech@tps.apientreprise.fr',
subject: "Création d'un compte Admin TPS")
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index 6c7d4b91c..6c75975df 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -3,12 +3,16 @@ class NotificationMailer < ApplicationMailer
after_action :create_commentaire_for_notification, only: :send_notification
- def send_notification(dossier, mail_template)
+ def send_notification(dossier, mail_template, attestation = nil)
vars_mailer(dossier)
@object = mail_template.object_for_dossier dossier
@body = mail_template.body_for_dossier dossier
+ if attestation.present?
+ attachments['attestation.pdf'] = attestation
+ end
+
mail(subject: @object) { |format| format.html { @body } }
end
diff --git a/app/mailers/welcome_mailer.rb b/app/mailers/welcome_mailer.rb
index 4306ee974..789b494b6 100644
--- a/app/mailers/welcome_mailer.rb
+++ b/app/mailers/welcome_mailer.rb
@@ -1,6 +1,5 @@
class WelcomeMailer < ApplicationMailer
def welcome_email user
-
@user = user
mail(to: user.email,
diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb
index 731e5df5c..072fd8c9d 100644
--- a/app/models/administrateur.rb
+++ b/app/models/administrateur.rb
@@ -1,6 +1,6 @@
class Administrateur < ActiveRecord::Base
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
+ :recoverable, :rememberable, :trackable, :validatable
has_and_belongs_to_many :gestionnaires
has_many :procedures
diff --git a/app/models/attestation.rb b/app/models/attestation.rb
new file mode 100644
index 000000000..220e2c364
--- /dev/null
+++ b/app/models/attestation.rb
@@ -0,0 +1,11 @@
+class Attestation < ApplicationRecord
+ belongs_to :dossier
+
+ mount_uploader :pdf, AttestationUploader
+
+ MAX_SIZE_EMAILABLE = 2.megabytes
+
+ def emailable?
+ pdf.size <= MAX_SIZE_EMAILABLE
+ end
+end
diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb
new file mode 100644
index 000000000..3e84c0108
--- /dev/null
+++ b/app/models/attestation_template.rb
@@ -0,0 +1,145 @@
+class AttestationTemplate < ApplicationRecord
+ include ActionView::Helpers::NumberHelper
+
+ belongs_to :procedure
+
+ mount_uploader :logo, AttestationTemplateImageUploader
+ mount_uploader :signature, AttestationTemplateImageUploader
+
+ validate :logo_signature_file_size
+ validates :footer, length: { maximum: 190 }
+
+ FILE_MAX_SIZE_IN_MB = 0.5
+
+ def tags
+ if procedure.for_individual?
+ identity_tags = individual_tags
+ else
+ identity_tags = entreprise_tags + etablissement_tags
+ end
+
+ identity_tags + dossier_tags + procedure_type_de_champ_public_private_tags
+ end
+
+ def attestation_for(dossier)
+ Attestation.new(title: replace_tags(title, dossier), pdf: build_pdf(dossier))
+ end
+
+ def dup
+ result = AttestationTemplate.new(title: title, body: body, footer: footer, activated: activated)
+
+ if logo.present?
+ CopyCarrierwaveFile::CopyFileService.new(self, result, :logo).set_file
+ end
+
+ if signature.present?
+ CopyCarrierwaveFile::CopyFileService.new(self, result, :signature).set_file
+ end
+
+ result
+ end
+
+ private
+
+ def logo_signature_file_size
+ %i[logo signature]
+ .select { |file_name| send(file_name).present? }
+ .each { |file_name| file_size_check(file_name) }
+ end
+
+ def file_size_check(file_name)
+ if send(file_name).file.size.to_f > FILE_MAX_SIZE_IN_MB.megabyte.to_f
+ errors.add(file_name, " : vous ne pouvez pas charger une image de plus de #{number_with_delimiter(FILE_MAX_SIZE_IN_MB, locale: :fr)} Mo")
+ end
+ end
+
+ def procedure_type_de_champ_public_private_tags
+ (procedure.types_de_champ + procedure.types_de_champ_private)
+ .map { |tdc| { libelle: tdc.libelle, description: tdc.description } }
+ end
+
+ def dossier_tags
+ [{ libelle: 'motivation', description: '', target: 'motivation' },
+ { libelle: 'numéro du dossier', description: '', target: 'id' }]
+ end
+
+ def individual_tags
+ [{ libelle: 'civilité', description: 'M., Mme', target: 'gender' },
+ { libelle: 'nom', description: "nom de l'usager", target: 'nom' },
+ { libelle: 'prénom', description: "prénom de l'usager", target: 'prenom' }]
+ end
+
+ def entreprise_tags
+ [{ libelle: 'SIREN', description: '', target: 'siren' },
+ { libelle: 'numéro de TVA intracommunautaire', description: '', target: 'numero_tva_intracommunautaire' },
+ { libelle: 'SIRET du siège social', description: '', target: 'siret_siege_social' },
+ { libelle: 'raison sociale', description: '', target: 'raison_sociale' }]
+ end
+
+ def etablissement_tags
+ [{ libelle: 'adresse', description: '', target: 'inline_adresse' }]
+ end
+
+ def build_pdf(dossier)
+ action_view = ActionView::Base.new(ActionController::Base.view_paths,
+ logo: logo,
+ title: replace_tags(title, dossier),
+ body: replace_tags(body, dossier),
+ signature: signature,
+ footer: footer,
+ created_at: Time.now)
+
+ attestation_view = action_view.render(file: 'admin/attestation_templates/show',
+ formats: [:pdf])
+
+ view_to_memory_file(attestation_view)
+ end
+
+ def view_to_memory_file(view)
+ pdf = StringIO.new(view)
+
+ def pdf.original_filename
+ 'attestation'
+ end
+
+ pdf
+ end
+
+ def replace_tags(text, dossier)
+ if text.nil?
+ return ''
+ end
+
+ text = replace_type_de_champ_tags(text, procedure.types_de_champ, dossier.champs)
+ text = replace_type_de_champ_tags(text, procedure.types_de_champ_private, dossier.champs_private)
+
+ tags_and_datas = [
+ [dossier_tags, dossier],
+ [individual_tags, dossier.individual],
+ [entreprise_tags, dossier.entreprise],
+ [etablissement_tags, dossier.entreprise&.etablissement]]
+
+ tags_and_datas.inject(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) }
+ end
+
+ def replace_type_de_champ_tags(text, types_de_champ, dossier_champs)
+ types_de_champ.inject(text) do |acc, tag|
+ value = dossier_champs
+ .select { |champ| champ.libelle == tag[:libelle] }
+ .first
+ .value
+
+ acc.gsub("--#{tag[:libelle]}--", value.to_s)
+ end
+ end
+
+ def replace_tags_with_values_from_data(text, tags, data)
+ if data.present?
+ tags.inject(text) do |acc, tag|
+ acc.gsub("--#{tag[:libelle]}--", data.send(tag[:target].to_sym).to_s)
+ end
+ else
+ text
+ end
+ end
+end
diff --git a/app/models/champ_private.rb b/app/models/champ_private.rb
index 6f7068148..118e58415 100644
--- a/app/models/champ_private.rb
+++ b/app/models/champ_private.rb
@@ -1,3 +1,2 @@
class ChampPrivate < Champ
-
end
diff --git a/app/models/champ_public.rb b/app/models/champ_public.rb
index 7b0efcb3d..c922614ae 100644
--- a/app/models/champ_public.rb
+++ b/app/models/champ_public.rb
@@ -1,3 +1,2 @@
class ChampPublic < Champ
-
end
diff --git a/app/models/concerns/credentials_syncable_concern.rb b/app/models/concerns/credentials_syncable_concern.rb
index f1ee62df8..f5bf6ae92 100644
--- a/app/models/concerns/credentials_syncable_concern.rb
+++ b/app/models/concerns/credentials_syncable_concern.rb
@@ -15,5 +15,4 @@ module CredentialsSyncableConcern
def force_sync_credentials
SyncCredentialsService.new(self.class, email_was, email, encrypted_password).change_credentials!
end
-
end
diff --git a/app/models/concerns/mail_template_concern.rb b/app/models/concerns/mail_template_concern.rb
index 25c87d133..cd44676f5 100644
--- a/app/models/concerns/mail_template_concern.rb
+++ b/app/models/concerns/mail_template_concern.rb
@@ -21,6 +21,10 @@ module MailTemplateConcern
name: "date_de_decision",
description: "Permet d'afficher la date à laquelle la décision finale (acceptation, refus, classement sans suite) sur le dossier a été prise."
}
+ TAGS << TAG_MOTIVATION = {
+ name: "motivation",
+ description: "Permet d'afficher la motivation associée à la décision finale (acceptation, refus, classement sans suite) sur le dossier. Attention, elle est facultative."
+ }
def object_for_dossier(dossier)
replace_tags(object, dossier)
@@ -55,6 +59,8 @@ module MailTemplateConcern
dossier.procedure.libelle
when TAG_DATE_DE_DECISION
dossier.processed_at.present? ? dossier.processed_at.localtime.strftime("%d/%m/%Y") : ""
+ when TAG_MOTIVATION
+ dossier.motivation || ""
else
'--BALISE_NON_RECONNUE--'
end
diff --git a/app/models/dossier.rb b/app/models/dossier.rb
index 8203618ed..a430dbf23 100644
--- a/app/models/dossier.rb
+++ b/app/models/dossier.rb
@@ -23,6 +23,7 @@ class Dossier < ActiveRecord::Base
has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy
has_one :individual, dependent: :destroy
+ has_one :attestation
has_many :cerfa, dependent: :destroy
has_many :pieces_justificatives, dependent: :destroy
@@ -41,6 +42,7 @@ class Dossier < ActiveRecord::Base
belongs_to :procedure
belongs_to :user
+ default_scope { where(hidden_at: nil) }
scope :state_brouillon, -> { where(state: BROUILLON) }
scope :state_not_brouillon, -> { where.not(state: BROUILLON) }
scope :state_nouveaux, -> { where(state: NOUVEAUX) }
@@ -130,7 +132,7 @@ class Dossier < ActiveRecord::Base
commentaires.order(created_at: :desc)
end
- def next_step! role, action
+ def next_step! role, action, motivation = nil
unless %w(initiate follow update comment receive refuse without_continuation close).include?(action)
fail 'action is not valid'
end
@@ -169,15 +171,33 @@ class Dossier < ActiveRecord::Base
end
when 'close'
if received?
+ self.attestation = build_attestation
+ save
+
closed!
+
+ if motivation
+ self.motivation = motivation
+ save
+ end
end
when 'refuse'
if received?
refused!
+
+ if motivation
+ self.motivation = motivation
+ save
+ end
end
when 'without_continuation'
if received?
without_continuation!
+
+ if motivation
+ self.motivation = motivation
+ save
+ end
end
end
end
@@ -223,6 +243,7 @@ class Dossier < ActiveRecord::Base
serialized_dossier = DossierTableExportSerializer.new(self)
data = serialized_dossier.attributes.values
data += self.champs.order('type_de_champ_id ASC').map(&:value)
+ data += self.champs_private.order('type_de_champ_id ASC').map(&:value)
data += self.export_entreprise_data.values
return data
end
@@ -231,6 +252,7 @@ class Dossier < ActiveRecord::Base
serialized_dossier = DossierTableExportSerializer.new(self)
headers = serialized_dossier.attributes.keys
headers += self.procedure.types_de_champ.order('id ASC').map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
+ headers += self.procedure.types_de_champ_private.order('id ASC').map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
headers += self.export_entreprise_data.keys
return headers
end
@@ -290,6 +312,12 @@ class Dossier < ActiveRecord::Base
private
+ def build_attestation
+ if procedure.attestation_template.present? && procedure.attestation_template.activated?
+ procedure.attestation_template.attestation_for(self)
+ end
+ end
+
def update_state_dates
if initiated? && !self.initiated_at
self.initiated_at = DateTime.now
diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb
index 44e840205..5e480ae85 100644
--- a/app/models/etablissement.rb
+++ b/app/models/etablissement.rb
@@ -9,4 +9,9 @@ class Etablissement < ActiveRecord::Base
def geo_adresse
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
end
+
+ def inline_adresse
+ #squeeze needed because of space in excess in the data
+ "#{numero_voie} #{type_voie} #{nom_voie}, #{complement_adresse}, #{code_postal} #{localite}".squeeze(' ')
+ end
end
diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb
index 6492cca64..30185d0a2 100644
--- a/app/models/gestionnaire.rb
+++ b/app/models/gestionnaire.rb
@@ -1,6 +1,6 @@
class Gestionnaire < ActiveRecord::Base
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
+ :recoverable, :rememberable, :trackable, :validatable
has_and_belongs_to_many :administrateurs
@@ -20,9 +20,13 @@ class Gestionnaire < ActiveRecord::Base
include CredentialsSyncableConcern
def procedure_filter
- return nil unless assign_to.pluck(:procedure_id).include?(self[:procedure_filter])
-
- self[:procedure_filter]
+ procedure_id = self[:procedure_filter]
+ if procedures.find_by(id: procedure_id).present?
+ procedure_id
+ else
+ self.update_column(:procedure_filter, nil)
+ nil
+ end
end
def can_view_dossier?(dossier_id)
@@ -52,10 +56,8 @@ class Gestionnaire < ActiveRecord::Base
end
def build_default_preferences_list_dossier procedure_id=nil
-
PreferenceListDossier.available_columns_for(procedure_id).each do |table|
table.second.each do |column|
-
if valid_couple_table_attr? table.first, column.first
PreferenceListDossier.create(
libelle: column.second[:libelle],
@@ -108,16 +110,15 @@ class Gestionnaire < ActiveRecord::Base
active_procedure_overviews = procedures
.where(published: true)
.all
- .map { |procedure| procedure.procedure_overview(start_date, dossiers_with_notifications_count_for_procedure(procedure)) }
+ .map { |procedure| procedure.procedure_overview(start_date) }
.select(&:had_some_activities?)
- if active_procedure_overviews.count == 0 && notifications.count == 0
+ if active_procedure_overviews.count == 0
nil
else
{
start_date: start_date,
procedure_overviews: active_procedure_overviews,
- notifications: notifications
}
end
end
diff --git a/app/models/invite.rb b/app/models/invite.rb
index de2e45fca..dde8b2c6f 100644
--- a/app/models/invite.rb
+++ b/app/models/invite.rb
@@ -1,5 +1,4 @@
class Invite < ActiveRecord::Base
-
belongs_to :dossier
belongs_to :user
diff --git a/app/models/invite_gestionnaire.rb b/app/models/invite_gestionnaire.rb
index 6021286da..fabc49f36 100644
--- a/app/models/invite_gestionnaire.rb
+++ b/app/models/invite_gestionnaire.rb
@@ -1,3 +1,2 @@
class InviteGestionnaire < Invite
-
end
diff --git a/app/models/invite_user.rb b/app/models/invite_user.rb
index 05ec141e9..c599c2f23 100644
--- a/app/models/invite_user.rb
+++ b/app/models/invite_user.rb
@@ -1,3 +1,2 @@
class InviteUser < Invite
-
end
diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb
index 80f706bf9..cef3a274f 100644
--- a/app/models/mails/closed_mail.rb
+++ b/app/models/mails/closed_mail.rb
@@ -6,6 +6,6 @@ module Mails
TEMPLATE_NAME = "mails/closed_mail"
DISPLAYED_NAME = "Accusé d'acceptation"
DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été accepté'
- ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE, TAG_DATE_DE_DECISION]
+ ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE, TAG_DATE_DE_DECISION, TAG_MOTIVATION]
end
end
diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb
index 9d8edc903..7ffa4082e 100644
--- a/app/models/mails/initiated_mail.rb
+++ b/app/models/mails/initiated_mail.rb
@@ -5,7 +5,7 @@ module Mails
SLUG = "initiated_mail"
TEMPLATE_NAME = "mails/initiated_mail"
DISPLAYED_NAME = 'Accusé de réception'
- DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été bien reçu'
+ DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a bien été reçu'
ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE]
end
end
diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb
index f9b859e74..8d0b9d032 100644
--- a/app/models/mails/refused_mail.rb
+++ b/app/models/mails/refused_mail.rb
@@ -6,6 +6,6 @@ module Mails
TEMPLATE_NAME = "mails/refused_mail"
DISPLAYED_NAME = 'Accusé de rejet du dossier'
DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été refusé'
- ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE, TAG_DATE_DE_DECISION]
+ ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE, TAG_DATE_DE_DECISION, TAG_MOTIVATION]
end
end
diff --git a/app/models/mails/without_continuation_mail.rb b/app/models/mails/without_continuation_mail.rb
index 0115037c3..7e615ca75 100644
--- a/app/models/mails/without_continuation_mail.rb
+++ b/app/models/mails/without_continuation_mail.rb
@@ -6,6 +6,6 @@ module Mails
TEMPLATE_NAME = "mails/without_continuation_mail"
DISPLAYED_NAME = 'Accusé de classement sans suite'
DEFAULT_OBJECT = 'Votre dossier TPS nº --numero_dossier-- a été classé sans suite'
- ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE, TAG_DATE_DE_DECISION]
+ ALLOWED_TAGS = [TAG_NUMERO_DOSSIER, TAG_LIEN_DOSSIER, TAG_LIBELLE_PROCEDURE, TAG_DATE_DE_DECISION, TAG_MOTIVATION]
end
end
diff --git a/app/models/piece_justificative.rb b/app/models/piece_justificative.rb
index c9537adf0..6b08703b4 100644
--- a/app/models/piece_justificative.rb
+++ b/app/models/piece_justificative.rb
@@ -33,7 +33,7 @@ class PieceJustificative < ActiveRecord::Base
(RemoteDownloader.new content.filename).url
else
(LocalDownloader.new content.path,
- (type_de_piece_justificative.nil? ? content.original_filename : type_de_piece_justificative.libelle)).url
+ (type_de_piece_justificative.nil? ? content.original_filename : type_de_piece_justificative.libelle)).url
end
end
end
diff --git a/app/models/procedure.rb b/app/models/procedure.rb
index c46b2d6da..83e88b823 100644
--- a/app/models/procedure.rb
+++ b/app/models/procedure.rb
@@ -7,6 +7,7 @@ class Procedure < ActiveRecord::Base
has_one :procedure_path, dependent: :destroy
has_one :module_api_carto, dependent: :destroy
+ has_one :attestation_template, dependent: :destroy
belongs_to :administrateur
@@ -30,12 +31,19 @@ class Procedure < ActiveRecord::Base
mount_uploader :logo, ProcedureLogoUploader
+ default_scope { where(hidden_at: nil) }
scope :not_archived, -> { where(archived: false) }
scope :by_libelle, -> { order(libelle: :asc) }
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, presence: true, allow_blank: false, allow_nil: false
+ def hide!
+ now = DateTime.now
+ self.update_attributes(hidden_at: now)
+ self.dossiers.update_all(hidden_at: now)
+ end
+
def path
procedure_path.path unless procedure_path.nil?
end
@@ -88,12 +96,13 @@ class Procedure < ActiveRecord::Base
def clone
procedure = self.deep_clone(include:
- [:types_de_piece_justificative,
- :types_de_champ,
- :types_de_champ_private,
- :module_api_carto,
- types_de_champ: [:drop_down_list]
- ])
+ {
+ types_de_piece_justificative: nil,
+ module_api_carto: nil,
+ attestation_template: nil,
+ types_de_champ: :drop_down_list,
+ types_de_champ_private: :drop_down_list
+ })
procedure.archived = false
procedure.published = false
procedure.logo_secure_token = nil
@@ -109,12 +118,12 @@ class Procedure < ActiveRecord::Base
end
def publish!(path)
- self.update_attributes!({published: true, archived: false})
+ self.update_attributes!({ published: true, archived: false, published_at: Time.now })
ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
end
def archive
- self.update_attributes!({archived: true})
+ self.update_attributes!(archived: true, archived_at: Time.now)
end
def total_dossier
@@ -133,8 +142,8 @@ class Procedure < ActiveRecord::Base
}
end
- def procedure_overview(start_date, notifications_count)
- ProcedureOverview.new(self, start_date, notifications_count)
+ def procedure_overview(start_date)
+ ProcedureOverview.new(self, start_date)
end
def initiated_mail_template
diff --git a/app/models/procedure_overview.rb b/app/models/procedure_overview.rb
index 464001cf2..c614bf4a3 100644
--- a/app/models/procedure_overview.rb
+++ b/app/models/procedure_overview.rb
@@ -1,82 +1,72 @@
class ProcedureOverview
- include Rails.application.routes.url_helpers
- attr_accessor :libelle, :notifications_count, :received_dossiers_count, :created_dossiers_count, :processed_dossiers_count, :date
+ attr_accessor :procedure,
+ :created_dossiers_count,
+ :dossiers_en_instruction_count,
+ :old_dossiers_en_instruction,
+ :dossiers_en_construction_count,
+ :old_dossiers_en_construction
- def initialize(procedure, start_date, notifications_count)
- @libelle = procedure.libelle
- @procedure_url = backoffice_dossiers_procedure_url(procedure)
- @notifications_count = notifications_count
+ def initialize(procedure, start_date)
+ @start_date = start_date
+ @procedure = procedure
- @received_dossiers_count = procedure.dossiers.where(state: :received).count
- @created_dossiers_count = procedure.dossiers
+ @dossiers_en_instruction_count = procedure.dossiers.state_en_instruction.count
+ @old_dossiers_en_instruction = procedure
+ .dossiers
+ .state_en_instruction
+ .where('received_at < ?', 1.week.ago)
+
+ @dossiers_en_construction_count = procedure.dossiers.state_en_construction.count
+ @old_dossiers_en_construction = procedure
+ .dossiers
+ .state_en_construction
+ .where('initiated_at < ?', 1.week.ago)
+
+ @created_dossiers_count = procedure
+ .dossiers
.where(created_at: start_date..DateTime.now)
- .where.not(state: :draft)
+ .state_not_brouillon
.count
- @processed_dossiers_count = procedure.dossiers.where(processed_at: start_date..DateTime.now).count
end
def had_some_activities?
- [received_dossiers_count,
- created_dossiers_count,
- processed_dossiers_count,
- notifications_count].reduce(:+) > 0
+ [@dossiers_en_instruction_count,
+ @dossiers_en_construction_count,
+ @created_dossiers_count].reduce(:+) > 0
end
- def to_html
- [libelle_description,
- dossiers_en_instruction_description,
- created_dossier_description,
- processed_dossier_description,
- notifications_description].compact.join(' ')
- end
-
- private
-
- def libelle_description
- "#{libelle} "
- end
-
- def dossiers_en_instruction_description
- case received_dossiers_count
+ def dossiers_en_construction_description
+ case @dossiers_en_construction_count
when 0
nil
when 1
- "1 dossier est en cours d'instruction"
+ 'dossier suivi en construction'
else
- "#{received_dossiers_count} dossiers sont en cours d'instruction"
+ 'dossiers suivis en construction'
+ end
+ end
+
+ def dossiers_en_instruction_description
+ case @dossiers_en_instruction_count
+ when 0
+ nil
+ when 1
+ "dossier est en cours d'instruction"
+ else
+ "dossiers sont en cours d'instruction"
end
end
def created_dossier_description
- case created_dossiers_count
- when 0
- nil
- when 1
- '1 nouveau dossier a été déposé'
- else
- "#{created_dossiers_count} nouveaux dossiers ont été déposés"
- end
- end
+ formated_date = I18n.l(@start_date, format: '%d %B %Y')
- def processed_dossier_description
- case processed_dossiers_count
+ case @created_dossiers_count
when 0
nil
when 1
- '1 dossier a été instruit'
+ "nouveau dossier a été déposé depuis le #{formated_date}"
else
- "#{processed_dossiers_count} dossiers ont été instruits"
- end
- end
-
- def notifications_description
- case notifications_count
- when 0
- nil
- when 1
- '1 notification en attente sur les dossiers que vous suivez'
- else
- "#{notifications_count} notifications en attente sur les dossiers que vous suivez"
+ "nouveaux dossiers ont été déposés depuis le #{formated_date}"
end
end
end
diff --git a/app/models/type_de_champ_private.rb b/app/models/type_de_champ_private.rb
index 1b4e7ed3f..ba6e89a82 100644
--- a/app/models/type_de_champ_private.rb
+++ b/app/models/type_de_champ_private.rb
@@ -1,3 +1,2 @@
class TypeDeChampPrivate < TypeDeChamp
-
end
diff --git a/app/models/type_de_champ_public.rb b/app/models/type_de_champ_public.rb
index 8e9fb760d..3be990e13 100644
--- a/app/models/type_de_champ_public.rb
+++ b/app/models/type_de_champ_public.rb
@@ -1,3 +1,2 @@
class TypeDeChampPublic < TypeDeChamp
-
end
diff --git a/app/models/user.rb b/app/models/user.rb
index c4dab2a5f..3189c652d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -7,7 +7,7 @@ class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
+ :recoverable, :rememberable, :trackable, :validatable
has_many :dossiers, dependent: :destroy
has_many :invites, dependent: :destroy
diff --git a/app/serializers/cerfa_serializer.rb b/app/serializers/cerfa_serializer.rb
index a5b832936..1971db96a 100644
--- a/app/serializers/cerfa_serializer.rb
+++ b/app/serializers/cerfa_serializer.rb
@@ -1,6 +1,6 @@
class CerfaSerializer < ActiveModel::Serializer
attributes :created_at,
- :content_url
+ :content_url
has_one :user
end
diff --git a/app/serializers/commentaire_serializer.rb b/app/serializers/commentaire_serializer.rb
index 587cde833..c7366b65b 100644
--- a/app/serializers/commentaire_serializer.rb
+++ b/app/serializers/commentaire_serializer.rb
@@ -1,5 +1,5 @@
class CommentaireSerializer < ActiveModel::Serializer
attributes :email,
- :body,
- :created_at
+ :body,
+ :created_at
end
diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb
index 73b7dcc8c..70693205f 100644
--- a/app/serializers/dossier_serializer.rb
+++ b/app/serializers/dossier_serializer.rb
@@ -1,16 +1,17 @@
class DossierSerializer < ActiveModel::Serializer
attributes :id,
- :created_at,
- :updated_at,
- :archived,
- :mandataire_social,
- :state,
- :simplified_state,
- :initiated_at,
- :received_at,
- :processed_at,
- :accompagnateurs,
- :invites
+ :created_at,
+ :updated_at,
+ :archived,
+ :mandataire_social,
+ :state,
+ :simplified_state,
+ :initiated_at,
+ :received_at,
+ :processed_at,
+ :motivation,
+ :accompagnateurs,
+ :invites
has_one :entreprise
has_one :etablissement
diff --git a/app/serializers/dossier_table_export_serializer.rb b/app/serializers/dossier_table_export_serializer.rb
index 3bd4ba52a..877b9b6d6 100644
--- a/app/serializers/dossier_table_export_serializer.rb
+++ b/app/serializers/dossier_table_export_serializer.rb
@@ -1,20 +1,21 @@
class DossierTableExportSerializer < ActiveModel::Serializer
attributes :id,
- :created_at,
- :updated_at,
- :archived,
- :mandataire_social,
- :state,
- :initiated_at,
- :received_at,
- :processed_at
+ :created_at,
+ :updated_at,
+ :archived,
+ :mandataire_social,
+ :state,
+ :initiated_at,
+ :received_at,
+ :processed_at,
+ :motivation
attribute :emails_accompagnateurs
attributes :individual_gender,
- :individual_prenom,
- :individual_nom,
- :individual_birthdate
+ :individual_prenom,
+ :individual_nom,
+ :individual_birthdate
def individual_prenom
object.individual.try(:prenom)
diff --git a/app/serializers/dossiers_serializer.rb b/app/serializers/dossiers_serializer.rb
index e2b53b679..e43f4b63d 100644
--- a/app/serializers/dossiers_serializer.rb
+++ b/app/serializers/dossiers_serializer.rb
@@ -1,4 +1,4 @@
class DossiersSerializer < ActiveModel::Serializer
attributes :id,
- :updated_at
+ :updated_at
end
diff --git a/app/serializers/entreprise_serializer.rb b/app/serializers/entreprise_serializer.rb
index b293b3142..d46ab8672 100644
--- a/app/serializers/entreprise_serializer.rb
+++ b/app/serializers/entreprise_serializer.rb
@@ -1,14 +1,14 @@
class EntrepriseSerializer < ActiveModel::Serializer
attributes :siren,
- :capital_social,
- :numero_tva_intracommunautaire,
- :forme_juridique,
- :forme_juridique_code,
- :nom_commercial,
- :raison_sociale,
- :siret_siege_social,
- :code_effectif_entreprise,
- :date_creation,
- :nom,
- :prenom
+ :capital_social,
+ :numero_tva_intracommunautaire,
+ :forme_juridique,
+ :forme_juridique_code,
+ :nom_commercial,
+ :raison_sociale,
+ :siret_siege_social,
+ :code_effectif_entreprise,
+ :date_creation,
+ :nom,
+ :prenom
end
diff --git a/app/serializers/etablissement_serializer.rb b/app/serializers/etablissement_serializer.rb
index 11b4ce969..6cd091859 100644
--- a/app/serializers/etablissement_serializer.rb
+++ b/app/serializers/etablissement_serializer.rb
@@ -1,15 +1,14 @@
class EtablissementSerializer < ActiveModel::Serializer
attributes :siret,
- :siege_social,
- :naf,
- :libelle_naf,
- :adresse,
- :numero_voie,
- :type_voie,
- :nom_voie,
- :complement_adresse,
- :code_postal,
- :localite,
- :code_insee_localite
-
+ :siege_social,
+ :naf,
+ :libelle_naf,
+ :adresse,
+ :numero_voie,
+ :type_voie,
+ :nom_voie,
+ :complement_adresse,
+ :code_postal,
+ :localite,
+ :code_insee_localite
end
diff --git a/app/serializers/module_api_carto_serializer.rb b/app/serializers/module_api_carto_serializer.rb
index 671b754bf..0c993848d 100644
--- a/app/serializers/module_api_carto_serializer.rb
+++ b/app/serializers/module_api_carto_serializer.rb
@@ -1,7 +1,5 @@
class ModuleApiCartoSerializer < ActiveModel::Serializer
attributes :use_api_carto,
- :quartiers_prioritaires,
- :cadastre
-
-
+ :quartiers_prioritaires,
+ :cadastre
end
diff --git a/app/serializers/piece_justificative_serializer.rb b/app/serializers/piece_justificative_serializer.rb
index 1b460e320..fdcf1d2c9 100644
--- a/app/serializers/piece_justificative_serializer.rb
+++ b/app/serializers/piece_justificative_serializer.rb
@@ -1,7 +1,7 @@
class PieceJustificativeSerializer < ActiveModel::Serializer
attributes :created_at,
- :type_de_piece_justificative_id,
- :content_url
+ :type_de_piece_justificative_id,
+ :content_url
has_one :user
end
diff --git a/app/serializers/procedure_serializer.rb b/app/serializers/procedure_serializer.rb
index c85ed7ff4..228a1f710 100644
--- a/app/serializers/procedure_serializer.rb
+++ b/app/serializers/procedure_serializer.rb
@@ -3,13 +3,12 @@ class ProcedureSerializer < ActiveModel::Serializer
attribute :lien_demarche, key: :link
attributes :id,
- :description,
- :organisation,
- :direction,
- :archived,
- :geographic_information,
- :total_dossier
-
+ :description,
+ :organisation,
+ :direction,
+ :archived,
+ :geographic_information,
+ :total_dossier
has_one :geographic_information, serializer: ModuleApiCartoSerializer
has_many :types_de_champ, serializer: TypeDeChampSerializer
diff --git a/app/serializers/type_de_champ_serializer.rb b/app/serializers/type_de_champ_serializer.rb
index bec424797..152e908e1 100644
--- a/app/serializers/type_de_champ_serializer.rb
+++ b/app/serializers/type_de_champ_serializer.rb
@@ -1,7 +1,7 @@
class TypeDeChampSerializer < ActiveModel::Serializer
attributes :id,
- :libelle,
- :type_champ,
- :order_place,
- :description
+ :libelle,
+ :type_champ,
+ :order_place,
+ :description
end
diff --git a/app/serializers/type_de_piece_justificative_serializer.rb b/app/serializers/type_de_piece_justificative_serializer.rb
index cff798508..53ee7cf81 100644
--- a/app/serializers/type_de_piece_justificative_serializer.rb
+++ b/app/serializers/type_de_piece_justificative_serializer.rb
@@ -1,7 +1,7 @@
class TypeDePieceJustificativeSerializer < ActiveModel::Serializer
attributes :id,
- :libelle,
- :description,
- :order_place,
- :lien_demarche
+ :libelle,
+ :description,
+ :order_place,
+ :lien_demarche
end
diff --git a/app/services/browser_service.rb b/app/services/browser_service.rb
index a11c030c1..0163bbe6e 100644
--- a/app/services/browser_service.rb
+++ b/app/services/browser_service.rb
@@ -1,5 +1,4 @@
class BrowserService
-
def self.get_browser request
BROWSER.value = Browser.new(request.user_agent)
end
@@ -15,5 +14,4 @@ class BrowserService
true
end
-
end
diff --git a/app/services/clamav_service.rb b/app/services/clamav_service.rb
index 5d1142c96..022f02de1 100644
--- a/app/services/clamav_service.rb
+++ b/app/services/clamav_service.rb
@@ -1,6 +1,5 @@
class ClamavService
def self.safe_file? path_file
-
if Rails.env == 'development'
return CLAMAV[:response] if CLAMAV[:mock?]
end
diff --git a/app/services/dossier_service.rb b/app/services/dossier_service.rb
index 511e4e1d9..bdd2e85ca 100644
--- a/app/services/dossier_service.rb
+++ b/app/services/dossier_service.rb
@@ -1,5 +1,4 @@
class DossierService
-
def initialize dossier, siret, france_connect_information
@dossier = dossier
@siret = siret
@@ -34,7 +33,6 @@ class DossierService
@dossier
end
-
def self.siren siret
siret[0..8]
end
diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb
index b110fde11..1cd0bd593 100644
--- a/app/services/dossiers_list_gestionnaire_service.rb
+++ b/app/services/dossiers_list_gestionnaire_service.rb
@@ -13,7 +13,6 @@ class DossiersListGestionnaireService
'termine' => termine,
'archive' => archive,
'all_state' => all_state}[@liste]
-
end
def self.dossiers_liste_libelle
@@ -186,5 +185,4 @@ class DossiersListGestionnaireService
def current_preference_smart_listing_page
@current_devise_profil.preference_smart_listing_page
end
-
end
diff --git a/app/services/france_connect_salt_service.rb b/app/services/france_connect_salt_service.rb
index f1d766e44..ac64ccbf1 100644
--- a/app/services/france_connect_salt_service.rb
+++ b/app/services/france_connect_salt_service.rb
@@ -1,5 +1,4 @@
class FranceConnectSaltService
-
attr_reader :model
def initialize france_connect_information
diff --git a/app/services/geojson_service.rb b/app/services/geojson_service.rb
index 7bc175fbe..1f6562089 100644
--- a/app/services/geojson_service.rb
+++ b/app/services/geojson_service.rb
@@ -11,7 +11,6 @@ class GeojsonService
end
def self.to_json_polygon_for_cadastre coordinates
-
polygon = {
geom: {
type: "Feature",
diff --git a/app/services/module_api_carto_service.rb b/app/services/module_api_carto_service.rb
index 4838d13b1..d32307e87 100644
--- a/app/services/module_api_carto_service.rb
+++ b/app/services/module_api_carto_service.rb
@@ -26,12 +26,14 @@ class ModuleApiCartoService
def self.generate_qp coordinates
coordinates.inject({}) { |acc, coordinate|
acc.merge CARTO::SGMAP::QuartiersPrioritaires::Adapter.new(
- coordinate.map { |element| [element['lng'], element['lat']] }).to_params }
+ coordinate.map { |element| [element['lng'], element['lat']] }).to_params
+ }
end
def self.generate_cadastre coordinates
(coordinates.inject([]) { |acc, coordinate|
acc << CARTO::SGMAP::Cadastre::Adapter.new(
- coordinate.map { |element| [element['lng'], element['lat']] }).to_params }).flatten
+ coordinate.map { |element| [element['lng'], element['lat']] }).to_params
+ }).flatten
end
end
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index a401064cf..991120e95 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -1,5 +1,4 @@
class NotificationService
-
def initialize type_notif, dossier_id, attribut_change=''
@type_notif = type_notif
@dossier_id = dossier_id
@@ -25,20 +24,20 @@ class NotificationService
def text_for_notif attribut=''
case @type_notif
- when 'commentaire'
- "#{notification.liste.size + 1} nouveau(x) commentaire(s) déposé(s)."
- when 'cerfa'
- "Un nouveau formulaire a été déposé."
- when 'piece_justificative'
- attribut
- when 'champs'
- attribut
- when 'submitted'
- "Le dossier nº #{@dossier_id} a été déposé."
- when 'avis'
- 'Un nouvel avis a été rendu'
- else
- 'Notification par défaut'
+ when 'commentaire'
+ "#{notification.liste.size + 1} nouveau(x) commentaire(s) déposé(s)."
+ when 'cerfa'
+ "Un nouveau formulaire a été déposé."
+ when 'piece_justificative'
+ attribut
+ when 'champs'
+ attribut
+ when 'submitted'
+ "Le dossier nº #{@dossier_id} a été déposé."
+ when 'avis'
+ 'Un nouvel avis a été rendu'
+ else
+ 'Notification par défaut'
end
end
end
diff --git a/app/services/render_partial_service.rb b/app/services/render_partial_service.rb
index efb5ed2ab..8e20fb8c6 100644
--- a/app/services/render_partial_service.rb
+++ b/app/services/render_partial_service.rb
@@ -1,5 +1,4 @@
class RenderPartialService
-
attr_accessor :controller, :method
def initialize controller, method
diff --git a/app/services/sync_credentials_service.rb b/app/services/sync_credentials_service.rb
index 06d912b29..1319ae0d5 100644
--- a/app/services/sync_credentials_service.rb
+++ b/app/services/sync_credentials_service.rb
@@ -1,5 +1,4 @@
class SyncCredentialsService
-
def initialize klass, email_was, email, encrypted_password
@klass = klass
@email_was = email_was
diff --git a/app/services/types_de_champ_service.rb b/app/services/types_de_champ_service.rb
index eba9a549a..2d25d0d6e 100644
--- a/app/services/types_de_champ_service.rb
+++ b/app/services/types_de_champ_service.rb
@@ -7,7 +7,6 @@ class TypesDeChampService
.permit("#{attributes}" => [:libelle, :description, :order_place, :type_champ, :id, :mandatory, :type,
drop_down_list_attributes: [:value, :id]])
-
parameters[attributes].each do |param_first, param_second|
if param_second[:libelle].empty?
parameters[attributes].delete(param_first.to_s)
diff --git a/app/services/user_routes_authorization_service.rb b/app/services/user_routes_authorization_service.rb
index 57b6f5af7..5507cdbbd 100644
--- a/app/services/user_routes_authorization_service.rb
+++ b/app/services/user_routes_authorization_service.rb
@@ -1,5 +1,4 @@
class UserRoutesAuthorizationService
-
def self.authorized_route? controller, dossier
auth = controller.route_authorization
diff --git a/app/uploaders/attestation_template_image_uploader.rb b/app/uploaders/attestation_template_image_uploader.rb
new file mode 100644
index 000000000..4baa5fe54
--- /dev/null
+++ b/app/uploaders/attestation_template_image_uploader.rb
@@ -0,0 +1,26 @@
+class AttestationTemplateImageUploader < BaseUploader
+ def root
+ File.join(Rails.root, 'public')
+ end
+
+ # Choose what kind of storage to use for this uploader:
+ if Features.remote_storage
+ storage :fog
+ else
+ storage :file
+ end
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ unless Features.remote_storage
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+ end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ def extension_white_list
+ %w(jpg jpeg png)
+ end
+end
diff --git a/app/uploaders/attestation_uploader.rb b/app/uploaders/attestation_uploader.rb
new file mode 100644
index 000000000..2697d330a
--- /dev/null
+++ b/app/uploaders/attestation_uploader.rb
@@ -0,0 +1,20 @@
+class AttestationUploader < BaseUploader
+ def root
+ File.join(Rails.root, 'public')
+ end
+
+ # Choose what kind of storage to use for this uploader:
+ if Features.remote_storage
+ storage :fog
+ else
+ storage :file
+ end
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ unless Features.remote_storage
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+ end
+end
diff --git a/app/uploaders/cerfa_uploader.rb b/app/uploaders/cerfa_uploader.rb
index c398801b8..7d31762f5 100644
--- a/app/uploaders/cerfa_uploader.rb
+++ b/app/uploaders/cerfa_uploader.rb
@@ -3,7 +3,7 @@
class CerfaUploader < BaseUploader
before :cache, :set_original_filename
-# Choose what kind of storage to use for this uploader:
+ # Choose what kind of storage to use for this uploader:
if Features.remote_storage
storage :fog
else
diff --git a/app/uploaders/procedure_logo_uploader.rb b/app/uploaders/procedure_logo_uploader.rb
index e5723f9a0..acce9da15 100644
--- a/app/uploaders/procedure_logo_uploader.rb
+++ b/app/uploaders/procedure_logo_uploader.rb
@@ -1,7 +1,6 @@
# encoding: utf-8
class ProcedureLogoUploader < BaseUploader
-
def root
File.join(Rails.root, "public")
end
@@ -47,5 +46,4 @@ class ProcedureLogoUploader < BaseUploader
def generate_secure_token
SecureRandom.uuid
end
-
end
diff --git a/app/validators/email_format_validator.rb b/app/validators/email_format_validator.rb
index 33f6b6065..bc9f01cb5 100644
--- a/app/validators/email_format_validator.rb
+++ b/app/validators/email_format_validator.rb
@@ -1,5 +1,4 @@
class EmailFormatValidator < ActiveModel::Validator
-
def email_regex
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
end
diff --git a/app/validators/procedure_path_format_validator.rb b/app/validators/procedure_path_format_validator.rb
index 2d677c37e..974f4c404 100644
--- a/app/validators/procedure_path_format_validator.rb
+++ b/app/validators/procedure_path_format_validator.rb
@@ -1,5 +1,4 @@
class ProcedurePathFormatValidator < ActiveModel::Validator
-
def path_regex
/^[a-z0-9_]{3,30}$/
end
@@ -8,5 +7,4 @@ class ProcedurePathFormatValidator < ActiveModel::Validator
return false if record.path.blank?
record.errors[:path] << "Path invalide" unless path_regex.match(record.path)
end
-
end
diff --git a/app/validators/siret_format_validator.rb b/app/validators/siret_format_validator.rb
index 50197f0c6..b891766f1 100644
--- a/app/validators/siret_format_validator.rb
+++ b/app/validators/siret_format_validator.rb
@@ -9,6 +9,7 @@ class SiretFormatValidator < ActiveModel::EachValidator
end
private
+
def luhn_checksum(value)
accum = 0
value.reverse.each_char.map(&:to_i).each_with_index do |digit, index|
diff --git a/app/views/admin/attestation_templates/edit.html.haml b/app/views/admin/attestation_templates/edit.html.haml
new file mode 100644
index 000000000..f5d790808
--- /dev/null
+++ b/app/views/admin/attestation_templates/edit.html.haml
@@ -0,0 +1,73 @@
+#attestation-template-edit.row.white-back
+ = form_for @attestation_template, url: admin_procedure_attestation_template_path do |f|
+ .row
+ .col-md-10
+ %h1
+ Attestation
+ - if @attestation_template.activated?
+ %small.text-success Activée
+ - else
+ %small Désactivée
+
+ %p.notice Les attestation, si elles sont activées, sont délivrées par email aux usagers lorsque leurs dossiers sont acceptés, et sont également disponibles au téléchargement sur leur espace personnel.
+
+ .image-upload
+ - if @attestation_template.logo.present?
+ = image_tag @attestation_template.logo.url, class: 'thumbnail'
+ .form-group
+ = f.label :logo, "Logo de l'attestation"
+ = f.file_field :logo, accept: 'image/png, image/jpg, image/jpeg'
+ %p.help-block
+ Fichier accepté : JPG / JPEG / PNG
+ %br
+ Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo.
+
+ .form-group
+ = f.label :title, 'Titre'
+ = f.text_field :title, class: 'form-control'
+
+ .form-group
+ = f.label :body, 'Corps du document'
+ ~ f.text_area :body, class: 'form-control', rows: 10
+
+ .row
+ .col-md-12.balises
+ %table.table.table-striped
+ %tr
+ %th.col-md-3
+ Balise
+ %th
+ Description
+ - @attestation_template.tags.each do |tag|
+ %tr
+ %td
+ = "--#{tag[:libelle]}--"
+ %td
+ = tag[:description]
+
+ .image-upload
+ - if @attestation_template.signature.present?
+ = image_tag @attestation_template.signature.url, class: 'thumbnail'
+ .form-group
+ = f.label :signature, "Tampon de l'attestation"
+ = f.file_field :signature, accept: 'image/png, image/jpg, image/jpeg'
+ %p.help-block
+ Fichier accepté : JPG / JPEG / PNG
+ %br
+ Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo.
+
+ .form-group
+ = f.label :footer, 'Adresse en bas de page'
+ = f.text_field :footer, class: 'form-control', maxlength: 190
+
+ %button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser
+
+ .pull-right
+ - if @attestation_template.activated && !@procedure.locked?
+ %button.btn.btn-warning{ formaction: admin_procedure_attestation_template_disactivate_path } désactiver l'attestation
+
+ - if @attestation_template.new_record? || !@attestation_template.activated
+ %button.btn.btn-success Activer l'attestation
+ - else
+ - save_data = @procedure.locked? ? { toggle: :tooltip, confirm: "Attention: les modifications n'affecteront pas les attestations déjà délivrées." } : nil
+ %button.btn.btn-success{ data: save_data } Enregistrer
diff --git a/app/views/admin/attestation_templates/show.pdf.prawn b/app/views/admin/attestation_templates/show.pdf.prawn
new file mode 100644
index 000000000..228bdc375
--- /dev/null
+++ b/app/views/admin/attestation_templates/show.pdf.prawn
@@ -0,0 +1,38 @@
+require 'prawn/measurement_extensions'
+
+prawn_document(margin: [50, 100, 20, 100]) do |pdf|
+ pdf.font_families.update( 'open sans' => { normal: './lib/prawn/fonts/OpenSans-Regular.ttf' })
+ pdf.font 'open sans'
+
+ grey = '555555'
+ black = '333333'
+ max_logo_size = 40.mm
+ max_signature_size = 40.mm
+
+ pdf.bounding_box([0, pdf.cursor], width: 400, height: 650) do
+ if @logo.present?
+ pdf.image StringIO.new(@logo.read), fit: [max_logo_size , max_logo_size], position: :center
+ end
+
+ pdf.fill_color grey
+ pdf.pad_top(40) { pdf.text "le #{l(@created_at, format: '%e %B %Y')}", size: 10, align: :right, character_spacing: -0.5 }
+
+ pdf.fill_color black
+ pdf.pad_top(40) { pdf.text @title, size: 18, character_spacing: -0.2 }
+
+ pdf.fill_color grey
+ pdf.pad_top(30) { pdf.text @body, size: 10, character_spacing: -0.2 }
+
+ if @signature.present?
+ pdf.pad_top(40) do
+ pdf.image StringIO.new(@signature.read), fit: [max_signature_size , max_signature_size], position: :right
+ end
+ end
+ end
+
+ pdf.repeat(:all) do
+ pdf.move_cursor_to 20
+ pdf.fill_color grey
+ pdf.text @footer, align: :center, size: 8
+ end
+end
diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml
index 253ee6729..706f90135 100644
--- a/app/views/admin/procedures/_informations.html.haml
+++ b/app/views/admin/procedures/_informations.html.haml
@@ -45,7 +45,7 @@
.checkbox
%label
= ff.check_box :quartiers_prioritaires
- Quartiers Prioritaires
+ Quartiers prioritaires
%li
.checkbox
%label
diff --git a/app/views/admin/procedures/_modal_transfer.html.haml b/app/views/admin/procedures/_modal_transfer.html.haml
index 733b19936..66edd79ab 100644
--- a/app/views/admin/procedures/_modal_transfer.html.haml
+++ b/app/views/admin/procedures/_modal_transfer.html.haml
@@ -5,18 +5,23 @@
.modal-header
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
%span{ "aria-hidden" => "true" } ×
+
%h4#myModalLabel.modal-title
- Petit transfert de procédure entre administrateur
+ Transférer la procédure à un autre administrateur
+
.modal-body
%p
Cette fonctionnalité vous permet de transmettre un clone de votre procédure à un autre administrateur.
+
%div{ style:'margin-top:20px' }
= text_field_tag :email_admin, '', { class: 'form-control',
- type: 'email',
- placeholder: 'Email administrateur cible',
- style: 'width: 300px; margin-left:auto; margin-right:auto' }
+ type: 'email',
+ placeholder: 'Email administrateur cible',
+ style: 'width: 300px; margin-left:auto; margin-right:auto' }
+
#not_found_admin.center.text-danger{ style:'display: none; margin-top: 10px;' }
Cet administrateur n'existe pas.
+
.modal-footer
= submit_tag "Envoyer", class: 'btn btn-success'
= button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml
index 10d45504e..91fa3dc42 100644
--- a/app/views/admin/procedures/show.html.haml
+++ b/app/views/admin/procedures/show.html.haml
@@ -129,3 +129,20 @@
Aucune statistique pour le moment
- else
= pie_chart @facade.dossiers_for_pie_highchart
+
+ - if @facade.procedure.published? || @facade.procedure.archived?
+ %h3 Supprimer la procédure
+ .alert.alert-danger
+ %p
+ Attention : la suppression d'une procédure est définitive.
+ - dossiers_count = @facade.procedure.dossiers.count
+ - if dossiers_count > 0
+ %p
+ = pluralize(dossiers_count, "dossier est rattaché", "dossiers sont rattachés")
+ à cette procédure, la suppression de cette procédure entrainera également leur suppression.
+ %p.text-right
+ = link_to "J'ai compris, je supprime la procédure",
+ hide_admin_procedure_path(@facade.procedure),
+ method: :post,
+ class: "btn btn-danger",
+ data: { confirm: "Voulez-vous supprimer la procédure ?", disable_with: "Suppression..." }
diff --git a/app/views/admin/procedures/transfer.js.erb b/app/views/admin/procedures/transfer.js.erb
index d57f2f48f..02e1bbdf6 100644
--- a/app/views/admin/procedures/transfer.js.erb
+++ b/app/views/admin/procedures/transfer.js.erb
@@ -1,11 +1,12 @@
<%- if response.status == 404 %>
transfer_errors_message(true);
<%- else %>
- <% flash.each do |type, message| %>
- $("#flash_message").html("
<%= message.html_safe %>
")
- <% end %>
- <% flash.clear %>
- transfer_errors_message(false);
- $("#email_admin").val('');
- $("button#cancel").click();
-<%- end %>
\ No newline at end of file
+ $("#main-container").prepend("");
+ $("#flash_message").prepend(" <%= flash.notice.html_safe %>
");
+ <% flash.clear %>
+
+ transfer_errors_message(false);
+ $("#email_admin").val('');
+
+ $("#transferModal button#cancel").click();
+<%- end %>
diff --git a/app/views/backoffice/avis/sign_up.html.haml b/app/views/backoffice/avis/sign_up.html.haml
index faeb3dadb..c14b92040 100644
--- a/app/views/backoffice/avis/sign_up.html.haml
+++ b/app/views/backoffice/avis/sign_up.html.haml
@@ -1,15 +1,16 @@
-.avis-sign-up
- .left
- %p.description= @dossier.procedure.libelle
- %p.dossier Dossier nº #{@dossier.id}
- .right
- %h1 Créez-vous un compte
+.two-columns.avis-sign-up
+ .columns-container
+ .column.left
+ %p.description= @dossier.procedure.libelle
+ %p.dossier Dossier nº #{@dossier.id}
+ .column
+ = form_for(Gestionnaire.new, url: { controller: "backoffice/avis", action: :create_gestionnaire }, method: :post, html: { class: "form" }) do |f|
+ %h1 Créez-vous un compte
- = form_for(Gestionnaire.new, url: { controller: 'backoffice/avis', action: :create_gestionnaire }, method: :post) do |f|
- = f.label :email, 'Email'
- = f.email_field :email, value: @email, disabled: true
+ = f.label :email, "Email"
+ = f.email_field :email, value: @email, disabled: true
- = f.label :password, 'Mot de passe'
- = f.password_field :password, autofocus: true, required: true, placeholder: '8 caractères minimum'
+ = f.label :password, "Mot de passe"
+ = f.password_field :password, autofocus: true, required: true, placeholder: "8 caractères minimum"
- %button Créer un compte
+ = f.submit "Créer un compte", class: "button large primary expand"
diff --git a/app/views/dossiers/_attestation.html.haml b/app/views/dossiers/_attestation.html.haml
new file mode 100644
index 000000000..dc77bc5f2
--- /dev/null
+++ b/app/views/dossiers/_attestation.html.haml
@@ -0,0 +1,17 @@
+- if dossier.attestation.present?
+ #attestation-recapitulatif.default-data-block
+ .row.show-block.clearfix
+ .header
+ .title
+ .carret-right
+ .carret-down
+ ATTESTATION
+ .details
+ .left
+ = 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?
+ = 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'
diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml
index cfbe4ee02..afb5a5c77 100644
--- a/app/views/dossiers/_dossier_show.html.haml
+++ b/app/views/dossiers/_dossier_show.html.haml
@@ -1,7 +1,11 @@
= render partial: 'dossiers/edit_avis', locals: { dossier_facade: @facade }
+= render partial: 'dossiers/attestation', locals: { dossier: @facade.dossier }
+
= render partial: 'dossiers/messagerie', locals: { dossier_facade: @facade }
+= render partial: 'dossiers/motivation', locals: { dossier_facade: @facade }
+
- if @facade.procedure.individual_with_siret
.default-data-block
.row.show-block.infos
@@ -53,7 +57,7 @@
= render partial: '/users/carte/map', locals: { dossier: @facade.dossier }
= render partial: 'users/carte/init_carto', locals: { dossier: @facade.dossier }
-- if @current_gestionnaire && gestionnaire_signed_in? && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id) && @champs_private.count > 0
+- if @current_gestionnaire && gestionnaire_signed_in? && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id) && @champs_private.present?
.default-data-block.default_visible
.row.show-block#private-fields
.header
diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml
index 7de372ba2..f607632e6 100644
--- a/app/views/dossiers/_infos_dossier.html.haml
+++ b/app/views/dossiers/_infos_dossier.html.haml
@@ -46,6 +46,11 @@
= dossier.text_summary
- else
Pas de dossier associé
+ - elsif champ.type_champ == 'yes_no'
+ - if champ.decorate.value == 'true'
+ Oui
+ - elsif champ.decorate.value == 'false'
+ Non
- else
= champ.decorate.value.html_safe
diff --git a/app/views/dossiers/_motivation.html.haml b/app/views/dossiers/_motivation.html.haml
new file mode 100644
index 000000000..dad4f1b5c
--- /dev/null
+++ b/app/views/dossiers/_motivation.html.haml
@@ -0,0 +1,11 @@
+- if Dossier::TERMINE.include?(@facade.dossier.state) && @facade.dossier.motivation.present?
+ .default-data-block.default_visible
+ .row.show-block.infos
+ .header
+ .col-xs-12.title
+ .carret-right
+ .carret-down
+ MOTIVATION
+ .body
+ .display-block-on-print
+ = @facade.dossier.motivation
diff --git a/app/views/dossiers/_show.html.haml b/app/views/dossiers/_show.html.haml
index a63cafa14..1aa3e24a1 100644
--- a/app/views/dossiers/_show.html.haml
+++ b/app/views/dossiers/_show.html.haml
@@ -5,10 +5,3 @@
.row.etape.etape-2
= render partial: '/dossiers/etapes/etape2'
-
- -# - if @facade.procedure.module_api_carto.use_api_carto?
- -# .row.etape.etape_3
- -# = render partial: '/dossiers/etapes/etape3'
- -#
- -# .row.etape.etape_4
- -# = render partial: '/dossiers/etapes/etape4'
diff --git a/app/views/gestionnaire_mailer/last_week_overview.html.haml b/app/views/gestionnaire_mailer/last_week_overview.html.haml
index a82bb9497..892e5b257 100644
--- a/app/views/gestionnaire_mailer/last_week_overview.html.haml
+++ b/app/views/gestionnaire_mailer/last_week_overview.html.haml
@@ -1,26 +1,44 @@
-%table{ align: 'center', border: '0', cellpadding: '0', cellspacing: '0', height: '100%', style: 'background-color: #fafafa', width: '100%' }
- %tbody
- %tr
- %td{ align: 'center', style: 'height: 100%; margin: 0; padding: 30px; width: 100%; border-top: 0', valign: 'top' }
- %table{ border: '0', cellpadding: '0', cellspacing: '0', style: 'border-collapse: collapse; border: 0; max-width: 600px!important;', width: '100%' }
- %tbody
- %tr
- %td{ style: 'background: #ffffff none no-repeat center/cover; background-color: #ffffff; background-image: none; background-repeat: no-repeat; background-position: center; background-size: cover; border-top: 0; padding-top: 0;', valign: 'top' }
- %table{ border: '0', cellpadding: '0', cellspacing: '0', style: 'min-width: 100%; border-collapse: collapse', width: '100%' }
- %tr
- %td{ style: 'padding: 0 30px; mso-line-height-rule: exactly; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; ', valign: 'top' }
- %img{ align: 'middle', alt: 'Logo TPS', src: image_url('mailer/gestionnaire_mailer/logo.png'), style: 'max-width: 125px; padding: 30px 0; display: inline !important; vertical-align: bottom; border: 0; height: auto; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic;' }
- %tr
- %td{ style: 'padding: 0 30px 30px; word-break: break-word; color: #333333; font-family: Helvetica; font-size: 16px; line-height: 150%; text-align: left; border-bottom: 2px solid #4393F3;', valign: 'top' }
- Bonjour, voici votre résumé de l'activité de la semaine du #{l(@args[:start_date], format: '%d %B')} au #{l(DateTime.now, format: '%d %B')}.
- %br
- %br
+- content_for(:title, 'Vos activités sur TPS')
- - @args[:procedure_overviews].each do |procedure_overview|
- = procedure_overview.to_html.html_safe
- %br
- %br
- Bonne journée,
- %br
- %br
- L'équipe Téléprocédures Simplifiées
+- @args[:procedure_overviews].each_with_index do |procedure_overview, index|
+
+ %h2{ style: 'font-size: 20px; font-weight: 300; margin: 25px 0 5px;' }
+ #{procedure_overview.procedure.libelle}
+ = link_to 'voir', backoffice_dossiers_procedure_url(procedure_overview.procedure), style: 'color: #4393F3; font-size: 14px;'
+ %table{ cellpadding: '0', cellspacing: '0', style: 'width: 100%; padding-bottom: 20px;' }
+ %tbody
+
+ - if procedure_overview.created_dossiers_count > 0
+ %tr
+ %td{ style: 'padding: 2px 0;' }
+ %span{ style: 'font-weight: bold;' }= procedure_overview.created_dossiers_count
+ = procedure_overview.created_dossier_description
+
+ - if procedure_overview.dossiers_en_construction_count > 0
+ %tr
+ %td{ style: 'padding: 2px 0;' }
+ %span{ style: 'font-weight: bold;' }= procedure_overview.dossiers_en_construction_count
+ = procedure_overview.dossiers_en_construction_description
+ - if procedure_overview.old_dossiers_en_construction.count > 0
+ dont #{procedure_overview.old_dossiers_en_construction.count} depuis plus de 7 jours
+ - if procedure_overview.old_dossiers_en_construction.count < 6
+ \:
+ = procedure_overview.old_dossiers_en_construction.map do |old_dossier|
+ - link_to "nº #{old_dossier.id}", backoffice_dossier_url(old_dossier), style: 'color: #4393F3;'
+ - end.join(', ').html_safe
+
+ - if procedure_overview.dossiers_en_instruction_count > 0
+ %tr
+ %td{ style: 'padding: 2px 0;' }
+ %span{ style: 'font-weight: bold;' }= procedure_overview.dossiers_en_instruction_count
+ = procedure_overview.dossiers_en_instruction_description
+ - if procedure_overview.old_dossiers_en_instruction.count > 0
+ dont #{procedure_overview.old_dossiers_en_instruction.count} depuis plus de 7 jours
+ - if procedure_overview.old_dossiers_en_instruction.count < 6
+ \:
+ = procedure_overview.old_dossiers_en_instruction.map do |old_dossier|
+ - link_to "nº #{old_dossier.id}", backoffice_dossier_url(old_dossier), style: 'color: #4393F3;'
+ - end.join(', ').html_safe
+
+ - if index != (@args[:procedure_overviews].count - 1)
+ .spacer{ style: 'border-bottom: 1px solid #CCC; margin: 25px 0 30px;' }
diff --git a/app/views/gestionnaire_mailer/new_assignement.text.erb b/app/views/gestionnaire_mailer/new_assignement.text.erb
deleted file mode 100644
index 9af14a3e6..000000000
--- a/app/views/gestionnaire_mailer/new_assignement.text.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-Bienvenue sur la plateforme TPS,
-
-Vous venez d'être assigné à un administrateur sur la plateforme TPS. Voici quelques informations utiles :
-
- URL : <%= new_gestionnaire_session_url %>
- Email administrateur : <%= @args %>
-
-Bonne journée,
-
-L'équipe Téléprocédures Simplifiées
diff --git a/app/views/layouts/_crisp.html.haml b/app/views/layouts/_crisp.html.haml
new file mode 100644
index 000000000..d16217cd0
--- /dev/null
+++ b/app/views/layouts/_crisp.html.haml
@@ -0,0 +1,15 @@
+- if request.path == root_path
+ :javascript
+ window.$crisp=[];
+ window.CRISP_WEBSITE_ID="779b5050-4cc1-4172-8dd0-bde55716a289";
+ (function(){
+ d=document;
+ s=d.createElement("script");
+ s.src="https://client.crisp.im/l.js";
+ s.async=1;
+ d.getElementsByTagName("head")[0].appendChild(s);
+ })();
+ window.$crisp.push(["do", "chat:show"]);
+- else
+ :javascript
+ window.$crisp && window.$crisp.push(["do", "chat:hide"]);
diff --git a/app/views/layouts/_flash_messages.html.haml b/app/views/layouts/_flash_messages.html.haml
index 730c11fde..1c1ec728b 100644
--- a/app/views/layouts/_flash_messages.html.haml
+++ b/app/views/layouts/_flash_messages.html.haml
@@ -1,8 +1,11 @@
-- if flash.notice.present? || flash.alert.present?
+- if flash.any?
#flash_message.center
- - if flash.notice.present?
- .alert.alert-success
- = flash.notice
- - if flash.alert.present?
- .alert.alert-danger
- = flash.alert.html_safe
+ - flash.each do |key, value|
+ - if value.class == Array
+ .alert{ class: flash_class(key) }
+ - value.each do |message|
+ = message
+ %br
+ - else
+ .alert{ class: flash_class(key) }
+ = value
diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml
index 6e656bbc4..e6919dc50 100644
--- a/app/views/layouts/_new_header.haml
+++ b/app/views/layouts/_new_header.haml
@@ -1,6 +1,46 @@
-.new-header{ class: current_page?(root_path) ? nil : 'new-header-with-border' }
+.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border" }
.header-inner-content
= link_to root_path do
- %img.header-logo{ src: image_url("header/logo-tps.svg") }
+ %img{ src: image_url("header/logo-tps.svg") }
- = link_to "Connexion", new_user_session_path, class: "header-login-button"
+ %ul.header-right-content
+ - if gestionnaire_signed_in?
+ %li
+ .header-search
+ = form_tag backoffice_dossiers_search_url, method: :get, class: "form" do
+ = text_field_tag "q", "#{@search_terms unless @search_terms.nil?}", placeholder: "Rechercher"
+ %button{ title: "Rechercher" }
+ = image_tag "icons/search-blue.svg"
+ %li
+ .header-menu-opener
+ = image_tag "icons/account-circle.svg", onclick: "javascript:TPS.toggleHeaderMenu(event);", title: "Mon compte"
+ %ul.header-menu
+ %li
+ .menu-item{ title: current_email }
+ = current_email
+
+ - if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect?
+ - if user_signed_in?
+ %li
+ = link_to users_dossiers_path, class: "menu-item menu-link" do
+ = image_tag "icons/switch-profile.svg"
+ Passer en usager
+ - if gestionnaire_signed_in?
+ %li
+ = link_to backoffice_dossiers_path, class: "menu-item menu-link" do
+ = image_tag "icons/switch-profile.svg"
+ Passer en accompagnateur
+ - if administrateur_signed_in?
+ %li
+ = link_to admin_procedures_path, class: "menu-item menu-link" do
+ = image_tag "icons/switch-profile.svg"
+ Passer en administrateur
+
+ %li
+ = link_to destroy_user_session_path, method: :delete, class: "menu-item menu-link" do
+ = image_tag "icons/sign-out.svg"
+ Se déconnecter
+
+ - elsif request.path != new_user_session_path
+ %li
+ = link_to "Connexion", new_user_session_path, class: "button secondary"
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index d4278bc3d..67b890749 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -10,8 +10,8 @@
= favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
= favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
- = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
- = stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track' => true
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => "reload"
+ = stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track' => "reload"
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
diff --git a/app/views/layouts/left_panels/_left_panel_admin_attestationtemplatescontroller_edit.html.haml b/app/views/layouts/left_panels/_left_panel_admin_attestationtemplatescontroller_edit.html.haml
new file mode 100644
index 000000000..832761229
--- /dev/null
+++ b/app/views/layouts/left_panels/_left_panel_admin_attestationtemplatescontroller_edit.html.haml
@@ -0,0 +1 @@
+= render partial: 'layouts/left_panels/left_panel_admin_procedurescontroller_navbar', locals: { active: 'Attestation' }
diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml
index 0bb60d458..22362a245 100644
--- a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml
+++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml
@@ -45,6 +45,9 @@
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
Prévisualisation
+ %a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
+ .procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
+
.split-hr-left
diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml
index 2560a0bb8..c24112ece 100644
--- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml
+++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml
@@ -8,17 +8,23 @@
= link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" }
- elsif @facade.dossier.received?
- %ul.list-inline
- %li
- = link_to url_for({ controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id }), class: 'btn btn-success', method: :post, title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
- %i.fa.fa-check
- %li
- = link_to url_for({ controller: 'backoffice/dossiers', action: :without_continuation, dossier_id: @facade.dossier.id }), class: 'btn btn-warning', method: :post, title: 'Classer sans suite', data: { toggle: :tooltip, confirm: "Classer sans suite ce dossier ?" } do
- %i.fa.fa-circle-o
- %li
- = link_to url_for({ controller: 'backoffice/dossiers', action: :refuse, dossier_id: @facade.dossier.id }), class: 'btn btn-danger', method: :post, title: 'Refuser', data: { toggle: :tooltip, confirm: "Refuser ce dossier ?" } do
- %i.fa.fa-times
+ = form_tag(backoffice_dossier_process_dossier_url(@facade.dossier.id), method: :post) do
+ = text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Motivation (facultative)"
+ %ul.list-inline
+ %li
+ = button_tag name: :process_action, value: "close", class: 'btn btn-success', title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
+ %i.fa.fa-check
+
+ %li
+ = button_tag name: :process_action, value: "without_continuation", class: 'btn btn-warning', title: 'Classer sans suite', data: { toggle: :tooltip, confirm: "Classer sans suite ce dossier ?" } do
+ %i.fa.fa-circle-o
+
+ %li
+ = button_tag name: :process_action, value: "refuse", class: 'btn btn-danger', title: 'Refuser', data: { toggle: :tooltip, confirm: "Refuser ce dossier ?" } do
+ %i.fa.fa-times
+
+ %hr
= link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous la réouverture de ce dossier ?" }
%hr
diff --git a/app/views/layouts/mailers/layout.html.erb b/app/views/layouts/mailers/layout.html.erb
new file mode 100644
index 000000000..8bdb0cc03
--- /dev/null
+++ b/app/views/layouts/mailers/layout.html.erb
@@ -0,0 +1,190 @@
+
+
+
+
+ <%= yield(:title) %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<%= yield(:title) %>
+ <%= yield %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/layouts/new_application.html.haml b/app/views/layouts/new_application.html.haml
index 19c5bc700..799b9f413 100644
--- a/app/views/layouts/new_application.html.haml
+++ b/app/views/layouts/new_application.html.haml
@@ -1,8 +1,8 @@
%html
%head
- %meta{ "http-equiv" => "Content-Type", :content => "text/html; charset=UTF-8" }
- %meta{ "http-equiv" => "X-UA-Compatible", :content => "IE=edge" }
- %meta{ :name => "turbolinks-cache-control", :content => "no-cache" }
+ %meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" }
+ %meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
+ %meta{ name: "turbolinks-cache-control", content: "no-cache" }
%meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
= csrf_meta_tags
= action_cable_meta_tag
@@ -14,12 +14,12 @@
= favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
= favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
- = stylesheet_link_tag "new_design/new_application", :media => "all", "data-turbolinks-track" => true
- = stylesheet_link_tag "print", :media => "print", "data-turbolinks-track" => true
+ = stylesheet_link_tag "new_design/new_application", media: "all", "data-turbolinks-track": "reload"
+ = stylesheet_link_tag "print", media: "print", "data-turbolinks-track": true
%body
- = render :partial => "layouts/support_navigator_banner"
- = render :partial => "layouts/ie_lt_10"
+ = render partial: "layouts/support_navigator_banner"
+ = render partial: "layouts/ie_lt_10"
#beta{ class:(Rails.env == "production" ? "" : "beta_staging") }
- if Rails.env == "production"
Beta
@@ -30,14 +30,13 @@
= render partial: "layouts/flash_messages"
= yield
- = render :partial => "layouts/switch_devise_profile_module"
-
= render partial: "layouts/new_footer"
= render partial: "layouts/google_analytics"
= render partial: "layouts/mailjet_newsletter"
+ = render partial: "layouts/crisp"
- = javascript_include_tag "application", "data-turbolinks-track" => true
+ = javascript_include_tag "new_design/application", "data-turbolinks-track": true
= yield :charts_js
- if Rails.env == "test"
- %script{ :type => "text/javascript" }
+ %script{ type: "text/javascript" }
(typeof jQuery !== "undefined") && (jQuery.fx.off = true);
diff --git a/app/views/new_admin_mailer/new_admin_email.text.erb b/app/views/new_admin_mailer/new_admin_email.text.erb
index 678123a26..e0946ef9a 100644
--- a/app/views/new_admin_mailer/new_admin_email.text.erb
+++ b/app/views/new_admin_mailer/new_admin_email.text.erb
@@ -3,7 +3,6 @@ Un nouvel administrateur a été créé sur TPS.
Plateforme : <%= TPS::Application::URL %>
Login : <%= @admin.email %>
-Password : <%= @password %>
Bonne journée,
diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml
index ddff3b458..875e9d908 100644
--- a/app/views/root/landing.html.haml
+++ b/app/views/root/landing.html.haml
@@ -8,11 +8,7 @@
%br
vos procédures administratives en quelques minutes
- = link_to "Demander une démo",
- "mailto:#{t("dynamics.contact_email")}?subject=Demande de démo TPS",
- class: "hero-button",
- target: "_blank",
- onclick: "javascript: ga('send', 'pageview', '/demander-une-demo')"
+ %a.hero-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:open'])" } Demander une démo
%p.hero-phone-cta
ou nous appeler au 01 40 15 68 49
@@ -132,10 +128,6 @@
%h1.cta-panel-title Commencez à dématerialiser vos procédures
%p.cta-panel-explanation Nous vous accompagnons dans la prise en main de l’outil
%div
- = link_to "Demander une démo",
- "mailto:#{t('dynamics.contact_email')}?subject=Demande de démo TPS",
- class: "cta-panel-button",
- target: "_blank",
- onclick: "javascript: ga('send', 'pageview', '/demander-une-demo')"
+ %a.cta-panel-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:open'])" } Demander une démo
%p.cta-panel-phone-cta
ou nous appeler au 01 40 15 68 49
diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml
new file mode 100644
index 000000000..6d2a06f92
--- /dev/null
+++ b/app/views/root/patron.html.haml
@@ -0,0 +1,39 @@
+.patron
+ .patron-container
+ %h1 Patron
+
+ %h2 Formulaires
+
+ %form.form
+ %label Nom
+ %input{ type: "text" }
+ %label Prénom
+ %input{ type: "text", placeholder: "ex : Ivan" }
+ %label Mot de passe
+ %input{ type: "password", value: "12345678" }
+ %input.button{ type: "submit", value: "Envoyer" }
+
+ %h2 Boutons
+
+ %p
+ = link_to ".button", "#", class: "button"
+
+ = link_to ".button.primary", "#", class: "button primary"
+
+ = link_to ".button.secondary", "#", class: "button secondary"
+
+ = link_to ".button.large", "#", class: "button large"
+
+ = link_to ".button.large.primary", "#", class: "button large primary"
+
+ %p
+ = link_to ".button.primary.expand", "#", class: "button primary expand"
+
+ %h2 Layout deux colonnes
+
+ .two-columns
+ .columns-container
+ .column
+ Insérer ici le contenu de la colonne 1
+ .column
+ Insérer ici le contenu de la colonne 2
diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml
index 4ca7c7914..d09269ecc 100644
--- a/app/views/stats/index.html.haml
+++ b/app/views/stats/index.html.haml
@@ -49,7 +49,8 @@
.chart-container
.chart
- = pie_chart @procedures_count_per_administrateur
+ = pie_chart @procedures_count_per_administrateur,
+ colors: ["rgba(191, 220, 249, 1)", "rgba(113, 176, 239, 1)", "rgba(61, 149, 236, 1)"]
- if administration_signed_in?
.stat-card.stat-card-half.pull-left
@@ -87,3 +88,16 @@
= line_chart @avis_answer_percentages, ytitle: 'avis avec réponse / total avis', xtitle: 'semaines'
.clearfix
+
+ %h2.new-h2 Encart motivation
+
+ .stat-cards
+ .stat-card.stat-card-half.pull-left
+ %span.stat-card-title Taux d'utilisation des motivations (par dossier)
+ = column_chart @motivation_usage_dossier, ytitle: 'dossiers avec motivation / total dossiers', xtitle: 'semaines'
+
+ .stat-card.stat-card-half.pull-left
+ %span.stat-card-title Taux d'utilisation des motivations (par procédure)
+ = column_chart @motivation_usage_procedure, ytitle: 'procedures avec motivation / total procedures', xtitle: 'semaines'
+
+ .clearfix
diff --git a/app/views/users/carte/_map.html.haml b/app/views/users/carte/_map.html.haml
index 80f1bbf36..edefdda66 100644
--- a/app/views/users/carte/_map.html.haml
+++ b/app/views/users/carte/_map.html.haml
@@ -3,7 +3,7 @@
- if dossier.procedure.module_api_carto.quartiers_prioritaires
.col-md-9.col-lg-9#qp.col-md-3.col-lg-3.list
- %h3.text-info Quartiers prioritaites
+ %h3.text-info Quartiers prioritaires
%ul
- if dossier.procedure.module_api_carto.cadastre
diff --git a/app/views/users/passwords/edit.html.haml b/app/views/users/passwords/edit.html.haml
index d1688e75c..8b7a7a563 100644
--- a/app/views/users/passwords/edit.html.haml
+++ b/app/views/users/passwords/edit.html.haml
@@ -1,31 +1,3 @@
--# Sign up
--#
--# <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
--# <%= devise_error_messages! %>
--#
--#
--# <%= f.label :email %>
--# <%= f.email_field :email, autofocus: true %>
--#
--#
--#
--# <%= f.label :password %>
--# <% if @validatable %>
--# (<%= @minimum_password_length %> characters minimum)
--# <% end %>
--# <%= f.password_field :password, autocomplete: "off" %>
--#
--#
--#
--# <%= f.label :password_confirmation %>
--# <%= f.password_field :password_confirmation, autocomplete: "off" %>
--#
--#
--#
--# <%= f.submit "Sign up" %>
--#
--# <% end %>
-
= devise_error_messages!
#form-login
diff --git a/app/views/users/passwords/new.html.haml b/app/views/users/passwords/new.html.haml
index fa5410532..85ad6d44f 100644
--- a/app/views/users/passwords/new.html.haml
+++ b/app/views/users/passwords/new.html.haml
@@ -1,31 +1,3 @@
--# Sign up
--#
--# <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
--# <%= devise_error_messages! %>
--#
--#
--# <%= f.label :email %>
--# <%= f.email_field :email, autofocus: true %>
--#
--#
--#
--# <%= f.label :password %>
--# <% if @validatable %>
--# (<%= @minimum_password_length %> characters minimum)
--# <% end %>
--# <%= f.password_field :password, autocomplete: "off" %>
--#
--#
--#
--# <%= f.label :password_confirmation %>
--# <%= f.password_field :password_confirmation, autocomplete: "off" %>
--#
--#
--#
--# <%= f.submit "Sign up" %>
--#
--# <% end %>
-
= devise_error_messages!
%br
diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml
index a81def70b..fcaf254d6 100644
--- a/app/views/users/registrations/new.html.haml
+++ b/app/views/users/registrations/new.html.haml
@@ -1,64 +1,33 @@
--# Sign up
--#
--# <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
--# <%= devise_error_messages! %>
--#
--#
--# <%= f.label :email %>
--# <%= f.email_field :email, autofocus: true %>
--#
--#
--#
--# <%= f.label :password %>
--# <% if @validatable %>
--# (<%= @minimum_password_length %> characters minimum)
--# <% end %>
--# <%= f.password_field :password, autocomplete: "off" %>
--#
--#
--#
--# <%= f.label :password_confirmation %>
--# <%= f.password_field :password_confirmation, autocomplete: "off" %>
--#
--#
--#
--# <%= f.submit "Sign up" %>
--#
--# <% end %>
+.two-columns.auth
+ .columns-container
+ .column.preview
+ = image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo"
+ .baseline.center
+ %h3 Un outil simple
+ %p
+ pour gérer les formulaires
+ %br
+ administratifs dématérialisés.
-= devise_error_messages!
+ .column.auth-form
+ = devise_error_messages!
+ = form_for User.new, url: user_registration_path, html: { class: "form" } do |f|
+ %h1 Créez-vous un compte
-#form-login
- %br
- .flag
- = image_tag(image_url(LOGO_NAME))
- %br
- %h2#gestionnaire_login Inscription
+ = f.label :email, "Email"
+ = f.text_field :email
- %br
- %br
- #new-user
- = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
- %h4
- = f.label :email
- .input-group
- .input-group-addon
- %span.fa.fa-user
- = f.email_field :email, class: 'form-control', placeholder: 'Email', value: params[:user_email]
- %br
- %h4
- = f.label :password, 'Mot de passe'
- .input-group
- .input-group-addon
- %span.fa.fa-asterisk
- = f.password_field :password, autocomplete: "off", class: 'form-control', placeholder: 'Mot de passe'
- %br
- .input-group
- .input-group-addon
- %span.fa.fa-asterisk
- = f.password_field :password_confirmation, autocomplete: "off", class: 'form-control', placeholder: 'Répeter le mot de passe'
- %br
- %br
- .actions
- = f.submit "S'enregistrer", class: 'btn btn-primary'
- %br
+ = f.label :password, "Mot de passe"
+ = f.password_field :password, value: @user.password, placeholder: "8 caractères minimum"
+
+ = f.submit "Créer un compte", class: "button large primary expand"
+
+ .separation.center
+ ou
+
+ .center
+ = image_tag "login-with-fc-hover.svg", style: "display: none"
+ = link_to "", france_connect_particulier_path, class: "login-with-fc"
+
+ .center
+ = link_to "Qu’est-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", class: "link"
diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml
index 51ba7cda6..ffac4fae9 100644
--- a/app/views/users/sessions/new.html.haml
+++ b/app/views/users/sessions/new.html.haml
@@ -1,28 +1,60 @@
-#form-login.user_connexion_page
- %br
- = render partial: 'users/sessions/resume_procedure'
+.two-columns.auth
+ .columns-container
+ .column.preview
+ - unless @dossier
+ = image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo"
+ .baseline.center
+ %h3 Un outil simple
+ %p
+ pour gérer les formulaires
+ %br
+ administratifs dématérialisés.
+ - else
+ .text-right
+ = link_to "Fermer", users_no_procedure_url, class: "link close-procedure"
+ .procedure-logos
+ = image_tag @dossier.procedure.decorate.logo_img
+ - if @dossier.procedure.euro_flag
+ = image_tag "flag_of_europe.svg"
- %h2#login-user
- = t('dynamics.users.connexion_title')
+ %h2.procedure-title
+ = @dossier.procedure.libelle
+ %p.procedure-description
+ = h @dossier.procedure.description.html_safe
- %a.btn-fc#btn-fcp{ href: '/france_connect/particulier' }
- = image_tag 'franceconnect_logo.png'
+ .column.auth-form
+ = form_for @user, url: user_session_path, html: { class: "form" } do |f|
+ %h1 Connectez-vous
- %br
- %a.text-info{ href: 'https://fcp.integ01.dev-franceconnect.fr/a-propos', target: '_blank' }
- Qu’est-ce que FranceConnect ?
+ = f.label :email, "Email"
+ = f.text_field :email
- %hr
+ = f.label :password, "Mot de passe"
+ = f.password_field :password, value: @user.password, placeholder: "8 caractères minimum"
+
+ - if [:user, :gestionnaire].include?(resource_name)
+ .reset-password.text-right
+ = link_to "Mot de passe oublié ?", new_password_path(resource_name), class: "link"
- .text-left
- #new-user
- = simple_form_for @user, url: user_session_path do |f|
- = f.input :email
- = f.input :password, label: 'Mot de passe', input_html: { value: @user.password }
- if devise_mapping.rememberable?
- = f.input :remember_me, as: :boolean, label: 'Se souvenir de moi'
- .text-center
- = f.submit "Se connecter", class: 'btn btn-primary'
+ = f.check_box :remember_me, as: :boolean
+ = f.label :remember_me, "Se souvenir de moi"
- - if @user.email != DemoEmails[:gestionnaire] && @user.email != DemoEmails[:admin]
- = render "users/shared/links"
+ = f.submit "Se connecter", class: "button large primary expand"
+
+ .separation.center
+ ou
+
+ .center
+ = image_tag "login-with-fc-hover.svg", style: "display: none"
+ = link_to "", france_connect_particulier_path, class: "login-with-fc"
+
+ .center
+ = link_to "Qu’est-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", class: "link"
+
+ - if resource_name == :user
+ %hr
+ %p.register
+ %span
+ Nouveau sur TPS ?
+ = link_to "Créer un compte", new_registration_path(resource_name), class: "button"
diff --git a/app/workers/auto_archive_procedure_worker.rb b/app/workers/auto_archive_procedure_worker.rb
index 54875a961..a1a46efcc 100644
--- a/app/workers/auto_archive_procedure_worker.rb
+++ b/app/workers/auto_archive_procedure_worker.rb
@@ -7,7 +7,7 @@ class AutoArchiveProcedureWorker
dossier.received!
end
- procedure.update_attributes!(archived: true)
+ procedure.archive
end
end
end
diff --git a/config/deploy.rb b/config/deploy.rb
index 1895843ba..568cf4771 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -15,7 +15,6 @@ raise "Bad to=#{+ENV['to']}" unless ["staging", "production"].include?(ENV['to']
raise "missing domain, run with 'rake deploy domain=37.187.154.237'" if ENV['domain'].nil?
-
# set :domain, '5.135.190.60'
set :domain, ENV['domain']
set :repository, 'https://github.com/sgmap/tps.git'
@@ -72,7 +71,6 @@ set :shared_paths, [
'app/views/cgu/index.html.haml'
]
-
set :rbenv_path, "/usr/local/rbenv/bin/rbenv"
# Optional settings:
diff --git a/config/initializers/apipie.rb b/config/initializers/apipie.rb
index 92f93c63d..383abc409 100644
--- a/config/initializers/apipie.rb
+++ b/config/initializers/apipie.rb
@@ -14,5 +14,4 @@ Apipie.configure do |config|
Description
EOS
-
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index c20bc1259..f6ab56d75 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -8,4 +8,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-Rails.application.config.assets.precompile += %w(print.css new_design/new_application.css)
+Rails.application.config.assets.precompile += %w(print.css new_design/new_application.css new_design/application.js)
diff --git a/config/initializers/chartkick.rb b/config/initializers/chartkick.rb
index 3fa55389c..c9269816f 100644
--- a/config/initializers/chartkick.rb
+++ b/config/initializers/chartkick.rb
@@ -1,4 +1,4 @@
Chartkick.options = {
content_for: :charts_js,
- colors: ["rgba(191, 220, 249, 1)", "rgba(113, 176, 239, 1)", "rgba(61, 149, 236, 1)"]
+ colors: ["rgba(61, 149, 236, 1)"]
}
diff --git a/config/initializers/smart_listing.rb b/config/initializers/smart_listing.rb
index 90e3f99f9..09a097d25 100644
--- a/config/initializers/smart_listing.rb
+++ b/config/initializers/smart_listing.rb
@@ -1,75 +1,75 @@
SmartListing.configure do |config|
config.global_options({
- #:param_names => { # param names
- #:page => :page,
- #:per_page => :per_page,
- #:sort => :sort,
- #},
- #:array => false, # controls whether smart list should be using arrays or AR collections
- #:max_count => nil, # limit number of rows
- #:unlimited_per_page => false, # allow infinite page size
- #:paginate => true, # allow pagination
- #:memorize_per_page => false, # save per page settings in the cookie
- :page_sizes => [10, 20, 50, 100], # set available page sizes array
- #:kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options
- })
+ # :param_names => { # param names
+ # :page => :page,
+ # :per_page => :per_page,
+ # :sort => :sort,
+ # },
+ # :array => false, # controls whether smart list should be using arrays or AR collections
+ # :max_count => nil, # limit number of rows
+ # :unlimited_per_page => false, # allow infinite page size
+ # :paginate => true, # allow pagination
+ # :memorize_per_page => false, # save per page settings in the cookie
+ :page_sizes => [10, 20, 50, 100], # set available page sizes array
+ # :kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options
+ })
config.constants :classes, {
- #:main => "smart-listing",
- #:editable => "editable",
- #:content => "content",
- #:loading => "loading",
- #:status => "smart-listing-status",
- #:item_actions => "actions",
- #:new_item_placeholder => "new-item-placeholder",
- #:new_item_action => "new-item-action",
- #:new_item_button => "btn",
- #:hidden => "hidden",
- #:autoselect => "autoselect",
- #:callback => "callback",
- #:pagination_per_page => "pagination-per-page text-center",
- #:pagination_count => "count",
- #:inline_editing => "info",
- #:no_records => "no-records",
- #:limit => "smart-listing-limit",
- #:limit_alert => "smart-listing-limit-alert",
- #:controls => "smart-listing-controls",
- #:controls_reset => "reset",
- #:filtering => "filter",
- #:filtering_search => "glyphicon-search",
- #:filtering_cancel => "glyphicon-remove",
- #:filtering_disabled => "disabled",
- #:sortable => "sortable",
- #:icon_new => "glyphicon glyphicon-plus",
- #:icon_edit => "glyphicon glyphicon-pencil",
- #:icon_trash => "glyphicon glyphicon-trash",
- #:icon_inactive => "glyphicon glyphicon-circle",
- #:icon_show => "glyphicon glyphicon-share-alt",
- #:icon_sort_none => "glyphicon glyphicon-resize-vertical",
- #:icon_sort_up => "glyphicon glyphicon-chevron-up",
- #:icon_sort_down => "glyphicon glyphicon-chevron-down",
- }
+ #:main => "smart-listing",
+ #:editable => "editable",
+ #:content => "content",
+ #:loading => "loading",
+ #:status => "smart-listing-status",
+ #:item_actions => "actions",
+ #:new_item_placeholder => "new-item-placeholder",
+ #:new_item_action => "new-item-action",
+ #:new_item_button => "btn",
+ #:hidden => "hidden",
+ #:autoselect => "autoselect",
+ #:callback => "callback",
+ #:pagination_per_page => "pagination-per-page text-center",
+ #:pagination_count => "count",
+ #:inline_editing => "info",
+ #:no_records => "no-records",
+ #:limit => "smart-listing-limit",
+ #:limit_alert => "smart-listing-limit-alert",
+ #:controls => "smart-listing-controls",
+ #:controls_reset => "reset",
+ #:filtering => "filter",
+ #:filtering_search => "glyphicon-search",
+ #:filtering_cancel => "glyphicon-remove",
+ #:filtering_disabled => "disabled",
+ #:sortable => "sortable",
+ #:icon_new => "glyphicon glyphicon-plus",
+ #:icon_edit => "glyphicon glyphicon-pencil",
+ #:icon_trash => "glyphicon glyphicon-trash",
+ #:icon_inactive => "glyphicon glyphicon-circle",
+ #:icon_show => "glyphicon glyphicon-share-alt",
+ #:icon_sort_none => "glyphicon glyphicon-resize-vertical",
+ #:icon_sort_up => "glyphicon glyphicon-chevron-up",
+ #:icon_sort_down => "glyphicon glyphicon-chevron-down",
+ }
config.constants :data_attributes, {
- #:main => "smart-listing",
- #:confirmation => "confirmation",
- #:id => "id",
- #:href => "href",
- #:callback_href => "callback-href",
- #:max_count => "max-count",
- #:inline_edit_backup => "smart-listing-edit-backup",
- #:params => "params",
- #:observed => "observed",
- #:href => "href",
- #:autoshow => "autoshow",
- #:popover => "slpopover",
- }
+ # :main => "smart-listing",
+ # :confirmation => "confirmation",
+ # :id => "id",
+ # :href => "href",
+ # :callback_href => "callback-href",
+ # :max_count => "max-count",
+ # :inline_edit_backup => "smart-listing-edit-backup",
+ # :params => "params",
+ # :observed => "observed",
+ # :href => "href",
+ # :autoshow => "autoshow",
+ # :popover => "slpopover",
+ }
config.constants :selectors, {
- #:item_action_destroy => "a.destroy",
- #:edit_cancel => "button.cancel",
- #:row => "tr",
- #:head => "thead",
- #:filtering_icon => "i"
- }
+ # :item_action_destroy => "a.destroy",
+ # :edit_cancel => "button.cancel",
+ # :row => "tr",
+ # :head => "thead",
+ # :filtering_icon => "i"
+ }
end
diff --git a/config/initializers/stringupcasepatch.rb b/config/initializers/stringupcasepatch.rb
index 0c888e580..39d2e107a 100644
--- a/config/initializers/stringupcasepatch.rb
+++ b/config/initializers/stringupcasepatch.rb
@@ -1,9 +1,7 @@
require "unicode_utils/upcase"
class String
-
def upcase
UnicodeUtils.upcase(self)
end
-
end
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index f1da0acaa..b94806305 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -87,6 +87,10 @@ fr:
activerecord:
errors:
models:
+ attestation_template:
+ attributes:
+ footer:
+ too_long: ": l'adresse en bas de page est trop longue."
piece_justificative:
attributes:
content:
diff --git a/config/routes.rb b/config/routes.rb
index 8e2c90217..b93f66f2b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,4 @@
Rails.application.routes.draw do
-
get "/ping" => "ping#index", :constraints => {:ip => /127.0.0.1/}
devise_for :administrations, skip: [:password, :registrations]
@@ -115,6 +114,10 @@ Rails.application.routes.draw do
patch 'change_dossier_state' => 'change_dossier_state#change'
resources :procedures do
+ member do
+ post :hide
+ end
+
resources :types_de_champ, only: [:destroy]
resource :types_de_champ, only: [:show, :update] do
post '/:index/move_up' => 'types_de_champ#move_up', as: :move_up
@@ -145,6 +148,13 @@ Rails.application.routes.draw do
resource :previsualisation, only: [:show]
+ resource :attestation_template, only: [:edit, :update, :create]
+
+ post 'attestation_template/disactivate' => 'attestation_templates#disactivate'
+ patch 'attestation_template/disactivate' => 'attestation_templates#disactivate'
+
+ post 'attestation_template/preview' => 'attestation_templates#preview'
+ patch 'attestation_template/preview' => 'attestation_templates#preview'
end
namespace :accompagnateurs do
@@ -174,9 +184,7 @@ Rails.application.routes.draw do
resources :dossiers do
post 'receive' => 'dossiers#receive'
- post 'refuse' => 'dossiers#refuse'
- post 'without_continuation' => 'dossiers#without_continuation'
- post 'close' => 'dossiers#close'
+ post 'process_dossier' => 'dossiers#process_dossier'
member do
post 'archive'
post 'unarchive'
@@ -221,5 +229,21 @@ Rails.application.routes.draw do
get '/:procedure_path' => '/users/dossiers#commencer'
end
+ get "patron" => "root#patron"
+
+ scope module: 'new_user' do
+ resources :dossiers, only: [] do
+ get 'attestation'
+ end
+ end
+
+ scope module: 'new_gestionnaire' do
+ resources :procedures, only: [] do
+ resources :dossiers, only: [] do
+ get 'attestation'
+ end
+ end
+ end
+
apipie
end
diff --git a/config/unicorn.rb b/config/unicorn.rb
index 88a5d746a..886a35f25 100644
--- a/config/unicorn.rb
+++ b/config/unicorn.rb
@@ -8,8 +8,6 @@
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
-
-
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
worker_processes 2
@@ -52,7 +50,6 @@ check_client_connection false
# local variable to guard against running a hook multiple times
run_once = true
-
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
diff --git a/db/migrate/20150623122513_create_entreprise.rb b/db/migrate/20150623122513_create_entreprise.rb
index 319a3c962..fff62fd73 100644
--- a/db/migrate/20150623122513_create_entreprise.rb
+++ b/db/migrate/20150623122513_create_entreprise.rb
@@ -13,7 +13,6 @@ class CreateEntreprise < ActiveRecord::Migration
t.integer :date_creation
t.string :nom
t.string :prenom
-
end
add_reference :entreprises, :dossier, references: :dossiers
end
diff --git a/db/migrate/20150728140340_devise_create_users.rb b/db/migrate/20150728140340_devise_create_users.rb
index 2188a87ae..7fd2ccc33 100644
--- a/db/migrate/20150728140340_devise_create_users.rb
+++ b/db/migrate/20150728140340_devise_create_users.rb
@@ -30,7 +30,6 @@ class DeviseCreateUsers < ActiveRecord::Migration
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
diff --git a/db/migrate/20150731121101_devise_create_pros.rb b/db/migrate/20150731121101_devise_create_pros.rb
index 0b3243ca1..ff1dca742 100644
--- a/db/migrate/20150731121101_devise_create_pros.rb
+++ b/db/migrate/20150731121101_devise_create_pros.rb
@@ -30,7 +30,6 @@ class DeviseCreatePros < ActiveRecord::Migration
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
diff --git a/db/migrate/20150918163159_devise_create_gestionnaires.rb b/db/migrate/20150918163159_devise_create_gestionnaires.rb
index e1640f6c4..218e5084a 100644
--- a/db/migrate/20150918163159_devise_create_gestionnaires.rb
+++ b/db/migrate/20150918163159_devise_create_gestionnaires.rb
@@ -30,7 +30,6 @@ class DeviseCreateGestionnaires < ActiveRecord::Migration
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
diff --git a/db/migrate/20150922141232_create_users.rb b/db/migrate/20150922141232_create_users.rb
index 1b2d78a3c..3fd611f64 100644
--- a/db/migrate/20150922141232_create_users.rb
+++ b/db/migrate/20150922141232_create_users.rb
@@ -30,7 +30,6 @@ class CreateUsers < ActiveRecord::Migration
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
diff --git a/db/migrate/20151023132121_devise_create_administrateurs.rb b/db/migrate/20151023132121_devise_create_administrateurs.rb
index bf5bb9167..34d627e9a 100644
--- a/db/migrate/20151023132121_devise_create_administrateurs.rb
+++ b/db/migrate/20151023132121_devise_create_administrateurs.rb
@@ -30,7 +30,6 @@ class DeviseCreateAdministrateurs < ActiveRecord::Migration
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
diff --git a/db/migrate/20151102104309_change_state_confirmed_to_validated.rb b/db/migrate/20151102104309_change_state_confirmed_to_validated.rb
index 4fbeff150..e19e39ed8 100644
--- a/db/migrate/20151102104309_change_state_confirmed_to_validated.rb
+++ b/db/migrate/20151102104309_change_state_confirmed_to_validated.rb
@@ -1,6 +1,5 @@
class ChangeStateConfirmedToValidated < ActiveRecord::Migration
def change
Dossier.where(state: 'confirmed').update_all(state: 'validated')
-
end
end
diff --git a/db/migrate/20151102163051_delete_attributs_to_dossier.rb b/db/migrate/20151102163051_delete_attributs_to_dossier.rb
index c7752598b..8928f910b 100644
--- a/db/migrate/20151102163051_delete_attributs_to_dossier.rb
+++ b/db/migrate/20151102163051_delete_attributs_to_dossier.rb
@@ -7,6 +7,5 @@ class DeleteAttributsToDossier < ActiveRecord::Migration
remove_column :dossiers, :position_lon
remove_column :dossiers, :ref_dossier_carto
-
end
end
diff --git a/db/migrate/20151207140202_update_module_api_carto.rb b/db/migrate/20151207140202_update_module_api_carto.rb
index 0bb9b77ab..25549224d 100644
--- a/db/migrate/20151207140202_update_module_api_carto.rb
+++ b/db/migrate/20151207140202_update_module_api_carto.rb
@@ -1,11 +1,8 @@
class UpdateModuleAPICarto < ActiveRecord::Migration
-
class Procedure < ActiveRecord::Base
-
end
class ModuleAPICarto < ActiveRecord::Base
-
end
def up
diff --git a/db/migrate/20160120094750_create_france_connect_information.rb b/db/migrate/20160120094750_create_france_connect_information.rb
index 8cddaa780..1cea47245 100644
--- a/db/migrate/20160120094750_create_france_connect_information.rb
+++ b/db/migrate/20160120094750_create_france_connect_information.rb
@@ -1,11 +1,8 @@
class CreateFranceConnectInformation < ActiveRecord::Migration
-
class User < ActiveRecord::Base
-
end
class FranceConnectInformation < ActiveRecord::Base
-
end
def up
@@ -38,7 +35,6 @@ class CreateFranceConnectInformation < ActiveRecord::Migration
remove_column :users, :france_connect_particulier_id
end
-
def down
add_column :users, :gender, :string
add_column :users, :given_name, :string
diff --git a/db/migrate/20160223134354_devise_create_administrations.rb b/db/migrate/20160223134354_devise_create_administrations.rb
index 8f5460074..7c48f4fcf 100644
--- a/db/migrate/20160223134354_devise_create_administrations.rb
+++ b/db/migrate/20160223134354_devise_create_administrations.rb
@@ -30,7 +30,6 @@ class DeviseCreateAdministrations < ActiveRecord::Migration
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
diff --git a/db/migrate/20160317144949_piece_justificative_have_user.rb b/db/migrate/20160317144949_piece_justificative_have_user.rb
index 10ee2b45b..23ddd81a3 100644
--- a/db/migrate/20160317144949_piece_justificative_have_user.rb
+++ b/db/migrate/20160317144949_piece_justificative_have_user.rb
@@ -8,7 +8,6 @@ class PieceJustificativeHaveUser < ActiveRecord::Migration
end
class User < ActiveRecord::Base
-
end
def change
diff --git a/db/migrate/20160317153115_cerfa_have_user.rb b/db/migrate/20160317153115_cerfa_have_user.rb
index 7a0710901..a50cbf4c4 100644
--- a/db/migrate/20160317153115_cerfa_have_user.rb
+++ b/db/migrate/20160317153115_cerfa_have_user.rb
@@ -8,7 +8,6 @@ class CerfaHaveUser < ActiveRecord::Migration
end
class User < ActiveRecord::Base
-
end
def change
diff --git a/db/migrate/20160524093540_set_original_filename_for_uploaders.rb b/db/migrate/20160524093540_set_original_filename_for_uploaders.rb
index d9d6306c6..bf8e700f2 100644
--- a/db/migrate/20160524093540_set_original_filename_for_uploaders.rb
+++ b/db/migrate/20160524093540_set_original_filename_for_uploaders.rb
@@ -1,10 +1,8 @@
class SetOriginalFilenameForUploaders < ActiveRecord::Migration
class PieceJustificative < ActiveRecord::Base
-
end
class Cerfa < ActiveRecord::Base
-
end
def change
diff --git a/db/migrate/20160609145737_delete_default_description_to_dossier.rb b/db/migrate/20160609145737_delete_default_description_to_dossier.rb
index ded5122e7..8ba2fc7d9 100644
--- a/db/migrate/20160609145737_delete_default_description_to_dossier.rb
+++ b/db/migrate/20160609145737_delete_default_description_to_dossier.rb
@@ -1,18 +1,14 @@
class DeleteDefaultDescriptionToDossier < ActiveRecord::Migration
class Dossier < ActiveRecord::Base
-
end
class Champ < ActiveRecord::Base
-
end
class Procedure < ActiveRecord::Base
-
end
class TypeDeChamp < ActiveRecord::Base
-
end
def up
diff --git a/db/migrate/20160622081321_convert_all_datetime_to_date_on_database.rb b/db/migrate/20160622081321_convert_all_datetime_to_date_on_database.rb
index 7d6d09bd0..2c61b98c2 100644
--- a/db/migrate/20160622081321_convert_all_datetime_to_date_on_database.rb
+++ b/db/migrate/20160622081321_convert_all_datetime_to_date_on_database.rb
@@ -1,7 +1,5 @@
class ConvertAllDatetimeToDateOnDatabase < ActiveRecord::Migration
-
class TypeDeChamp < ActiveRecord::Base
-
end
def change
diff --git a/db/migrate/20160802113112_build_default_preference_list_dossier.rb b/db/migrate/20160802113112_build_default_preference_list_dossier.rb
index d5fad79a4..2a11ea8f0 100644
--- a/db/migrate/20160802113112_build_default_preference_list_dossier.rb
+++ b/db/migrate/20160802113112_build_default_preference_list_dossier.rb
@@ -1,10 +1,8 @@
class BuildDefaultPreferenceListDossier < ActiveRecord::Migration
class Gestionnaire < ActiveRecord::Base
def build_default_preferences_list_dossier
-
PreferenceListDossier.available_columns.each do |table|
table.second.each do |column|
-
if valid_couple_table_attr? table.first, column.first
PreferenceListDossier.create(
libelle: column.second[:libelle],
diff --git a/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb b/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb
index 01636f7c6..56120ef60 100644
--- a/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb
+++ b/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb
@@ -1,6 +1,5 @@
class FixDefaultTypeOnTypeDeChampTable < ActiveRecord::Migration
class TypeDeChamp < ActiveRecord::Base
-
end
def up
diff --git a/db/migrate/20160804130638_add_type_attr_in_champ_table.rb b/db/migrate/20160804130638_add_type_attr_in_champ_table.rb
index 465d9ce63..df21b33ea 100644
--- a/db/migrate/20160804130638_add_type_attr_in_champ_table.rb
+++ b/db/migrate/20160804130638_add_type_attr_in_champ_table.rb
@@ -1,5 +1,4 @@
class AddTypeAttrInChampTable < ActiveRecord::Migration
-
class TypeDeChamp < ActiveRecord::Base
has_many :champs
end
diff --git a/db/migrate/20160822142045_delete_value_of_filter_procedure.rb b/db/migrate/20160822142045_delete_value_of_filter_procedure.rb
index f541aefc9..30a12da5f 100644
--- a/db/migrate/20160822142045_delete_value_of_filter_procedure.rb
+++ b/db/migrate/20160822142045_delete_value_of_filter_procedure.rb
@@ -1,6 +1,5 @@
class DeleteValueOfFilterProcedure < ActiveRecord::Migration
- class Gestionnaire < ActiveRecord::Base
-
+ class Gestionnaire < ActiveRecord::Base
end
def change
diff --git a/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb b/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb
index 89e5f03cd..a2ccc89d9 100644
--- a/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb
+++ b/db/migrate/20160901082824_initiated_all_received_mail_for_procedure.rb
@@ -4,7 +4,6 @@ class InitiatedAllReceivedMailForProcedure < ActiveRecord::Migration
end
class MailTemplate < ActiveRecord::Base
-
end
class ::MailReceived < MailTemplate
diff --git a/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb b/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb
index a5905c8e2..e4203c62c 100644
--- a/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb
+++ b/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb
@@ -1,6 +1,5 @@
class ChangeEmptytoNilInPreferenceListDossierTable < ActiveRecord::Migration
class PreferenceListDossier < ActiveRecord::Base
-
end
def change
diff --git a/db/migrate/20161004175442_fix_type_de_champ_header_section_with_mandatory_true.rb b/db/migrate/20161004175442_fix_type_de_champ_header_section_with_mandatory_true.rb
index 945d4a910..23aec6f90 100644
--- a/db/migrate/20161004175442_fix_type_de_champ_header_section_with_mandatory_true.rb
+++ b/db/migrate/20161004175442_fix_type_de_champ_header_section_with_mandatory_true.rb
@@ -1,6 +1,5 @@
class FixTypeDeChampHeaderSectionWithMandatoryTrue < ActiveRecord::Migration
class TypeDeChamp < ActiveRecord::Base
-
end
def change
diff --git a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb
index b137b1d8f..137cf286b 100644
--- a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb
+++ b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb
@@ -96,10 +96,8 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration
has_many :procedures, through: :assign_to
def build_default_preferences_list_dossier procedure_id=nil
-
PreferenceListDossier.available_columns_for(procedure_id).each do |table|
table.second.each do |column|
-
if valid_couple_table_attr? table.first, column.first
PreferenceListDossier.create(
libelle: column.second[:libelle],
@@ -144,7 +142,6 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration
class Procedure < ActiveRecord::Base
has_many :assign_to, dependent: :destroy
has_many :gestionnaires, through: :assign_to
-
end
def change
diff --git a/db/migrate/20161221153929_create_notification.rb b/db/migrate/20161221153929_create_notification.rb
index 745086412..b6158499e 100644
--- a/db/migrate/20161221153929_create_notification.rb
+++ b/db/migrate/20161221153929_create_notification.rb
@@ -1,14 +1,12 @@
class CreateNotification < ActiveRecord::Migration[5.0]
def change
create_table :notifications do |t|
-
t.boolean :already_read, default: false
t.string :liste, array: true
t.boolean :multiple, default: false
t.string :type_notif
t.datetime :created_at
t.datetime :updated_at
-
end
add_belongs_to :notifications, :dossier
diff --git a/db/migrate/20170524140630_create_attestation_templates.rb b/db/migrate/20170524140630_create_attestation_templates.rb
new file mode 100644
index 000000000..6517c72ea
--- /dev/null
+++ b/db/migrate/20170524140630_create_attestation_templates.rb
@@ -0,0 +1,16 @@
+class CreateAttestationTemplates < ActiveRecord::Migration[5.0]
+ def change
+ create_table :attestation_templates do |t|
+ t.text :title
+ t.text :body
+ t.text :footer
+ t.string :logo
+ t.string :signature
+ t.boolean :activated
+
+ t.timestamps
+
+ t.references :procedure, index: { unique: true }, foreign_key: true
+ end
+ end
+end
diff --git a/db/migrate/20170530141608_add_motivation_to_dossier.rb b/db/migrate/20170530141608_add_motivation_to_dossier.rb
new file mode 100644
index 000000000..6ee802630
--- /dev/null
+++ b/db/migrate/20170530141608_add_motivation_to_dossier.rb
@@ -0,0 +1,5 @@
+class AddMotivationToDossier < ActiveRecord::Migration[5.0]
+ def change
+ add_column :dossiers, :motivation, :text
+ end
+end
diff --git a/db/migrate/20170601123221_create_attestations.rb b/db/migrate/20170601123221_create_attestations.rb
new file mode 100644
index 000000000..52bf54664
--- /dev/null
+++ b/db/migrate/20170601123221_create_attestations.rb
@@ -0,0 +1,11 @@
+class CreateAttestations < ActiveRecord::Migration[5.0]
+ def change
+ create_table :attestations do |t|
+ t.string :pdf
+ t.string :title
+ t.references :dossier, foreign_key: true, null: false
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20170627091953_add_published_at_to_procedure.rb b/db/migrate/20170627091953_add_published_at_to_procedure.rb
new file mode 100644
index 000000000..8f46123e5
--- /dev/null
+++ b/db/migrate/20170627091953_add_published_at_to_procedure.rb
@@ -0,0 +1,5 @@
+class AddPublishedAtToProcedure < ActiveRecord::Migration[5.0]
+ def change
+ add_column :procedures, :published_at, :datetime
+ end
+end
diff --git a/db/migrate/20170627120928_add_hidden_at_to_procedures.rb b/db/migrate/20170627120928_add_hidden_at_to_procedures.rb
new file mode 100644
index 000000000..a0c109597
--- /dev/null
+++ b/db/migrate/20170627120928_add_hidden_at_to_procedures.rb
@@ -0,0 +1,6 @@
+class AddHiddenAtToProcedures < ActiveRecord::Migration[5.0]
+ def change
+ add_column :procedures, :hidden_at, :datetime
+ add_index :procedures, :hidden_at
+ end
+end
diff --git a/db/migrate/20170627143701_add_archived_at_to_procedure.rb b/db/migrate/20170627143701_add_archived_at_to_procedure.rb
new file mode 100644
index 000000000..ba1bf7890
--- /dev/null
+++ b/db/migrate/20170627143701_add_archived_at_to_procedure.rb
@@ -0,0 +1,5 @@
+class AddArchivedAtToProcedure < ActiveRecord::Migration[5.0]
+ def change
+ add_column :procedures, :archived_at, :datetime
+ end
+end
diff --git a/db/migrate/20170627144046_add_hidden_at_to_dossiers.rb b/db/migrate/20170627144046_add_hidden_at_to_dossiers.rb
new file mode 100644
index 000000000..b70d02e69
--- /dev/null
+++ b/db/migrate/20170627144046_add_hidden_at_to_dossiers.rb
@@ -0,0 +1,6 @@
+class AddHiddenAtToDossiers < ActiveRecord::Migration[5.0]
+ def change
+ add_column :dossiers, :hidden_at, :datetime
+ add_index :dossiers, :hidden_at
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 81476287a..2b3bbab8c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170523092900) do
+ActiveRecord::Schema.define(version: 20170627144046) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -71,6 +71,28 @@ ActiveRecord::Schema.define(version: 20170523092900) do
t.index ["procedure_id"], name: "index_assign_tos_on_procedure_id", using: :btree
end
+ create_table "attestation_templates", force: :cascade do |t|
+ t.text "title"
+ t.text "body"
+ t.text "footer"
+ t.string "logo"
+ t.string "signature"
+ t.boolean "activated"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "procedure_id"
+ t.index ["procedure_id"], name: "index_attestation_templates_on_procedure_id", unique: true, using: :btree
+ end
+
+ create_table "attestations", force: :cascade do |t|
+ t.string "pdf"
+ t.string "title"
+ t.integer "dossier_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["dossier_id"], name: "index_attestations_on_dossier_id", using: :btree
+ end
+
create_table "avis", force: :cascade do |t|
t.string "email"
t.text "introduction"
@@ -152,6 +174,9 @@ ActiveRecord::Schema.define(version: 20170523092900) do
t.datetime "initiated_at"
t.datetime "received_at"
t.datetime "processed_at"
+ t.text "motivation"
+ t.datetime "hidden_at"
+ t.index ["hidden_at"], name: "index_dossiers_on_hidden_at", using: :btree
t.index ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
t.index ["user_id"], name: "index_dossiers_on_user_id", using: :btree
end
@@ -359,6 +384,10 @@ ActiveRecord::Schema.define(version: 20170523092900) do
t.boolean "for_individual", default: false
t.boolean "individual_with_siret", default: false
t.date "auto_archive_on"
+ t.datetime "hidden_at"
+ t.index ["hidden_at"], name: "index_procedures_on_hidden_at", using: :btree
+ t.datetime "published_at"
+ t.datetime "archived_at"
end
create_table "quartier_prioritaires", force: :cascade do |t|
@@ -448,6 +477,8 @@ ActiveRecord::Schema.define(version: 20170523092900) do
t.index ["procedure_id"], name: "index_without_continuation_mails_on_procedure_id", using: :btree
end
+ add_foreign_key "attestation_templates", "procedures"
+ add_foreign_key "attestations", "dossiers"
add_foreign_key "avis", "gestionnaires", column: "claimant_id"
add_foreign_key "cerfas", "dossiers"
add_foreign_key "closed_mails", "procedures"
diff --git a/doc/apipie_examples.json b/doc/apipie_examples.json
index 7010bc322..f67e5140d 100644
--- a/doc/apipie_examples.json
+++ b/doc/apipie_examples.json
@@ -50,6 +50,7 @@
"initiated_at": "2017-04-11T12:00:12.000Z",
"received_at": null,
"processed_at": null,
+ "motivation": null,
"accompagnateurs": [
"gestionnaire@apientreprise.fr"
],
diff --git a/lib/prawn/fonts/OpenSans-Regular.ttf b/lib/prawn/fonts/OpenSans-Regular.ttf
new file mode 100644
index 000000000..db433349b
Binary files /dev/null and b/lib/prawn/fonts/OpenSans-Regular.ttf differ
diff --git a/lib/tasks/cloud_storage.rake b/lib/tasks/cloud_storage.rake
index 92789fa65..06b8c836d 100644
--- a/lib/tasks/cloud_storage.rake
+++ b/lib/tasks/cloud_storage.rake
@@ -1,5 +1,4 @@
namespace :cloudstorage do
-
task init: :environment do
os_config = (YAML.load_file(Fog.credentials_path))['default']
@os = OpenStack::Connection.create(
@@ -91,7 +90,6 @@ namespace :cloudstorage do
}
end
-
desc 'Clear old documents in tenant'
task :clear do
Rake::Task['cloudstorage:init'].invoke
@@ -110,5 +108,4 @@ namespace :cloudstorage do
@cont.delete_object(object) unless last_modified.utc > (Time.now - 2.year).utc
}
end
-
end
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index 3373efb79..cd9f5eb23 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -1,6 +1,6 @@
namespace :dev do
desc 'Initialise dev environment'
- task :init do
+ task :init do
puts 'start initialisation'
Rake::Task['dev:generate_token_file'].invoke
Rake::Task['dev:generate_franceconnect_file'].invoke
@@ -10,10 +10,10 @@ namespace :dev do
puts 'end initialisation'
end
- task :generate_token_file do
+ task :generate_token_file do
puts 'creating token.rb file'
res = `rake secret`.gsub("\n", '')
- file = File.new('config/initializers/token.rb', 'w+')
+ file = File.new('config/initializers/token.rb', 'w+')
comment = < dossier_champs_first
- }} }
+ params: {
+ dossier_id: dossier.id,
+ champs: {
+ "'#{dossier.champs_private.first.id}'" => dossier_champs_first
+ }
+ }
+ }
before do
subject
diff --git a/spec/controllers/ban/search_controller_spec.rb b/spec/controllers/ban/search_controller_spec.rb
index e51ef2a52..7fe454e19 100644
--- a/spec/controllers/ban/search_controller_spec.rb
+++ b/spec/controllers/ban/search_controller_spec.rb
@@ -16,7 +16,6 @@ describe Ban::SearchController, type: :controller do
end
context 'when request return nothing', vcr: {cassette_name: 'bano_search_nothing'} do
-
let (:request) { 'je recherche pas grand chose' }
it { expect(response.status).to eq 200 }
diff --git a/spec/controllers/cgu_controller_spec.rb b/spec/controllers/cgu_controller_spec.rb
index c656c0ca1..710f6ddb2 100644
--- a/spec/controllers/cgu_controller_spec.rb
+++ b/spec/controllers/cgu_controller_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe CguController, type: :controller do
describe 'GET #index' do
-
subject { get :index }
it { expect(subject.status).to eq 200 }
diff --git a/spec/controllers/demo_controller_spec.rb b/spec/controllers/demo_controller_spec.rb
index 4411a2848..5e9ef92e9 100644
--- a/spec/controllers/demo_controller_spec.rb
+++ b/spec/controllers/demo_controller_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe DemoController, type: :controller do
describe 'GET #index' do
-
subject { get :index }
it { expect(subject.status).to eq 200 }
diff --git a/spec/controllers/france_connect/particulier_controller_spec.rb b/spec/controllers/france_connect/particulier_controller_spec.rb
index c0a6857b3..279f7b9ef 100644
--- a/spec/controllers/france_connect/particulier_controller_spec.rb
+++ b/spec/controllers/france_connect/particulier_controller_spec.rb
@@ -13,7 +13,7 @@ describe FranceConnect::ParticulierController, type: :controller do
let(:user_info) { Hashie::Mash.new(france_connect_particulier_id: france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, birthplace: birthplace, gender: gender, email: email, password: password) }
- describe '.login' do
+ describe '.auth' do
it 'redirect to france connect serveur' do
get :login
expect(response.status).to eq(302)
diff --git a/spec/controllers/gestionnaires/sessions_controller_spec.rb b/spec/controllers/gestionnaires/sessions_controller_spec.rb
index 6266e429f..9f8bc37d0 100644
--- a/spec/controllers/gestionnaires/sessions_controller_spec.rb
+++ b/spec/controllers/gestionnaires/sessions_controller_spec.rb
@@ -7,6 +7,7 @@ describe Gestionnaires::SessionsController, type: :controller do
describe '.demo' do
subject { get :demo }
+ render_views
context 'when rails env is production' do
before do
@@ -20,8 +21,9 @@ describe Gestionnaires::SessionsController, type: :controller do
it { expect(subject.status).to eq 200 }
it 'Gestionnaire demo is initiated' do
- expect(User).to receive(:new).with(email: 'gestionnaire@apientreprise.fr', password: 'password').and_return(Gestionnaire)
subject
+ expect(response.body).to have_css("input#user_email[value='gestionnaire@apientreprise.fr']")
+ expect(response.body).to have_css("input#user_password[value='password']")
end
end
end
diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb
index 9f6d38d81..9577aca7c 100644
--- a/spec/controllers/invites_controller_spec.rb
+++ b/spec/controllers/invites_controller_spec.rb
@@ -41,7 +41,6 @@ describe InvitesController, type: :controller do
it { expect(invite.user).to eq user }
it { expect(flash[:notice]).to be_present }
-
end
context 'when email is not assign to an user' do
diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb
new file mode 100644
index 000000000..0ec7b4bda
--- /dev/null
+++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe NewGestionnaire::DossiersController, type: :controller do
+ let(:gestionnaire) { create(:gestionnaire) }
+ before { sign_in(gestionnaire) }
+
+ describe 'attestation' do
+ context 'when a dossier has an attestation' do
+ let(:fake_pdf) { double(read: 'pdf content') }
+ let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
+ let!(:dossier) { create(:dossier, attestation: Attestation.new, procedure: procedure) }
+
+ it 'returns the attestation pdf' do
+ allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
+
+ expect(controller).to receive(:send_data)
+ .with('pdf content', filename: 'attestation.pdf', type: 'application/pdf') do
+ controller.render nothing: true
+ end
+
+ get :attestation, params: { procedure_id: procedure.id, dossier_id: dossier.id }
+ expect(response).to have_http_status(:success)
+ end
+ end
+ end
+end
diff --git a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb
new file mode 100644
index 000000000..ed8ac8fba
--- /dev/null
+++ b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe NewGestionnaire::GestionnaireController, type: :controller do
+ describe 'before actions: authenticate_gestionnaire!' do
+ it 'is present' do
+ before_actions = NewGestionnaire::GestionnaireController
+ ._process_action_callbacks
+ .find_all{|process_action_callbacks| process_action_callbacks.kind == :before}
+ .map(&:filter)
+
+ expect(before_actions).to include(:authenticate_gestionnaire!)
+ end
+ end
+end
+
diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb
new file mode 100644
index 000000000..fc7623488
--- /dev/null
+++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe NewGestionnaire::ProceduresController, type: :controller do
+ describe 'before_action: ensure_ownership!' do
+ it 'is present' do
+ before_actions = NewGestionnaire::ProceduresController
+ ._process_action_callbacks
+ .find_all{|process_action_callbacks| process_action_callbacks.kind == :before}
+ .map(&:filter)
+
+ expect(before_actions).to include(:ensure_ownership!)
+ end
+ end
+
+ describe 'ensure_ownership!' do
+ let(:gestionnaire) { create(:gestionnaire) }
+
+ before do
+ @controller.params[:procedure_id] = asked_procedure.id
+ expect(@controller).to receive(:current_gestionnaire).and_return(gestionnaire)
+ allow(@controller).to receive(:redirect_to)
+
+ @controller.send(:ensure_ownership!)
+ end
+
+ context 'when a gestionnaire asks for its procedure' do
+ let(:asked_procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
+
+ it 'does not redirects nor flash' do
+ expect(@controller).not_to have_received(:redirect_to)
+ expect(flash.alert).to eq(nil)
+ end
+ end
+
+ context 'when a gestionnaire asks for another procedure' do
+ let(:asked_procedure) { create(:procedure) }
+
+ it 'redirects and flash' do
+ expect(@controller).to have_received(:redirect_to).with(root_path)
+ expect(flash.alert).to eq("Vous n'avez pas accès à cette procédure")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb
new file mode 100644
index 000000000..b08d7d21d
--- /dev/null
+++ b/spec/controllers/new_user/dossiers_controller_spec.rb
@@ -0,0 +1,67 @@
+require 'spec_helper'
+
+describe NewUser::DossiersController, type: :controller do
+ let(:user) { create(:user) }
+
+ describe 'before_action: ensure_ownership!' do
+ it 'is present' do
+ before_actions = NewUser::DossiersController
+ ._process_action_callbacks
+ .find_all{|process_action_callbacks| process_action_callbacks.kind == :before}
+ .map(&:filter)
+
+ expect(before_actions).to include(:ensure_ownership!)
+ end
+ end
+
+ describe 'ensure_ownership!' do
+ let(:user) { create(:user) }
+
+ before do
+ @controller.params[:dossier_id] = asked_dossier.id
+ expect(@controller).to receive(:current_user).and_return(user)
+ allow(@controller).to receive(:redirect_to)
+
+ @controller.send(:ensure_ownership!)
+ end
+
+ context 'when a user asks for its dossier' do
+ let(:asked_dossier) { create(:dossier, user: user) }
+
+ it 'does not redirects nor flash' do
+ expect(@controller).not_to have_received(:redirect_to)
+ expect(flash.alert).to eq(nil)
+ end
+ end
+
+ context 'when a user asks for another dossier' do
+ let(:asked_dossier) { create(:dossier) }
+
+ it 'redirects and flash' do
+ expect(@controller).to have_received(:redirect_to).with(root_path)
+ expect(flash.alert).to eq("Vous n'avez pas accès à ce dossier")
+ end
+ end
+ end
+
+ describe 'attestation' do
+ before { sign_in(user) }
+
+ context 'when a dossier has an attestation' do
+ let(:fake_pdf) { double(read: 'pdf content') }
+ let!(:dossier) { create(:dossier, attestation: Attestation.new, user: user) }
+
+ it 'returns the attestation pdf' do
+ allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
+
+ expect(controller).to receive(:send_data)
+ .with('pdf content', filename: 'attestation.pdf', type: 'application/pdf') do
+ controller.render nothing: true
+ end
+
+ get :attestation, params: { dossier_id: dossier.id }
+ expect(response).to have_http_status(:success)
+ end
+ end
+ end
+end
diff --git a/spec/controllers/new_user/user_controller_spec.rb b/spec/controllers/new_user/user_controller_spec.rb
new file mode 100644
index 000000000..125466fb6
--- /dev/null
+++ b/spec/controllers/new_user/user_controller_spec.rb
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe NewUser::UserController, type: :controller do
+ describe 'before actions: authenticate_gestionnaire!' do
+ it 'is present' do
+ before_actions = NewUser::UserController
+ ._process_action_callbacks
+ .find_all{|process_action_callbacks| process_action_callbacks.kind == :before}
+ .map(&:filter)
+
+ expect(before_actions).to include(:authenticate_user!)
+ end
+ end
+end
diff --git a/spec/controllers/ping_controller_spec.rb b/spec/controllers/ping_controller_spec.rb
index 91a05ee16..1c723512c 100644
--- a/spec/controllers/ping_controller_spec.rb
+++ b/spec/controllers/ping_controller_spec.rb
@@ -2,13 +2,11 @@ require 'spec_helper'
describe PingController, type: :controller do
describe 'GET #index' do
-
subject { get :index }
it { expect(subject.status).to eq 200 }
context 'when base is un-plug' do
-
before do
allow(ActiveRecord::Base).to receive(:connected?).and_return(false)
end
diff --git a/spec/controllers/root_controller_spec.rb b/spec/controllers/root_controller_spec.rb
index 9b0b7ed56..4ea5e837b 100644
--- a/spec/controllers/root_controller_spec.rb
+++ b/spec/controllers/root_controller_spec.rb
@@ -57,14 +57,13 @@ describe RootController, type: :controller do
render_views
before do
- stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest").
- to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
+ stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest")
+ .to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
subject
end
it { expect(response.body).to have_css('.landing') }
-
end
context "unified login" do
@@ -78,5 +77,4 @@ describe RootController, type: :controller do
expect(response.body).to have_css("a[href='#{new_user_session_path}']")
end
end
-
end
diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb
index d574fde07..09ce7f38c 100644
--- a/spec/controllers/stats_controller_spec.rb
+++ b/spec/controllers/stats_controller_spec.rb
@@ -5,37 +5,69 @@ describe StatsController, type: :controller do
context "without a date attribute" do
before do
FactoryGirl.create(:procedure, :created_at => 6.months.ago)
- FactoryGirl.create(:procedure, :created_at => 45.days.ago)
- FactoryGirl.create(:procedure, :created_at => 1.days.ago)
- FactoryGirl.create(:procedure, :created_at => 1.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 62.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 62.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 31.days.ago)
+
+ @controller = StatsController.new
+
+ allow(@controller).to receive(:administration_signed_in?).and_return(false)
end
let (:association) { Procedure.all }
- subject { StatsController.new.send(:last_four_months_hash, association) }
+ subject { @controller.send(:last_four_months_hash, association) }
it { expect(subject).to eq([
- [I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1],
- [I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 2]
- ] ) }
+ [I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2],
+ [I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1]
+ ])
+ }
end
context "with a date attribute" do
before do
FactoryGirl.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago)
- FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 45.days.ago)
- FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 45.days.ago)
- FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 1.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago)
+ @controller = StatsController.new
+
+ allow(@controller).to receive(:administration_signed_in?).and_return(false)
end
let (:association) { Procedure.all }
- subject { StatsController.new.send(:last_four_months_hash, association, :updated_at) }
+ subject { @controller.send(:last_four_months_hash, association, :updated_at) }
it { expect(subject).to eq([
- [I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 2],
- [I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 1]
- ] ) }
+ [I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2],
+ [I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1]
+ ])
+ }
+ end
+
+ context "while a super admin is logged in" do
+ before do
+ FactoryGirl.create(:procedure, :created_at => 6.months.ago)
+ FactoryGirl.create(:procedure, :created_at => 45.days.ago)
+ FactoryGirl.create(:procedure, :created_at => 1.day.ago)
+ FactoryGirl.create(:procedure, :created_at => 1.day.ago)
+
+ @controller = StatsController.new
+
+ allow(@controller).to receive(:administration_signed_in?).and_return(true)
+ end
+
+ let (:association) { Procedure.all }
+
+ subject { @controller.send(:last_four_months_hash, association) }
+
+ it { expect(subject).to eq([
+ [I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1],
+ [I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 2]
+ ])
+ }
end
end
@@ -52,9 +84,10 @@ describe StatsController, type: :controller do
subject { StatsController.new.send(:cumulative_hash, association) }
it { expect(subject).to eq({
- 45.days.ago.beginning_of_month => 1,
- 15.days.ago.beginning_of_month => 3
- }) }
+ 45.days.ago.beginning_of_month => 1,
+ 15.days.ago.beginning_of_month => 3
+ })
+ }
end
context "with a date attribute" do
@@ -69,9 +102,10 @@ describe StatsController, type: :controller do
subject { StatsController.new.send(:cumulative_hash, association, :updated_at) }
it { expect(subject).to eq({
- 20.days.ago.beginning_of_month => 2,
- 10.days.ago.beginning_of_month => 3
- }) }
+ 20.days.ago.beginning_of_month => 2,
+ 10.days.ago.beginning_of_month => 3
+ })
+ }
end
end
@@ -263,4 +297,33 @@ describe StatsController, type: :controller do
it { is_expected.to match [[3.week.ago.to_i, 0], [2.week.ago.to_i, 0], [1.week.ago.to_i, 66.67]] }
end
+
+ describe '#motivation_usage_dossier' do
+ let!(:dossier) { create(:dossier, processed_at: 1.week.ago, motivation: "Motivation") }
+ let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
+ let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) }
+
+ before do
+ Timecop.freeze(Time.now)
+ end
+
+ subject { StatsController.new.send(:motivation_usage_dossier) }
+
+ it { expect(subject).to match([[I18n.l(3.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(2.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(1.week.ago.end_of_week, format: '%d/%m/%Y'), 33.33]]) }
+ end
+
+ describe '#motivation_usage_procedure' do
+ let!(:dossier) { create(:dossier, processed_at: 1.week.ago, motivation: "Motivation" ) }
+ let!(:dossier1) { create(:dossier, processed_at: 1.week.ago, motivation: "Motivation", procedure: dossier.procedure) }
+ let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
+ let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) }
+
+ before do
+ Timecop.freeze(Time.now)
+ end
+
+ subject { StatsController.new.send(:motivation_usage_procedure) }
+
+ it { expect(subject).to match([[I18n.l(3.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(2.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(1.week.ago.end_of_week, format: '%d/%m/%Y'), 33.33]]) }
+ end
end
diff --git a/spec/controllers/users/carte_controller_shared_example.rb b/spec/controllers/users/carte_controller_shared_example.rb
index 55d63d266..dff16acca 100644
--- a/spec/controllers/users/carte_controller_shared_example.rb
+++ b/spec/controllers/users/carte_controller_shared_example.rb
@@ -81,9 +81,9 @@ shared_examples 'carte_controller_spec' do
let(:module_api_carto) { create(:module_api_carto, :with_quartiers_prioritaires) }
before do
- allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter).
- to receive(:to_params).
- and_return({"QPCODE1234" => {:code => "QPCODE1234", :nom => "QP de test", :commune => "Paris", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}})
+ allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter)
+ .to receive(:to_params)
+ .and_return({"QPCODE1234" => {:code => "QPCODE1234", :nom => "QP de test", :commune => "Paris", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}})
post :save, params: {dossier_id: dossier.id, json_latlngs: json_latlngs}
end
@@ -128,9 +128,9 @@ shared_examples 'carte_controller_spec' do
let(:module_api_carto) { create(:module_api_carto, :with_cadastre) }
before do
- allow_any_instance_of(CARTO::SGMAP::Cadastre::Adapter).
- to receive(:to_params).
- and_return([{:surface_intersection => "0.0006", :surface_parcelle => 11252.692583090324, :numero => "0013", :feuille => 1, :section => "CD", :code_dep => "30", :nom_com => "Le Grau-du-Roi", :code_com => "133", :code_arr => "000", :geometry => {:type => "MultiPolygon", :coordinates => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]]}}])
+ allow_any_instance_of(CARTO::SGMAP::Cadastre::Adapter)
+ .to receive(:to_params)
+ .and_return([{:surface_intersection => "0.0006", :surface_parcelle => 11252.692583090324, :numero => "0013", :feuille => 1, :section => "CD", :code_dep => "30", :nom_com => "Le Grau-du-Roi", :code_com => "133", :code_arr => "000", :geometry => {:type => "MultiPolygon", :coordinates => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]]}}])
post :save, params: {dossier_id: dossier.id, json_latlngs: json_latlngs}
end
@@ -179,7 +179,6 @@ shared_examples 'carte_controller_spec' do
end
describe '#get_position' do
-
context 'when etablissement is nil' do
before do
dossier.update etablissement: nil
@@ -244,9 +243,9 @@ shared_examples 'carte_controller_spec' do
describe 'POST #get_qp' do
before do
- allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter).
- to receive(:to_params).
- and_return({"QPCODE1234" => {:code => "QPCODE1234", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}})
+ allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter)
+ .to receive(:to_params)
+ .and_return({"QPCODE1234" => {:code => "QPCODE1234", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}})
post :get_qp, params: {dossier_id: dossier.id, coordinates: coordinates}
end
diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb
index f74eb29b1..3d3a71114 100644
--- a/spec/controllers/users/description_controller_shared_example.rb
+++ b/spec/controllers/users/description_controller_shared_example.rb
@@ -87,7 +87,6 @@ shared_examples 'description_controller_spec' do
context 'when dossier does not have an enterprise datas' do
before do
-
end
it { expect(dossier.entreprise).to be_nil }
@@ -161,7 +160,8 @@ shared_examples 'description_controller_spec' do
context 'Quand la procédure accepte les CERFA' do
subject { post :update, params: {dossier_id: dossier_id,
- cerfa_pdf: cerfa_pdf} }
+ cerfa_pdf: cerfa_pdf}
+ }
it 'Notification interne is create' do
expect { subject }.to change(Notification, :count).by (1)
@@ -319,7 +319,8 @@ shared_examples 'description_controller_spec' do
subject { patch :pieces_justificatives, params: {dossier_id: dossier.id,
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
- 'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1} }
+ 'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
+ }
context 'when user is a guest' do
let(:guest) { create :user }
@@ -394,7 +395,8 @@ shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner
subject { patch :pieces_justificatives, params: {dossier_id: dossier.id,
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
- 'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1} }
+ 'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
+ }
context 'when user is the owner', vcr: {cassette_name: 'controllers_users_description_controller_pieces_justificatives'} do
before do
diff --git a/spec/controllers/users/dossiers/add_siret_controller_spec.rb b/spec/controllers/users/dossiers/add_siret_controller_spec.rb
index 45962c0fc..2481fd480 100644
--- a/spec/controllers/users/dossiers/add_siret_controller_spec.rb
+++ b/spec/controllers/users/dossiers/add_siret_controller_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe Users::Dossiers::AddSiretController, type: :controller do
describe '#GET show' do
-
let(:dossier) { create :dossier }
before do
diff --git a/spec/controllers/users/dossiers/commentaires_controller_spec.rb b/spec/controllers/users/dossiers/commentaires_controller_spec.rb
index f83943979..1fd067919 100644
--- a/spec/controllers/users/dossiers/commentaires_controller_spec.rb
+++ b/spec/controllers/users/dossiers/commentaires_controller_spec.rb
@@ -5,7 +5,6 @@ describe Users::Dossiers::CommentairesController, type: :controller do
let(:texte_commentaire) { 'Commentaire de test' }
describe '#POST create' do
-
subject {
post :create, params:{dossier_id: dossier.id, texte_commentaire: texte_commentaire}
dossier.reload
@@ -42,7 +41,6 @@ describe Users::Dossiers::CommentairesController, type: :controller do
expect(NotificationMailer).to_not receive(:new_answer)
subject
end
-
end
end
end
diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb
index 458db571f..abf8361a6 100644
--- a/spec/controllers/users/dossiers_controller_spec.rb
+++ b/spec/controllers/users/dossiers_controller_spec.rb
@@ -66,7 +66,6 @@ describe Users::DossiersController, type: :controller do
it { expect { subject }.to change(Dossier, :count).by 1 }
describe 'save user siret' do
-
context 'when user have not a saved siret' do
context 'when siret is present on request' do
subject { get :new, params: {procedure_id: procedure_id, siret: siret} }
@@ -349,7 +348,6 @@ describe Users::DossiersController, type: :controller do
end
it { expect(response.status).to eq 200 }
-
end
end
@@ -371,10 +369,10 @@ describe Users::DossiersController, type: :controller do
dossier.reload
end
- it { expect(dossier.individual.gender).to eq 'M.' }
- it { expect(dossier.individual.nom).to eq 'Julien' }
- it { expect(dossier.individual.prenom).to eq 'Xavier' }
- it { expect(dossier.individual.birthdate).to eq '20/01/1991' }
+ it { expect(dossier.individual.gender).to eq 'M.' }
+ it { expect(dossier.individual.nom).to eq 'Julien' }
+ it { expect(dossier.individual.prenom).to eq 'Xavier' }
+ it { expect(dossier.individual.birthdate).to eq '20/01/1991' }
it { expect(dossier.procedure.for_individual).to eq true }
end
@@ -456,7 +454,6 @@ describe Users::DossiersController, type: :controller do
it { expect { subject }.to change { Dossier.count }.by(0) }
end
-
end
describe 'PUT #change_siret' do
diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb
index 06b63f1ea..120e2e344 100644
--- a/spec/controllers/users/recapitulatif_controller_spec.rb
+++ b/spec/controllers/users/recapitulatif_controller_spec.rb
@@ -33,7 +33,6 @@ describe Users::RecapitulatifController, type: :controller do
it { is_expected.to redirect_to root_path }
end
end
-
end
describe 'POST #initiate' do
diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb
index e65f10a98..dd7d1add8 100644
--- a/spec/controllers/users/registrations_controller_spec.rb
+++ b/spec/controllers/users/registrations_controller_spec.rb
@@ -1,22 +1,19 @@
require 'spec_helper'
describe Users::RegistrationsController, type: :controller do
-
let(:email) { 'test@octo.com' }
let(:password) { 'password' }
- let(:user) { {email: email, password: password, password_confirmation: password} }
+ let(:user) { { email: email, password: password } }
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
describe '.create' do
- subject { post :create, params: {user: user }}
+ subject { post :create, params: { user: user } }
context 'when user is correct' do
- it { expect(described_class).to be < Devise::RegistrationsController }
-
it 'sends welcome email' do
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
expect(WelcomeMailer).to receive(:deliver_now!)
@@ -39,7 +36,7 @@ describe Users::RegistrationsController, type: :controller do
end
context 'when user is not correct' do
- let(:user) { {email: '', password: password, password_confirmation: password} }
+ let(:user) { { email: '', password: password } }
it 'not sends welcome email' do
expect(WelcomeMailer).not_to receive(:welcome_email)
diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb
index f3e0072b8..cc0570193 100644
--- a/spec/controllers/users/sessions_controller_spec.rb
+++ b/spec/controllers/users/sessions_controller_spec.rb
@@ -83,7 +83,6 @@ describe Users::SessionsController, type: :controller do
end
it 'signs user + gestionnaire + administrateur in' do
-
post :create, params: {user: {email: administrateur.email, password: administrateur.password}}
expect(@response.redirect?).to be(true)
expect(subject.current_user).to eq(user)
@@ -136,7 +135,6 @@ describe Users::SessionsController, type: :controller do
expect(user.loged_in_with_france_connect?).to be_falsey
end
-
context 'when user is connect with france connect particulier' do
let(:loged_in_with_france_connect) { 'particulier' }
@@ -201,7 +199,6 @@ describe Users::SessionsController, type: :controller do
expect(subject.current_administrateur).to be(nil)
end
end
-
end
end
diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/decorators/champ_decorator_spec.rb
index a5a2554a4..c0817e4b6 100644
--- a/spec/decorators/champ_decorator_spec.rb
+++ b/spec/decorators/champ_decorator_spec.rb
@@ -4,7 +4,6 @@ describe ChampDecorator do
let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: type_champ)}
let(:decorator) { champ.decorate }
-
describe 'value' do
subject { decorator.value }
diff --git a/spec/decorators/procedure_decorator_spec.rb b/spec/decorators/procedure_decorator_spec.rb
index 26540d80f..34ab7ceab 100644
--- a/spec/decorators/procedure_decorator_spec.rb
+++ b/spec/decorators/procedure_decorator_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe ProcedureDecorator do
- let(:procedure) { create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10)) }
+ let(:procedure) { create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10)) }
subject { procedure.decorate }
describe 'lien' do
@@ -25,5 +25,4 @@ describe ProcedureDecorator do
it { expect(subject.quartiers_prioritaires).to be_falsey }
it { expect(subject.cadastre).to be_falsey }
end
-
end
diff --git a/spec/decorators/procedures_decorator_spec.rb b/spec/decorators/procedures_decorator_spec.rb
index e298b1180..1ad516042 100644
--- a/spec/decorators/procedures_decorator_spec.rb
+++ b/spec/decorators/procedures_decorator_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe ProceduresDecorator do
-
before do
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
diff --git a/spec/decorators/type_de_champ_decorator_spec.rb b/spec/decorators/type_de_champ_decorator_spec.rb
index 88779c782..0a6ac784a 100644
--- a/spec/decorators/type_de_champ_decorator_spec.rb
+++ b/spec/decorators/type_de_champ_decorator_spec.rb
@@ -9,7 +9,6 @@ describe TypeDeChampDecorator do
let!(:type_de_champ_2) { create(:type_de_champ_public, procedure: procedure, order_place: 2) }
describe '#button_up' do
-
describe 'with first piece justificative' do
let(:index) { 0 }
subject { type_de_champ_0.decorate }
@@ -50,6 +49,4 @@ describe TypeDeChampDecorator do
end
end
end
-
-
end
diff --git a/spec/decorators/type_de_piece_justificative_decorator_spec.rb b/spec/decorators/type_de_piece_justificative_decorator_spec.rb
index f9b9d3a61..5503b68a0 100644
--- a/spec/decorators/type_de_piece_justificative_decorator_spec.rb
+++ b/spec/decorators/type_de_piece_justificative_decorator_spec.rb
@@ -9,7 +9,6 @@ describe TypeDePieceJustificativeDecorator do
let!(:type_de_piece_justificative_2) { create(:type_de_piece_justificative, procedure: procedure, order_place: 2) }
describe '#button_up' do
-
describe 'with first piece justificative' do
let(:index) { 0 }
subject { type_de_piece_justificative_0.decorate }
@@ -49,6 +48,4 @@ describe TypeDePieceJustificativeDecorator do
end
end
end
-
-
end
diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb
index 9352eecd6..1ea3a1a1e 100644
--- a/spec/facades/admin_procedures_show_facades_spec.rb
+++ b/spec/facades/admin_procedures_show_facades_spec.rb
@@ -20,7 +20,7 @@ describe AdminProceduresShowFacades do
describe '.dossiers' do
subject { super().dossiers }
- it { expect(subject.size).to eq(4) }
+ it { expect(subject.size).to eq(4) }
end
describe '.dossiers_for_pie_highchart' do
@@ -34,7 +34,7 @@ describe AdminProceduresShowFacades do
it { expect(subject.size).to eq(1) }
- it { expect(subject.first.state).to eq('initiated') }
+ it { expect(subject.first.state).to eq('initiated') }
it { expect(subject.first.total).to eq(1) }
end
diff --git a/spec/facades/dossiers_list_facades_spec.rb b/spec/facades/dossiers_list_facades_spec.rb
index 8713df086..08ca0c878 100644
--- a/spec/facades/dossiers_list_facades_spec.rb
+++ b/spec/facades/dossiers_list_facades_spec.rb
@@ -1,23 +1,24 @@
require 'spec_helper'
describe DossiersListFacades do
-
let(:gestionnaire) { create :gestionnaire }
let(:procedure) { create :procedure, libelle: 'Ma procédure' }
let(:procedure_2) { create :procedure, libelle: 'Ma seconde procédure' }
let!(:preference) { create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: nil,
- attr: 'state',
- attr_decorate: 'display_state' }
+ gestionnaire: gestionnaire,
+ table: nil,
+ attr: 'state',
+ attr_decorate: 'display_state'
+ }
let!(:preference_2) { create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: 'champs',
- attr: 'state',
- attr_decorate: 'display_state',
- procedure_id: procedure.id }
+ gestionnaire: gestionnaire,
+ table: 'champs',
+ attr: 'state',
+ attr_decorate: 'display_state',
+ procedure_id: procedure.id
+ }
before do
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
@@ -25,7 +26,6 @@ describe DossiersListFacades do
end
describe '#preference_list_dossiers_filter' do
-
subject { facade.preference_list_dossiers_filter }
context 'when procedure is not pasted at the facade' do
@@ -58,12 +58,13 @@ describe DossiersListFacades do
let(:facade) { described_class.new gestionnaire, 'nouveaux', procedure_2 }
let!(:preference) { create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: table,
- attr: 'state',
- attr_decorate: 'display_state',
- filter: filter,
- procedure_id: procedure_id }
+ gestionnaire: gestionnaire,
+ table: table,
+ attr: 'state',
+ attr_decorate: 'display_state',
+ filter: filter,
+ procedure_id: procedure_id
+ }
subject { facade.active_filter? preference }
@@ -99,12 +100,12 @@ describe DossiersListFacades do
before do
create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: 'champs',
- attr: 'state',
- attr_decorate: 'display_state',
- filter: 'plop',
- procedure_id: procedure_id
+ gestionnaire: gestionnaire,
+ table: 'champs',
+ attr: 'state',
+ attr_decorate: 'display_state',
+ filter: 'plop',
+ procedure_id: procedure_id
end
it { is_expected.to be_falsey }
diff --git a/spec/factories/attestation_template.rb b/spec/factories/attestation_template.rb
new file mode 100644
index 000000000..46eb4bee1
--- /dev/null
+++ b/spec/factories/attestation_template.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :attestation_template do
+ title 'title'
+ body 'body'
+ footer 'footer'
+ activated true
+ end
+end
diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb
index 3a2302f4c..630e787ba 100644
--- a/spec/factories/champ.rb
+++ b/spec/factories/champ.rb
@@ -1,6 +1,5 @@
FactoryGirl.define do
factory :champ do
-
type_de_champ { FactoryGirl.create(:type_de_champ_public) }
end
end
diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb
index 415e1d58d..f53eeb0f6 100644
--- a/spec/factories/dossier.rb
+++ b/spec/factories/dossier.rb
@@ -42,7 +42,6 @@ FactoryGirl.define do
trait :with_cerfa_upload do
after(:build) do |dossier, _evaluator|
-
dossier.cerfa << create(:cerfa)
end
end
diff --git a/spec/factories/drop_down_list.rb b/spec/factories/drop_down_list.rb
index 6b81511cf..0aeabf30d 100644
--- a/spec/factories/drop_down_list.rb
+++ b/spec/factories/drop_down_list.rb
@@ -1,5 +1,5 @@
FactoryGirl.define do
factory :drop_down_list do
- value ''
+ value "val1\r\nval2\r\n--separateur--\r\nval3"
end
end
diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb
index 9e0b76e7b..0f240362c 100644
--- a/spec/factories/procedure.rb
+++ b/spec/factories/procedure.rb
@@ -75,6 +75,14 @@ FactoryGirl.define do
end
end
+ trait :with_yes_no do
+ after(:build) do |procedure, _evaluator|
+ type_de_champ = create(:type_de_champ_public, :type_yes_no)
+
+ procedure.types_de_champ << type_de_champ
+ end
+ end
+
trait :with_two_type_de_piece_justificative do
after(:build) do |procedure, _evaluator|
rib = create(:type_de_piece_justificative, :rib, order_place: 1)
diff --git a/spec/factories/type_de_champ_private.rb b/spec/factories/type_de_champ_private.rb
index 408279d05..356028d91 100644
--- a/spec/factories/type_de_champ_private.rb
+++ b/spec/factories/type_de_champ_private.rb
@@ -5,5 +5,11 @@ FactoryGirl.define do
type_champ 'text'
order_place 1
mandatory false
+
+ trait :type_drop_down_list do
+ libelle 'Menu déroulant'
+ type_champ 'drop_down_list'
+ drop_down_list { create(:drop_down_list) }
+ end
end
end
diff --git a/spec/factories/type_de_champ_public.rb b/spec/factories/type_de_champ_public.rb
index b1ef85016..307ec2077 100644
--- a/spec/factories/type_de_champ_public.rb
+++ b/spec/factories/type_de_champ_public.rb
@@ -14,5 +14,16 @@ FactoryGirl.define do
libelle 'Référence autre dossier'
type_champ 'dossier_link'
end
+
+ trait :type_yes_no do
+ libelle 'Yes/no'
+ type_champ 'yes_no'
+ end
+
+ trait :type_drop_down_list do
+ libelle 'Menu déroulant'
+ type_champ 'drop_down_list'
+ drop_down_list { create(:drop_down_list) }
+ end
end
end
diff --git a/spec/factories/type_de_piece_justificative.rb b/spec/factories/type_de_piece_justificative.rb
index 36084ab39..76af4cf37 100644
--- a/spec/factories/type_de_piece_justificative.rb
+++ b/spec/factories/type_de_piece_justificative.rb
@@ -1,6 +1,5 @@
FactoryGirl.define do
factory :type_de_piece_justificative do
-
libelle 'RIB'
description 'Releve identité bancaire'
diff --git a/spec/features/admin/add_type_de_champ_spec.rb b/spec/features/admin/add_type_de_champ_spec.rb
index adbf661f9..77e0f446b 100644
--- a/spec/features/admin/add_type_de_champ_spec.rb
+++ b/spec/features/admin/add_type_de_champ_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'add a new type de champs', js: true do
-
let(:administrateur) { create(:administrateur) }
let(:procedure) { create(:procedure, administrateur: administrateur) }
diff --git a/spec/features/admin/connection_spec.rb b/spec/features/admin/connection_spec.rb
index 3966641c9..bb6205b84 100644
--- a/spec/features/admin/connection_spec.rb
+++ b/spec/features/admin/connection_spec.rb
@@ -5,8 +5,8 @@ feature 'Administrator connection' do
before do
visit new_administrateur_session_path
end
- scenario 'administrator is on admin loggin page' do
- expect(page).to have_css('#form-login.user_connexion_page')
+ scenario 'administrator is on sign in page' do
+ expect(page).to have_css('#new_user')
end
context "admin fills form and log in" do
@@ -30,8 +30,8 @@ feature 'Administrator connection' do
end
context 'when clicking on sign-out' do
before do
- stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest").
- to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
+ stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest")
+ .to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
page.find_by_id('sign-out').find('a.fa-sign-out').click
end
@@ -58,6 +58,5 @@ feature 'Administrator connection' do
end
end
end
-
end
end
diff --git a/spec/features/admin/procedure_cloning_spec.rb b/spec/features/admin/procedure_cloning_spec.rb
index 78e13045a..15530b161 100644
--- a/spec/features/admin/procedure_cloning_spec.rb
+++ b/spec/features/admin/procedure_cloning_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'As an administrateur I wanna clone a procedure', js: true do
-
let(:administrateur) { create(:administrateur) }
before do
@@ -10,7 +9,6 @@ feature 'As an administrateur I wanna clone a procedure', js: true do
end
context 'Cloning procedure' do
-
before 'Create procedure' do
page.find_by_id('new-procedure').click
fill_in 'procedure_libelle', with: 'libelle de la procedure'
diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb
index 8e14bd43a..987030e7c 100644
--- a/spec/features/admin/procedure_creation_spec.rb
+++ b/spec/features/admin/procedure_creation_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'As an administrateur I wanna create a new procedure', js: true do
-
let(:administrateur) { create(:administrateur) }
before do
@@ -10,7 +9,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
end
context 'Right after sign_in I shall see all procedure states links' do
-
scenario 'Finding draft procedures' do
page.find_by_id('draft-procedures').trigger('click')
expect(page).to have_current_path(admin_procedures_draft_path, only_path: true)
@@ -28,7 +26,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
end
context 'Creating a new procedure' do
-
scenario 'Finding new procedure link' do
page.find_by_id('new-procedure').click
expect(page).to have_current_path(new_admin_procedure_path, only_path: true)
diff --git a/spec/features/admin/procedure_locked_spec.rb b/spec/features/admin/procedure_locked_spec.rb
index 12961e56c..2a89232b0 100644
--- a/spec/features/admin/procedure_locked_spec.rb
+++ b/spec/features/admin/procedure_locked_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'procedure locked' do
-
let(:administrateur) { create(:administrateur) }
let(:published) { false }
let(:procedure) { create(:procedure, administrateur: administrateur, published: published) }
diff --git a/spec/features/backoffice/connection_spec.rb b/spec/features/backoffice/connection_spec.rb
index 603546fb5..10252b367 100644
--- a/spec/features/backoffice/connection_spec.rb
+++ b/spec/features/backoffice/connection_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
feature 'when gestionnaire come to /backoffice and is not authenticated' do
let(:procedure) { create(:procedure) }
- let!(:dossier) { create(:dossier, procedure: procedure) }
+ let!(:dossier) { create(:dossier, procedure: procedure) }
before do
visit backoffice_path
end
@@ -25,8 +25,8 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
- page.find_by_id(:user_email).set gestionnaire.email
- page.find_by_id(:user_password).set gestionnaire.password
+ page.find_by_id(:user_email).set gestionnaire.email
+ page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter'
end
scenario 'he is redirected to /backoffice' do
diff --git a/spec/features/backoffice/index_show_procedure_spec.rb b/spec/features/backoffice/index_show_procedure_spec.rb
index d24910eca..ef0eade1a 100644
--- a/spec/features/backoffice/index_show_procedure_spec.rb
+++ b/spec/features/backoffice/index_show_procedure_spec.rb
@@ -20,7 +20,6 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
end
context 'On index' do
-
scenario 'Switching between procedures' do
page.all('#procedure-list a').first.click
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_1.id.to_s), only_path: true)
diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb
index 9a36bf116..9e7ff7289 100644
--- a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb
+++ b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'usage of pref list dossier lateral panel', js: true do
-
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, administrateur: administrateur) }
diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb
index 9ed134a75..21f5e1801 100644
--- a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb
+++ b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'usage of pref list dossier lateral panel by procedure', js: true do
-
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, :with_type_de_champ, administrateur: administrateur) }
diff --git a/spec/features/backoffice/search_file_spec.rb b/spec/features/backoffice/search_file_spec.rb
index dc6baeb85..42ecf5655 100644
--- a/spec/features/backoffice/search_file_spec.rb
+++ b/spec/features/backoffice/search_file_spec.rb
@@ -39,8 +39,8 @@ feature 'search file on gestionnaire backoffice' do
end
context 'when terms input does return result' do
- let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
- let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
+ let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
+ let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
let(:terms) { dossier.entreprise.raison_sociale }
diff --git a/spec/features/description_page/upload_piece_justificative_spec.rb b/spec/features/description_page/upload_piece_justificative_spec.rb
index bd8cffc8a..25ccf4f75 100644
--- a/spec/features/description_page/upload_piece_justificative_spec.rb
+++ b/spec/features/description_page/upload_piece_justificative_spec.rb
@@ -9,7 +9,7 @@ feature 'user is on description page' do
visit users_dossier_description_path dossier
- within('#new-user') do
+ within('#new_user') do
page.find_by_id('user_email').set dossier.user.email
page.find_by_id('user_password').set dossier.user.password
page.click_on 'Se connecter'
diff --git a/spec/features/france_connect/france_connect_particulier_spec.rb b/spec/features/france_connect/france_connect_particulier_spec.rb
index 1ed8ca15f..720523714 100644
--- a/spec/features/france_connect/france_connect_particulier_spec.rb
+++ b/spec/features/france_connect/france_connect_particulier_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'France Connect Particulier Connexion' do
-
let(:code) { 'plop' }
let(:given_name) { 'titi' }
let(:family_name) { 'toto' }
@@ -17,16 +16,16 @@ feature 'France Connect Particulier Connexion' do
birthdate: birthdate,
birthplace: birthplace,
gender: gender,
- email: email) }
+ email: email)
+ }
context 'when user is on login page' do
-
before do
visit new_user_session_path
end
scenario 'link to France Connect is present' do
- expect(page).to have_css('a#btn-fcp')
+ expect(page).to have_css('a.login-with-fc')
end
context 'and click on france connect link' do
@@ -34,13 +33,14 @@ feature 'France Connect Particulier Connexion' do
context 'when authentification is ok' do
let(:france_connect_information) { create(:france_connect_information,
- france_connect_particulier_id: france_connect_particulier_id,
- given_name: given_name,
- family_name: family_name,
- birthdate: birthdate,
- birthplace: birthplace,
- gender: gender,
- email_france_connect: email) }
+ france_connect_particulier_id: france_connect_particulier_id,
+ given_name: given_name,
+ family_name: family_name,
+ birthdate: birthdate,
+ birthplace: birthplace,
+ gender: gender,
+ email_france_connect: email)
+ }
before do
allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code))
@@ -49,7 +49,7 @@ feature 'France Connect Particulier Connexion' do
context 'when is the first connexion' do
before do
- page.find_by_id('btn-fcp').click
+ page.find('.login-with-fc').click
end
scenario 'he is redirected to france connect particulier page' do
expect(page).to have_content('Nouvelle connexion')
@@ -70,7 +70,7 @@ feature 'France Connect Particulier Connexion' do
context 'when is not the first connexion' do
before do
create(:user, france_connect_information: france_connect_information)
- page.find_by_id('btn-fcp').click
+ page.find('.login-with-fc').click
end
scenario 'he is redirected to user dossiers page' do
@@ -83,11 +83,11 @@ feature 'France Connect Particulier Connexion' do
before do
allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
- page.find_by_id('btn-fcp').click
+ page.find('.login-with-fc').click
end
scenario 'he is redirected to login page' do
- expect(page).to have_css('a#btn-fcp')
+ expect(page).to have_css('a.login-with-fc')
end
scenario 'error message is displayed' do
diff --git a/spec/features/users/complete_demande_spec.rb b/spec/features/users/complete_demande_spec.rb
index 2f1eb1d42..26254c31b 100644
--- a/spec/features/users/complete_demande_spec.rb
+++ b/spec/features/users/complete_demande_spec.rb
@@ -12,14 +12,14 @@ feature 'user path for dossier creation' do
end
scenario 'he is redirected on login page' do
- expect(page).to have_css('#login-user')
- expect(page).to have_css('#logo_procedure')
- expect(page).to have_css('#titre-procedure')
+ expect(page).to have_css('#new_user')
+ expect(page).to have_css('.procedure-logos')
+ expect(page).to have_content(procedure.libelle)
end
context 'user sign_in' do
before do
- within('#new-user') do
+ within('#new_user') do
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
page.click_on 'Se connecter'
diff --git a/spec/features/users/dossier_edition_spec.rb b/spec/features/users/dossier_edition_spec.rb
index 5aca700d9..238a7c3d9 100644
--- a/spec/features/users/dossier_edition_spec.rb
+++ b/spec/features/users/dossier_edition_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'As a User I want to edit a dossier I own' do
-
let(:user) { create(:user) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, :with_dossier_link) }
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') }
@@ -12,7 +11,6 @@ feature 'As a User I want to edit a dossier I own' do
end
context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do
-
scenario 'After sign_in, I can see dossiers "à traiter" (default), and other indexes' do
expect(page.find('#a_traiter')['class'] ).to eq('active procedure-list-element')
page.find_by_id('brouillon').click
diff --git a/spec/features/users/dossier_index_spec.rb b/spec/features/users/dossier_index_spec.rb
index 913efcf79..dc696a9ad 100644
--- a/spec/features/users/dossier_index_spec.rb
+++ b/spec/features/users/dossier_index_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature 'As a User I want to sort and paginate dossiers', js: true do
-
let(:user) { create(:user) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual) }
@@ -21,7 +20,6 @@ feature 'As a User I want to sort and paginate dossiers', js: true do
end
context 'After sign_in, I can see my 51 dossiers on the index' do
-
scenario 'Using sort' do
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
@@ -50,5 +48,4 @@ feature 'As a User I want to sort and paginate dossiers', js: true do
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id).to_s)
end
end
-
end
diff --git a/spec/features/users/drawing_a_zone_with_freedraw_spec.rb b/spec/features/users/drawing_a_zone_with_freedraw_spec.rb
index 1ecc5a0ee..a7e54ce25 100644
--- a/spec/features/users/drawing_a_zone_with_freedraw_spec.rb
+++ b/spec/features/users/drawing_a_zone_with_freedraw_spec.rb
@@ -12,11 +12,11 @@ feature 'drawing a zone with freedraw' do
end
scenario 'he is redirected to login page' do
- expect(page).to have_css('#login-user')
+ expect(page).to have_css('#new_user')
end
scenario 'he logs in and he is redirected to carte page', vcr: { cassette_name: 'drawing_a_zone_with_freedraw_redirected_to_carte_page' } do
- within('#new-user') do
+ within('#new_user') do
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
page.click_on 'Se connecter'
@@ -49,7 +49,7 @@ feature 'drawing a zone with freedraw' do
end
scenario 'alert message is present' do
- expect(page).to have_content('Le status de votre dossier n\'autorise pas cette URL')
+ expect(page).to have_content('Le statut de votre dossier n\'autorise pas cette URL')
end
end
end
diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb
index 7a5236f12..6acdbfb50 100644
--- a/spec/features/users/list_dossiers_spec.rb
+++ b/spec/features/users/list_dossiers_spec.rb
@@ -11,7 +11,7 @@ describe 'user access to the list of his dossier' do
last_updated_dossier.update_column(:updated_at, "19/07/2052 15:35".to_time)
visit new_user_session_path
- within('#new-user') do
+ within('#new_user') do
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
page.click_on 'Se connecter'
diff --git a/spec/features/users/start_demande_spec.rb b/spec/features/users/start_demande_spec.rb
index a908412a8..f91c44214 100644
--- a/spec/features/users/start_demande_spec.rb
+++ b/spec/features/users/start_demande_spec.rb
@@ -11,11 +11,11 @@ feature 'user arrive on siret page' do
visit new_users_dossiers_path(procedure_id: procedure.id)
end
scenario 'he is redirected to login page' do
- expect(page).to have_css('#login-user')
+ expect(page).to have_css('#new_user')
end
context 'when he enter login information' do
before do
- within('#new-user') do
+ within('#new_user') do
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
page.click_on 'Se connecter'
diff --git a/spec/fixtures/black.png b/spec/fixtures/black.png
new file mode 100644
index 000000000..17f1d2ed7
Binary files /dev/null and b/spec/fixtures/black.png differ
diff --git a/spec/fixtures/white.png b/spec/fixtures/white.png
new file mode 100644
index 000000000..7d3a386a2
Binary files /dev/null and b/spec/fixtures/white.png differ
diff --git a/spec/lib/carto/geo_api/driver_spec.rb b/spec/lib/carto/geo_api/driver_spec.rb
index 417bf0ba9..4d13c15ca 100644
--- a/spec/lib/carto/geo_api/driver_spec.rb
+++ b/spec/lib/carto/geo_api/driver_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe Carto::GeoAPI::Driver do
-
describe '.regions', vcr: {cassette_name: 'geoapi_regions'} do
subject { described_class.regions }
@@ -18,7 +17,6 @@ describe Carto::GeoAPI::Driver do
subject { described_class.pays }
it { is_expected.to eq File.open('app/lib/carto/geo_api/pays.json').read }
-
end
describe 'departements_url' do
diff --git a/spec/lib/carto/sgmap/api_spec.rb b/spec/lib/carto/sgmap/api_spec.rb
index 1a383a96f..7825b9af7 100644
--- a/spec/lib/carto/sgmap/api_spec.rb
+++ b/spec/lib/carto/sgmap/api_spec.rb
@@ -5,10 +5,10 @@ describe CARTO::SGMAP::API do
subject { described_class.search_qp(geojson) }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search").
- with(:body => /.*/,
- :headers => {'Content-Type'=>'application/json'}).
- to_return(status: status, body: body)
+ stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search")
+ .with(:body => /.*/,
+ :headers => {'Content-Type'=>'application/json'})
+ .to_return(status: status, body: body)
end
context 'when geojson is empty' do
let(:geojson) { '' }
@@ -53,10 +53,10 @@ describe CARTO::SGMAP::API do
subject { described_class.search_cadastre(geojson) }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie").
- with(:body => /.*/,
- :headers => {'Content-Type'=>'application/json'}).
- to_return(status: status, body: body)
+ stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
+ .with(:body => /.*/,
+ :headers => {'Content-Type'=>'application/json'})
+ .to_return(status: status, body: body)
end
context 'when geojson is empty' do
let(:geojson) { '' }
diff --git a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb
index 134675d3a..96734e784 100644
--- a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb
+++ b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb
@@ -4,10 +4,10 @@ describe CARTO::SGMAP::Cadastre::Adapter do
subject { described_class.new(coordinates).to_params }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie").
- with(:body => /.*/,
- :headers => {'Content-Type' => 'application/json'}).
- to_return(status: status, body: body)
+ stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
+ .with(:body => /.*/,
+ :headers => {'Content-Type' => 'application/json'})
+ .to_return(status: status, body: body)
end
context 'coordinates are filled' do
@@ -31,7 +31,8 @@ describe CARTO::SGMAP::Cadastre::Adapter do
:code_dep,
:nom_com,
:code_com,
- :code_arr] }
+ :code_arr]
+ }
end
describe 'Attributes' do
diff --git a/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb b/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb
index f235dbf51..c72bbc04e 100644
--- a/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb
+++ b/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb
@@ -4,10 +4,10 @@ describe CARTO::SGMAP::QuartiersPrioritaires::Adapter do
subject { described_class.new(coordinates).to_params }
before do
- stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search").
- with(:body => /.*/,
- :headers => {'Content-Type' => 'application/json'}).
- to_return(status: status, body: body)
+ stub_request(:post, "https://apicarto.sgmap.fr/quartiers-prioritaires/search")
+ .with(:body => /.*/,
+ :headers => {'Content-Type' => 'application/json'})
+ .to_return(status: status, body: body)
end
context 'coordinates are filled' do
diff --git a/spec/mailers/avis_mailer_spec.rb b/spec/mailers/avis_mailer_spec.rb
index 83673e899..0d9820d32 100644
--- a/spec/mailers/avis_mailer_spec.rb
+++ b/spec/mailers/avis_mailer_spec.rb
@@ -9,6 +9,5 @@ RSpec.describe AvisMailer, type: :mailer do
it { expect(subject.subject).to eq("Donnez votre avis sur le dossier nº #{avis.dossier.id} (#{avis.dossier.procedure.libelle})") }
it { expect(subject.body).to include("Vous avez été invité par #{avis.claimant.email} à donner votre avis sur le dossier nº #{avis.dossier.id} de la procédure : #{avis.dossier.procedure.libelle}.") }
it { expect(subject.body).to include(avis.introduction) }
-
end
end
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index e9a66e4a7..9fcfba7bf 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -5,11 +5,25 @@ RSpec.describe NotificationMailer, type: :mailer do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }
let(:email) { instance_double('email', object_for_dossier: 'object', body_for_dossier: 'body') }
- let (:notifications_count_before) { Notification.count }
- subject { described_class.send_notification(dossier, email) }
+ let(:attestation) { nil }
+ let(:notifications_count_before) { Notification.count }
+
+ subject { described_class.send_notification(dossier, email, attestation) }
it { expect(subject.subject).to eq(email.object_for_dossier) }
it { expect(subject.body).to eq(email.body_for_dossier) }
+ it { expect(subject.attachments['attestation.pdf']).to eq(nil) }
+
+ context 'when an attestation is provided' do
+ let(:attestation) { 'attestation' }
+
+ it do
+ expect(subject.attachments['attestation.pdf'].content_type)
+ .to eq('application/pdf; filename=attestation.pdf')
+
+ expect(subject.attachments['attestation.pdf'].body).to eq('attestation')
+ end
+ end
it "creates a commentaire, which is not notified" do
described_class.send_notification(dossier, email).deliver_now
diff --git a/spec/mailers/previews/avis_mailer_preview.rb b/spec/mailers/previews/avis_mailer_preview.rb
index 55d153cd1..be78eae74 100644
--- a/spec/mailers/previews/avis_mailer_preview.rb
+++ b/spec/mailers/previews/avis_mailer_preview.rb
@@ -1,8 +1,6 @@
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
class AvisMailerPreview < ActionMailer::Preview
-
def avis_invitation
AvisMailer.avis_invitation(Avis.last)
end
-
end
diff --git a/spec/mailers/previews/notification_mailer_preview.rb b/spec/mailers/previews/notification_mailer_preview.rb
index 3cb6079a2..63691a2cd 100644
--- a/spec/mailers/previews/notification_mailer_preview.rb
+++ b/spec/mailers/previews/notification_mailer_preview.rb
@@ -1,7 +1,5 @@
class NotificationMailerPreview < ActionMailer::Preview
-
def send_notification
NotificationMailer.send_notification(Dossier.last, Dossier.last.procedure.initiated_mail_template)
end
-
end
diff --git a/spec/models/administrateur_spec.rb b/spec/models/administrateur_spec.rb
index 238c3376f..538417c55 100644
--- a/spec/models/administrateur_spec.rb
+++ b/spec/models/administrateur_spec.rb
@@ -33,7 +33,7 @@ describe Administrateur, type: :model do
describe 'generate_api_token' do
let(:token) { 'bullshit' }
let(:new_token) { 'pocket_master' }
- let!(:admin_1) { create(:administrateur, email: 'toto@tps.com', password: 'password', api_token: token) }
+ let!(:admin_1) { create(:administrateur, email: 'toto@tps.com', password: 'password', api_token: token) }
before do
allow(SecureRandom).to receive(:hex).and_return(token, new_token)
admin_1.renew_api_token
diff --git a/spec/models/attestation_spec.rb b/spec/models/attestation_spec.rb
new file mode 100644
index 000000000..5bf9e89f5
--- /dev/null
+++ b/spec/models/attestation_spec.rb
@@ -0,0 +1,23 @@
+RSpec.describe Attestation, type: :model do
+ describe 'emailable' do
+ let(:attestation) do
+ attestation = Attestation.new
+ expect(attestation).to receive(:pdf).and_return(double(size: size))
+ attestation
+ end
+
+ subject { attestation.emailable? }
+
+ context 'when the pdf size is acceptable' do
+ let(:size) { Attestation::MAX_SIZE_EMAILABLE }
+
+ it { is_expected.to be true }
+ end
+
+ context 'when the pdf size is unacceptable' do
+ let(:size) { Attestation::MAX_SIZE_EMAILABLE + 1 }
+
+ it { is_expected.to be false }
+ end
+ end
+end
diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb
new file mode 100644
index 000000000..6d7dffb7c
--- /dev/null
+++ b/spec/models/attestation_template_spec.rb
@@ -0,0 +1,259 @@
+describe AttestationTemplate, type: :model do
+ describe 'validate' do
+ let(:logo_size) { AttestationTemplate::FILE_MAX_SIZE_IN_MB.megabyte }
+ let(:signature_size) { AttestationTemplate::FILE_MAX_SIZE_IN_MB.megabyte }
+ let(:fake_logo) { double(AttestationTemplateImageUploader, file: double(size: logo_size)) }
+ let(:fake_signature) { double(AttestationTemplateImageUploader, file: double(size: signature_size)) }
+ let(:attestation_template) { AttestationTemplate.new }
+
+ before do
+ allow(attestation_template).to receive(:logo).and_return(fake_logo)
+ allow(attestation_template).to receive(:signature).and_return(fake_signature)
+ attestation_template.validate
+ end
+
+ subject { attestation_template.errors.details }
+
+ context 'when no files are present' do
+ let(:fake_logo) { nil }
+ let(:fake_signature) { nil }
+
+ it { is_expected.to match({}) }
+ end
+
+ context 'when the logo and the signature have the right size' do
+ it { is_expected.to match({}) }
+ end
+
+ context 'when the logo and the signature are too heavy' do
+ let(:logo_size) { AttestationTemplate::FILE_MAX_SIZE_IN_MB.megabyte + 1 }
+ let(:signature_size) { AttestationTemplate::FILE_MAX_SIZE_IN_MB.megabyte + 1 }
+
+ it do
+ expected = {
+ signature: [{ error: ' : vous ne pouvez pas charger une image de plus de 0,5 Mo' }],
+ logo: [{ error: ' : vous ne pouvez pas charger une image de plus de 0,5 Mo' }]
+ }
+
+ is_expected.to match(expected)
+ end
+ end
+ end
+
+ describe 'validates footer length' do
+ let(:attestation_template) { AttestationTemplate.new(footer: footer) }
+
+ subject do
+ attestation_template.validate
+ attestation_template.errors.details
+ end
+
+ context 'when the footer is too long' do
+ let(:footer) { 'a' * 191 }
+
+ it { is_expected.to match({ footer: [{ error: :too_long, count: 190 }] }) }
+ end
+ end
+
+ describe 'dup' do
+ before do
+ @logo = File.open('spec/fixtures/white.png')
+ @signature = File.open('spec/fixtures/black.png')
+ end
+
+ after do
+ @logo.close
+ @signature.close
+ subject.destroy
+ end
+
+ let(:attestation_template) { AttestationTemplate.create(attributes) }
+ subject { attestation_template.dup }
+
+ context 'with an attestation without images' do
+ let(:attributes) { { title: 't', body: 'b', footer: 'f', activated: true } }
+
+ it { is_expected.to have_attributes(attributes) }
+ it { is_expected.to have_attributes(id: nil) }
+ it { expect(subject.logo.file).to be_nil }
+ end
+
+ context 'with an attestation with images' do
+ let(:attributes) { { logo: @logo, signature: @signature } }
+
+ it { expect(subject.logo.file.file).not_to eq(attestation_template.logo.file.file) }
+ it { expect(subject.logo.file.read).to eq(attestation_template.logo.file.read) }
+
+ it { expect(subject.signature.file.file).not_to eq(attestation_template.signature.file.file) }
+ it { expect(subject.signature.file.read).to eq(attestation_template.signature.file.read) }
+ end
+ end
+
+ describe 'attestation_for' do
+ let(:procedure) do
+ create(:procedure,
+ types_de_champ: types_de_champ,
+ types_de_champ_private: types_de_champ_private,
+ for_individual: for_individual)
+ end
+ let(:for_individual) { false }
+ let(:individual) { nil }
+ let(:etablissement) { nil }
+ let(:entreprise) { create(:entreprise, etablissement: etablissement) }
+ let(:types_de_champ) { [] }
+ let(:types_de_champ_private) { [] }
+ let(:dossier) { create(:dossier, procedure: procedure, individual: individual, entreprise: entreprise) }
+ let(:template_title) { 'title' }
+ let(:template_body) { 'body' }
+ let(:attestation_template) do
+ AttestationTemplate.new(procedure: procedure,
+ title: template_title,
+ body: template_body,
+ logo: @logo,
+ signature: @signature)
+ end
+
+ before do
+ @logo = File.open('spec/fixtures/white.png')
+ @signature = File.open('spec/fixtures/black.png')
+ Timecop.freeze(Time.now)
+ end
+
+ after do
+ @logo.close
+ @signature.close
+ end
+
+ let(:view_args) do
+ original_new = ActionView::Base.method(:new)
+ arguments = nil
+
+ allow(ActionView::Base).to receive(:new) do |paths, args|
+ arguments = args
+ original_new.call(paths, args)
+ end
+
+ attestation_template.attestation_for(dossier)
+
+ arguments
+ end
+
+ let(:attestation) { attestation_template.attestation_for(dossier) }
+
+ it 'provides a pseudo file' do
+ expect(attestation.pdf.file).to exist
+ expect(attestation.pdf.filename).to eq('attestation')
+ end
+
+ context 'when the dossier and the procedure has an individual' do
+ let(:for_individual) { true }
+ let(:individual) { Individual.create(nom: 'nom', prenom: 'prenom', gender: 'Mme') }
+
+ context 'and the template title use the individual tags' do
+ let(:template_title) { '--civilité-- --nom-- --prénom--' }
+
+ it { expect(view_args[:title]).to eq('Mme nom prenom') }
+ end
+ end
+
+ context 'when the dossier and the procedure has an entreprise' do
+ let(:for_individual) { false }
+
+ context 'and the template title use the entreprise tags' do
+ let(:template_title) do
+ '--SIREN-- --numéro de TVA intracommunautaire-- --SIRET du siège social-- --raison sociale-- --adresse--'
+ end
+
+ let(:expected_title) do
+ "#{entreprise.siren} #{entreprise.numero_tva_intracommunautaire} #{entreprise.siret_siege_social} #{entreprise.raison_sociale} --adresse--"
+ end
+
+ it { expect(view_args[:title]).to eq(expected_title) }
+
+ context 'and the entreprise has a etablissement with an adresse' do
+ let(:etablissement) { create(:etablissement, adresse: 'adresse') }
+ let(:template_title) { '--adresse--' }
+
+ it { expect(view_args[:title]).to eq(etablissement.inline_adresse) }
+ end
+ end
+ end
+
+ context 'when the procedure has a type de champ named libelleA et libelleB' do
+ let(:types_de_champ) do
+ [create(:type_de_champ_public, libelle: 'libelleA'),
+ create(:type_de_champ_public, libelle: 'libelleB')]
+ end
+
+ context 'and the template title is nil' do
+ let(:template_title) { nil }
+
+ it { expect(view_args[:title]).to eq('') }
+ end
+
+ context 'and it is not used in the template title nor body' do
+ it { expect(view_args[:title]).to eq('title') }
+ it { expect(view_args[:body]).to eq('body') }
+ it { expect(view_args[:created_at]).to eq(Time.now) }
+ it { expect(view_args[:logo]).to eq(attestation_template.logo) }
+ it { expect(view_args[:signature]).to eq(attestation_template.signature) }
+ end
+
+ context 'and the are used in the template title and body' do
+ let(:template_title) { 'title --libelleA--' }
+ let(:template_body) { 'body --libelleB--' }
+
+ context 'and their value in the dossier are nil' do
+ it { expect(view_args[:title]).to eq('title ') }
+ end
+
+ context 'and their value in the dossier are not nil' do
+ before :each do
+ dossier.champs
+ .select { |champ| champ.libelle == 'libelleA' }
+ .first
+ .value = 'libelle1'
+
+ dossier.champs
+ .select { |champ| champ.libelle == 'libelleB' }
+ .first
+ .value = 'libelle2'
+ end
+
+ it { expect(view_args[:title]).to eq('title libelle1') }
+ it { expect(view_args[:body]).to eq('body libelle2') }
+ it { expect(attestation.title).to eq('title libelle1') }
+ end
+ end
+ end
+
+ context 'when the dossier has a motivation' do
+ let(:dossier) { create(:dossier, motivation: 'motivation') }
+
+ context 'and the title has some dossier tags' do
+ let(:template_title) { 'title --motivation-- --numéro du dossier--' }
+
+ it { expect(view_args[:title]).to eq("title motivation #{dossier.id}") }
+ end
+ end
+
+ context 'when the procedure has a type de champ prive named libelleA' do
+ let(:types_de_champ_private) { [create(:type_de_champ_private, libelle: 'libelleA')] }
+
+ context 'and the are used in the template title' do
+ let(:template_title) { 'title --libelleA--' }
+
+ context 'and its value in the dossier are not nil' do
+ before :each do
+ dossier.champs_private
+ .select { |champ| champ.libelle == 'libelleA' }
+ .first
+ .value = 'libelle1'
+ end
+
+ it { expect(view_args[:title]).to eq('title libelle1') }
+ end
+ end
+ end
+ end
+end
diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb
index ac668ee64..39a6e6794 100644
--- a/spec/models/dossier_spec.rb
+++ b/spec/models/dossier_spec.rb
@@ -262,7 +262,6 @@ describe Dossier do
it { is_expected.to eq 'replied' }
end
-
end
end
@@ -295,7 +294,6 @@ describe Dossier do
it { is_expected.to eq('replied') }
end
-
end
end
@@ -488,13 +486,13 @@ describe Dossier do
end
context 'when dossier is followed' do
- let(:procedure) { create(:procedure, :with_type_de_champ) }
+ let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
let(:gestionnaire) { create(:gestionnaire) }
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
let(:date1) { 1.day.ago }
let(:date2) { 1.hour.ago }
let(:date3) { 1.minute.ago }
- let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow], initiated_at: date1, received_at: date2, processed_at: date3) }
+ let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow], initiated_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") }
describe '#export_headers' do
subject { dossier.export_headers }
@@ -504,7 +502,11 @@ describe Dossier do
it { expect(subject).to include(:individual_nom) }
it { expect(subject).to include(:individual_prenom) }
it { expect(subject).to include(:individual_birthdate) }
- it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
+ it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
+ dossier.procedure.types_de_champ.count +
+ dossier.procedure.types_de_champ_private.count +
+ dossier.export_entreprise_data.count)
+ }
end
describe '#data_with_champs' do
@@ -520,21 +522,27 @@ describe Dossier do
it { expect(subject[7]).to eq(date2) }
it { expect(subject[8]).to eq(date3) }
it { expect(subject[9]).to be_a_kind_of(String) }
- it { expect(subject[10]).to be_nil }
+ it { expect(subject[10]).to be_a_kind_of(String) }
it { expect(subject[11]).to be_nil }
it { expect(subject[12]).to be_nil }
it { expect(subject[13]).to be_nil }
- it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
+ it { expect(subject[14]).to be_nil }
+ it { expect(subject[15]).to be_nil }
+ it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
+ dossier.procedure.types_de_champ.count +
+ dossier.procedure.types_de_champ_private.count +
+ dossier.export_entreprise_data.count)
+ }
context 'dossier for individual' do
let(:dossier_with_individual) { create(:dossier, :for_individual, user: user, procedure: procedure) }
subject { dossier_with_individual.data_with_champs }
- it { expect(subject[10]).to eq(dossier_with_individual.individual.gender) }
- it { expect(subject[11]).to eq(dossier_with_individual.individual.prenom) }
- it { expect(subject[12]).to eq(dossier_with_individual.individual.nom) }
- it { expect(subject[13]).to eq(dossier_with_individual.individual.birthdate) }
+ it { expect(subject[11]).to eq(dossier_with_individual.individual.gender) }
+ it { expect(subject[12]).to eq(dossier_with_individual.individual.prenom) }
+ it { expect(subject[13]).to eq(dossier_with_individual.individual.nom) }
+ it { expect(subject[14]).to eq(dossier_with_individual.individual.birthdate) }
end
end
@@ -550,12 +558,14 @@ describe Dossier do
dossier.initiated_at,
dossier.received_at,
dossier.processed_at,
+ "Motivation",
gestionnaire.email,
nil,
nil,
nil,
nil,
nil,
+ nil,
"44011762001530",
"true",
"4950Z",
@@ -661,7 +671,6 @@ describe Dossier do
it { expect(subject.second.type_de_champ.libelle).to eq 'type_2_2' }
it { expect(subject.last.type_de_champ.libelle).to eq 'type_2_3' }
end
-
end
describe '#ordered_champs_private' do
@@ -850,7 +859,6 @@ describe Dossier do
it_behaves_like 'dossier is processed', 'without_continuation'
end
-
end
describe '.downloadable' do
@@ -890,4 +898,51 @@ describe Dossier do
expect(ActionMailer::Base.deliveries.size).to eq(0)
end
end
+
+ describe '.build_attestation' do
+ let(:attestation_template) { nil }
+ let(:procedure) { create(:procedure, attestation_template: attestation_template) }
+
+ before :each do
+ dossier.next_step!('gestionnaire', 'close')
+ dossier.reload
+ end
+
+ context 'when the dossier is in received state ' do
+ let!(:dossier) { create(:dossier, procedure: procedure, state: :received) }
+
+ context 'when the procedure has no attestation' do
+ it { expect(dossier.attestation).to be_nil }
+ end
+
+ context 'when the procedure has an unactivated attestation' do
+ let(:attestation_template) { AttestationTemplate.new(activated: false) }
+
+ it { expect(dossier.attestation).to be_nil }
+ end
+
+ context 'when the procedure attached has an activated attestation' do
+ let(:attestation_template) { AttestationTemplate.new(activated: true) }
+
+ it { expect(dossier.attestation).not_to be_nil }
+ end
+ end
+ end
+
+ describe ".default_scope" do
+ let!(:dossier) { create(:dossier, hidden_at: hidden_at) }
+
+ context "when dossier is not hidden" do
+ let(:hidden_at) { nil }
+
+ it { expect(Dossier.count).to eq(1) }
+ it { expect(Dossier.all).to include(dossier) }
+ end
+
+ context "when dossier is hidden" do
+ let(:hidden_at) { 1.day.ago }
+
+ it { expect(Dossier.count).to eq(0) }
+ end
+ end
end
diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb
index 0455985fc..712e76d59 100644
--- a/spec/models/drop_down_list_spec.rb
+++ b/spec/models/drop_down_list_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe DropDownList do
-
describe 'database columns' do
it { is_expected.to have_db_column(:value) }
end
@@ -17,16 +16,17 @@ describe DropDownList do
Dév.Eco / Emploi
Cadre de vie / Urb.
Pilotage / Ingénierie
-" }
+"
+}
it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Dév.Eco / Emploi', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] }
context 'when one value is empty' do
let(:value) { "Cohésion sociale
-
Cadre de vie / Urb.
Pilotage / Ingénierie
-" }
+"
+}
it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] }
end
@@ -36,7 +36,8 @@ Pilotage / Ingénierie
let(:value) { "tip
--top--
--troupt--
-ouaich" }
+ouaich"
+}
it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) }
end
diff --git a/spec/models/etablissement_spec.rb b/spec/models/etablissement_spec.rb
index 6097cac9c..c89d5ec43 100644
--- a/spec/models/etablissement_spec.rb
+++ b/spec/models/etablissement_spec.rb
@@ -23,11 +23,16 @@ describe Etablissement do
end
describe '#geo_adresse' do
-
let(:etablissement) { create(:etablissement) }
subject { etablissement.geo_adresse }
it { is_expected.to eq '6 RUE RAOUL NORDLING IMMEUBLE BORA 92270 BOIS COLOMBES' }
end
+
+ describe '#inline_adresse' do
+ let(:etablissement) { create(:etablissement, nom_voie: 'green moon') }
+
+ it { expect(etablissement.inline_adresse).to eq '6 RUE green moon, IMMEUBLE BORA, 92270 BOIS COLOMBES' }
+ end
end
diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb
index fbfbfd76f..ba09804f2 100644
--- a/spec/models/gestionnaire_spec.rb
+++ b/spec/models/gestionnaire_spec.rb
@@ -103,7 +103,6 @@ describe Gestionnaire, type: :model do
subject { gestionnaire.follow? dossier.id }
context 'when gestionnaire follow a dossier' do
-
before do
create :follow, dossier_id: dossier.id, gestionnaire_id: gestionnaire.id
end
@@ -204,7 +203,8 @@ describe Gestionnaire, type: :model do
it { is_expected.to eq 0 }
it { expect(gestionnaire.follows.count).to eq 0 }
it { expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:inject)
- subject }
+ subject
+ }
end
context 'when gestionnaire follow any dossier into the procedure past in params' do
@@ -215,7 +215,8 @@ describe Gestionnaire, type: :model do
it { is_expected.to eq 0 }
it { expect(gestionnaire.follows.count).to eq 1 }
it { expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:inject)
- subject }
+ subject
+ }
end
context 'when gestionnaire follow a dossier with a notification into the procedure past in params' do
@@ -229,7 +230,8 @@ describe Gestionnaire, type: :model do
it { is_expected.to eq 1 }
it { expect(gestionnaire.follows.count).to eq 1 }
it { expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).to receive(:inject)
- subject }
+ subject
+ }
end
end
@@ -258,6 +260,15 @@ describe Gestionnaire, type: :model do
it { expect(AssignTo.where(gestionnaire: gestionnaire, procedure: procedure_3).count).to eq 0 }
it { is_expected.to be_nil }
end
+
+ context "when procedure is hidden clear procedure_filter" do
+ before do
+ gestionnaire.update_column :procedure_filter, procedure_3.id
+ procedure_3.hide!
+ end
+
+ it { is_expected.to be_nil }
+ end
end
end
@@ -363,14 +374,6 @@ describe Gestionnaire, type: :model do
context 'when the gestionnaire has no notifications' do
it { is_expected.to eq(nil) }
end
-
- context 'when the gestionnaire has one notification' do
- before :each do
- expect(gestionnaire2).to receive(:notifications).twice.and_return([1])
- end
-
- it { is_expected.to eq({ start_date: monday, procedure_overviews: [], notifications: [1] }) }
- end
end
context 'when a procedure published was active' do
diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb
index 29b53f41a..e6c637d69 100644
--- a/spec/models/invite_spec.rb
+++ b/spec/models/invite_spec.rb
@@ -32,7 +32,6 @@ describe Invite do
end
it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid }
-
end
end
end
diff --git a/spec/models/piece_justificative_spec.rb b/spec/models/piece_justificative_spec.rb
index 70abcb299..62da2cd96 100644
--- a/spec/models/piece_justificative_spec.rb
+++ b/spec/models/piece_justificative_spec.rb
@@ -13,7 +13,6 @@ describe PieceJustificative do
it { is_expected.to belong_to(:type_de_piece_justificative) }
it { is_expected.to belong_to(:user) }
it { is_expected.to have_one(:commentaire) }
-
end
describe 'validations' do
diff --git a/spec/models/preference_list_dossier_spec.rb b/spec/models/preference_list_dossier_spec.rb
index cba6265a3..9ddb467f5 100644
--- a/spec/models/preference_list_dossier_spec.rb
+++ b/spec/models/preference_list_dossier_spec.rb
@@ -190,7 +190,6 @@ describe PreferenceListDossier do
it { expect(subject[:order]).to be_nil }
it { expect(subject[:filter]).to be_nil }
end
-
end
describe 'etablissement' do
diff --git a/spec/models/procedure_overview_spec.rb b/spec/models/procedure_overview_spec.rb
index defe51345..2ab2f8c9d 100644
--- a/spec/models/procedure_overview_spec.rb
+++ b/spec/models/procedure_overview_spec.rb
@@ -9,14 +9,36 @@ describe ProcedureOverview, type: :model do
Timecop.freeze(friday)
end
- let(:procedure_overview) { ProcedureOverview.new(procedure, monday, 0) }
+ let(:procedure_overview) { ProcedureOverview.new(procedure, monday) }
- describe 'received_dossiers_count' do
- let!(:received_dossier) do
- dossier = create(:dossier, procedure: procedure, state: :received, created_at: monday)
+ describe 'dossiers_en_instruction_count' do
+ let!(:en_instruction_dossier) do
+ create(:dossier, procedure: procedure, state: :received, created_at: monday)
end
- it { expect(procedure_overview.received_dossiers_count).to eq(1) }
+ it { expect(procedure_overview.dossiers_en_instruction_count).to eq(1) }
+ end
+
+ describe 'old_dossiers_en_instruction' do
+ let!(:old_dossier_en_instruction) do
+ create(:dossier, procedure: procedure, state: :received, received_at: monday - 1.month)
+ end
+
+ let!(:dossier_en_instruction) do
+ create(:dossier, procedure: procedure, state: :received, received_at: monday)
+ end
+
+ it do
+ expect(procedure_overview.old_dossiers_en_instruction).to match([old_dossier_en_instruction])
+ end
+ end
+
+ describe 'dossiers_en_construction_count' do
+ let!(:dossier_en_construction) do
+ create(:dossier, procedure: procedure, state: :initiated, created_at: monday)
+ end
+
+ it { expect(procedure_overview.dossiers_en_construction_count).to eq(1) }
end
describe 'created_dossiers_count' do
@@ -35,53 +57,32 @@ describe ProcedureOverview, type: :model do
it { expect(procedure_overview.created_dossiers_count).to eq(1) }
end
- describe 'processed_dossiers_count' do
- let!(:processed_dossier_during_the_week) do
- create(:dossier, procedure: procedure, created_at: monday, processed_at: monday)
+ describe 'had_some_activities?' do
+ subject { procedure_overview.had_some_activities? }
+
+ before :each do
+ procedure_overview.dossiers_en_instruction_count = 0
+ procedure_overview.dossiers_en_construction_count = 0
+ procedure_overview.created_dossiers_count = 0
end
- let!(:processed_dossier_before_the_week) do
- create(:dossier, procedure: procedure, created_at: (monday - 1.week), processed_at: (monday - 1.week))
+ context 'when there are no activities' do
+ it { is_expected.to be false }
end
- it { expect(procedure_overview.processed_dossiers_count).to eq(1) }
- end
-
- describe 'to_html' do
- subject { procedure_overview.to_html }
-
- context 'when the different count are equal to 0' do
- it { is_expected.to match(/^libelle<\/strong><\/a>$/) }
+ context 'when there are some dossiers en instruction' do
+ before { procedure_overview.dossiers_en_instruction_count = 2 }
+ it { is_expected.to be true }
end
- context 'when the different counts are equal to 1' do
- before :each do
- procedure_overview.notifications_count = 1
- procedure_overview.received_dossiers_count = 1
- procedure_overview.created_dossiers_count = 1
- procedure_overview.processed_dossiers_count = 1
- end
-
- it { is_expected.to match(/^libelle<\/strong><\/a>/) }
- it { is_expected.to include("1 dossier est en cours d'instruction") }
- it { is_expected.to include('1 nouveau dossier a été déposé') }
- it { is_expected.to include('1 dossier a été instruit') }
- it { is_expected.to include('1 notification en attente sur les dossiers que vous suivez') }
+ context 'when there are some dossiers en construction' do
+ before { procedure_overview.dossiers_en_construction_count = 2 }
+ it { is_expected.to be true }
end
- context 'when the different counts are equal to 2' do
- before :each do
- procedure_overview.notifications_count = 2
- procedure_overview.received_dossiers_count = 3
- procedure_overview.created_dossiers_count = 4
- procedure_overview.processed_dossiers_count = 5
- end
-
- it { is_expected.to match(/^libelle<\/strong><\/a>/) }
- it { is_expected.to include("3 dossiers sont en cours d'instruction") }
- it { is_expected.to include('4 nouveaux dossiers ont été déposés') }
- it { is_expected.to include('5 dossiers ont été instruits') }
- it { is_expected.to include('2 notifications en attente sur les dossiers que vous suivez') }
+ context 'when there are some created dossiers' do
+ before { procedure_overview.created_dossiers_count = 2 }
+ it { is_expected.to be true }
end
end
end
diff --git a/spec/models/procedure_path_spec.rb b/spec/models/procedure_path_spec.rb
index dfb268291..6f4565fd3 100644
--- a/spec/models/procedure_path_spec.rb
+++ b/spec/models/procedure_path_spec.rb
@@ -46,5 +46,4 @@ describe ProcedurePath do
end
end
end
-
end
diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb
index a9e3f2185..cf31199ae 100644
--- a/spec/models/procedure_spec.rb
+++ b/spec/models/procedure_spec.rb
@@ -147,12 +147,25 @@ describe Procedure do
let(:procedure) { create(:procedure, archived: archived, published: published, received_mail: received_mail) }
let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) }
+ let!(:type_de_champ_2) { create(:type_de_champ_public, :type_drop_down_list, procedure: procedure, order_place: 2) }
let!(:type_de_champ_private_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) }
let!(:type_de_champ_private_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) }
+ let!(:type_de_champ_private_2) { create(:type_de_champ_private, :type_drop_down_list, procedure: procedure, order_place: 2) }
let!(:piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) }
let!(:piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
let(:received_mail){ create(:received_mail) }
+ before do
+ @logo = File.open('spec/fixtures/white.png')
+ @signature = File.open('spec/fixtures/black.png')
+ @attestation_template = create(:attestation_template, procedure: procedure, logo: @logo, signature: @signature)
+ end
+
+ after do
+ @logo.close
+ @signature.close
+ end
+
subject { procedure.clone }
it 'should duplicate specific objects with different id' do
@@ -163,6 +176,8 @@ describe Procedure do
expect(subject.types_de_piece_justificative.size).to eq procedure.types_de_piece_justificative.size
expect(subject.types_de_champ.size).to eq procedure.types_de_champ.size
expect(subject.types_de_champ_private.size).to eq procedure.types_de_champ_private.size
+ expect(subject.types_de_champ.map(&:drop_down_list).compact.size).to eq procedure.types_de_champ.map(&:drop_down_list).compact.size
+ expect(subject.types_de_champ_private.map(&:drop_down_list).compact.size).to eq procedure.types_de_champ_private.map(&:drop_down_list).compact.size
subject.types_de_champ.zip(procedure.types_de_champ).each do |stc, ptc|
expect(stc).to have_same_attributes_as(ptc)
@@ -176,6 +191,7 @@ describe Procedure do
expect(stc).to have_same_attributes_as(ptc)
end
+ expect(subject.attestation_template.title).to eq(procedure.attestation_template.title)
end
it 'should duplicate existing mail_templates' do
@@ -207,44 +223,47 @@ describe Procedure do
end
end
- describe 'publish' do
- let(:procedure) { create(:procedure, :published) }
- let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
+ describe '#publish!' do
+ let(:procedure) { create(:procedure) }
+ let(:now) { Time.now.beginning_of_minute }
- it 'is available from a valid path' do
- expect(procedure.path).to match(/fake_path/)
- expect(procedure.published).to be_truthy
+ before do
+ Timecop.freeze(now)
+ procedure.publish!("example-path")
end
- it 'is correctly set in ProcedurePath table' do
- expect(ProcedurePath.where(path: procedure.path).count).to eq(1)
- expect(procedure_path.procedure_id).to eq(procedure.id)
- expect(procedure_path.administrateur_id).to eq(procedure.administrateur_id)
+ it { expect(procedure.published).to eq(true) }
+ it { expect(procedure.archived).to eq(false) }
+ it { expect(procedure.published_at).to eq(now) }
+ it { expect(ProcedurePath.find_by_path("example-path")).to be }
+ it { expect(ProcedurePath.find_by_path("example-path").procedure).to eq(procedure) }
+ it { expect(ProcedurePath.find_by_path("example-path").administrateur).to eq(procedure.administrateur) }
+
+ after do
+ Timecop.return
end
end
describe 'archive' do
let(:procedure) { create(:procedure, :published) }
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
+ let(:now) { Time.now.beginning_of_minute }
before do
+ Timecop.freeze(now)
procedure.archive
procedure.reload
end
- it 'is not available from a valid path anymore' do
- expect(procedure.path).to eq procedure_path.path
- expect(procedure.published).to be_truthy
- expect(procedure.archived).to be_truthy
- end
+ it { expect(procedure.published).to be_truthy }
+ it { expect(procedure.archived).to be_truthy }
+ it { expect(procedure.archived_at).to eq(now) }
- it 'is not in ProcedurePath table anymore' do
- expect(ProcedurePath.where(path: procedure.path).count).to eq(1)
- expect(ProcedurePath.find_by_procedure_id(procedure.id)).not_to be_nil
+ after do
+ Timecop.return
end
end
describe 'total_dossier' do
-
let(:procedure) { create :procedure }
before do
@@ -293,4 +312,40 @@ describe Procedure do
it { is_expected.to eq('a-long-libelle-with-accents-blabla-coucou-hello-un') }
end
+
+ describe ".default_scope" do
+ let!(:procedure) { create(:procedure, hidden_at: hidden_at) }
+
+ context "when hidden_at is nil" do
+ let(:hidden_at) { nil }
+
+ it { expect(Procedure.count).to eq(1) }
+ it { expect(Procedure.all).to include(procedure) }
+ end
+
+ context "when hidden_at is not nil" do
+ let(:hidden_at) { 2.days.ago }
+
+ it { expect(Procedure.count).to eq(0) }
+ it { expect { Procedure.find(procedure.id) }.to raise_error(ActiveRecord::RecordNotFound) }
+ end
+ end
+
+ describe "#hide!" do
+ let(:procedure) { create(:procedure) }
+ let!(:dossier) { create(:dossier, procedure: procedure) }
+ let!(:dossier2) { create(:dossier, procedure: procedure) }
+
+ it { expect(Dossier.count).to eq(2) }
+ it { expect(Dossier.all).to include(dossier, dossier2) }
+
+ context "when hidding procedure" do
+ before do
+ procedure.hide!
+ end
+
+ it { expect(procedure.dossiers.count).to eq(0) }
+ it { expect(Dossier.count).to eq(0) }
+ end
+ end
end
diff --git a/spec/models/quartier_prioritaire_spec.rb b/spec/models/quartier_prioritaire_spec.rb
index 30c52cd47..6295ad74e 100644
--- a/spec/models/quartier_prioritaire_spec.rb
+++ b/spec/models/quartier_prioritaire_spec.rb
@@ -9,7 +9,6 @@ describe QuartierPrioritaire do
it { is_expected.to belong_to(:dossier) }
describe 'geometry' do
-
let(:qp) { create :quartier_prioritaire, geometry: qp_geometry }
let(:qp_geometry) { File.open('spec/support/files/qp_geometry_value.txt').read }
diff --git a/spec/models/siret_spec.rb b/spec/models/siret_spec.rb
index 3b81bf51b..c5d197660 100644
--- a/spec/models/siret_spec.rb
+++ b/spec/models/siret_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe Siret, type: :model do
-
let(:valid_siret) { '41816609600051' }
let(:invalid_siret) { '111111111' }
diff --git a/spec/models/type_de_champ_shared_example.rb b/spec/models/type_de_champ_shared_example.rb
index c1b37a8f6..3ed2e0f0c 100644
--- a/spec/models/type_de_champ_shared_example.rb
+++ b/spec/models/type_de_champ_shared_example.rb
@@ -43,7 +43,6 @@ shared_examples 'type_de_champ_spec' do
end
describe 'field_for_list?' do
-
let(:type_de_champ_yes) { create :type_de_champ_public, type_champ: 'text' }
let(:type_de_champ_no_1) { create :type_de_champ_public, type_champ: 'textarea' }
let(:type_de_champ_no_2) { create :type_de_champ_public, type_champ: 'header_section' }
diff --git a/spec/models/type_de_champ_spec.rb b/spec/models/type_de_champ_spec.rb
index 702b8d64f..e7eb763f5 100644
--- a/spec/models/type_de_champ_spec.rb
+++ b/spec/models/type_de_champ_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe TypeDeChamp do
-
require 'models/type_de_champ_shared_example'
it_should_behave_like "type_de_champ_spec"
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 8cac2f476..552d42bca 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -16,7 +16,6 @@ describe User, type: :model do
it { is_expected.to have_db_column(:updated_at) }
it { is_expected.to have_db_column(:siret) }
it { is_expected.to have_db_column(:loged_in_with_france_connect) }
-
end
describe 'associations' do
it { is_expected.to have_many(:dossiers) }
diff --git a/spec/serializers/dossier_table_export_serializer_spec.rb b/spec/serializers/dossier_table_export_serializer_spec.rb
index 3373ecbed..0dcd1598e 100644
--- a/spec/serializers/dossier_table_export_serializer_spec.rb
+++ b/spec/serializers/dossier_table_export_serializer_spec.rb
@@ -1,9 +1,7 @@
require 'spec_helper'
describe DossierTableExportSerializer do
-
describe '#emails_accompagnateurs' do
-
let(:gestionnaire){ create(:gestionnaire) }
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
@@ -28,7 +26,5 @@ describe DossierTableExportSerializer do
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
end
-
end
-
end
diff --git a/spec/services/accompagnateur_service_spec.rb b/spec/services/accompagnateur_service_spec.rb
index 0d01b9f29..ae6fbb016 100644
--- a/spec/services/accompagnateur_service_spec.rb
+++ b/spec/services/accompagnateur_service_spec.rb
@@ -1,15 +1,13 @@
require 'spec_helper'
describe AccompagnateurService do
-
let(:procedure) { create :procedure }
let(:accompagnateur) { create :gestionnaire }
let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to}
describe '#change_assignement!' do
-
- subject { accompagnateur_service.change_assignement! }
+ subject { accompagnateur_service.change_assignement! }
context 'when accompagnateur is not assign at the procedure' do
let(:to) { AccompagnateurService::ASSIGN }
@@ -34,7 +32,6 @@ describe AccompagnateurService do
end
describe '#build_default_column' do
-
subject { accompagnateur_service.build_default_column }
context 'when to is not assign' do
diff --git a/spec/services/dossiers_list_gestionnaire_service_spec.rb b/spec/services/dossiers_list_gestionnaire_service_spec.rb
index d45293868..3af0796b9 100644
--- a/spec/services/dossiers_list_gestionnaire_service_spec.rb
+++ b/spec/services/dossiers_list_gestionnaire_service_spec.rb
@@ -24,7 +24,6 @@ describe DossiersListGestionnaireService do
end
context 'when gestionnaire have default sort' do
-
before do
preference_attr.update_column(:order, 'asc')
end
@@ -49,7 +48,8 @@ describe DossiersListGestionnaireService do
let(:order) { 'desc' }
let(:select_preference_list_dossier) { gestionnaire.preference_list_dossiers
- .find_by(table: table, attr: attr, procedure: nil) }
+ .find_by(table: table, attr: attr, procedure: nil)
+ }
subject { DossiersListGestionnaireService.new(gestionnaire, liste).change_sort! param_sort }
@@ -73,7 +73,6 @@ describe DossiersListGestionnaireService do
it { expect(select_preference_list_dossier.order).to eq 'desc' }
end
-
end
context 'when procedure as already a preference order' do
@@ -99,7 +98,8 @@ describe DossiersListGestionnaireService do
let(:filter_value) { 'plop' }
let(:select_preference_list_dossier) { gestionnaire.preference_list_dossiers
- .find_by(table: table, attr: attr, procedure: nil) }
+ .find_by(table: table, attr: attr, procedure: nil)
+ }
subject { described_class.new(gestionnaire, liste).add_filter new_filter }
@@ -126,7 +126,6 @@ describe DossiersListGestionnaireService do
end
describe '#join_filter' do
-
subject { DossiersListGestionnaireService.new(gestionnaire, liste, nil).joins_filter }
it { is_expected.to eq []}
@@ -178,7 +177,6 @@ describe DossiersListGestionnaireService do
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%plop%'" }
context 'when last filter caractere is *' do
-
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
@@ -231,16 +229,15 @@ describe DossiersListGestionnaireService do
context 'when preference list contain a champ' do
before do
create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: 'champs',
- attr: '34',
- attr_decorate: '',
- filter: 'plop',
- procedure_id: create(:procedure)
+ gestionnaire: gestionnaire,
+ table: 'champs',
+ attr: '34',
+ attr_decorate: '',
+ filter: 'plop',
+ procedure_id: create(:procedure)
end
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%plop%' AND champs.type_de_champ_id = 34 AND CAST(champs.value as TEXT) LIKE '%plop%'" }
-
end
end
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 6a6cc4762..6368b3eb7 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe NotificationService do
-
describe '.notify' do
let(:dossier) { create :dossier }
let(:service) { described_class.new type_notif, dossier.id }
diff --git a/spec/services/previsualisation_service_spec.rb b/spec/services/previsualisation_service_spec.rb
index 81f84e5ab..64bd03735 100644
--- a/spec/services/previsualisation_service_spec.rb
+++ b/spec/services/previsualisation_service_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe PrevisualisationService do
-
describe '.destroy_all_champs' do
subject { described_class.destroy_all_champs dossier }
diff --git a/spec/services/user_routes_authorization_service_spec.rb b/spec/services/user_routes_authorization_service_spec.rb
index 231e4685b..4bbb7d825 100644
--- a/spec/services/user_routes_authorization_service_spec.rb
+++ b/spec/services/user_routes_authorization_service_spec.rb
@@ -43,7 +43,6 @@ describe UserRoutesAuthorizationService do
let(:controller) { Users::CarteController }
context 'when use_api_carto is false' do
-
describe 'draft' do
let(:state) { 'draft' }
it { is_expected.to be_falsey }
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
index 96483dbb3..fba37f056 100644
--- a/spec/support/database_cleaner.rb
+++ b/spec/support/database_cleaner.rb
@@ -1,5 +1,4 @@
RSpec.configure do |config|
-
expect_list = %w()
config.before(:suite) do
@@ -14,7 +13,6 @@ RSpec.configure do |config|
DatabaseCleaner.strategy = :truncation, { except: expect_list }
end
-
config.before(:each) do
DatabaseCleaner.start
end
diff --git a/spec/uploaders/base_uploader_spec.rb b/spec/uploaders/base_uploader_spec.rb
index d3c9b1f2e..10b0033b0 100644
--- a/spec/uploaders/base_uploader_spec.rb
+++ b/spec/uploaders/base_uploader_spec.rb
@@ -4,7 +4,6 @@ describe BaseUploader do
let(:uploader) { described_class.new }
describe '#cache_dir' do
-
subject { uploader.cache_dir }
context 'when rails env is not production' do
diff --git a/spec/uploaders/remote_downloader_spec.rb b/spec/uploaders/remote_downloader_spec.rb
index 0f0629ee3..1eee1d6c2 100644
--- a/spec/uploaders/remote_downloader_spec.rb
+++ b/spec/uploaders/remote_downloader_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe RemoteDownloader do
-
let(:filename) { 'file_name.pdf' }
subject { described_class.new filename }
diff --git a/spec/views/admin/accompagnateurs/show.html.haml_spec.rb b/spec/views/admin/accompagnateurs/show.html.haml_spec.rb
index 4593795ec..231b6f05a 100644
--- a/spec/views/admin/accompagnateurs/show.html.haml_spec.rb
+++ b/spec/views/admin/accompagnateurs/show.html.haml_spec.rb
@@ -12,14 +12,14 @@ describe 'admin/accompagnateurs/show.html.haml', type: :view do
assign(:gestionnaire, Gestionnaire.new)
assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign,
- assign_gestionnaires,
- partial: "admin/accompagnateurs/list_assign",
- array: true))
+ assign_gestionnaires,
+ partial: "admin/accompagnateurs/list_assign",
+ array: true))
assign(:accompagnateurs_not_assign, (smart_listing_create :accompagnateurs_not_assign,
- not_assign_gestionnaires,
- partial: "admin/accompagnateurs/list_not_assign",
- array: true))
+ not_assign_gestionnaires,
+ partial: "admin/accompagnateurs/list_not_assign",
+ array: true))
end
context 'when admin have none accompagnateur ' do
@@ -43,14 +43,14 @@ describe 'admin/accompagnateurs/show.html.haml', type: :view do
assign_gestionnaires.reload
assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign,
- assign_gestionnaires,
- partial: "admin/accompagnateurs/list_assign",
- array: true))
+ assign_gestionnaires,
+ partial: "admin/accompagnateurs/list_assign",
+ array: true))
assign(:accompagnateurs_not_assign, (smart_listing_create :accompagnateurs_not_assign,
- not_assign_gestionnaires,
- partial: "admin/accompagnateurs/list_not_assign",
- array: true))
+ not_assign_gestionnaires,
+ partial: "admin/accompagnateurs/list_not_assign",
+ array: true))
render
end
diff --git a/spec/views/admin/gestionnaires/index.html.haml_spec.rb b/spec/views/admin/gestionnaires/index.html.haml_spec.rb
index 7f8820abd..be3014619 100644
--- a/spec/views/admin/gestionnaires/index.html.haml_spec.rb
+++ b/spec/views/admin/gestionnaires/index.html.haml_spec.rb
@@ -6,9 +6,9 @@ describe 'admin/gestionnaires/index.html.haml', type: :view do
before do
assign(:gestionnaires, (smart_listing_create :gestionnaires,
- admin.gestionnaires,
- partial: "admin/gestionnaires/list",
- array: true))
+ admin.gestionnaires,
+ partial: "admin/gestionnaires/list",
+ array: true))
assign(:gestionnaire, Gestionnaire.new())
end
@@ -24,9 +24,9 @@ describe 'admin/gestionnaires/index.html.haml', type: :view do
create(:gestionnaire, administrateurs: [admin])
admin.reload
assign(:gestionnaires, (smart_listing_create :gestionnaires,
- admin.gestionnaires,
- partial: "admin/gestionnaires/list",
- array: true))
+ admin.gestionnaires,
+ partial: "admin/gestionnaires/list",
+ array: true))
render
end
it { expect(rendered).to match(/gest\d+@gest.com/) }
diff --git a/spec/views/admin/previsualisations/show.html.haml_spec.rb b/spec/views/admin/previsualisations/show.html.haml_spec.rb
index cfed1dd02..0677ee177 100644
--- a/spec/views/admin/previsualisations/show.html.haml_spec.rb
+++ b/spec/views/admin/previsualisations/show.html.haml_spec.rb
@@ -65,8 +65,7 @@ describe 'admin/previsualisations/show.html.haml', type: :view do
context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do
let!(:dossier) do
- create(:dossier,
- user: user)
+ create(:dossier, user: user)
end
before do
@@ -128,6 +127,5 @@ describe 'admin/previsualisations/show.html.haml', type: :view do
context 'when dossier not have cerfa, piece justificative and demarche link' do
it { expect(rendered).not_to have_content 'Documents administratifs' }
end
-
end
end
diff --git a/spec/views/admin/procedures/show.html.haml_spec.rb b/spec/views/admin/procedures/show.html.haml_spec.rb
index d974cac37..714b5151d 100644
--- a/spec/views/admin/procedures/show.html.haml_spec.rb
+++ b/spec/views/admin/procedures/show.html.haml_spec.rb
@@ -23,7 +23,6 @@ describe 'admin/procedures/show.html.haml', type: :view do
end
context 'when procedure have a gestionnare affected' do
-
before do
create :assign_to, gestionnaire: create(:gestionnaire), procedure: procedure
render
@@ -76,7 +75,5 @@ describe 'admin/procedures/show.html.haml', type: :view do
describe 'procedure link is present' do
it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) }
end
-
end
-
end
diff --git a/spec/views/admin/types_de_champ/show.html.haml_spec.rb b/spec/views/admin/types_de_champ/show.html.haml_spec.rb
index acac3297a..1921dd9f6 100644
--- a/spec/views/admin/types_de_champ/show.html.haml_spec.rb
+++ b/spec/views/admin/types_de_champ/show.html.haml_spec.rb
@@ -43,7 +43,7 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) }
it { expect(subject).to have_css('#btn_down_0') }
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
- it { expect(subject).to have_css('#btn_up_1') }
+ it { expect(subject).to have_css('#btn_up_1') }
it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
end
end
diff --git a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb
index 510224e9c..36dce5ecc 100644
--- a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb
+++ b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb
@@ -51,7 +51,7 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
let!(:type_de_champ_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) }
it { expect(subject).to have_css('#btn_down_0') }
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
- it { expect(subject).to have_css('#btn_up_1') }
+ it { expect(subject).to have_css('#btn_up_1') }
it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
end
end
diff --git a/spec/views/admin/types_de_piece_justificative/show.html.haml_spec.rb b/spec/views/admin/types_de_piece_justificative/show.html.haml_spec.rb
index 73b1be675..ced3d0e9f 100644
--- a/spec/views/admin/types_de_piece_justificative/show.html.haml_spec.rb
+++ b/spec/views/admin/types_de_piece_justificative/show.html.haml_spec.rb
@@ -41,7 +41,7 @@ describe 'admin/pieces_justificatives/show.html.haml', type: :view do
let!(:type_de_piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
it { expect(subject).to have_css('#btn_down_0') }
it { expect(subject).not_to have_css('#btn_up_0') }
- it { expect(subject).to have_css('#btn_up_1') }
+ it { expect(subject).to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
end
end
diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb
index 4951907d1..307fa0113 100644
--- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb
+++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb
@@ -29,28 +29,28 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: nil,
- attr: 'state',
- attr_decorate: 'display_state'
+ gestionnaire: gestionnaire,
+ table: nil,
+ attr: 'state',
+ attr_decorate: 'display_state'
create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: 'procedure',
- attr: 'libelle',
- attr_decorate: 'libelle'
+ gestionnaire: gestionnaire,
+ table: 'procedure',
+ attr: 'libelle',
+ attr_decorate: 'libelle'
create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: 'entreprise',
- attr: 'raison_sociale',
- attr_decorate: 'raison_sociale'
+ gestionnaire: gestionnaire,
+ table: 'entreprise',
+ attr: 'raison_sociale',
+ attr_decorate: 'raison_sociale'
create :preference_list_dossier,
- gestionnaire: gestionnaire,
- table: nil,
- attr: 'last_update',
- attr_decorate: 'last_update'
+ gestionnaire: gestionnaire,
+ table: nil,
+ attr: 'last_update',
+ attr_decorate: 'last_update'
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
sign_in gestionnaire
@@ -58,19 +58,19 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
assign :facade_data_view, dossiers_list_facade
assign(:new_dossiers, (smart_listing_create :new_dossiers,
- new_dossiers_list,
- partial: "backoffice/dossiers/list",
- array: true))
+ new_dossiers_list,
+ partial: "backoffice/dossiers/list",
+ array: true))
assign(:follow_dossiers, (smart_listing_create :follow_dossiers,
- follow_dossiers_list,
- partial: "backoffice/dossiers/list",
- array: true))
+ follow_dossiers_list,
+ partial: "backoffice/dossiers/list",
+ array: true))
assign(:all_state_dossiers, (smart_listing_create :all_state_dossiers,
- all_state_dossiers_list,
- partial: "backoffice/dossiers/list",
- array: true))
+ all_state_dossiers_list,
+ partial: "backoffice/dossiers/list",
+ array: true))
render
end
diff --git a/spec/views/backoffice/dossiers/show.html.html_spec.rb b/spec/views/backoffice/dossiers/show.html.html_spec.rb
index 865cb28ef..0be7ed6f9 100644
--- a/spec/views/backoffice/dossiers/show.html.html_spec.rb
+++ b/spec/views/backoffice/dossiers/show.html.html_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe 'backoffice/dossiers/show.html.haml', type: :view do
- let!(:dossier) { create(:dossier, :with_entreprise, state: state) }
- let(:state) { 'draft' }
+ let!(:dossier) { create(:dossier, :with_entreprise, state: state, motivation: "Motivation de décision") }
+ let(:state) { 'closed' }
let(:dossier_id) { dossier.id }
let(:gestionnaire) { create(:gestionnaire) }
@@ -44,5 +44,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
expect(rendered).to_not have_css('#maj_infos')
end
end
+
+ it "shows the motivation" do
+ expect(rendered).to have_content("Motivation de décision")
+ end
end
end
diff --git a/spec/views/dossiers/_infos_dossier_spec.rb b/spec/views/dossiers/_infos_dossier_spec.rb
index ed6c1e76f..ff7af8d36 100644
--- a/spec/views/dossiers/_infos_dossier_spec.rb
+++ b/spec/views/dossiers/_infos_dossier_spec.rb
@@ -1,25 +1,71 @@
require 'spec_helper'
describe 'dossiers/_infos_dossier.html.haml', type: :view do
- let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
+ describe "champs rendering" do
+ let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
- before do
- champs.each do |champ|
- champ.value = ((0...8).map { (65 + rand(26)).chr }.join)
- champ.save
+ before do
+ champs.each do |champ|
+ champ.value = ((0...8).map { (65 + rand(26)).chr }.join)
+ champ.save
+ end
+
+ assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
+ render
end
- assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
- render
+ describe 'every champs are present on the page' do
+ let(:champs) { dossier.champs }
+
+ it { expect(rendered).to have_content(champs.first.libelle) }
+ it { expect(rendered).to have_content(champs.first.value) }
+
+ it { expect(rendered).to have_content(champs.last.libelle) }
+ it { expect(rendered).to have_content(champs.last.value) }
+ end
end
- describe 'every champs are present on the page' do
- let(:champs) { dossier.champs }
+ describe "oui_non champ rendering" do
+ let(:dossier_with_yes_no) { create(:dossier, procedure: create(:procedure, :with_yes_no)) }
- it { expect(rendered).to have_content(champs.first.libelle) }
- it { expect(rendered).to have_content(champs.first.value) }
+ context "with the true value" do
+ before do
+ oui_non_champ = dossier_with_yes_no.champs.first
+ oui_non_champ.value = 'true'
+ oui_non_champ.save
- it { expect(rendered).to have_content(champs.last.libelle) }
- it { expect(rendered).to have_content(champs.last.value) }
+ assign(:facade, DossierFacades.new(dossier_with_yes_no.id, dossier_with_yes_no.user.email))
+ render
+ end
+
+ it { expect(rendered).to have_content("Oui") }
+ end
+
+ context "with the false value" do
+ before do
+ oui_non_champ = dossier_with_yes_no.champs.first
+ oui_non_champ.value = 'false'
+ oui_non_champ.save
+
+ assign(:facade, DossierFacades.new(dossier_with_yes_no.id, dossier_with_yes_no.user.email))
+ render
+ end
+
+ it { expect(rendered).to have_content("Non") }
+ end
+
+ context "with no value" do
+ before do
+ oui_non_champ = dossier_with_yes_no.champs.first
+ oui_non_champ.value = nil
+ oui_non_champ.save
+
+ assign(:facade, DossierFacades.new(dossier_with_yes_no.id, dossier_with_yes_no.user.email))
+ render
+ end
+
+ it { expect(rendered).not_to have_content("Oui") }
+ it { expect(rendered).not_to have_content("Non") }
+ end
end
end
diff --git a/spec/views/layouts/_navbar_spec.rb b/spec/views/layouts/_navbar_spec.rb
index a23f67cae..448456d4f 100644
--- a/spec/views/layouts/_navbar_spec.rb
+++ b/spec/views/layouts/_navbar_spec.rb
@@ -7,7 +7,6 @@ describe 'layouts/_navbar.html.haml', type: :view do
let!(:procedure) { create(:procedure, administrateur: administrateur) }
describe 'navbar entries' do
-
context 'when disconnected' do
before do
render
@@ -39,6 +38,5 @@ describe 'layouts/_navbar.html.haml', type: :view do
subject { rendered }
it { is_expected.to match(/Déconnexion/) }
end
-
end
end
diff --git a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb
index 308acb09c..4682bb331 100644
--- a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb
+++ b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml', type: :view do
-
let!(:dossier) { create(:dossier, :with_entreprise, state: state, archived: archived) }
let(:state) { 'draft' }
let(:archived) { false }
@@ -25,7 +24,6 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
end
context 'button dossier state changements' do
-
shared_examples 'button Passer en instruction is present' do
it { expect(rendered).to have_link('Passer en instruction') }
end
@@ -76,9 +74,9 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('En instruction') }
it 'button accepter / refuser / classer sans suite are present' do
- expect(rendered).to have_css('a[title="Accepter"]')
- expect(rendered).to have_css('a[title="Classer sans suite"]')
- expect(rendered).to have_css('a[title="Refuser"]')
+ expect(rendered).to have_css('button[title="Accepter"]')
+ expect(rendered).to have_css('button[title="Classer sans suite"]')
+ expect(rendered).to have_css('button[title="Refuser"]')
end
end
@@ -149,8 +147,6 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('Archivé') }
it { expect(rendered).to have_link('Désarchiver') }
-
end
end
-
end
diff --git a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb
index 7996e3d1f..f580715a9 100644
--- a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb
+++ b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb
@@ -82,5 +82,4 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
end
end
end
-
end
diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb
index b30733034..325683e43 100644
--- a/spec/views/users/carte/show.html.haml_spec.rb
+++ b/spec/views/users/carte/show.html.haml_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'users/carte/show.html.haml', type: :view do
let(:state) { 'draft' }
- let(:dossier) { create(:dossier, state: state) }
+ let(:dossier) { create(:dossier, state: state) }
let(:dossier_id) { dossier.id }
before do
diff --git a/spec/views/users/description/_pieces_justificatives.html.haml_spec.rb b/spec/views/users/description/_pieces_justificatives.html.haml_spec.rb
index d0bcacd86..410d63c74 100644
--- a/spec/views/users/description/_pieces_justificatives.html.haml_spec.rb
+++ b/spec/views/users/description/_pieces_justificatives.html.haml_spec.rb
@@ -2,20 +2,24 @@ require 'spec_helper'
describe 'users/description/_pieces_justificatives.html.haml', type: :view do
let!(:procedure) { create(:procedure) }
- let!(:tpj1) { create(:type_de_piece_justificative,
- procedure: procedure,
- libelle: "Première pièce jointe",
- description: "Première description",
- order_place: 1,
- mandatory: true
- )}
- let!(:tpj2) { create(:type_de_piece_justificative,
- procedure: procedure,
- libelle: "Seconde pièce jointe",
- description: "Seconde description",
- order_place: 2,
- lien_demarche: "https://www.google.fr"
- )}
+ let!(:tpj1) {
+ create(:type_de_piece_justificative,
+ procedure: procedure,
+ libelle: "Première pièce jointe",
+ description: "Première description",
+ order_place: 1,
+ mandatory: true
+ )
+ }
+ let!(:tpj2) {
+ create(:type_de_piece_justificative,
+ procedure: procedure,
+ libelle: "Seconde pièce jointe",
+ description: "Seconde description",
+ order_place: 2,
+ lien_demarche: "https://www.google.fr"
+ )
+ }
let!(:dossier) { create(:dossier, :procedure => procedure) }
before do
diff --git a/spec/views/users/description/show.html.haml_spec.rb b/spec/views/users/description/show.html.haml_spec.rb
index c278c09f1..1e35f5d5b 100644
--- a/spec/views/users/description/show.html.haml_spec.rb
+++ b/spec/views/users/description/show.html.haml_spec.rb
@@ -124,6 +124,5 @@ describe 'users/description/show.html.haml', type: :view do
context 'when dossier not have cerfa, piece justificative and demarche link' do
it { expect(rendered).not_to have_content 'Documents administratifs' }
end
-
end
end
diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb
index 3813456f8..dc6721b41 100644
--- a/spec/views/users/dossiers/index_html.haml_spec.rb
+++ b/spec/views/users/dossiers/index_html.haml_spec.rb
@@ -22,9 +22,9 @@ describe 'users/dossiers/index.html.haml', type: :view do
assign :dossiers_list_facade, (DossiersListFacades.new user, liste)
assign(:dossiers, (smart_listing_create :dossiers,
- dossiers_to_display,
- partial: "users/dossiers/list",
- array: true))
+ dossiers_to_display,
+ partial: "users/dossiers/list",
+ array: true))
render
end
diff --git a/spec/views/users/recapitulatif/show.html.haml_spec.rb b/spec/views/users/recapitulatif/show.html.haml_spec.rb
index ccef84120..7761bca13 100644
--- a/spec/views/users/recapitulatif/show.html.haml_spec.rb
+++ b/spec/views/users/recapitulatif/show.html.haml_spec.rb
@@ -69,11 +69,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
expect(rendered).to have_content('Modifier les documents')
expect(rendered).to have_css('#upload-pj-modal')
end
-
end
context 'when invite is logged' do
-
context 'when invite is by Gestionnaire' do
let!(:invite_user) { create(:user, email: 'invite@octo.com') }
diff --git a/spec/views/users/sessions/new.html.haml_spec.rb b/spec/views/users/sessions/new.html.haml_spec.rb
index cc7880f45..714817335 100644
--- a/spec/views/users/sessions/new.html.haml_spec.rb
+++ b/spec/views/users/sessions/new.html.haml_spec.rb
@@ -18,8 +18,7 @@ describe 'users/sessions/new.html.haml', type: :view do
render
end
- it { expect(rendered).to have_selector('#form-login #logo_procedure') }
- it { expect(rendered).to have_selector('#form-login #titre-procedure') }
+ it { expect(rendered).to have_selector('.procedure-logos') }
it { expect(rendered).to have_content(dossier.procedure.libelle) }
it { expect(rendered).to have_content(dossier.procedure.description) }
end
@@ -29,6 +28,6 @@ describe 'users/sessions/new.html.haml', type: :view do
render
end
- it { expect(rendered).to have_selector('#form-login #logo_tps') }
+ it { expect(rendered).to have_content('Un outil simple') }
end
end
diff --git a/spec/workers/auto_archive_procedure_worker_spec.rb b/spec/workers/auto_archive_procedure_worker_spec.rb
index 2a30fa764..7a9c2a380 100644
--- a/spec/workers/auto_archive_procedure_worker_spec.rb
+++ b/spec/workers/auto_archive_procedure_worker_spec.rb
@@ -9,7 +9,6 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
subject { AutoArchiveProcedureWorker.new.perform }
context "when procedures have no auto_archive_on" do
-
before do
subject
procedure.reload
@@ -19,43 +18,39 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
end
context "when procedures have auto_archive_on set on yesterday or today" do
- describe "titi" do
- before do
- subject
- procedure_hier.reload
- procedure_aujourdhui.reload
+ let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'draft', archived: false)}
+ let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)}
+ let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'replied', archived: false)}
+ let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'updated', archived: false)}
+ let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)}
+ let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)}
+ let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refused', archived: false)}
+ let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'without_continuation', archived: false)}
+ let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'initiated', archived: false)}
+
+ before do
+ subject
+
+ (1..9).each do |i|
+ eval "dossier#{i}.reload"
end
- it { expect(procedure_hier.archived).to eq true }
- it { expect(procedure_aujourdhui.archived).to eq true }
+ procedure_hier.reload
+ procedure_aujourdhui.reload
end
- context "with dossiers" do
- let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'draft', archived: false)}
- let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)}
- let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'replied', archived: false)}
- let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'updated', archived: false)}
- let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)}
- let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)}
- let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refused', archived: false)}
- let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'without_continuation', archived: false)}
+ it { expect(dossier1.state).to eq 'draft' }
+ it { expect(dossier2.state).to eq 'received' }
+ it { expect(dossier3.state).to eq 'received' }
+ it { expect(dossier4.state).to eq 'received' }
+ it { expect(dossier5.state).to eq 'received' }
+ it { expect(dossier6.state).to eq 'closed' }
+ it { expect(dossier7.state).to eq 'refused' }
+ it { expect(dossier8.state).to eq 'without_continuation' }
+ it { expect(dossier9.state).to eq 'received' }
- before do
- subject
- (1..8).each do |i|
- eval "dossier#{i}.reload"
- end
- end
-
- it { expect(dossier1.state).to eq 'draft' }
- it { expect(dossier2.state).to eq 'received' }
- it { expect(dossier3.state).to eq 'received' }
- it { expect(dossier4.state).to eq 'received' }
- it { expect(dossier5.state).to eq 'received' }
- it { expect(dossier6.state).to eq 'closed' }
- it { expect(dossier7.state).to eq 'refused' }
- it { expect(dossier8.state).to eq 'without_continuation' }
- end
+ it { expect(procedure_hier.archived).to eq true }
+ it { expect(procedure_aujourdhui.archived).to eq true }
end
context "when procedures have auto_archive_on set on future" do