Skip to content
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

Include 10 events in seeds of database #2272

Merged
merged 3 commits into from
Feb 6, 2024
Merged

Include 10 events in seeds of database #2272

merged 3 commits into from
Feb 6, 2024

Conversation

lizgarciao
Copy link
Contributor

closes #2268

sandbergja
sandbergja previously approved these changes Nov 26, 2023
Copy link
Member

@sandbergja sandbergja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @lizgarciao !

db/seeds.rb Outdated
@@ -1,3 +1,7 @@
seeder = DataSeeder.new
seeder.generate_dump_types
seeder.generate_dump_file_types

10.times do |i|
Event.find_or_create_by(id: i+1, start: "200#{i}-10-10", finish: "200#{i}-10-11", success: true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the year interpolation!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are some failing tests. I think because you are specifying ids here, the database doesn't think to increment the id sequence, so there are failures when it attempts to create a second row with the same ID (e.g. 1).

If you don't specify an id in this line, and just let the database keep track of assigning IDs, it should fix it.

Copy link
Contributor Author

@lizgarciao lizgarciao Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, Jane. I removed the id, but there are three tests with Rspec that are failing. I think this is because the tests are creating events and checking that these records are saved in the ActiveRecord. However, the tests do not take into account that there already exist 10 events.

Here are the failures for convenience:
image
image

@christinach
Copy link
Member

There are a couple of things that we need to do for this ticket:

  • When we create an event we should also create a dump with a file and mark the event success: true. I'll review the relations in the code and update the logic that needs to be followed for the creation of these records in the seeds file.
  • In the failing spec: 1. we can delete all the events (which will also delete the dumps etc that are connected to the specific event.) in a before do. However this would mean that someone would have to run the seeds file again in env: dev to see the events in the events page. 2. Or we could run this part of the seeds file only in env: dev so that we don't mess up with the test env. 3. Or we can review the specs and see how we can improve them.

@@ -1,3 +1,9 @@
seeder = DataSeeder.new
seeder.generate_dump_types
seeder.generate_dump_file_types

if Event.count < 10 && Rails.env.development?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

get :index
expect(assigns(:events)).to eq([event2, event3, event4, event1])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you still need these changes with your recent update in the seeds file?

@lizgarciao lizgarciao marked this pull request as ready for review February 6, 2024 15:41
Copy link
Member

@christinach christinach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lizgarciao 😃

@christinach christinach merged commit c293a79 into main Feb 6, 2024
10 checks passed
@christinach christinach deleted the include-events branch February 6, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database seeds should include Events
3 participants