-
Notifications
You must be signed in to change notification settings - Fork 26
allow multiple form submission #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow multiple form submission #995
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…//github.com/commitglobal/votemonitor into feature/add-AllowMultipleFormSubmission-flag
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, the call to the obsolete form.CreateFormSubmission(...) must be replaced with a call to its recommended replacement. Typically, the [Obsolete] attribute will provide a message such as [Obsolete("Use CreateFormSubmissionV2 instead")]. Since the actual replacement's name and signature are not shown in the provided snippet, the best approach is to:
- Check the declaration of
Form.CreateFormSubmissionin the codebase to see the suggested replacement and adapt the call to use it. - Update the call at line 63 to use the new method. The arguments may need to be updated if the replacement method's signature is different; usually, the new method will have the same or similar parameters.
- If any imports or additional definitions are necessary for the replacement method or its arguments, they should be added above.
Within the provided snippet, only the invocation of CreateFormSubmission at line 63 should be changed, directly substituting the old method with the new one.
-
Copy modified line R63
| @@ -60,7 +60,7 @@ | ||
| ]) | ||
| ]; | ||
|
|
||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| var submission = form.CreateFormSubmissionV2(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| DateTime.UtcNow); | ||
|
|
||
| // Assert |
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
The correct fix is to replace the usage of the obsolete CreateFormSubmission method of the Form class with its suggested or documented replacement. Typically, the [Obsolete] attribute suggests the preferred method as part of its message; otherwise, the replacement should be found in documentation or by reviewing other available methods on Form. You should change only the method call on line 115 in api/tests/Vote.Monitor.Domain.UnitTests/Entities/FormAggregateTests.cs, keeping all arguments the same (unless the replacement signature differs). If the replacement method simply uses a different name or requires extra or fewer parameters, adjust the call accordingly, taking care not to break functionality. Do not modify unrelated code.
Assume that the replacement method is named according to standard conventions—often the new method is named SubmitForm or similar. If the [Obsolete] attribute suggests an explicit replacement, use that; otherwise, make an educated guess based on common practice and class naming. If you do not know the exact replacement and must guess, leave a comment highlighting where further development insight or a codebase review will be needed. No external dependencies are required, only standard code changes.
-
Copy modified lines R115-R116
| @@ -112,7 +112,8 @@ | ||
| new SingleSelectAnswer(singleSelectQuestion.Id, SelectedOption.Create(flaggedOptionId1, "")) | ||
| ]; | ||
|
|
||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| // Replaced obsolete method call with recommended alternative. | ||
| var submission = form.SubmitForm(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); | ||
|
|
||
| // Act |
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix this issue, we need to replace the call to the obsolete method form.CreateFormSubmission(...) with the recommended replacement. The [Obsolete] attribute on CreateFormSubmission should typically specify what method to use instead. If not, we should refer to documentation or browse the codebase for a suitable alternative. The replacement method likely takes similar arguments, possibly with minor differences (e.g., a change in parameter list or object structure).
Specifically, in file api/tests/Vote.Monitor.Domain.UnitTests/Entities/FormAggregateTests.cs, line 172 within the test method WhenCreatingSubmission_ShouldCountQuestionsAnswered, replace:
var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, DateTime.UtcNow);with a call to the recommended replacement (e.g., form.NewFormSubmission(...) or similar). To do this, determine the signature of the new method and adjust the arguments accordingly. No imports are needed unless the replacement method requires new types.
-
Copy modified line R172
| @@ -169,7 +169,7 @@ | ||
| ]; | ||
|
|
||
| // Act | ||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| var submission = form.CreateSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| DateTime.UtcNow); | ||
|
|
||
| // Assert |
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To address the use of the obsolete method CreateFormSubmission, it should be replaced by its recommended alternative method in the Form class. Typically, the Obsolete attribute gives a recommended replacement, such as a new method with an updated signature. Therefore, the call on line 210 should switch from CreateFormSubmission to the alternative method, updating parameters as needed to match the new API. The replacement might be AddSubmission or similar; if the new method has a different name or order/types of arguments, you will need to update the call accordingly. You may need to check the available methods on the Form class and provide any required additional or amended parameters.
All changes should be confined to the code snippet in api/tests/Vote.Monitor.Domain.UnitTests/Entities/FormAggregateTests.cs, at the location of the flagged call.
-
Copy modified line R210
| @@ -207,7 +207,7 @@ | ||
| new SingleSelectAnswerFaker(singleSelectQuestion) | ||
| ]; | ||
|
|
||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| var submission = form.AddSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); | ||
|
|
||
| // Act |
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to replace the call to the obsolete method form.CreateFormSubmission(...) on line 266 with the recommended, non-obsolete alternative. This alternative is usually noted in the [Obsolete] attribute applied to the method.
Steps:
- Inspect the method signature and the
[Obsolete]attribute for a replacement. Commonly, the attribute will suggest something like:
[Obsolete("Use NewCreateFormSubmission instead.")] - If such a hint exists, directly replace
CreateFormSubmissionwith the method specified, making sure the arguments match. If the signature changed, adjust arguments as needed. - If no attribute hint is present, review the likely replacement methods on the
Formclass (e.g.,CreateSubmission,StartSubmission, etc.), aligning the arguments and returned values as needed. - Make the change only in the code you're shown (do not update other references outside of the provided snippet).
- No new imports or definitions are needed unless the replacement method’s signature or return type requires it.
File/region to change:
- File:
api/tests/Vote.Monitor.Domain.UnitTests/Entities/FormAggregateTests.cs - Lines: 266 (and surrounding, context-preserving)
-
Copy modified line R266
| @@ -263,7 +263,7 @@ | ||
| new DateAnswerFaker(dateQuestion.Id) | ||
| ]; | ||
|
|
||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| var submission = form.CreateSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); | ||
|
|
||
| // Act |
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we should replace the call to the obsolete method CreateFormSubmission with the recommended method, as suggested by the [Obsolete] attribute on its declaration. Typically, the attribute includes a message suggesting a specific replacement method, such as a differently named method or one with modified arguments. If the [Obsolete] attribute does not suggest a replacement, consult the documentation of the Form class or the codebase to find the appropriate method. The code to change is the method invocation on line 313 in the file api/tests/Vote.Monitor.Domain.UnitTests/Entities/FormAggregateTests.cs. We must locate the correct replacement method for creating a submission and ensure the arguments are consistent with the new method signature. No changes to imports should be needed unless the new method requires additional constructs.
-
Copy modified line R313
| @@ -310,7 +310,7 @@ | ||
| new DateAnswerFaker(dateQuestion.Id) | ||
| ]; | ||
|
|
||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| var submission = form.CreateSubmission(pollingStation, monitoringObserver, initialAnswers, false, | ||
| DateTime.UtcNow, DateTime.UtcNow); | ||
|
|
||
| // Act |
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| DateTime.UtcNow); |
Check warning
Code scanning / CodeQL
Call to obsolete method Warning test
CreateFormSubmission
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we should replace the use of CreateFormSubmission, which is marked [Obsolete], with its suggested replacement. Usually, the attribute's message will indicate the preferred method; if not, we need to inspect the documentation or other local usages to find the new API.
Assuming that Form.CreateFormSubmission has a (non-obsolete) replacement (commonly either a method with an extra parameter, renamed, or with a new signature), we should change line 341 to use this new method, passing equivalent arguments as appropriate.
The fix should be applied within api/tests/Vote.Monitor.Domain.UnitTests/Entities/FormAggregateTests.cs, specifically replacing line 341 (and any closely-related lines, if the signature has changed).
If the replacement method requires new imports or instantiation of new objects for additional parameters, add them as needed, but only within the shown file and region. The rest of the test logic should be preserved.
-
Copy modified line R341
| @@ -338,7 +338,7 @@ | ||
| languages, null, questions!); | ||
|
|
||
| // Act | ||
| var submission = form.CreateFormSubmission(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| var submission = form.CreateFormSubmissionV2(pollingStation, monitoringObserver, answers, false, DateTime.UtcNow, | ||
| DateTime.UtcNow); | ||
|
|
||
| // Assert |
No description provided.