-
Notifications
You must be signed in to change notification settings - Fork 110
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
1033 external form upload #1038
1033 external form upload #1038
Conversation
@kasugaijin There is an assertion that is commented. This is because it works perfectly when tested individually. But when using |
@organization = ActsAsTenant.current_tenant | ||
@file = fixture_file_upload("google_form_sample.csv", "text/csv") | ||
@params = {files: [@file]} | ||
@user = create(:admin, email: "adopter1@alta.com") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be creating an adopter
here, instead of admin
There are also some changes happening in this PR #997
- a Person can have multiple form submissions
- a form submission will be created on a person when a new adopter signs up
This means the asserstions on lines 20 and 21 will become unnecessary. We'll want to just test two cases
- when a form submission does not have any form answers (and no CSV timestamp), assert that new form answers are created
- when a form submission does have a csv timestamp matching the timestamp in the CSV, no new Form Answers are created
I think the best thing to do, here, is wait for that PR to get merged, then finish these tests off. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand lines 20 and 21 can be removed.
On the other assertions I'm verifying that FormSubmissions and FormAnswers are being created after the upload csv. Where we have 4 answers and questions/cells and 1 form was uploaded so one FormSubmission was created.
As I understood we may need to add a test for when a csv file matches an existing csv_timestamp entry... Nothing should happen. But all of these are subject to change after PR #997
Then I will remove the unnecessary assertions, address controller comments, and wait for your instructions on the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wandergithub FYI this PR has now been merged #997
So now person has many form submissions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wandergithub let me know if you have any blockers on this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kasugaijin Yeah, I would like to know which requirements or specifications changed on this PR. It's not clear to me.
app/controllers/organizations/staff/external_form_upload_controller.rb
Outdated
Show resolved
Hide resolved
Modify external form controller to support just one file upload correct controller test
@@ -0,0 +1,21 @@ | |||
require "test_helper" | |||
|
|||
class Organizations::Staff::ExternalFormUploadControllerTest < ActionDispatch::IntegrationTest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we nest the modules instead please?
test/controllers/organizations/staff/external_form_upload_controller_test.rb
Outdated
Show resolved
Hide resolved
Ok, I will address it here in this PR. |
I'm blocked, I cant make the factory for |
Can you please push your latest changes up to this branch? I'd like to see the full picture before looking at why |
@wandergithub I think you can ignore my comment about changing the email in the setup and the csv...that should not be an issue with the updates I suggest. https://www.loom.com/share/d462da8a6a534cd0b75b831fcc593786?sid=4cf176c6-89f8-408d-8aa1-289c46fb3c7f |
@kasugaijin Thank you! I really needed that. I will implement the new service logic first to get it out of the way, and then check out everything else. |
I am glad it helped! |
I am just leaving a note for myself here - we should make sure we fully test the refactor of the CSV import service i.e.
@wandergithub You could add the above tests to this PR...but it has already changed a lot for you, so it might be better to not change the scope of this PR any further, and then tackle any of the missing above tests separately to keep things manageable (if you prefer). |
- Updates users Factorie to create the person - fix external_form_upload_controller_tests
I added the last two since the first test already exists as the first one in |
app/services/organizations/importers/google_csv_import_service.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good @wandergithub! Just one comment to DRY up the service object refactor.
test/controllers/organizations/staff/external_form_upload_controller_test.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved but please change the variable names in the tests per my suggestion
@@ -4,14 +4,14 @@ | |||
module Organizations | |||
class CsvImportServiceTest < ActiveSupport::TestCase | |||
setup do | |||
person = create(:person) | |||
person = create(:adopter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here re variable naming
test/controllers/organizations/staff/external_form_upload_controller_test.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I think that would do it 👍🏽 |
🔗 Issue
#1033
✍️ Description
📷 Screenshots/Demos