diff --git a/tracks/app/controllers/note_controller.rb b/tracks/app/controllers/notes_controller.rb
similarity index 95%
rename from tracks/app/controllers/note_controller.rb
rename to tracks/app/controllers/notes_controller.rb
index 46c6bbbd..03447eb7 100644
--- a/tracks/app/controllers/note_controller.rb
+++ b/tracks/app/controllers/notes_controller.rb
@@ -1,4 +1,4 @@
-class NoteController < ApplicationController
+class NotesController < ApplicationController
def index
@all_notes = @user.notes
@@ -27,7 +27,7 @@ class NoteController < ApplicationController
end
end
- def delete
+ def destroy
note = check_user_return_note
if note.destroy
render :text => ''
diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb
index b3f3dd8f..f38f4a46 100644
--- a/tracks/app/controllers/projects_controller.rb
+++ b/tracks/app/controllers/projects_controller.rb
@@ -1,6 +1,6 @@
class ProjectsController < ApplicationController
- helper :todo
+ helper :todo, :notes
before_filter :init, :except => [:create, :destroy, :order]
def index
diff --git a/tracks/app/helpers/note_helper.rb b/tracks/app/helpers/note_helper.rb
deleted file mode 100644
index d27337d4..00000000
--- a/tracks/app/helpers/note_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module NoteHelper
-end
diff --git a/tracks/app/helpers/notes_helper.rb b/tracks/app/helpers/notes_helper.rb
new file mode 100644
index 00000000..6216f08b
--- /dev/null
+++ b/tracks/app/helpers/notes_helper.rb
@@ -0,0 +1,5 @@
+module NotesHelper
+ def truncated_note(note, characters = 50)
+ sanitize(textilize(truncate(note.body, characters, "...")))
+ end
+end
diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml
index 9f50b126..ac2a673c 100644
--- a/tracks/app/views/layouts/standard.rhtml
+++ b/tracks/app/views/layouts/standard.rhtml
@@ -45,7 +45,7 @@
-<%= link_to( image_tag("blank.png", :border => 0), { :controller => "note", :action => "show",
- :id => note.id}, :title => "Show note", :class => "show_notes icon") %>
-<%= sanitize(textilize(truncate(note.body, 50, "..."))) %>
-
-<% note = nil -%>
diff --git a/tracks/app/views/note/_note_edit_form.rhtml b/tracks/app/views/notes/_note_edit_form.rhtml
similarity index 100%
rename from tracks/app/views/note/_note_edit_form.rhtml
rename to tracks/app/views/notes/_note_edit_form.rhtml
diff --git a/tracks/app/views/notes/_notes.rhtml b/tracks/app/views/notes/_notes.rhtml
new file mode 100644
index 00000000..3a329481
--- /dev/null
+++ b/tracks/app/views/notes/_notes.rhtml
@@ -0,0 +1,35 @@
+<% note = notes -%>
+
+<%= link_to( image_tag("blank.png", :border => 0), note_path(note), :title => "Show note", :class => "show_notes icon") %>
+<%= truncated_note(note) %>
+
+<% note = nil -%>
diff --git a/tracks/app/views/note/index.rhtml b/tracks/app/views/notes/index.rhtml
similarity index 100%
rename from tracks/app/views/note/index.rhtml
rename to tracks/app/views/notes/index.rhtml
diff --git a/tracks/app/views/note/show.rhtml b/tracks/app/views/notes/show.rhtml
similarity index 100%
rename from tracks/app/views/note/show.rhtml
rename to tracks/app/views/notes/show.rhtml
diff --git a/tracks/app/views/projects/show.rhtml b/tracks/app/views/projects/show.rhtml
index ff54f877..266c7447 100644
--- a/tracks/app/views/projects/show.rhtml
+++ b/tracks/app/views/projects/show.rhtml
@@ -12,17 +12,18 @@
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no notes attached to this project"} %>
- <%= render :partial => "note/notes_summary", :collection => @project.notes %>
+ <%= render :partial => "notes/notes_summary", :collection => @project.notes %>
- <% form_remote_tag :url => { :controller => "note", :action => "create" },
- :update => "notes",
- :position => "bottom",
- :complete => "new Effect.Highlight('notes');$('empty-n').hide();",
- :html => {:id=>'form-new-note', :class => 'inline-form'} do %>
+ <% form_remote_tag :url => notes_path,
+ :method => :post,
+ :update => "notes",
+ :position => "bottom",
+ :complete => "new Effect.Highlight('notes');$('empty-n').hide();",
+ :html => {:id=>'form-new-note', :class => 'inline-form'} do %>
<%= hidden_field( "new_note", "project_id", "value" => "#{@project.id}" ) %>
<%= text_area( "new_note", "body", "cols" => 50, "rows" => 3, "tabindex" => 1 ) %>
diff --git a/tracks/config/routes.rb b/tracks/config/routes.rb
index f3602415..e4a354e6 100644
--- a/tracks/config/routes.rb
+++ b/tracks/config/routes.rb
@@ -45,10 +45,7 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'projects/feed/:feedtype/:login/:token', :controller => 'feed', :action => 'list_projects_only'
# Notes Routes
- map.connect 'note/create', :controller => 'note', :action => 'create'
- map.connect 'note/update/:id', :controller => 'note', :action => 'update', :id => 'id'
- map.connect 'note/:id', :controller => 'note', :action => 'show', :id => 'id'
- map.connect 'notes', :controller => 'note', :action => 'index'
+ map.resources :notes
# Feed Routes
map.connect 'feeds', :controller => 'feedlist', :action => 'index'
diff --git a/tracks/db/schema.rb b/tracks/db/schema.rb
index 6aa2ff83..f3fde4cc 100644
--- a/tracks/db/schema.rb
+++ b/tracks/db/schema.rb
@@ -2,16 +2,17 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 24) do
+ActiveRecord::Schema.define(:version => 25) do
create_table "contexts", :force => true do |t|
- t.column "name", :string, :default => "", :null => false
- t.column "position", :integer, :default => 0, :null => false
- t.column "hide", :boolean, :default => false
- t.column "user_id", :integer, :default => 1
+ t.column "name", :string, :default => "", :null => false
+ t.column "hide", :integer, :limit => 4, :default => 0, :null => false
+ t.column "position", :integer, :default => 0, :null => false
+ t.column "user_id", :integer, :default => 0, :null => false
end
add_index "contexts", ["user_id"], :name => "index_contexts_on_user_id"
+ add_index "contexts", ["user_id", "name"], :name => "index_contexts_on_user_id_and_name"
create_table "notes", :force => true do |t|
t.column "user_id", :integer, :default => 0, :null => false
@@ -61,12 +62,13 @@ ActiveRecord::Schema.define(:version => 24) do
create_table "projects", :force => true do |t|
t.column "name", :string, :default => "", :null => false
t.column "position", :integer, :default => 0, :null => false
- t.column "user_id", :integer, :default => 1
+ t.column "user_id", :integer, :default => 0, :null => false
t.column "description", :text
t.column "state", :string, :limit => 20, :default => "active", :null => false
end
add_index "projects", ["user_id"], :name => "index_projects_on_user_id"
+ add_index "projects", ["user_id", "name"], :name => "index_projects_on_user_id_and_name"
create_table "sessions", :force => true do |t|
t.column "session_id", :string
@@ -94,16 +96,16 @@ ActiveRecord::Schema.define(:version => 24) do
add_index "tags", ["name"], :name => "index_tags_on_name"
create_table "todos", :force => true do |t|
- t.column "context_id", :integer, :default => 0, :null => false
- t.column "project_id", :integer
- t.column "description", :string, :default => "", :null => false
+ t.column "context_id", :integer, :default => 0, :null => false
+ t.column "description", :string, :limit => 100, :default => "", :null => false
t.column "notes", :text
t.column "created_at", :datetime
t.column "due", :date
t.column "completed_at", :datetime
- t.column "user_id", :integer, :default => 1
+ t.column "project_id", :integer
+ t.column "user_id", :integer, :default => 0, :null => false
t.column "show_from", :date
- t.column "state", :string, :limit => 20, :default => "immediate", :null => false
+ t.column "state", :string, :limit => 20, :default => "immediate", :null => false
end
add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
@@ -113,10 +115,10 @@ ActiveRecord::Schema.define(:version => 24) do
add_index "todos", ["user_id", "context_id"], :name => "index_todos_on_user_id_and_context_id"
create_table "users", :force => true do |t|
- t.column "login", :string, :limit => 80, :default => "", :null => false
- t.column "password", :string, :limit => 40, :default => "", :null => false
+ t.column "login", :string, :limit => 80
+ t.column "password", :string, :limit => 40
t.column "word", :string
- t.column "is_admin", :boolean, :default => false, :null => false
+ t.column "is_admin", :integer, :limit => 4, :default => 0, :null => false
t.column "first_name", :string
t.column "last_name", :string
t.column "auth_type", :string, :default => "database", :null => false
diff --git a/tracks/test/functional/note_controller_test.rb b/tracks/test/functional/notes_controller_test.rb
similarity index 63%
rename from tracks/test/functional/note_controller_test.rb
rename to tracks/test/functional/notes_controller_test.rb
index 6b76f0ee..9100fbf4 100644
--- a/tracks/test/functional/note_controller_test.rb
+++ b/tracks/test/functional/notes_controller_test.rb
@@ -1,12 +1,12 @@
require File.dirname(__FILE__) + '/../test_helper'
-require 'note_controller'
+require 'notes_controller'
# Re-raise errors caught by the controller.
-class NoteController; def rescue_action(e) raise e end; end
+class NotesController; def rescue_action(e) raise e end; end
-class NoteControllerTest < Test::Unit::TestCase
+class NotesControllerTest < Test::Unit::TestCase
def setup
- @controller = NoteController.new
+ @controller = NotesController.new
request = ActionController::TestRequest.new
response = ActionController::TestResponse.new
end
diff --git a/tracks/test/selenium/notes/link_to_note.rsel b/tracks/test/selenium/notes/link_to_note.rsel
new file mode 100644
index 00000000..01e90f2a
--- /dev/null
+++ b/tracks/test/selenium/notes/link_to_note.rsel
@@ -0,0 +1,5 @@
+setup :fixtures => :all
+include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
+open "/projects/Build_a_working_time_machine"
+click_and_wait "css=#note_1 .show_notes"
+assert_element_present "note_1"
diff --git a/tracks/test/selenium/notes/see_all_notes.rsel b/tracks/test/selenium/notes/see_all_notes.rsel
new file mode 100644
index 00000000..2b06ecbd
--- /dev/null
+++ b/tracks/test/selenium/notes/see_all_notes.rsel
@@ -0,0 +1,5 @@
+setup :fixtures => :all
+include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
+open "/notes/"
+assert_element_present "note_1"
+assert_element_present "note_2"