Skip to content

Pipes - Sairagul - MediaRanker#20

Open
sairagula wants to merge 36 commits intoAda-C8:masterfrom
sairagula:master
Open

Pipes - Sairagul - MediaRanker#20
sairagula wants to merge 36 commits intoAda-C8:masterfrom
sairagula:master

Conversation

@sairagula
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. I added a few custom methods to my Work model. work_with_the_most_votes method is one of them. It will return a work with the most votes
Describe how you approached testing that model method. What edge cases did you come up with? Testing these custom methods were complicated for me, I used data from yml file as expected value and tested if result was equal to expected
Describe an edge case test you wrote for a controller I tested login method with an edge case where it will through an error if no name given
What are session and flash? What is the difference between them? These are special objects which behave like hashes. They are used to save data across multiple requests. A flash stores a value until the next request, while a session stores data during the complete session.
Describe a controller filter you wrote. To DRY up work controller's show, edit, update, destroy methods , I created find_work_by_params_id private method, that finds a work from the params id key or throws an error if not found .
What was one thing that you gained more clarity on through this assignment? A lot of things are still kind of foggy in my head, but now I know the whole structure of the application, and what parts it needs to function. I enjoyed using filters, sessions and flash.
What is the Heroku URL of your deployed application https://sairamediaranker.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? I still didn't digest most of the new things we learned in class last week, I didn't have time to go through them , understand and use in my project. So probably longer time period for the project would be a good practice.

@droberts-sea
Copy link

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) yes - some extra routes
Semantic HTML yes
Errors are reported to the user yes
Business logic lives in the models yes - good work
Models are thoroughly tested, including relations, validations and any custom logic yes - see inline comments for suggestions
Controllers are thoroughly tested yes - good work
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
Individual user pages and the user list are present 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
Media pages contain lists of voting users yes
Wave 3 - Styling
Foundation is used appropriately yes
Look and feel is similar to the original yes - good work
Overall Great job overall! This is a large project with many complex requirements, and you've done a great job with it. I'm especially happy with your controller testing. Keep up the hard work!

root :to => "main#index"
post "works/:id/upvote", to: "works#upvote", as:"upvote"
resources :works
resources :users

Choose a reason for hiding this comment

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

You probably don't need the full resources :users here. Make sure to only generate routes you're planning to use.


def self.top_n_in_category(category, count)
return Work.left_outer_joins(:votes).select('works.*, COUNT(votes.*) AS votes_count').group('works.id').where(category: category).order('votes_count desc').limit(count)
end

Choose a reason for hiding this comment

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

Good work figuring out these database operations.

res = Work.top_n_in_category(:movie, 10)
res.must_include Work.find_by_title("Jurassic_Park")
res.size.must_equal 1
end

Choose a reason for hiding this comment

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

I would also be interested to see:

  • What happens if there are no works?
  • What if there are more than n works?

it "returns all works ordered by vote count" do
res = Work.all_with_vote_count
expected = [
Work.find_by_title("Countdown to Ecstasy"),

Choose a reason for hiding this comment

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

This test ends up being very fragile - if your fixtures change, this test will probably break.

Instead of requiring specific works to be returned, you might check that the right number of works are there, and that each work has a vote count equal to or less than the vote before it.


must_respond_with :not_found # Assert
Work.count.must_equal work_count
end

Choose a reason for hiding this comment

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

What if you try to destroy a work with associated votes? Does it work? What happens to the votes?

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