Skip to content

Sockets - Evelynn#30

Open
evelynnkaplan wants to merge 95 commits intoAda-C11:masterfrom
evelynnkaplan:master
Open

Sockets - Evelynn#30
evelynnkaplan wants to merge 95 commits intoAda-C11:masterfrom
evelynnkaplan:master

Conversation

@evelynnkaplan
Copy link
Copy Markdown

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. Work.categories returns a list of all categories for media in an array. If I wanted to change the categories available later, I'd only have to change the hardcoded list in this method.
Describe how you approached testing that model method. What edge cases did you come up with? I had a hard time finding edge cases for this since the data was hardcoded.
What are session and flash? What is the difference between them? Session is data that the browser stores for the entire time it's open. It helps us keep track of user data. Flash is data stored in a hash that persists through the end of the current request/response cycle and onto the next. It's used to send messages to users. The difference is how long the data is persisted.
What was one thing that you gained more clarity on through this assignment? Use of more complex and customized routing and customized actions.
What is the Heroku URL of your deployed application? https://ekaplan-media-ranker.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort?

@droberts-sea
Copy link
Copy Markdown

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) some extra routes
Views are well-organized (DRY, use of semantic HTML, use of partials) yes
Errors are reported to the user yes
Business logic lives in the models yes
Models are thoroughly tested, including relations, validations and any custom logic mostly - see inline
Controllers are thoroughly tested, including the login/logout process and multi-step workflows like voting for a work mostly - see inline
Wave 1 - Media
Splash page shows the three media categories yes
Basic CRUD operations on media are present and functional yes
Wave 2 - Users and Votes
Users can log in and log out yes
The ID of the current user is stored in the session yes
A user cannot vote for the same media more than once yes
All media lists are ordered by vote count yes
Splash page contains a media spotlight yes
Wave 3 - Users and Votes
Media pages contain lists of voting users yes
Individual user pages and the user list are present yes
Optional - Styling
Bootstrap is used appropriately no
Look and feel is similar to the original aside from styling, you've done a good job matching the functionality and workflows of the demo site
Overall Great job overall! Your implementation matches the demo site very closely, and I would say the learning goals for this assignment were definitely met. There are a few places where things could be cleaned up, which I've tried to outline below, but in general I am quite happy with this submission. Keep up the hard work!

Comment thread config/routes.rb

get "/users/current", to: "users#current_user", as: "current_user"

resources :users, except: [:new, :create]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This assignment should only need the index and show actions for users.

def edit
if !@work
flash[:error] = "No work with that ID found."
redirect_to works_path
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This error checking is repeated many times in this controller. You've already written the find_work controller filter, could you do this work there?

Comment thread app/models/user.rb

def already_voted?(work)
return self.works.include?(work)
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like that you've made this a model method.

If you wanted to make the interface even simpler / more foolproof, you could define it as a validation on Vote, so that it's impossible to create a duplicate vote. Look up "rails validation uniqueness scope"

Comment thread app/models/work.rb
unless all_works == []
return all_works.max_by(10) { |work| work.votes.count }
else
return []
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think that this conditional isn't needed - calling max_by(10) on an empty array should return an empty array.

@@ -0,0 +1,37 @@
<body>

<header>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In general you shouldn't need to include a <body> tag in view templates.

describe "index" do
it "can get the root path" do
get root_path
must_respond_with :success
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The spotlight presents us with an interesting edge case when there are no works in the database. Do your controller and view handle that without crashing?

describe "login" do
it "can login a user" do
user = perform_login

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are a couple of behavior modes you're not covering:

  • Logging in a new user (should create that user)
  • Attempting to log in with an invalid username (e.g. empty string) (should fail)


it "won't let a user vote if they're not logged in" do
expect { post vote_work_path(@gump.id) }.wont_change "#{@gump.votes.count}"
expect(@gump.votes.count).must_equal 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good work getting the three interesting cases for this action, especially since the testing logic is so complex.

Comment thread test/models/work_test.rb
end

it "returns an empty array if there are no works in that category" do
top_cars = Work.top_works("car")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good work finding the edge cases for top_works. Another interesting question is, how does it handle ties?

Comment thread test/models/work_test.rb
describe "categories" do
it "must return a list of categories" do
categories = Work.categories

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does this still work if one of the categories has no works?

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