-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add Author to Article Show Page #19
Open
AKidd95
wants to merge
20
commits into
CraftAcademy:develop
Choose a base branch
from
AKidd95:author
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
823c6d8
add author field to new article
AKidd95 899d977
add author and article associations
AKidd95 4115a2d
create author table
AKidd95 4242955
create author table
AKidd95 e9bdf75
fix factory bot tests
AKidd95 43c3821
edit article path in controller
AKidd95 b4f7f63
rollback author db changes
AKidd95 adf0782
delete author class
AKidd95 88cf87c
generate migration for user ref to articles
AKidd95 77ec4b5
delete author field
AKidd95 c3d613e
set articles creator to current user
AKidd95 dd938b9
set author name to user email address
AKidd95 ae54e9f
fix merge conflict
AKidd95 1df15f3
fix merge conflicts
AKidd95 d44b104
fix merge conflict
AKidd95 9dc83cf
edit factory create
AKidd95 8943240
fix author display
AKidd95 92d36d6
delete chrome driver binary
AKidd95 9d66c96
remove comma
AKidd95 7ac0835
resolve merge conflicts
AKidd95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class Article < ApplicationRecord | ||
validates :title, :content, presence: true | ||
|
||
belongs_to :user, optional: true | ||
has_many :comments, dependent: :destroy | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Comment < ApplicationRecord | ||
validates_presence_of :content, :email | ||
|
||
belongs_to :article | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class User < ApplicationRecord | ||
devise :database_authenticatable, :registerable, | ||
:recoverable, :rememberable, :trackable, :validatable | ||
|
||
has_many :articles | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
%p | ||
%strong Title: | ||
= @article.title | ||
%p | ||
%strong Author: | ||
[email protected] | ||
%p | ||
%strong Text: | ||
= @article.content | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddUserRefToArticles < ActiveRecord::Migration[5.2] | ||
def change | ||
add_reference :articles, :user, foreign_key: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Feature: | ||
As a user | ||
In order to know who's the author of an article | ||
I should see the author's name in the article | ||
|
||
Background: | ||
Given I visit the Homepage | ||
Given the following user exists | ||
| email | password | password_confirmation | | ||
| [email protected] | OsloOslo123 | OsloOslo123 | | ||
And I am logged in as "[email protected]" | ||
|
||
Scenario: Successfully create an article | ||
When I click "New Article" link | ||
Then I fill in "Title" with "A Whole New World" | ||
And I fill in "Content" with "A new fantastic point of view" | ||
And I click "Create Article" button | ||
Then I should be on "A Whole New World" page | ||
And I should see "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ Feature: Create articles | |
|
||
Background: | ||
Given I visit the Homepage | ||
Given the following user exists | ||
| email | password | password_confirmation | | ||
| [email protected] | OsloOslo123 | OsloOslo123 | | ||
And I am logged in as "[email protected]" | ||
|
||
Scenario: Successfully create an article | ||
When I click "New Article" link | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Warden.test_mode! | ||
World Warden::Test::Helpers | ||
After { Warden.test_reset! } | ||
After { Warden.test_reset! } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be article. You are testing the article factory :)
If you are getting an error maybe you forgot to add user to the factory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at the article factory and it's missing the user. :) See comment above.