-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
99258a5
to
8b8cb07
Compare
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.
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) |
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.
I like the year interpolation!
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.
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.
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.
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.
8b8cb07
to
e445a23
Compare
There are a couple of things that we need to do for this ticket:
|
@@ -1,3 +1,9 @@ | |||
seeder = DataSeeder.new | |||
seeder.generate_dump_types | |||
seeder.generate_dump_file_types | |||
|
|||
if Event.count < 10 && Rails.env.development? |
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.
👍🏻
get :index | ||
expect(assigns(:events)).to eq([event2, event3, event4, event1]) | ||
|
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.
do you still need these changes with your recent update in the seeds file?
…erly Co-authored-by: Christina Chortaria <[email protected]>
d87b636
to
0473b83
Compare
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.
Thanks @lizgarciao 😃
closes #2268