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

Amber Lynn | Media Ranker Revisited - Edges #40

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

griffifam
Copy link

Needed more help understanding session controller testing and tests involving OAuth.

@droberts-sea
Copy link

MediaRanker Revisted

What We're Looking For

Feature Feedback
General
Appropriate Tests on WorksController This is a good start, but there's a lot left to fill in.
Appropriate Tests on SessionsController no
Appropriate Tests on UsersController some - missing for show
Completed OAuth yes
Basic Authorization (who can see what) no
Overall This is a good start, but there's a lot missing from this submission. I suspect you're still at the point where testing feels like a burden. Our goal is for it to be a useful tool that helps you understand and have confidence in the product code you write. If it sounds good to you, I would love to sit down for an hour and go over how the TDD workflow goes in practice and some techniques for making it work for you. I'm booked up for this week, but we could schedule something during project time next week.

flash[:status] = :success
flash[:result_text] = "Successfully logged in as existing user #{user.username}"
flash[:messages] = user.errors.messages
flash[:result_text] = "Logged in as returning user #{user.name}"

Choose a reason for hiding this comment

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

You shouldn't need to set error messages if nothing went wrong

user = User.new(username: username)
# User doesn't match anything in the DB
# TODO: Attempt to create a new user
user = User.new(username: auth_hash[:info][:nickname], uid: auth_hash[:uid], provider: 'github')

Choose a reason for hiding this comment

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

This is no longer a TODO

def destroy
session[:user_id] = nil
flash[:success] = "Successfully logged out!"

Choose a reason for hiding this comment

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

Looks like this and the logout path below are the same. You should only keep one or the other.

redirect_to root_path
end

def login_form
end

Choose a reason for hiding this comment

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

Since we're using OAuth, do we still need the login form?

# get root_path

# Precondition: there is at least one media of each category
# must_respond_with :success

Choose a reason for hiding this comment

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

Why is all of this commented out? These tests look good to me.

Remember that you can specify which test file to run:

rails test test/controllers/users_controller_test.rb

get users_path

expect( response.body ).must_include("dan")
expect( response.body ).must_include("kari")

Choose a reason for hiding this comment

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

This is more work than we typically need to do for controller tests - you're looking at the rendered HTML, and making sure it includes these two values. If your fixture data or view code changes, this test will also need to change.

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.

2 participants