Skip to content

Commit

Permalink
Refs #13: red test
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBrendel committed Nov 3, 2017
1 parent c5fe05e commit bb5bdd7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/authors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def new
@author = Author.new
end

def edit
@article = Author.find(params[:id])
end

def create
@author = Author.new(params.require(:author).permit(:first_name, :last_name, :homepage))

Expand Down
35 changes: 35 additions & 0 deletions app/views/authors/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1>Editing author</h1>

<%= form_for :article, url: article_path(@article), method: :patch do |f| %>

<% if @article.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@article.errors.count, "error") %> prohibited
this article from being saved:
</h2>
<ul>
<% @article.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>

<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
</p>

<p>
<%= f.submit %>
</p>

<% end %>

<%= link_to 'Back', articles_path %>
10 changes: 10 additions & 0 deletions spec/features/author/edit_author_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'rails_helper'

describe "Edit author page", type: :feature do

it "should render withour error" do
@alan = FactoryGirl.create :author
visit edit_author_path(@alan)
end

end

0 comments on commit bb5bdd7

Please sign in to comment.