From 55765f9a751866be4935b11499de667e3220734b Mon Sep 17 00:00:00 2001 From: Erik Brendel Date: Fri, 3 Nov 2017 21:09:42 +0100 Subject: [PATCH] Refs #17: add mock papers/new --- app/assets/javascripts/papers.js | 2 ++ app/assets/stylesheets/papers.css | 4 ++++ app/controllers/papers_controller.rb | 5 +++++ app/helpers/papers_helper.rb | 2 ++ app/views/papers/new.html.erb | 21 +++++++++++++++++++++ config/routes.rb | 4 +++- spec/controllers/papers_controller_spec.rb | 12 ++++++++++++ spec/features/paper/new_paper_spec.rb | 2 +- spec/helpers/papers_helper_spec.rb | 15 +++++++++++++++ spec/views/papers/new.html.erb_spec.rb | 5 +++++ 10 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/papers.js create mode 100644 app/assets/stylesheets/papers.css create mode 100644 app/controllers/papers_controller.rb create mode 100644 app/helpers/papers_helper.rb create mode 100644 app/views/papers/new.html.erb create mode 100644 spec/controllers/papers_controller_spec.rb create mode 100644 spec/helpers/papers_helper_spec.rb create mode 100644 spec/views/papers/new.html.erb_spec.rb diff --git a/app/assets/javascripts/papers.js b/app/assets/javascripts/papers.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/papers.js @@ -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. diff --git a/app/assets/stylesheets/papers.css b/app/assets/stylesheets/papers.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/papers.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/papers_controller.rb b/app/controllers/papers_controller.rb new file mode 100644 index 0000000..b4dbce3 --- /dev/null +++ b/app/controllers/papers_controller.rb @@ -0,0 +1,5 @@ +class PapersController < ApplicationController + def new + #@paper = Paper.new + end +end diff --git a/app/helpers/papers_helper.rb b/app/helpers/papers_helper.rb new file mode 100644 index 0000000..323706d --- /dev/null +++ b/app/helpers/papers_helper.rb @@ -0,0 +1,2 @@ +module PapersHelper +end diff --git a/app/views/papers/new.html.erb b/app/views/papers/new.html.erb new file mode 100644 index 0000000..fe0f2e5 --- /dev/null +++ b/app/views/papers/new.html.erb @@ -0,0 +1,21 @@ +<%= form_for :paper, url: papers_path do |f| %> + +

+ <%= f.label :title %>
+ <%= f.text_field :title %> +

+ +

+ <%= f.label :venue %>
+ <%= f.text_field :venue %> +

+ +

+ <%= f.label :year %>
+ <%= f.text_field :year %> +

+ +

+ <%= f.submit %> +

+<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d2d4181..892ebe8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/spec/controllers/papers_controller_spec.rb b/spec/controllers/papers_controller_spec.rb new file mode 100644 index 0000000..c0b799c --- /dev/null +++ b/spec/controllers/papers_controller_spec.rb @@ -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 diff --git a/spec/features/paper/new_paper_spec.rb b/spec/features/paper/new_paper_spec.rb index 578e319..b73ae7c 100644 --- a/spec/features/paper/new_paper_spec.rb +++ b/spec/features/paper/new_paper_spec.rb @@ -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') diff --git a/spec/helpers/papers_helper_spec.rb b/spec/helpers/papers_helper_spec.rb new file mode 100644 index 0000000..8dfc3d1 --- /dev/null +++ b/spec/helpers/papers_helper_spec.rb @@ -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 diff --git a/spec/views/papers/new.html.erb_spec.rb b/spec/views/papers/new.html.erb_spec.rb new file mode 100644 index 0000000..8948484 --- /dev/null +++ b/spec/views/papers/new.html.erb_spec.rb @@ -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