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
Create UserLevelInfo Table #31429
Create UserLevelInfo Table #31429
Changes from 4 commits
dfbb5e6
5f89dc7
149217c
e9b8191
d4a0b79
1bfd992
a7ea285
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# == Schema Information | ||
# | ||
# Table name: user_level_infos | ||
# | ||
# id :integer not null, primary key | ||
# time_spent :integer default(0) | ||
# user_level_id :integer unsigned | ||
# | ||
|
||
class UserLevelInfo < ApplicationRecord | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CreateUserLevelInfos < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :user_level_infos do |t| | ||
t.integer :time_spent, default: 0 | ||
t.bigint :user_level_id, unsigned: true | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# == Schema Information | ||
# | ||
# Table name: user_level_infos | ||
# | ||
# id :integer not null, primary key | ||
# time_spent :integer default(0) | ||
# user_level_id :integer unsigned | ||
# | ||
|
||
FactoryGirl.define do | ||
factory :user_level_info do | ||
time_spent 10 | ||
user_level_id 1 | ||
end | ||
dmcavoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
dmcavoy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'test_helper' | ||
|
||
class UserLevelInfoTest < ActiveSupport::TestCase | ||
test "can create user_level_info" do | ||
user_level_info = create :user_level_info | ||
assert_equal user_level_info.user_level_id, 1 | ||
assert_equal user_level_info.time_spent, 10 | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we keep these Rails auto generated files around even if we don't have any content in them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷♀ I was assuming that as I added things to the table I would probably need to use them for testing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I didn't realize these were auto generated! Perhaps your first test can just make sure that we can create a user_level_info using the new factory method? |
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.
Please try this instead:
To do this, you will need to rollback the migration in its current state, change this code line, and then migrate forward again.
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.
This was failing yesterday because of the issue that is talked about here: rails/rails#30806 . When I asked in infra channel they said it was okay to move forward without the foreign_key.
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.
got it. they would know best! sounds good.