-
Notifications
You must be signed in to change notification settings - Fork 42
&& Nicoleta B #41
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?
&& Nicoleta B #41
Conversation
…utes for votes, added dependent/destroy on models
Media RankerWhat We're Looking For
|
| has_many :votes, dependent: :destroy | ||
| validates :title, presence: true | ||
| validates :category, presence: true | ||
| validates :category, inclusion: { in: %w(movie book album)} |
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.
👍
| if @user | ||
| session[:user_id] = @user.id | ||
| else | ||
| @user = User.create user_name: params[:user][:user_name] |
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 check to verify that create worked! I tried to log in with a blank username and got no error message.
| value(user).must_be :valid? | ||
| end | ||
|
|
||
| it "requires a unique username" do |
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 also need to test with blank or nil usernames
| user2.errors.messages.must_include :user_name | ||
| end | ||
|
|
||
| describe "total_votes" do |
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 makes more sense in the works model
| it "must be invalid without a supported category type" do | ||
| work.category = "gdfhjgfhjd" | ||
| value(work).wont_be :valid? | ||
| 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.
You also need to test your custom methods bot in the nominal cases and in the case where there are no works or votes.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?