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

Journalist can assign an article to a category #26

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

holgertidemand
Copy link
Contributor

PT Story: https://www.pivotaltracker.com/story/show/155903746

Description

Changes proposed in this pull request:

  • Category model
  • Association between articles and categories

What I have learned working on this feature:

  • That params is not always sent in the same datatype
  • have and belongs to many relationship & Joint Table migrations


categories.each do |category_id|
category = Category.find_by(id: category_id)
@article.categories.include?(category) ? next : @article.categories << category
Copy link
Member

Choose a reason for hiding this comment

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

Could you please see if this solution work?

@article.categories.push category unless  @article.categories.include? category

Copy link
Member

@tochman tochman left a comment

Choose a reason for hiding this comment

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

No blockers IMO

@holgertidemand holgertidemand changed the title WIP - Journalist can assign an article to a category Journalist can assign an article to a category Mar 24, 2018
Copy link
Member

@tochman tochman left a comment

Choose a reason for hiding this comment

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

Please see comments. I would also add category to the Article factory. Also, ask yourself if there's a use case for articles WITHOUT a category. If not, please make sure there's a method to make sure there's always a category associated with an article. (validation)

@@ -1,24 +1,15 @@
class HomeController < ApplicationController
before_action :get_coordinates, only: [:index]
GOTHENBURG = [57.700501, 11.975463]
Copy link
Member

Choose a reason for hiding this comment

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

In what way is this code related to this feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's is my bad. Local gitflow mistake

def get_location
user = create_guest_user
current_user ? current_user.address : user.address
@local_articles = Article.near(current_user.address, 20) if [email protected]?
Copy link
Member

Choose a reason for hiding this comment

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

In what way is this code related to this feature?

end

def set_edition
if User.near([57.700501, 11.975463], 50).include? current_user
if User.near(GOTHENBURG, 50).include? current_user
Copy link
Member

Choose a reason for hiding this comment

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

In what way is this code related to this feature?

end
current_user.latitude = @coordinates.values.first
current_user.longitude = @coordinates.values.second
current_user.save
Copy link
Member

Choose a reason for hiding this comment

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

In what way is this code refactoring related to this feature?

article = Article.find_by(title: article[:title])
article.categories.push category
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Why not do this in the step definition where you create articles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This made more since to us. didn't know if that would mess up all the other test that are using that step so we decided to make a new one.

end

Then("I select {string} from {string}") do |category, select_box|
select(category, from: select_box)
Copy link
Member

Choose a reason for hiding this comment

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

I sense that you are mixing styles. Most of the step definitions omit the parathesis, here you have them. Stick to one style, please.

Background:
Given the following article exists
| title | content |
| A Whole New World | A new fantastic point of view |
Copy link
Member

Choose a reason for hiding this comment

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

Why do you have this background step here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't sure how we would make it write the test in the beginning. Will remove it!

And the following user exists
| email | password |
| [email protected] | OsloOslo123 |
And the following categories exists
Copy link
Member

Choose a reason for hiding this comment

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

Please separate steps in the background with an empty line.

| name |
| Fashion |
| Tech |
And the following article exists
Copy link
Member

Choose a reason for hiding this comment

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

Please separate steps in the background with an empty line.

Copy link
Member

@tochman tochman left a comment

Choose a reason for hiding this comment

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

IMO this one was ready to be merged the other day. Now it's not.

@tochman
Copy link
Member

tochman commented Mar 24, 2018

You need to have another team member to review this one. I just did a review and red flagged it. It was a go the other day, so you should have merged it when it was. 😳

@tochman
Copy link
Member

tochman commented Mar 24, 2018

Also, from what I understand, you guys implemented Active Admin, right. So Article creation will be moved to that part of the application, right?

@holgertidemand
Copy link
Contributor Author

@tochman thank you for your comments.
When you told us that this was ready the ci didn't pass and the story wasn't done.
Regarding the active admin, we decided to have the writers log in as normal only with a different view.

Copy link
Contributor

@isabellelii isabellelii left a comment

Choose a reason for hiding this comment

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

Good job!

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.

3 participants