add Specimen resource
authorTom Clegg <tom@clinicalfuture.com>
Wed, 16 Jan 2013 02:55:17 +0000 (18:55 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Wed, 16 Jan 2013 02:55:17 +0000 (18:55 -0800)
13 files changed:
app/assets/javascripts/specimens.js.coffee [new file with mode: 0644]
app/assets/stylesheets/specimens.css.scss [new file with mode: 0644]
app/controllers/orvos/v1/specimens_controller.rb [new file with mode: 0644]
app/helpers/specimens_helper.rb [new file with mode: 0644]
app/models/specimen.rb [new file with mode: 0644]
config/initializers/inflections.rb
config/routes.rb
db/migrate/20130116024233_create_specimens.rb [new file with mode: 0644]
db/schema.rb
test/fixtures/specimens.yml [new file with mode: 0644]
test/functional/specimens_controller_test.rb [new file with mode: 0644]
test/unit/helpers/specimens_helper_test.rb [new file with mode: 0644]
test/unit/specimen_test.rb [new file with mode: 0644]

diff --git a/app/assets/javascripts/specimens.js.coffee b/app/assets/javascripts/specimens.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -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/specimens.css.scss b/app/assets/stylesheets/specimens.css.scss
new file mode 100644 (file)
index 0000000..460e42e
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Specimens 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/orvos/v1/specimens_controller.rb b/app/controllers/orvos/v1/specimens_controller.rb
new file mode 100644 (file)
index 0000000..22620df
--- /dev/null
@@ -0,0 +1,2 @@
+class Orvos::V1::SpecimensController < ApplicationController
+end
diff --git a/app/helpers/specimens_helper.rb b/app/helpers/specimens_helper.rb
new file mode 100644 (file)
index 0000000..8c30d97
--- /dev/null
@@ -0,0 +1,2 @@
+module SpecimensHelper
+end
diff --git a/app/models/specimen.rb b/app/models/specimen.rb
new file mode 100644 (file)
index 0000000..a7de822
--- /dev/null
@@ -0,0 +1,9 @@
+class Specimen < ActiveRecord::Base
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :material
+  end
+end
index 9e8b0131f8ff7e3d3923697eca0b0ffdc77b19ce..7f100f3604cf546edb431648de8d335811e2b1e4 100644 (file)
@@ -8,3 +8,8 @@
 #   inflect.irregular 'person', 'people'
 #   inflect.uncountable %w( fish sheep )
 # end
+
+ActiveSupport::Inflector.inflections do |inflect|
+  inflect.plural /^(specimen)$/i, '\1s'
+  inflect.singular /^(specimen)s/i, '\1'
+end
index 8acc5bb6f532850e8fa4c4ad22a84e3a7271ac33..bbfbe862f85bed51359c5d267d61928a90daf1f8 100644 (file)
@@ -1,4 +1,5 @@
 Server::Application.routes.draw do
+  resources :specimens
   resources :collections
   resources :metadata
   resources :nodes
@@ -70,6 +71,7 @@ Server::Application.routes.draw do
       resources :pipelines
       resources :pipeline_invocations
       resources :pipelineInvocations
+      resources :specimens
       match '/schema' => 'schema#show'
       match '/nodes/:uuid/ping' => 'nodes#ping', :as => :ping_node
       match '/metadata/:target_kind/:target_uuid' => 'metadata#index'
diff --git a/db/migrate/20130116024233_create_specimens.rb b/db/migrate/20130116024233_create_specimens.rb
new file mode 100644 (file)
index 0000000..443369e
--- /dev/null
@@ -0,0 +1,20 @@
+class CreateSpecimens < ActiveRecord::Migration
+  def up
+    create_table :specimens do |t|
+      t.string :uuid
+      t.string :created_by_client
+      t.string :created_by_user
+      t.datetime :created_at
+      t.string :modified_by_client
+      t.string :modified_by_user
+      t.datetime :modified_at
+      t.string :material
+
+      t.timestamps
+    end
+    add_index :specimens, :uuid, :unique => true
+  end
+  def down
+    drop_table :specimens
+  end
+end
index aa21ec4c6c7f2a621aad78e8ca29a7b28e5895d4..9d2c4297fe6b8da3a8f50306d31a29303f65c169 100644 (file)
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130113214204) do
+ActiveRecord::Schema.define(:version => 20130116024233) do
 
   create_table "collections", :force => true do |t|
     t.string   "locator"
@@ -109,4 +109,18 @@ ActiveRecord::Schema.define(:version => 20130113214204) do
 
   add_index "pipelines", ["uuid"], :name => "index_pipelines_on_uuid", :unique => true
 
+  create_table "specimens", :force => true do |t|
+    t.string   "uuid"
+    t.string   "created_by_client"
+    t.string   "created_by_user"
+    t.datetime "created_at"
+    t.string   "modified_by_client"
+    t.string   "modified_by_user"
+    t.datetime "modified_at"
+    t.string   "material"
+    t.datetime "updated_at"
+  end
+
+  add_index "specimens", ["uuid"], :name => "index_specimens_on_uuid", :unique => true
+
 end
diff --git a/test/fixtures/specimens.yml b/test/fixtures/specimens.yml
new file mode 100644 (file)
index 0000000..6254218
--- /dev/null
@@ -0,0 +1,21 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+  uuid: MyString
+  created_at: 2013-01-15 18:42:33
+  created_by_client: MyString
+  created_by_user: MyString
+  modified_at: 2013-01-15 18:42:33
+  modified_by_client: MyString
+  modified_by_user: MyString
+  material: MyString
+
+two:
+  uuid: MyString
+  created_at: 2013-01-15 18:42:33
+  created_by_client: MyString
+  created_by_user: MyString
+  modified_at: 2013-01-15 18:42:33
+  modified_by_client: MyString
+  modified_by_user: MyString
+  material: MyString
diff --git a/test/functional/specimens_controller_test.rb b/test/functional/specimens_controller_test.rb
new file mode 100644 (file)
index 0000000..8401ecc
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SpecimensControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/unit/helpers/specimens_helper_test.rb b/test/unit/helpers/specimens_helper_test.rb
new file mode 100644 (file)
index 0000000..825af25
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SpecimensHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/specimen_test.rb b/test/unit/specimen_test.rb
new file mode 100644 (file)
index 0000000..a9abc8c
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SpecimenTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end