chore: fix tests

This commit is contained in:
Gregor Kleen 2021-07-07 11:33:14 +02:00
parent 09a1c829bd
commit a9fe7487a6
6 changed files with 17 additions and 5 deletions

View File

@ -51,7 +51,7 @@ postEEditR tid ssh csh examn = do
| Just (Entity previousStatementId _) <- mPreviousStatement | Just (Entity previousStatementId _) <- mPreviousStatement
-> update previousStatementId [ AuthorshipStatementDefinitionContent =. newStatementContent ] >> return (Just previousStatementId) -> update previousStatementId [ AuthorshipStatementDefinitionContent =. newStatementContent ] >> return (Just previousStatementId)
| otherwise | otherwise
-> fmap Just $ insert AuthorshipStatementDefinition { authorshipStatementDefinitionContent = newStatementContent } -> Just <$> insert AuthorshipStatementDefinition { authorshipStatementDefinitionContent = newStatementContent }
insertRes <- myReplaceUnique eId Exam insertRes <- myReplaceUnique eId Exam
{ examCourse = cid { examCourse = cid

View File

@ -151,7 +151,7 @@ examForm (Entity _ Course{..}) template csrf = hoist liftHandler $ do
reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup
reqContentField ttip = areq htmlField reqContentField ttip = areq htmlField
(fslI MsgExamAuthorshipStatementContent & ttip) (fslI MsgExamAuthorshipStatementContent & ttip)
( (join $ efAuthorshipStatement <$> template) ( (efAuthorshipStatement =<< template)
<|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement) <|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)
) )
forcedContentField = aforced htmlField forcedContentField = aforced htmlField

View File

@ -111,7 +111,7 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS
reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup
reqContentField ttip = areq htmlField reqContentField ttip = areq htmlField
(fslI MsgSheetAuthorshipStatementContent & ttip) (fslI MsgSheetAuthorshipStatementContent & ttip)
( (join $ sfAuthorshipStatement <$> template) ( (sfAuthorshipStatement =<< template)
<|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement) <|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)
) )
forcedContentField = aforced htmlField forcedContentField = aforced htmlField

View File

@ -25,7 +25,7 @@ data SchoolAuthorshipStatementMode
deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic, Typeable) deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic, Typeable)
deriving anyclass (Universe, Finite, NFData) deriving anyclass (Universe, Finite, NFData)
nullaryPathPiece ''SchoolAuthorshipStatementMode $ camelToPathPiece' 4 finitePathPiece ''SchoolAuthorshipStatementMode [ "no-statement", "optional", "required" ]
pathPieceJSON ''SchoolAuthorshipStatementMode pathPieceJSON ''SchoolAuthorshipStatementMode
pathPieceJSONKey ''SchoolAuthorshipStatementMode pathPieceJSONKey ''SchoolAuthorshipStatementMode
derivePersistFieldPathPiece ''SchoolAuthorshipStatementMode derivePersistFieldPathPiece ''SchoolAuthorshipStatementMode

View File

@ -340,6 +340,9 @@ instance Arbitrary UploadNonce where
arbitrary = pure $ unsafePerformIO newUploadNonce arbitrary = pure $ unsafePerformIO newUploadNonce
instance Arbitrary SchoolAuthorshipStatementMode where
arbitrary = genericArbitrary
spec :: Spec spec :: Spec
spec = do spec = do
@ -448,6 +451,8 @@ spec = do
[ eqLaws, ordLaws, showLaws, showReadLaws, pathPieceLaws, jsonLaws, persistFieldLaws, binaryLaws ] [ eqLaws, ordLaws, showLaws, showReadLaws, pathPieceLaws, jsonLaws, persistFieldLaws, binaryLaws ]
lawsCheckHspec (Proxy @UploadNonce) lawsCheckHspec (Proxy @UploadNonce)
[ eqLaws, ordLaws, showLaws, showReadLaws, pathPieceLaws, jsonLaws, jsonKeyLaws, persistFieldLaws ] [ eqLaws, ordLaws, showLaws, showReadLaws, pathPieceLaws, jsonLaws, jsonKeyLaws, persistFieldLaws ]
lawsCheckHspec (Proxy @SchoolAuthorshipStatementMode)
[ eqLaws, ordLaws, showLaws, showReadLaws, boundedEnumLaws, finiteLaws, pathPieceLaws, jsonLaws, jsonKeyLaws, persistFieldLaws, binaryLaws ]
describe "TermIdentifier" $ do describe "TermIdentifier" $ do
it "has compatible encoding/decoding to/from Text" . property $ it "has compatible encoding/decoding to/from Text" . property $

View File

@ -68,8 +68,9 @@ instance Arbitrary Sheet where
<*> arbitrary <*> arbitrary
<*> arbitrary <*> arbitrary
<*> arbitrary <*> arbitrary
<*> return Nothing <*> pure Nothing
<*> arbitrary <*> arbitrary
<*> pure Nothing
shrink = genericShrink shrink = genericShrink
instance Arbitrary Tutorial where instance Arbitrary Tutorial where
@ -164,6 +165,12 @@ instance Arbitrary School where
schoolExamRequireModeForRegistration <- arbitrary schoolExamRequireModeForRegistration <- arbitrary
schoolExamDiscouragedModes <- arbitrary schoolExamDiscouragedModes <- arbitrary
schoolExamCloseMode <- arbitrary schoolExamCloseMode <- arbitrary
schoolSheetAuthorshipStatementMode <- arbitrary
let schoolSheetAuthorshipStatementDefinition = Nothing
schoolSheetAuthorshipStatementAllowOther <- arbitrary
schoolSheetExamAuthorshipStatementMode <- arbitrary
let schoolSheetExamAuthorshipStatementDefinition = Nothing
schoolSheetExamAuthorshipStatementAllowOther <- arbitrary
return School{..} return School{..}
instance Arbitrary Term where instance Arbitrary Term where