diff --git a/.rspec b/.rspec
index 89b89ff..53607ea 100644
--- a/.rspec
+++ b/.rspec
@@ -1,2 +1 @@
--colour
---format=d
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index d643000..a7dc129 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,6 +22,16 @@ end
gem 'jquery-rails'
+group :test, :development do
+ gem "rspec-rails", "~> 2.0"
+ gem 'capybara'
+ gem 'launchy'
+end
+gem 'pry-rails'
+gem 'factory_girl_rails'
+gem 'bootstrap-sass', '2.0.0'
+gem "dynamic_form"
+
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
@@ -36,11 +46,3 @@ gem 'jquery-rails'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
-
-group :test, :development do
- gem "rspec-rails", "~> 2.0"
- gem 'capybara'
- gem 'launchy'
-end
-gem 'pry-rails'
-gem 'factory_girl_rails'
diff --git a/Gemfile.lock b/Gemfile.lock
index 0f24858..fef5a9c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -30,6 +30,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.8)
arel (3.0.2)
+ bootstrap-sass (2.0.0)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
@@ -49,6 +50,7 @@ GEM
execjs
coffee-script-source (1.3.3)
diff-lcs (1.1.3)
+ dynamic_form (1.1.4)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -75,13 +77,19 @@ GEM
treetop (~> 1.4.8)
method_source (0.7.1)
mime-types (1.18)
- multi_json (1.3.5)
+ multi_json (1.3.6)
nokogiri (1.5.2)
+ nokogiri (1.5.2-x86-mingw32)
polyglot (0.3.3)
pry (0.9.9.6)
coderay (~> 1.0.5)
method_source (~> 0.7.1)
slop (>= 2.4.4, < 3)
+ pry (0.9.9.6-x86-mingw32)
+ coderay (~> 1.0.5)
+ method_source (~> 0.7.1)
+ slop (>= 2.4.4, < 3)
+ win32console (~> 1.3)
pry-rails (0.1.6)
pry
rack (1.4.1)
@@ -140,6 +148,7 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
+ sqlite3 (1.3.6-x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -149,15 +158,18 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ win32console (1.3.2-x86-mingw32)
xpath (0.1.4)
nokogiri (~> 1.3)
PLATFORMS
- ruby
+ x86-mingw32
DEPENDENCIES
+ bootstrap-sass (= 2.0.0)
capybara
coffee-rails (~> 3.2.1)
+ dynamic_form
factory_girl_rails
jquery-rails
launchy
diff --git a/Rakefile b/Rakefile
index 5dc0f03..cd33acc 100644
--- a/Rakefile
+++ b/Rakefile
@@ -4,4 +4,4 @@
require File.expand_path('../config/application', __FILE__)
-BookMemo2::Application.load_tasks
+YacBookMemo::Application.load_tasks
diff --git a/app/assets/javascripts/memos.js.coffee b/app/assets/javascripts/memos.js.coffee
new file mode 100644
index 0000000..7615679
--- /dev/null
+++ b/app/assets/javascripts/memos.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 3b5cc66..9cd0403 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -11,3 +11,37 @@
*= require_self
*= require_tree .
*/
+
+@import "bootstrap";
+
+table
+{
+border-collapse:collapse;
+}
+
+th {
+ background-color: #AAAAAA;
+}
+
+th, td {
+ border: 1px solid black;
+ overflow: hidden;
+ width: 500px;
+}
+
+table,th, td
+{
+table-layout:auto;
+border: 1px solid black;
+text-align: center;
+}
+
+
+h2 {
+ font-size: 1.7em;
+ letter-spacing: -1px;
+ margin-bottom: 30px;
+ text-align: left;
+ font-weight: normal;
+ color: $grayLight;
+}
\ No newline at end of file
diff --git a/app/assets/stylesheets/memos.css.scss b/app/assets/stylesheets/memos.css.scss
new file mode 100644
index 0000000..3aaa23b
--- /dev/null
+++ b/app/assets/stylesheets/memos.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Memos controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb
index d13ffd9..2110bfa 100644
--- a/app/controllers/books_controller.rb
+++ b/app/controllers/books_controller.rb
@@ -1,6 +1,4 @@
class BooksController < ApplicationController
- before_filter :find_book, :only => [:show, :destroy, :edit, :update]
-
# GET /books
# GET /books.json
def index
@@ -8,7 +6,6 @@ def index
respond_to do |format|
format.html # index.html.erb
- format.xml { render xml: @books }
format.json { render json: @books }
end
end
@@ -16,9 +13,10 @@ def index
# GET /books/1
# GET /books/1.json
def show
+ @book = Book.find(params[:id])
+
respond_to do |format|
format.html # show.html.erb
- format.xml { render xml: @book }
format.json { render json: @book }
end
end
@@ -30,13 +28,13 @@ def new
respond_to do |format|
format.html # new.html.erb
- format.xml { render xml: @book }
format.json { render json: @book }
end
end
# GET /books/1/edit
def edit
+ @book = Book.find(params[:id])
end
# POST /books
@@ -47,11 +45,9 @@ def create
respond_to do |format|
if @book.save
format.html { redirect_to @book, notice: 'Book was successfully created.' }
- format.xml { render xml: @book, status: :created, location: @book }
format.json { render json: @book, status: :created, location: @book }
else
format.html { render action: "new" }
- format.xml { render xml: @book.errors, status: :unprocessable_entity }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
@@ -60,14 +56,14 @@ def create
# PUT /books/1
# PUT /books/1.json
def update
+ @book = Book.find(params[:id])
+
respond_to do |format|
if @book.update_attributes(params[:book])
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
- format.xml { head :no_content }
format.json { head :no_content }
else
format.html { render action: "edit" }
- format.xml { render xml: @book.errors, status: :unprocessable_entity }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
@@ -76,17 +72,12 @@ def update
# DELETE /books/1
# DELETE /books/1.json
def destroy
+ @book = Book.find(params[:id])
@book.destroy
respond_to do |format|
format.html { redirect_to books_url }
- format.xml { head :no_content }
format.json { head :no_content }
end
end
-
- private
- def find_book
- @book = Book.find(params[:id])
- end
end
diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
new file mode 100644
index 0000000..e928b3e
--- /dev/null
+++ b/app/controllers/memos_controller.rb
@@ -0,0 +1,50 @@
+class MemosController < ApplicationController
+
+
+ def index
+ @book = Book.find(params[:book_id])
+ @memos = @book.memos.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @memos }
+ end
+ end
+
+ def new
+ @book = Book.find(params[:book_id])
+ @memo = @book.memos.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @memo }
+ end
+ end
+
+ def create
+ @book = Book.find(params[:book_id])
+ @memo = @book.memos.new(params[:memo])
+
+ respond_to do |format|
+ if @memo.save
+ format.html { redirect_to book_memos_path, notice: 'Memo was successfully created.' }
+ else
+ format.html { render action: "new" }
+ end
+ end
+
+
+ end
+
+ def destroy
+ @book = Book.find(params[:book_id])
+ @memo = @book.memos.find(params[:id])
+ @memo.destroy
+
+ respond_to do |format|
+ format.html { redirect_to book_memos_path }
+ format.json { head :no_content }
+ end
+ end
+
+end
diff --git a/app/helpers/memos_helper.rb b/app/helpers/memos_helper.rb
new file mode 100644
index 0000000..0e732a1
--- /dev/null
+++ b/app/helpers/memos_helper.rb
@@ -0,0 +1,2 @@
+module MemosHelper
+end
diff --git a/app/models/book.rb b/app/models/book.rb
index 95c42dd..edf50a4 100644
--- a/app/models/book.rb
+++ b/app/models/book.rb
@@ -1,11 +1,9 @@
-# encoding: UTF-8
class Book < ActiveRecord::Base
- attr_accessible :memo, :purchased_on, :title
+ attr_accessible :author, :purchase_date, :title
+
validates :title, :presence => true
-
- before_create :total_books_count
-
- def total_books_count
- self.memo += "【 累計冊数#{Book.count + 1} 】"
- end
+
+ validates :author, :presence => true
+
+ has_many :memos, :dependent => :destroy
end
diff --git a/app/models/memo.rb b/app/models/memo.rb
new file mode 100644
index 0000000..18a1bea
--- /dev/null
+++ b/app/models/memo.rb
@@ -0,0 +1,7 @@
+class Memo < ActiveRecord::Base
+ belongs_to :book
+ attr_accessible :comment_date, :content, :name
+
+ validates :name, :presence => true
+ validates :content, :presence => true, :length => { :maximum => 100 }
+end
diff --git a/app/views/books/_form.html.erb b/app/views/books/_form.html.erb
index da45ee0..8d2dbaf 100644
--- a/app/views/books/_form.html.erb
+++ b/app/views/books/_form.html.erb
@@ -16,12 +16,12 @@
<%= f.text_field :title %>
- <%= f.label :memo %>
- <%= f.text_area :memo %>
+ <%= f.label :author %>
+ <%= f.text_field :author %>
- <%= f.label :purchased_on %>
- <%= f.date_select :purchased_on %>
+ <%= f.label :purchase_date %>
+ <%= f.date_select :purchase_date %>
<%= f.submit %>
diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb
index 5f03ad6..4215bf3 100644
--- a/app/views/books/index.html.erb
+++ b/app/views/books/index.html.erb
@@ -3,8 +3,8 @@
| Title |
- Memo |
- Purchased on |
+ Author |
+ Purchase date |
|
|
|
@@ -13,8 +13,8 @@
<% @books.each do |book| %>
| <%= book.title %> |
- <%= book.memo %> |
- <%= book.purchased_on %> |
+ <%= book.author %> |
+ <%= book.purchase_date %> |
<%= link_to 'Show', book %> |
<%= link_to 'Edit', edit_book_path(book) %> |
<%= link_to 'Destroy', book, confirm: 'Are you sure?', method: :delete %> |
@@ -24,4 +24,5 @@
-<%= link_to 'New Book', new_book_path %>
+<%= link_to 'New Book', new_book_path %>
+
diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb
index 23005ab..8eefcd8 100644
--- a/app/views/books/show.html.erb
+++ b/app/views/books/show.html.erb
@@ -6,15 +6,15 @@
- Memo:
- <%= @book.memo %>
+ Author:
+ <%= @book.author %>
- Purchased on:
- <%= @book.purchased_on %>
+ Purchase date:
+ <%= @book.purchase_date %>
-
<%= link_to 'Edit', edit_book_path(@book) %> |
+<%= link_to 'View Memos', book_memos_path(@book) %>|
<%= link_to 'Back', books_path %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 3bed8c4..83dcbee 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
- BookMemo2
+ YacBookMemo
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
diff --git a/app/views/memos/_form.html.erb b/app/views/memos/_form.html.erb
new file mode 100644
index 0000000..1f1e1a9
--- /dev/null
+++ b/app/views/memos/_form.html.erb
@@ -0,0 +1,29 @@
+<%= form_for([@book,@memo]) do |f| %>
+ <% if @memo.errors.any? %>
+
+
<%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:
+
+
+ <% @memo.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+ <%= f.label :content %>
+ <%= f.text_area :content %>
+
+
+ <%= f.label :comment_date %>
+ <%= f.date_select :comment_date %>
+
+
+ <%= f.submit %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/memos/_memo.html.erb b/app/views/memos/_memo.html.erb
new file mode 100644
index 0000000..70049ab
--- /dev/null
+++ b/app/views/memos/_memo.html.erb
@@ -0,0 +1,16 @@
+Book:
+ <%= @book.title %>
+ <% if @book.memos.any? %>
+Memos: <%= @book.memos.count %>
+
+ <% @memos.each do |memo| %>
+
+ On <%= memo.comment_date %>, <%= memo.name %> wrote:
+ <%= memo.content %>
+ <%= link_to 'Delete Memo', [memo.book, memo], confirm: 'Are you sure?', method: :delete %>
+ |
+<% end %>
+
+<% else %>
+No memos. Please write a new one.
+<% end %>
\ No newline at end of file
diff --git a/app/views/memos/index.html.erb b/app/views/memos/index.html.erb
new file mode 100644
index 0000000..9df1499
--- /dev/null
+++ b/app/views/memos/index.html.erb
@@ -0,0 +1,7 @@
+<%= notice %>
+<%= render 'memo' %>
+<%= link_to 'New Memo', new_book_memo_path(@book) %>|
+<%= link_to 'Back to Book', book_path(@book) %>
+
+
+
diff --git a/app/views/memos/new.html.erb b/app/views/memos/new.html.erb
new file mode 100644
index 0000000..73b992a
--- /dev/null
+++ b/app/views/memos/new.html.erb
@@ -0,0 +1,5 @@
+New Memo
+
+<%= render 'form' %>
+
+<%= link_to 'Back', book_memos_path %>
\ No newline at end of file
diff --git a/config.ru b/config.ru
index 91b104f..27e3472 100644
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run BookMemo2::Application
+run YacBookMemo::Application
diff --git a/config/application.rb b/config/application.rb
index 07dc8af..34bf021 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,12 +1,6 @@
require File.expand_path('../boot', __FILE__)
-# Pick the frameworks you want:
-require "active_record/railtie"
-require "action_controller/railtie"
-require "action_mailer/railtie"
-require "active_resource/railtie"
-require "sprockets/railtie"
-# require "rails/test_unit/railtie"
+require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
@@ -15,7 +9,7 @@
# Bundler.require(:default, :assets, Rails.env)
end
-module BookMemo2
+module YacBookMemo
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
diff --git a/config/environment.rb b/config/environment.rb
index 44aa6ab..af33576 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)
# Initialize the rails application
-BookMemo2::Application.initialize!
+YacBookMemo::Application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 2be7b65..dc99641 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,4 +1,4 @@
-BookMemo2::Application.configure do
+YacBookMemo::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 2e2826f..cf99651 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,4 +1,4 @@
-BookMemo2::Application.configure do
+YacBookMemo::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
diff --git a/config/environments/test.rb b/config/environments/test.rb
index aebc324..425a797 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,4 +1,4 @@
-BookMemo2::Application.configure do
+YacBookMemo::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
index 018120e..5d3b6ce 100644
--- a/config/initializers/secret_token.rb
+++ b/config/initializers/secret_token.rb
@@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
-BookMemo2::Application.config.secret_token = '97ab978246c99f550f2228ffb4b6b7bd6d1f515ec3810c3d1d7225f631f7d31defa4f7bc6cd11d9376e19711a951135b188bff86f6a3bc646aa95fc54ba87bb7'
+YacBookMemo::Application.config.secret_token = 'dc7daa364d5c23a9a9d46ec8de62a4fb7df7161f0be22add3b0c018cb2286c9814f339ae5d39ae6832c8bb86c1bb36c19d7810100f36a5f73435e46ae06d4f76'
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 8ed19e1..c0599a4 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
-BookMemo2::Application.config.session_store :cookie_store, key: '_book_memo2_session'
+YacBookMemo::Application.config.session_store :cookie_store, key: '_yac_book_memo_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
-# BookMemo2::Application.config.session_store :active_record_store
+# YacBookMemo::Application.config.session_store :active_record_store
diff --git a/config/routes.rb b/config/routes.rb
index f3d38ab..155c0df 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,11 @@
-BookMemo2::Application.routes.draw do
- resources :books
-
+YacBookMemo::Application.routes.draw do
+ root :to => 'books#index'
+ resources :books do
+ resources :memos
+ end
+
+ #match "/books/:id/memos" => "memos#show"
+
# The priority is based upon order of creation:
# first created -> highest priority.
diff --git a/db/migrate/20120614014639_create_books.rb b/db/migrate/20120614014639_create_books.rb
new file mode 100644
index 0000000..9aa5aa7
--- /dev/null
+++ b/db/migrate/20120614014639_create_books.rb
@@ -0,0 +1,11 @@
+class CreateBooks < ActiveRecord::Migration
+ def change
+ create_table :books do |t|
+ t.string :title
+ t.string :author
+ t.date :purchase_date
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20120614015411_create_memos.rb b/db/migrate/20120614015411_create_memos.rb
new file mode 100644
index 0000000..38f0a4e
--- /dev/null
+++ b/db/migrate/20120614015411_create_memos.rb
@@ -0,0 +1,13 @@
+class CreateMemos < ActiveRecord::Migration
+ def change
+ create_table :memos do |t|
+ t.text :name
+ t.text :content
+ t.date :comment_date
+ t.references :book
+
+ t.timestamps
+ end
+ add_index :memos, :book_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5fc61c2..08f272d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,24 +1,35 @@
-# encoding: UTF-8
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(:version => 20120526050801) do
-
- create_table "books", :force => true do |t|
- t.string "title"
- t.text "memo"
- t.date "purchased_on"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
-end
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20120614015411) do
+
+ create_table "books", :force => true do |t|
+ t.string "title"
+ t.string "author"
+ t.date "purchase_date"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "memos", :force => true do |t|
+ t.text "name"
+ t.text "content"
+ t.date "comment_date"
+ t.integer "book_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "memos", ["book_id"], :name => "index_memos_on_book_id"
+
+end
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
new file mode 100644
index 0000000..a84eca2
--- /dev/null
+++ b/nbproject/private/private.properties
@@ -0,0 +1 @@
+rails.servertype=WEBRICK
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644
index 0000000..cc2c0e5
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/nbproject/private/rake-d.txt b/nbproject/private/rake-d.txt
new file mode 100644
index 0000000..d503cf5
--- /dev/null
+++ b/nbproject/private/rake-d.txt
@@ -0,0 +1,114 @@
+about=
+assets\:clean=
+assets\:clean\:all=
+assets\:environment=
+assets\:precompile=
+assets\:precompile\:all=
+assets\:precompile\:nondigest=
+assets\:precompile\:primary=
+db\:_dump=
+db\:abort_if_pending_migrations=
+db\:charset=
+db\:collation=
+db\:create=
+db\:create\:all=
+db\:drop=
+db\:drop\:all=
+db\:fixtures\:identify=
+db\:fixtures\:load=
+db\:forward=
+db\:load_config=
+db\:migrate=
+db\:migrate\:down=
+db\:migrate\:redo=
+db\:migrate\:reset=
+db\:migrate\:status=
+db\:migrate\:up=
+db\:reset=
+db\:rollback=
+db\:schema\:dump=
+db\:schema\:load=
+db\:schema\:load_if_ruby=
+db\:seed=
+db\:sessions\:clear=
+db\:sessions\:create=
+db\:setup=
+db\:structure\:dump=
+db\:structure\:load=
+db\:structure\:load_if_sql=
+db\:test\:clone=
+db\:test\:clone_structure=
+db\:test\:load=
+db\:test\:load_schema=
+db\:test\:load_structure=
+db\:test\:prepare=
+db\:test\:purge=
+db\:version=
+default=
+doc=
+doc/api=
+doc/api/index.html=
+doc/app=
+doc/app/index.html=
+doc\:app=Generate docs for the app -- also available doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
+doc\:clobber=
+doc\:clobber_app=
+doc\:clobber_plugins=
+doc\:clobber_rails=
+doc\:guides=
+doc\:plugins=
+doc\:rails=
+doc\:reapp=
+doc\:rerails=
+environment=
+log\:clear=
+middleware=
+noop=
+notes=
+notes\:custom=
+notes\:fixme=
+notes\:optimize=
+notes\:todo=
+rails\:template=
+rails\:templates\:copy=
+rails\:update=
+rails\:update\:application_controller=
+rails\:update\:configs=
+rails\:update\:scripts=
+rails_env=
+railties\:install\:migrations=
+routes=
+secret=
+spec=
+spec\:controllers=
+spec\:helpers=
+spec\:lib=
+spec\:mailers=
+spec\:models=
+spec\:rcov=
+spec\:requests=
+spec\:routing=
+spec\:statsetup=
+spec\:views=
+stats=
+test=
+test\:benchmark=
+test\:functionals=
+test\:integration=
+test\:plugins=
+test\:prepare=
+test\:profile=
+test\:recent=Test recent changes
+test\:run=
+test\:single=
+test\:uncommitted=Test changes since last checkin (only Subversion and Git)
+test\:units=
+time\:zones\:all=
+time\:zones\:local=
+time\:zones\:us=
+tmp\:cache\:clear=
+tmp\:clear=
+tmp\:create=
+tmp\:pids\:clear=
+tmp\:sessions\:clear=
+tmp\:sockets\:clear=
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..6766cac
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,3 @@
+platform.active=Ruby
+rails.port=3000
+source.encoding=UTF-8
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..ea2dcc5
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,9 @@
+
+
+ org.netbeans.modules.ruby.railsprojects
+
+
+ yac_book_memo
+
+
+
diff --git a/script/rails b/script/rails
index f8da2cf..81eab02 100755
--- a/script/rails
+++ b/script/rails
@@ -1,4 +1,4 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env ruby.exe
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb
index eb6727c..e0cb749 100644
--- a/spec/controllers/books_controller_spec.rb
+++ b/spec/controllers/books_controller_spec.rb
@@ -1,66 +1,38 @@
require 'spec_helper'
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
describe BooksController do
-
- # This should return the minimal set of attributes required to create a valid
- # Book. As you add validations to Book, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- { title: 'book title', memo: '' }
- end
- # This should return the minimal set of values that should be in the session
- # in order to pass any filters (e.g. authentication) defined in
- # BooksController. Be sure to keep this updated too.
- def valid_session
- {}
+ def valid_attributes
+ { :title => 'test title', :author => 'test author', :purchase_date => '2012-06-06' }
end
-
+
describe "GET index" do
- it "assigns all books as @books" do
+ it "displays all books" do
book = Book.create! valid_attributes
- get :index, {}, valid_session
+ get :index, {}
assigns(:books).should eq([book])
end
end
describe "GET show" do
- it "assigns the requested book as @book" do
+ it "displays a book" do
book = Book.create! valid_attributes
- get :show, {:id => book.to_param}, valid_session
+ get :show, {:id => book.to_param}
assigns(:book).should eq(book)
end
end
describe "GET new" do
- it "assigns a new book as @book" do
- get :new, {}, valid_session
+ it "displays new book screen" do
+ get :new, {}
assigns(:book).should be_a_new(Book)
end
end
describe "GET edit" do
- it "assigns the requested book as @book" do
+ it "edits an existing book" do
book = Book.create! valid_attributes
- get :edit, {:id => book.to_param}, valid_session
+ get :edit, {:id => book.to_param}
assigns(:book).should eq(book)
end
end
@@ -69,18 +41,18 @@ def valid_session
describe "with valid params" do
it "creates a new Book" do
expect {
- post :create, {:book => valid_attributes}, valid_session
+ post :create, {:book => valid_attributes}
}.to change(Book, :count).by(1)
end
it "assigns a newly created book as @book" do
- post :create, {:book => valid_attributes}, valid_session
+ post :create, {:book => valid_attributes}
assigns(:book).should be_a(Book)
assigns(:book).should be_persisted
end
it "redirects to the created book" do
- post :create, {:book => valid_attributes}, valid_session
+ post :create, {:book => valid_attributes}
response.should redirect_to(Book.last)
end
end
@@ -89,14 +61,14 @@ def valid_session
it "assigns a newly created but unsaved book as @book" do
# Trigger the behavior that occurs when invalid params are submitted
Book.any_instance.stub(:save).and_return(false)
- post :create, {:book => {}}, valid_session
+ post :create, {:book => {}}
assigns(:book).should be_a_new(Book)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Book.any_instance.stub(:save).and_return(false)
- post :create, {:book => {}}, valid_session
+ post :create, {:book => {}}
response.should render_template("new")
end
end
@@ -111,18 +83,18 @@ def valid_session
# receives the :update_attributes message with whatever params are
# submitted in the request.
Book.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, {:id => book.to_param, :book => {'these' => 'params'}}, valid_session
+ put :update, {:id => book.to_param, :book => {'these' => 'params'}}
end
it "assigns the requested book as @book" do
book = Book.create! valid_attributes
- put :update, {:id => book.to_param, :book => valid_attributes}, valid_session
+ put :update, {:id => book.to_param, :book => valid_attributes}
assigns(:book).should eq(book)
end
it "redirects to the book" do
book = Book.create! valid_attributes
- put :update, {:id => book.to_param, :book => valid_attributes}, valid_session
+ put :update, {:id => book.to_param, :book => valid_attributes}
response.should redirect_to(book)
end
end
@@ -132,7 +104,7 @@ def valid_session
book = Book.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Book.any_instance.stub(:save).and_return(false)
- put :update, {:id => book.to_param, :book => {}}, valid_session
+ put :update, {:id => book.to_param, :book => {}}
assigns(:book).should eq(book)
end
@@ -140,7 +112,7 @@ def valid_session
book = Book.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Book.any_instance.stub(:save).and_return(false)
- put :update, {:id => book.to_param, :book => {}}, valid_session
+ put :update, {:id => book.to_param, :book => {}}
response.should render_template("edit")
end
end
@@ -150,15 +122,15 @@ def valid_session
it "destroys the requested book" do
book = Book.create! valid_attributes
expect {
- delete :destroy, {:id => book.to_param}, valid_session
+ delete :destroy, {:id => book.to_param}
}.to change(Book, :count).by(-1)
end
it "redirects to the books list" do
book = Book.create! valid_attributes
- delete :destroy, {:id => book.to_param}, valid_session
+ delete :destroy, {:id => book.to_param}
response.should redirect_to(books_url)
end
end
-
-end
+
+end
\ No newline at end of file
diff --git a/spec/controllers/memos_controller_spec.rb b/spec/controllers/memos_controller_spec.rb
new file mode 100644
index 0000000..30bd897
--- /dev/null
+++ b/spec/controllers/memos_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe MemosController do
+
+end
\ No newline at end of file
diff --git a/spec/factories/books.rb b/spec/factories/books.rb
index 2047d44..11f865c 100644
--- a/spec/factories/books.rb
+++ b/spec/factories/books.rb
@@ -3,8 +3,8 @@
FactoryGirl.define do
factory :book do
- sequence(:title) { |n| "title_#{n}" }
- memo "this is memo"
- purchased_on Time.now
+ sequence(:title) { |n| "test_title_#{n}" }
+ author "mr jones"
+ purchase_date Time.now
end
end
diff --git a/spec/factories/memo.rb b/spec/factories/memo.rb
new file mode 100644
index 0000000..529fb10
--- /dev/null
+++ b/spec/factories/memo.rb
@@ -0,0 +1,10 @@
+# coding:utf-8
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :memo do
+ sequence(:content) { |n| "this is comment number #{n}" }
+ name "me"
+ comment_date Time.now
+ end
+end
diff --git a/spec/models/book_spec.rb b/spec/models/book_spec.rb
index f820855..c4ee2b7 100644
--- a/spec/models/book_spec.rb
+++ b/spec/models/book_spec.rb
@@ -1,21 +1,33 @@
-# coding:utf-8
require 'spec_helper'
describe Book do
- describe 'validation' do
- describe 'title' do
- subject { Book.new.valid? }
- it '未入力の場合はエラー' do
- should be_false
- end
+
+ before do
+ @book=Book.new
end
- end
- describe '#total_books_count' do
- let(:book){ FactoryGirl.build :book }
- before { book.save }
- it "memoに累計冊数が表示されること" do
- book.memo.should include "【 累計冊数#{Book.count} 】"
+ subject { @book}
+
+ it { should respond_to(:author) }
+ it { should respond_to(:purchase_date) }
+ it { should respond_to(:title) }
+
+ describe "When author field is blank" do
+ before { @book.author = "" }
+ it { should_not be_valid }
end
+
+ describe "When title field is blank" do
+ before { @book.title = "" }
+ it { should_not be_valid }
+ end
+
+ describe 'the book title' do
+ let(:book){ FactoryGirl.build :book }
+ before { book.save }
+ it "should be as indicated" do
+ book.title.should include "test"
+ end
end
-end
+
+end
\ No newline at end of file
diff --git a/spec/models/memo_spec.rb b/spec/models/memo_spec.rb
new file mode 100644
index 0000000..b0db29a
--- /dev/null
+++ b/spec/models/memo_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe Memo do
+
+ before do
+ @memo=Memo.new
+ end
+
+ subject { @memo}
+
+ it { should respond_to(:name) }
+ it { should respond_to(:content) }
+ it { should respond_to(:comment_date) }
+
+ describe "When author field is blank" do
+ before { @memo.name = "" }
+ it { should_not be_valid }
+ end
+
+ describe "When title field is blank" do
+ before { @memo.content = "" }
+ it { should_not be_valid }
+ end
+
+ describe "When memo is too long" do
+ before { @memo.content = "a"*150 }
+ it { should_not be_valid }
+ end
+
+ describe 'thecomment content' do
+ let(:memo){ FactoryGirl.build :memo }
+ before { memo.save }
+ it "should be as indicated" do
+ memo.content.should include "this is comment"
+ end
+ end
+
+
+
+end
\ No newline at end of file
diff --git a/spec/requests/memos_spec.rb b/spec/requests/memos_spec.rb
new file mode 100644
index 0000000..e159381
--- /dev/null
+++ b/spec/requests/memos_spec.rb
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Memos" do
+
+ describe "GET /books/:book_id/memos" do
+ let!(:book){ FactoryGirl.create :book }
+ subject { page }
+
+ it "displays memos" do
+ get "/books/#{book.id}/memos"
+ response.status.should be(200)
+ end
+
+ before { visit "/books/#{book.id}/memos/new" }
+
+ context "create new memo" do
+
+ let(:test_name1){ 'name1' }
+ let(:test_content1){ 'test content 1' }
+
+ before do
+ fill_in "memo[name]", with: :test_name1
+ fill_in "memo[content]", with: :test_content1
+ click_on 'Create Memo'
+ end
+
+ it "redirects to memos index page " do
+ current_path.should == book_memos_path(book)
+ end
+
+ let(:test_name2){ 'name2' }
+ let(:test_content2){ 'test content 2' }
+
+ before do
+ fill_in "memo[name]", with: :test_name2
+ fill_in "memo[content]", with: :test_content2
+ click_on 'Create Memo'
+ end
+
+ it "redirects to memos index page " do
+ current_path.should == book_memos_path(book)
+ end
+
+
+
+ end
+
+ end
+
+
+end
\ No newline at end of file
diff --git a/spec/routing/books_routing_spec.rb b/spec/routing/books_routing_spec.rb
index 187a511..36244f1 100644
--- a/spec/routing/books_routing_spec.rb
+++ b/spec/routing/books_routing_spec.rb
@@ -1,6 +1,7 @@
require "spec_helper"
describe BooksController do
+
describe "routing" do
it "routes to #index" do
diff --git a/spec/routing/memos_routing_spec.rb b/spec/routing/memos_routing_spec.rb
new file mode 100644
index 0000000..2303eb6
--- /dev/null
+++ b/spec/routing/memos_routing_spec.rb
@@ -0,0 +1,24 @@
+require "spec_helper"
+
+describe MemosController do
+
+ describe "routing" do
+
+ it "routes to #index" do
+ get("/books/1/memos").should route_to("memos#index", :book_id => "1")
+ end
+
+ it "routes to #new" do
+ get("/books/1/memos/new").should route_to("memos#new", :book_id => "1")
+ end
+
+ it "routes to #create" do
+ post("/books/1/memos").should route_to("memos#create", :book_id => "1" )
+ end
+
+ it "routes to #destroy" do
+ delete("/books/1/memos/1").should route_to("memos#destroy", :book_id => "1", :id => "1")
+ end
+
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e66d980..4c6b7e7 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,6 +6,14 @@
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
+
+module ::RSpec::Core
+ class ExampleGroup
+ include Capybara::DSL
+ include Capybara::RSpecMatchers
+ end
+end
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
diff --git a/spec/views/books/edit.html.erb_spec.rb b/spec/views/books/edit.html.erb_spec.rb
index 87484cb..efd07e9 100644
--- a/spec/views/books/edit.html.erb_spec.rb
+++ b/spec/views/books/edit.html.erb_spec.rb
@@ -3,18 +3,17 @@
describe "books/edit" do
before(:each) do
@book = assign(:book, stub_model(Book,
- :title => "MyString",
- :memo => "MyText"
+ :title => "test Title",
+ :author => "test author"
))
end
it "renders the edit book form" do
render
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => books_path(@book), :method => "post" do
+ assert_select "form", :action => books_path(@book), :method => "post" do
assert_select "input#book_title", :name => "book[title]"
- assert_select "textarea#book_memo", :name => "book[memo]"
+ assert_select "input#book_author", :name => "book[author]"
end
end
end
diff --git a/spec/views/books/index.html.erb_spec.rb b/spec/views/books/index.html.erb_spec.rb
index 190efa1..7d36ede 100644
--- a/spec/views/books/index.html.erb_spec.rb
+++ b/spec/views/books/index.html.erb_spec.rb
@@ -4,20 +4,19 @@
before(:each) do
assign(:books, [
stub_model(Book,
- :title => "Title",
- :memo => "MyText"
+ :title => "test Title",
+ :author => "test author"
),
stub_model(Book,
- :title => "Title",
- :memo => "MyText"
+ :title => "test Title",
+ :author => "test author"
)
])
end
it "renders a list of books" do
render
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => "Title".to_s, :count => 2
- assert_select "tr>td", :text => "MyText".to_s, :count => 2
+ assert_select "tr>td", :text => "test Title".to_s, :count => 2
+ assert_select "tr>td", :text => "test author".to_s, :count => 2
end
end
diff --git a/spec/views/books/new.html.erb_spec.rb b/spec/views/books/new.html.erb_spec.rb
index e9c5dc7..213b13e 100644
--- a/spec/views/books/new.html.erb_spec.rb
+++ b/spec/views/books/new.html.erb_spec.rb
@@ -3,18 +3,17 @@
describe "books/new" do
before(:each) do
assign(:book, stub_model(Book,
- :title => "MyString",
- :memo => "MyText"
+ :title => "test Title",
+ :author => "test author"
).as_new_record)
end
it "renders new book form" do
render
- # Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => books_path, :method => "post" do
assert_select "input#book_title", :name => "book[title]"
- assert_select "textarea#book_memo", :name => "book[memo]"
+ assert_select "input#book_author", :name => "book[memo]"
end
end
-end
+end
\ No newline at end of file
diff --git a/spec/views/books/show.html.erb_spec.rb b/spec/views/books/show.html.erb_spec.rb
index 82d0e4b..f0984dd 100644
--- a/spec/views/books/show.html.erb_spec.rb
+++ b/spec/views/books/show.html.erb_spec.rb
@@ -3,15 +3,15 @@
describe "books/show" do
before(:each) do
@book = assign(:book, stub_model(Book,
- :title => "Title",
- :memo => "MyText"
+ :title => "test Title",
+ :author => "test author"
))
end
it "renders attributes in " do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- rendered.should match(/Title/)
- rendered.should match(/MyText/)
+ rendered.should match(/test Title/)
+ rendered.should match(/test author/)
end
end
diff --git a/spec/views/memos/index.html.erb_spec.rb b/spec/views/memos/index.html.erb_spec.rb
new file mode 100644
index 0000000..f0970f9
--- /dev/null
+++ b/spec/views/memos/index.html.erb_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe "books/:book_id/memos" do
+
+ before(:each) do
+ @book=assign(:book, stub_model(Book,
+ :title => "test Title",
+ :author => "test author",
+ :book_id => "1"
+ ))
+ assign(:memos, [
+ stub_model(Memo,
+ :name => "test name",
+ :content => "test content"
+ ),
+ stub_model(Memo,
+ :name => "test name",
+ :content => "test content"
+ )
+ ])
+ end
+
+ it "renders index memo" do
+ render :template => "memos/_memo", :layout => "layouts/application"
+
+ end
+
+end
diff --git a/spec/views/memos/new.html.erb_spec.rb b/spec/views/memos/new.html.erb_spec.rb
new file mode 100644
index 0000000..58e9855
--- /dev/null
+++ b/spec/views/memos/new.html.erb_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe "/books/:book_id/memos/new" do
+ before(:each) do
+ @book = assign(:book, stub_model(Book,
+ :title => "test Title",
+ :author => "test author",
+ :book_id => "1"
+ ))
+ assign(:memo, stub_model(Memo,
+ :name => "test name",
+ :content => "test content"
+ ).as_new_record)
+ end
+
+ it "renders new memo form" do
+ render :template => "memos/_form", :layout => "layouts/application"
+
+ assert_select "form", :action => book_memos_path(@book), :method => "post" do
+ assert_select "input#memo_name", :name => "memo[name]"
+ assert_select "textarea#memo_content", :name => "memo[content]"
+ end
+ end
+end
\ No newline at end of file
diff --git a/test/fixtures/.gitkeep b/test/fixtures/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/books.yml b/test/fixtures/books.yml
new file mode 100644
index 0000000..b11df8c
--- /dev/null
+++ b/test/fixtures/books.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ title: MyString
+ author: MyString
+ purchase_date: 2012-06-14
+
+two:
+ title: MyString
+ author: MyString
+ purchase_date: 2012-06-14
diff --git a/test/fixtures/memos.yml b/test/fixtures/memos.yml
new file mode 100644
index 0000000..fd690db
--- /dev/null
+++ b/test/fixtures/memos.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyText
+ content: MyText
+ comment_date: 2012-06-14
+ book:
+
+two:
+ name: MyText
+ content: MyText
+ comment_date: 2012-06-14
+ book:
diff --git a/test/functional/.gitkeep b/test/functional/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/test/functional/books_controller_test.rb b/test/functional/books_controller_test.rb
new file mode 100644
index 0000000..e0afc8a
--- /dev/null
+++ b/test/functional/books_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class BooksControllerTest < ActionController::TestCase
+ setup do
+ @book = books(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:books)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create book" do
+ assert_difference('Book.count') do
+ post :create, book: { author: @book.author, purchase_date: @book.purchase_date, title: @book.title }
+ end
+
+ assert_redirected_to book_path(assigns(:book))
+ end
+
+ test "should show book" do
+ get :show, id: @book
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @book
+ assert_response :success
+ end
+
+ test "should update book" do
+ put :update, id: @book, book: { author: @book.author, purchase_date: @book.purchase_date, title: @book.title }
+ assert_redirected_to book_path(assigns(:book))
+ end
+
+ test "should destroy book" do
+ assert_difference('Book.count', -1) do
+ delete :destroy, id: @book
+ end
+
+ assert_redirected_to books_path
+ end
+end
diff --git a/test/functional/memos_controller_test.rb b/test/functional/memos_controller_test.rb
new file mode 100644
index 0000000..e5f58df
--- /dev/null
+++ b/test/functional/memos_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class MemosControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/integration/.gitkeep b/test/integration/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb
new file mode 100644
index 0000000..3fea27b
--- /dev/null
+++ b/test/performance/browsing_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class BrowsingTest < ActionDispatch::PerformanceTest
+ # Refer to the documentation for all available options
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # :output => 'tmp/performance', :formats => [:flat] }
+
+ def test_homepage
+ get '/'
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..8bf1192
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/test/unit/book_test.rb b/test/unit/book_test.rb
new file mode 100644
index 0000000..e48079d
--- /dev/null
+++ b/test/unit/book_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class BookTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/helpers/books_helper_test.rb b/test/unit/helpers/books_helper_test.rb
new file mode 100644
index 0000000..b4547f9
--- /dev/null
+++ b/test/unit/helpers/books_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class BooksHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/memos_helper_test.rb b/test/unit/helpers/memos_helper_test.rb
new file mode 100644
index 0000000..44a7038
--- /dev/null
+++ b/test/unit/helpers/memos_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class MemosHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/memo_test.rb b/test/unit/memo_test.rb
new file mode 100644
index 0000000..b3f59b9
--- /dev/null
+++ b/test/unit/memo_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class MemoTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end