Skip to content

Commit

Permalink
Refs #17: add mock papers/new
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBrendel committed Nov 3, 2017
1 parent a7b90b8 commit 55765f9
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/papers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/papers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
5 changes: 5 additions & 0 deletions app/controllers/papers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class PapersController < ApplicationController
def new
#@paper = Paper.new
end
end
2 changes: 2 additions & 0 deletions app/helpers/papers_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PapersHelper
end
21 changes: 21 additions & 0 deletions app/views/papers/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%= form_for :paper, url: papers_path do |f| %>

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

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

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

<p>
<%= f.submit %>
</p>
<% end %>
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Rails.application.routes.draw do
get 'papers/new'

get 'authors/new'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

resources :authors
resources :authors, :papers

# You can have the root of your site routed with "root"
root 'home#index'
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/papers_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails_helper'

RSpec.describe PapersController, type: :controller do

describe "GET #new" do
it "returns http success" do
get :new
expect(response).to have_http_status(:success)
end
end

end
2 changes: 1 addition & 1 deletion spec/features/paper/new_paper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
visit new_paper_path
end

it 'should have text input for first title, venue and year' do
it 'should have text input for title, venue and year' do
visit new_paper_path

expect(page).to have_field('Title')
Expand Down
15 changes: 15 additions & 0 deletions spec/helpers/papers_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the PapersHelper. For example:
#
# describe PapersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe PapersHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/views/papers/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe "papers/new.html.erb", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 55765f9

Please sign in to comment.