-
Notifications
You must be signed in to change notification settings - Fork 48
Amanda Ungco-MediaRanker #29
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
base: master
Are you sure you want to change the base?
Conversation
…table relationshps
Match2 constructor media ranker
Media RankerWhat We're Looking For
|
| Rails.application.routes.draw do | ||
|
|
||
| root 'works#main' | ||
| resources :users |
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 need the full CRUD routes for users? You're not using :edit or :destroy for example.
| @@ -0,0 +1,5 @@ | |||
| class User < ApplicationRecord | |||
| has_many :works | |||
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.
No validations? Username can be blank? What about requiring unique usernames?
This isn't essential, but something to think about.
| belongs_to :user | ||
| belongs_to :work | ||
|
|
||
| validates :user_id, presence: true, uniqueness: { scope: :work, message: "You can only add one vote per work"} |
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.
Since a vote belongs to a user by default user_id is required. The uniqueness of combining user_id and work_id is good. The custom message is great!
| has_many :votes, dependent: :destroy | ||
| # has_many :users, through :votes | ||
|
|
||
| validates :title, presence: true, uniqueness: {scope: :category} |
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 uniqueness using the scope category here.
| validates :publication_year, numericality: true, length: {is: 4} | ||
| validates :creator, presence: true | ||
|
|
||
| def self.sort_by_category(category) |
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.
The name sort_by_category doesn't sound right since this method doesn't really do sorting. Instead it does filtering.
| end | ||
|
|
||
| it 'can only be voted on by a unique user once' do | ||
| # first_vote = Vote.first |
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 would suggest here, creating a new vote which is identical to one from your fixtures.
| it 'must have a publication_year with a 4 integers' do | ||
| work.publication_year = 0 | ||
| # Arrange | ||
| work.publication_year += 999 |
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.
Why add 999 here?
| expect(poodr.errors.messages).must_include :title | ||
| end | ||
| end | ||
|
|
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.
No test for category being present?
| # below each fixture, per the syntax in the comments below | ||
| # | ||
| one: | ||
| user_id: 1 |
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.
You should use the nicknames of existing fixtures in users.yml and works.yml
| category: movie | ||
| description: magical movie | ||
|
|
||
|
|
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.
👍
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?