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

Milestone 3 - users & posts #5

Merged
merged 28 commits into from
Sep 25, 2019
Merged

Milestone 3 - users & posts #5

merged 28 commits into from
Sep 25, 2019

Conversation

samgaco
Copy link
Owner

@samgaco samgaco commented Sep 23, 2019

Things I have worked on in this milestone:

  • Created models with associations and implement all requested features for users and posts.
  • Added authentication with Devise as described in requirements.
  • Added unit and integrations tests
  • Did some CSS styling (still a lot left)

Rubocop doesn't get activated in the pull request:

I am running the linters locally because of the reasons mentioned in my last comment in the previous milestone ( #4 ) there are two offenses which I cannot solve.

Offenses:

spec/models/post_spec.rb:41:24: E: Lint/Syntax: unexpected token tRCURLY
(Using Ruby 2.6 parser; configure using TargetRubyVersion parameter, under AllCops)
expect({post.save}).to change{ post.errors.full_messages.count }
^
spec/models/user_spec.rb:63:70: E: Lint/Syntax: unexpected token tRCURLY
(Using Ruby 2.6 parser; configure using TargetRubyVersion parameter, under AllCops)
expect({@user.posts.create(content: 'bla' * 100, title: 'When')}).to change { Post.count }

I have been googling, and they might be a bug.


Working alone:

I am working on this project alone, allowed by student success.


SECOND REVIEW:

I have worked on the requested changes and I am submitting for another review.

  • Run rails g devise:controllers users
  • Added before_action :authenticate_user! in every controller (before non-signed in users could see pages they shouldn't be able to see, like the users' index, post index, and they could create posts)
  • Some unresolved linter checks are bugs

Copy link

@Oghenebrume50 Oghenebrume50 left a comment

Choose a reason for hiding this comment

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

Hi @samgaco good implementation and good UI too, but we need to make more things work, it seems you are not using devise properly, for example, I cannot see the auto-generated folder by devise in the controllers' folder.
Did you run rails g devise:controllers users that?

Also currently I can access anypage on the site without signing, this is not the right behaviour. If no user is signed in, changing the url should redirect back to the signin page.
currently there are no sessions, no current_user. So this functionality cannot be provided, but devise provides them out of the box for you. Please see the devise guide on how to use these provided functionalities.

Make changes and request a re-review 🙏

@samgaco
Copy link
Owner Author

samgaco commented Sep 24, 2019

I have worked on the requested changes and I am submitting for another review.

  • Run rails g devise:controllers users
  • Added before_action :authenticate_user! in every controller (before non-signed in users could see pages they shouldn't be able to see, like the users' index, post index, and they could create posts)

  • Some unresolved linter checks are bugs

Copy link

@adriaanbd adriaanbd left a comment

Choose a reason for hiding this comment

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

I really like how this project is coming along. Really nice!

Just a few things to consider before moving on (required):

  • PostsController#index displays posts in a timeline

Other optional things to consider (see in comments below):

  • update routes
  • update FactoryBot
  • more tests

In regards to testing, I'd strongly suggest covering all CRUD operations at the integration testing level (controller); therefore, your posts_controller_spec.rb should contain more tests. Do the same later on for the next milestones. Take advantage of this opportunity to get to know Rails, Rspec and Capybara while doing this project. It's a good skill and toolbox to have. Also, you'll be more clear and less error prone as your project advances and is more complex. The extra time will pay off.

Status: Request changes

@@ -0,0 +1,7 @@
<h1>Home#index</h1>

<% @posts.each do |post| %>

Choose a reason for hiding this comment

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

Posts need to be displayed in a timeline manner, so @posts should be sorted / ordered by date and time, preferably most recently created post first.

[REQUIRED]

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hi @adriaanbd, thanks for the review

I have currently this scope in my post model (app/ models/post.rb)

default_scope { order(created_at: :desc) }

Wouldn't that be working as such?

Choose a reason for hiding this comment

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

Oh @samgaco yes you are right, somehow I missed this. Since no dates/time is displayed on the UI I wasn't able to confirm it. You should have gotten a pass, let me tell Alvaro to correct this. Sorry about this!

Copy link
Owner Author

@samgaco samgaco Sep 24, 2019

Choose a reason for hiding this comment

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

No problem. I will work on those test moving on, thanks a lot for your review 👍 . It was very helpful, I definitely need to improve (and widen) my testing skills.

app/controllers/posts_controller.rb Show resolved Hide resolved
spec/factories/posts.rb Show resolved Hide resolved
spec/factories/users.rb Show resolved Hide resolved

require 'rails_helper'

RSpec.describe PostsController, type: :controller do

Choose a reason for hiding this comment

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

How about adding some integration tests in here for all CRUD operations? The tests defined in here are only Read operations on :new and :index and :show. It'd be nice to include tests for Create, Update and Delete. When doing update and delete, test that only the post creator can make an edit or delete his own post and also test the opposite (that you can't edit or delete a post you haven't created).

Doing these tests now will help you out a lot while developing your app and give you less headaches later on.

[OPTIONAL]

config/routes.rb Outdated Show resolved Hide resolved
config/routes.rb Show resolved Hide resolved
config/routes.rb Outdated Show resolved Hide resolved
@samgaco
Copy link
Owner Author

samgaco commented Oct 7, 2019

The project was approved in one of the comments in the code:

Oh @samgaco yes you are right, somehow I missed this. Since no dates/time is displayed on the UI I wasn't able to confirm it. You should have gotten a pass, let me tell Alvaro to correct this. Sorry about this!


The option for submitting the project completion form is still not showing. That is why I am re-submitting.

@samgaco samgaco mentioned this pull request Oct 9, 2019
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.

None yet

3 participants